[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

should definitions introduced by macros be gensymmed?



I was under the impression that if a macro produced a definition whose
variable did not come from the pattern, then the definition would
define a gensymmed dummy variable, i.e. there would be no way to refer
to the value bound by this definition.  I use this trick to make
macros that can appear in definition position, i.e. at the beginning
of a body before other definitions, even if they don't have anything
to define:

  (define-syntax define-foo
    (syntax-rules ()
      ((_ expr) (define foo expr))))

  (let ()
    (define-foo (display 'f))
    (define-foo (display 'o))
    (define o 'o)
    o)

When I evaluate these in MzScheme (v200alpha15), everything works fine 
(it displays "foo").  But when I evaluate these in DrScheme (language
"Textual (MzScheme)"), it complains:

  def-foo.scm:3:23: letrec-values: duplicate binding name in: foo

Why do MzScheme and DrScheme behave differently, and which is the
right behavior?  Do I have to rewrite this macro with syntax-case and
use generate-temporaries?

--dougo@ccs.neu.edu

P.S. If you use a definition in the middle of a body, after an
expression, the error message says:

  define-values: illegal use (not at top-level)

It should probably say "not at top-level or beginning of body" or
something like that.