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

Re: should definitions introduced by macros be gensymmed?



This appears to be a bug in DrScheme (or, perhaps a bug in mzscheme
that DrScheme tickles but that raw mzscheme and raw mred don't). I'm
looking into it, but haven't been able to narrow things down yet. For
now, I'd suggest that you use mzscheme or generate-temporaries.

Sorry,
Robby

At Wed, 10 Apr 2002 04:21:32 -0400 (EDT), Doug Orleans wrote:
> 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.