[plt-scheme] Contract Comments / Suggestions / Requests

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Oct 19 15:22:37 EDT 2004

On Oct 19, 2004, at 11:50 AM, Williams, M. Douglas wrote:

> I have a couple (of rather trivial) comments / suggestions / requests 
> (however anyone wants to interpret them) for contracts.  In general, 
> these are nitpicks that I can (and do) implement on my own (except for 
> #4).  But I think they might useful enough to include in the contracts 
> module – or at least it keeps me from including my own 
> contracts-extension module.
> 1) There are places in the language that require exact integers (e.g., 
> pretty much anyplace an index into something is needed).  How about 
> exact counterparts to the contracts that match integers.  For example, 
> (exact-integer-in 1 10) or exact-natural-number?.  [Also add 
> exact-integer? as a counterpart to integer?.]

Wonderful idea. I have used this, too.

> 2) This is a total nitpick.  I would have rather seen natural-number? 
> named natural? (or natural-integer?).  I think the –number appended 
> makes it look to someone new to the language that it is higher in the 
> numeric hierarchy than it really is.  Plus, the exact-natural-number? 
> in #1 is getting a bit long.

Robby is in the process of renaming these contracts. Great! Short is 
good here.

> 3) At first I thought that in addition to natural-number? it would be 
> nice to have something matching positive integers, etc.  But I’ve 
> gotten so used to writing (integer-in 1 +inf.0) that it seems natural 
> (no pun intended).  Indeed, maybe natural-number? is superfluous.  
> Should we just encourage this format?
> 4) This one may not be so trivial.  Is there any way to dynamically 
> check a list that could potentially be used as a function call (or 
> alternatively, a function and list of arguments to be applied) against 
> a contract, prior to evaluation (or application) of the function?  (I 
> am thinking a super-extension of procedure-arity-includes? that one 
> could use to check against a contract instead of just the arity of the 
> procedure.)

Can you make an example? Sounds interesting.

Thanks -- Matthias

> Doug

Posted on the users mailing list.