Greetings Luca,

On Fri 26 Mar 2010 14:02, Luca Saiu <posit...@gnu.org> 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/


Reply via email to