bug-guile
[Top][All Lists]
Advanced

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

Re: [r6rs] probably bad syntax expansion


From: Andy Wingo
Subject: Re: [r6rs] probably bad syntax expansion
Date: Mon, 21 Jun 2010 21:24:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux)

Hello,

On Mon 21 Jun 2010 09:59, Marco Maggi <address@hidden> writes:

> (define A <function-using-macro-B>)
> (define-syntax B <>)
> (A)

I have abbreviated your illuminating example. I don't really know what
to think of it, except to say that for top-level programs Guile
implements "REPL semantics".

It would seem that both for toplevel programs and for libraries --
because Guile expands the `library' form to toplevel definitions -- that
these REPL semantics do diverge from lexically-nested semantics.

It's the difference between:

    (let ()
      (define even?
        (lambda (x)
          (or (= x 0) (odd? (- x 1)))))
      (define-syntax odd?
        (syntax-rules ()
          ((odd? x) (not (even? x)))))
      (even? 10))
     => #t

and

    (begin
     (define even?
       (lambda (x)
         (or (= x 0) (odd? (- x 1)))))
     (define-syntax odd?
       (syntax-rules ()
         ((odd? x) (not (even? x)))))
     (even? 10))
    ERROR: In procedure vm-debug-engine:
    ERROR: Wrong type to apply: #<syntax-transformer odd?>

It is unfortunate for users that expect R6RS semantics for toplevel and
library definitions. I would be happy to accept a well-reasoned patch to
letrec-compile the first forms from a file that prove to be definitions,
though we cannot remove support for mixed definitions and expressions at
the toplevel. However, I don't have the motivation to work on this in
the foreseeable future.

Thank you for the report, though, and I will document the
incompatibility.

Andy
-- 
http://wingolog.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]