From: Damien Mattei <damien.mattei@gmail.com>
To: Jean Abou Samra <jean@abou-samra.fr>
Cc: guile-user <guile-user@gnu.org>
Subject: Re: error Wrong type to apply: #<syntax-transformer
Date: Fri, 4 Aug 2023 10:23:23 +0200 [thread overview]
Message-ID: <CADEOaddOQedVt6EH8XD37S4qH4XG=z+dZH34ni5a0OT38Zc0pQ@mail.gmail.com> (raw)
In-Reply-To: <CADEOademEa=mMB5ZR3ySvmO+e+cYXBDmdRG3XvbUipy1nepd-g@mail.gmail.com>
i know what disturb me in this error, it is because the order of
definitions has effect but i always learn (was it right?) that in
scheme the order of definitions should have no effect on the resulting
evaluations.
On Thu, Aug 3, 2023 at 1:01 PM Damien Mattei <damien.mattei@gmail.com> wrote:
>
> 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.
> >
> >
next prev parent reply other threads:[~2023-08-04 8:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 9:09 error Wrong type to apply: #<syntax-transformer Damien Mattei
2023-08-03 9:36 ` Damien Mattei
2023-08-03 9:58 ` Jean Abou Samra
2023-08-03 11:01 ` Damien Mattei
2023-08-04 8:23 ` Damien Mattei [this message]
2023-08-04 8:31 ` Jean Abou Samra
2023-08-04 12:45 ` Damien Mattei
2023-08-08 19:38 ` Maxime Devos
2023-08-08 20:17 ` Damien Mattei
2023-08-08 23:00 ` Jean Abou Samra
2023-08-09 9:42 ` Maxime Devos
2023-08-09 10:25 ` Maxime Devos
2023-08-09 13:22 ` Jean Abou Samra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADEOaddOQedVt6EH8XD37S4qH4XG=z+dZH34ni5a0OT38Zc0pQ@mail.gmail.com' \
--to=damien.mattei@gmail.com \
--cc=guile-user@gnu.org \
--cc=jean@abou-samra.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).