[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: error Wrong type to apply: #<syntax-transformer
From: |
Damien Mattei |
Subject: |
Re: error Wrong type to apply: #<syntax-transformer |
Date: |
Thu, 3 Aug 2023 13:01:19 +0200 |
thank you
it is clear now , even if i really never find the macro needed upward
i tested too in racket your example and the messages is simple to understand :
Welcome to DrRacket, version 8.9 [cs].
Language: reader
"../Scheme-PLUS-for-Racket/main/Scheme-PLUS-for-Racket/SRFI/SRFI-105.rkt",
with debugging; memory limit: 8192 MB.
'()
> foo
foo: undefined;
cannot reference an identifier before its definition
> bar
bar: undefined;
cannot reference an identifier before its definition
> (define (foo)
(bar 'quux))
> (define-syntax-rule (bar x) x)
> (display (foo))
. . ../../../../../../../Applications/Racket
v8.9/collects/racket/private/kw.rkt:1263:25: bar: undefined;
cannot reference an identifier before its definition
On Thu, Aug 3, 2023 at 11:58 AM Jean Abou Samra <jean@abou-samra.fr> wrote:
>
> overload.scm must be before some definitions of scheme-infix.scm even
> if it is not used here, it is strange, i do not understand all but it
> compiles now
>
>
>
> A minimal reproducer for your problem is
>
> (define (foo)
> (bar 'quux))
> (define-syntax-rule (bar x) x)
> (display (foo))
>
>
> Let's dissect what happens. At macro expansion time (during byte
> compilation), first the definition of foo is expanded. bar is unbound, so
> it's compiled as a function call. Then comes the definition of bar as a
> macro, but foo has already been expanded without it.
>
> At runtime, a macro is bound to a syntax transformer, so the binding for bar
> that was unresolved at expand time gets resolved to the toplevel binding that
> gets defined for bar, and you get this error because a macro transformer
> can't be called as a function.
>
>
- error Wrong type to apply: #<syntax-transformer, Damien Mattei, 2023/08/03
- Re: error Wrong type to apply: #<syntax-transformer, Maxime Devos, 2023/08/08
- Re: error Wrong type to apply: #<syntax-transformer, Damien Mattei, 2023/08/08
- Re: error Wrong type to apply: #<syntax-transformer, Jean Abou Samra, 2023/08/08
- Re: error Wrong type to apply: #<syntax-transformer, Maxime Devos, 2023/08/09
- Re: error Wrong type to apply: #<syntax-transformer, Maxime Devos, 2023/08/09
- Re: error Wrong type to apply: #<syntax-transformer, Jean Abou Samra, 2023/08/09