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

Re: Redefining define

Quoting Lauri Alanko:
> How do I redefine syntactic keywords that are already bound in the
> mzscheme module? [...]
> What's the right way to do this?

Here's the way I do it:

 (module util mzscheme
    (define-syntax util-define ...)

    (provide (rename util-define define)
             (all-from-except mzscheme define)))

With this approach, `define' still works in the usual way within the
implementation of `util'.

> (module util #%kernel
>   (require-for-syntax (rename mzscheme old-define define) 
>                       (all-except mzscheme define))
>   (require (rename mzscheme old-define define) 
>            (all-except mzscheme define))
>   (define-syntax define ....)
>   ....)
> But then the error was "module: identifier already imported (from a
> different source) at: #%module-begin in: (require mzscheme)". Does this
> refer to the primitive syntaxes that are defined in #%kernel?

Yes - the names exported by `#%kernel' overlap with the names exported
by `mzscheme'.