[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syntax transformers and definition order
From: |
Andy Wingo |
Subject: |
Re: Syntax transformers and definition order |
Date: |
Sun, 28 Mar 2010 14:50:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) |
Greetings Luca,
On Fri 26 Mar 2010 14:02, Luca Saiu <address@hidden> writes:
> ;;; Define a function calling a macro which is not yet defined:
> (define (go)
> (display (m 42)))
>
> ;;; Define the macro:
> (define-macro (m form)
> `(list ,form))
>
> ;;; Call the function:
> (go)
I'm afraid that this is just how it is. Fortunately it's easy to fix, as
you have seen.
>From the NEWS:
** Macros need to be defined before their first use.
It used to be that with lazy memoization, this might work:
(define (foo x)
(ref x))
(define-macro (ref x) x)
(foo 1) => 1
But now, the body of `foo' is interpreted to mean a call to the toplevel
`ref' function, instead of a macro expansion. The solution is to define
macros before code that uses them.
Regards,
Andy
--
http://wingolog.org/