[racket] Why check-expect only at the top level?

From: Stephen Bloch (bloch at adelphi.edu)
Date: Tue Sep 6 09:00:21 EDT 2011

On Sep 6, 2011, at 7:45 AM, Shriram Krishnamurthi wrote:

> I suspect everyone who teaches has run into just such a desire.

I've asked a very similar question.  And in fact, until two years ago or so check-expect DID run like normal code, which meant students had to put all their test cases AFTER (i.e. below, in the source file) their definitions.  One could live with this: I told my students to write a contract comment, then write test cases, then insert a function skeleton between the comment and the test cases, then insert an inventory into the function skeleton, then fill in a whole function body in the function skeleton.  But it's a little easier to explain the sequence of steps in the Design Recipe if you can just write things in the order in which you do them, so the PLT folks gave check-expect and friends this "magical" property that they run AFTER everything else at the top level.

So here's a modified version of the question.  How difficult and/or confusing would it be to write check-expect in such a way that, WHEN IT APPEARS AT THE TOP LEVEL, it is magically delayed as above, but when it appears inside something else (a function, a "begin", a "local", etc.) it acts like an ordinary function?



Stephen Bloch
sbloch at adelphi.edu




Posted on the users mailing list.