[plt-scheme] Questions about (contract ...) form

From: Richard Cobbe (cobbe at ccs.neu.edu)
Date: Sun Nov 6 14:44:47 EST 2005

I need to use the (contract ...) form in a macro I'm writing, and I've
got a couple of questions about its use.  Here's the setting:

(define-syntax stream-cons
  (syntax-rules ()
    [(_ a d)
     (make-stream:cell a (delay d))]))

(Yes, I know about SRFI 40, but even streams won't work for my

I'd like to wrap a contract around (the value of) d to ensure that it's
a stream, and of course I want to check this contract only when the
stream's cdr is forced.  I'm imagining changing the macro template to
read (make-stream:cell a (delay (contract stream? d positive-blame

First, the manual specifies that positive-blame and negative-blame must
be symbols indicating where blame is to be assigned.

  a) Are these symbols supposed to be module names?

  b) Is negative-blame meaningful when the value in question is not a

  c) If these symbols are supposed to be module names, how do I get the
     name of the module which contains the use of stream-cons?  I've
     seen syntax-source-module, but that can potentially return a module
     path index, and it's not clear how to extract the module name from

Second, the manual says that "contract-source, if specified, indicates
where the contract was assumed."  What does it mean to assume a

Or is there a better way to do this altogether?



Posted on the users mailing list.