[plt-scheme] syntax-case and the name 'debug'
Wow, talk about cutting yourself with your power tools! Did it hurt
much Guillaume?
Now, I'm surprised that such a capture would be considered a good
thing. Is there some rationale for that?
Thanks,
Robby
At Tue, 21 Oct 2003 19:09:54 -0700, Matthew Flatt wrote:
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> At Wed, 22 Oct 2003 14:35:09 -0400 (EDT), Guillaume Marceau wrote:
> > > (syntax-case (quote-syntax asd) ()
> > [(#%top . id) (debug "asd")]
> > [_ (debug 5)])
> > STDIN::77: #%top: illegal use of syntax in: (#%top . debug)
>
> This is certainly deeply confusing...
>
> To simplify a little, and to show that "debug" is not special:
>
> > (syntax-case not-even-evaluated ()
> [(#%top . any) xdebug])
> repl-1:2:21: #%top: illegal use of syntax in: (#%top . xdebug)
>
> The problem is that xdebug is implictly wrapped with "#%top", like any
> reference to a top-level variable. But the implicit "#%top" gets
> captured by the syntax binding in the pattern!
>
> I think it's likely that you meant to list `#%top' as a literal.
> Otherwise, you can just pick a different name for the pattern. (Either
> will avoid the problem.)
>
> Matthew
>
>