[plt-scheme] Contract Comments / Suggestions / Requests
I my case, I evaluate the arguments at the time the schedule macro is
invoked and save the values in the event list - they are not re-evaluated
later.
-----Original Message-----
From: Robby Findler
To: Williams, M. Douglas
Cc: plt-scheme at web-ext.cs.brown.edu; Matthias Felleisen
Sent: 10/19/2004 2:14 PM
Subject: RE: [plt-scheme] Contract Comments / Suggestions / Requests
At Tue, 19 Oct 2004 12:43:53 -0700, "Williams, M. Douglas" wrote:
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> 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
> invocation.
In general, I would guess that you have to re-run the contract checking
right before calling the function for this example to work right. There
are two ways that this could come up. The first is if the arguments to
my-function are re-evaluated every 100.0 seconds. In that case, you
don't know that `b' is going to be a good value (in the case it is
set!'d) The second is that the contract on my-function might somehow
depend on some global state. For example, it might have a pre-condition
requiring some global variable to be greater than 3 (perhaps expressed
as part of a dependent ->d contract).
Are either of those the case?
Robby