[plt-scheme] Contracts with keywords -- opaque error message

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Tue May 25 14:45:58 EDT 2010

Stevie, hello.

On 2010 May 25, at 19:01, Stevie Strickland wrote:

> However, we would like our contracts should be "erasable."  That is, if a program with contracts evaluates to a value, then the same program with the contracts removed should evaluate to the same value.  While we limit the scope of this statement for some language features, such as eq?, we need to decide whether reflective operations, like retrieving the keywords that a procedure supports, should return the same value on both contracted and uncontracted versions of the same procedure.


> This is similar to the reflective operations that investigate the arity of a function

Aha: reflection.  I think I see the issue, and a potential distinction between contracts and arity.

So things like arity, and the keyword information produced by the functions returned by procedure-reduce-keyword-arity, are 'known' to the function and can be reflected about, whereas contracts are (conceptually, potentially) wrappers around the function which can't be reflected about.  So the issue is whether or not contracts _should_ be available for reflection, which would (probably) result in them being non-erasable.

Though since you say that

> -- right now they return different values on contracted and uncontracted versions of a procedure (if the contract describes a subset of the possible arity uses)

...it appears that this 'wrapper' idea is wrong, but I still see the issue.

I'm curious about this partly because a little while ago I wrote some contract wrappers for R5RS code <http://nxg.me.uk/dist/scm/#lambda-contract.scm>.  Nothing exotic, but a good exercise in coming to terms with define-syntax.

Good luck with the contract surgery.  Rather you than me!

Best wishes,


Norman Gray  :  http://nxg.me.uk

Posted on the users mailing list.