[plt-dev] Symptom of REPL's hopelessness?

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Thu Oct 1 16:50:02 EDT 2009

On Thu, Oct 1, 2009 at 4:35 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> There's a special hack to solve this problem: when a top-level
> `define-syntaxes' gets zero results from the RHS expression, it just
> makes the identifiers exist (in a suitable way) without defining
> anything. So, this works:
>  (define-syntax (m stx)
>  (syntax-case stx ()
>    [(_ x)
>     (with-syntax ([(y) (generate-temporaries (syntax (x)))])
>       (syntax
>        (begin
>         (define-syntaxes (y) (values))
>         (define (y) y))))]))
> I see that the problem and workaround are not documented (at least not
> where I can find it), so I'll work on the docs.

For whoever's information, (planet cce/scheme:6/define) provides
"declare-names" as a short-hand for this trick.  It has two benefits:
it is more mnemonic than a define-syntaxes that produces zero values,
and it works in non-top-level contexts (by expanding to an empty
begin, whereas the zero-values define-syntaxes trick is an error in
modules and so forth).

I mention this mostly because Ryan tried to write a version of the
macro that would work in both module and top level contexts, without
using set!, and it blew up on him.

Practically, though... just don't define things in the REPL.  ;)


Posted on the dev mailing list.