[plt-scheme] Contract Comments / Suggestions / Requests

From: Williams, M. Douglas (M.DOUGLAS.WILLIAMS at saic.com)
Date: Tue Oct 19 15:43:53 EDT 2004

As an example for #4:

In the simulation collection there is a macro, schedule, that schedules
events (for this discussion they can be function calls).  For example:

  (schedule 100.0 (my-function 1 'b c))

would schedule the function, my-function, to be applied to the arguments (1
b <the value of c>) at (simulated) time 100.0.  If my-function has a
contract on it, it wouldn't be checked until the call is actually made (at
simulated time 100.0) - and it would be from inside the main simulation
loop, not the user's invocation of the schedule macro.

Currently, I use procedure-arity-includes? as a sanity check before I add
the event to the event list, but it might still violate the contract when it
is actually applied.

I would like to be able to do the contract check (at least on the input
parameters - there is no result at that point to check) before I add the
event to the event list and give an error at the point of the schedule


> -----Original Message-----
> From: plt-scheme-admin at web-ext.cs.brown.edu [mailto:plt-scheme-admin at web-
> ext.cs.brown.edu] On Behalf Of Matthias Felleisen
> Sent: Tuesday, October 19, 2004 1:23 PM
> To: Williams, M. Douglas
> Cc: plt-scheme at web-ext.cs.brown.edu
> Subject: Re: [plt-scheme] Contract Comments / Suggestions / Requests
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 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.