Subject: Re: bug#22142: A bug with define-syntax

From: Mark H Weaver <[email-masked]>
Date: Tue, 15 Dec 2015 03:19:43 -0500

Tommi Höynälänmaa <[email-masked]> writes:

> I get the following error message:

[...]

> ERROR: In procedure #<syntax-transformer assert>:
> ERROR: Wrong type to apply: #<syntax-transformer assert>
> make: *** [hello-world.scm] Virhe 1
> --- cut here ---
>
> The code should compile.

This error indicates, roughly speaking, that 'assert' was used before it
was defined.  More precisely: an expression that uses the 'assert' macro
was (macro-)expanded before 'assert' was defined.

This works in Guile 1.x, because it's a pure interpreter that performs
macro expansion lazily, i.e. it delays expansion of a given expression
until the first time the expression is evaluated.  This allows you to
_define_ a procedure that uses 'assert' before 'assert' is defined, as
long as the procedure is not _applied_ (i.e. called) before 'assert' is
defined.

Guile 2.x uses a new macro expander that is far superior in most
respects, but it does not support lazy expansion, and therefore strictly
requires that macros be defined before their uses are expanded.

     Regards,
       Mark