[plt-scheme] Faking modules with define-values

From: Doug Orleans (dougorleans at gmail.com)
Date: Mon Jun 26 13:04:21 EDT 2006

Jon Rafkind writes:
 > 
 > > Try this:
 > >
 > > (define-values (make-foo foo-f)
 > >   (let ()
 > >     (define BLAH 2)
 > >     (define-struct foo (f))
 > >     (define (my-make-foo x)
 > >       (make-foo (+ BLAH x)))
 > >     (values my-make-foo foo-f)))
 > >
 > >   
 > That worked. I didnt realize you could define things in a let. I looked
 > through the help-desk for a while before posting but didnt see anything
 > explicitly saying I could define things in a let. Did I miss it?

It's in R5RS.  "Definitions may occur at the beginning of a <body>
(that is, the body of a lambda, let, let*, letrec, let-syntax, or
letrec-syntax expression or that of a definition of an appropriate
form)."
http://download.plt-scheme.org/doc/350/html/r5rs/r5rs-Z-H-8.html#%_sec_5.2.2

--dougorleans at gmail.com


Posted on the users mailing list.