From: "Linus Björnstam" <linus.bjornstam@veryfast.biz>
To: "David Kastrup" <dak@gnu.org>
Cc: guile-devel@gnu.org, Han-Wen Nienhuys <hanwenn@gmail.com>
Subject: Re: unhandled constant?
Date: Sat, 01 Feb 2020 16:21:43 +0100 [thread overview]
Message-ID: <1953f8c7-3648-40d3-83ed-72a26d20e6ec@www.fastmail.com> (raw)
In-Reply-To: <877e16v12n.fsf@fencepost.gnu.org>
tried it in a couple of syntax-case-enabled schemes (defmacro is implemented using syntax-case in guile) and it doesn't work anywhere. The procedure ends up undefined everywhere.
The #<procedure> object ,inner points to doesn't exist at runtime because it is not defined anywhere in any meaningful way to the compiler. One work-around would be to output the literal lambda in place of ,inner but by then you should just output a (let ...) With the lambda in it and let the inliner take care of it.
--
Linus Björnstam
On Sat, 1 Feb 2020, at 15:23, David Kastrup wrote:
> Linus Björnstam <linus.bjornstam@veryfast.biz> writes:
>
> > On Sat, 1 Feb 2020, at 12:09, David Kastrup wrote:
> >>
> >> Can you expand about the "expansion time and macro time separation"?
> >>
> >> If we have
> >>
> >> (define decl '())
> >> (define (make-var n v) (list "var" n v))
> >> (defmacro define-session (name value)
> >> (define (inner n v)
> >> (set! decl
> >> (cons
> >> (make-var n v)
> >> decl))
> >> )
> >> `(,inner ',name ,value))
> >> (define-session foo 1)
> >> (display decl)
> >> (newline)
> >>
> >> as stated, the local function "inner" is defined at macro time, but the
> >> form
> >> `(,inner ',name ,value)
> >> does not export the _name_ inner but rather the defined function. That
> >> part naively appears to me like it should work; an "expansion time and
> >> macro time" issue appears rather to be that inner calls make-var (and
> >> accesses decl) which is only being defined at expansion time.
> >>
> >> The error message, however, rather appears to complain about inner being
> >> undefined rather than the definition of inner referring to undefined
> >> entities.
> >
> >
> > I am not sure what is really the problem. Either the inner function is
> > not present at runtime due to separation of compile time and runtime,
> > or it is a result of how defmacro re-introduces the result of the
> > macro into the syntactic context of the macro usage (where inner is
> > not visible). Either way, having the inner definition in the macro
> > output will solve the problem of it not being visible.
>
> This fails when byte-compiling, so it would appear that the equivalent
> of
>
> (defmacro ...
> (define local-fun ...
> `(,local-fun ...)))
>
> is not able to represent the local (and thus ultimately anonymous)
> function here. Whether this is a general shortcoming or is conditioned
> on local-fun calling functions not available at byte-compile time (in
> which case those would need to get wrapped in eval-and-expand) I haven't
> checked yet.
>
> --
> David Kastrup
>
next prev parent reply other threads:[~2020-02-01 15:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-28 23:08 unhandled constant? Han-Wen Nienhuys
2020-01-29 15:06 ` Ricardo Wurmus
2020-01-30 8:05 ` Han-Wen Nienhuys
2020-01-31 10:49 ` Han-Wen Nienhuys
2020-01-31 11:17 ` Ricardo Wurmus
2020-02-02 19:30 ` Jan Nieuwenhuizen
2020-01-31 14:57 ` Linus Björnstam
2020-01-31 15:16 ` Han-Wen Nienhuys
2020-01-31 17:50 ` Han-Wen Nienhuys
2020-01-31 18:19 ` Linus Björnstam
2020-01-31 19:17 ` Han-Wen Nienhuys
2020-01-31 19:52 ` Linus Björnstam
2020-01-31 20:01 ` Linus Björnstam
2020-02-01 9:54 ` Han-Wen Nienhuys
2020-02-01 9:56 ` Han-Wen Nienhuys
2020-02-01 10:10 ` David Kastrup
2020-02-01 11:23 ` Han-Wen Nienhuys
2020-02-01 11:36 ` David Kastrup
2020-02-01 13:12 ` Linus Björnstam
2020-02-01 11:09 ` David Kastrup
2020-02-01 13:16 ` Linus Björnstam
2020-02-01 14:23 ` David Kastrup
2020-02-01 15:21 ` Linus Björnstam [this message]
2020-02-01 21:55 ` Taylan Kammer
2020-02-01 21:58 ` Fwd: " Taylan Kammer
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=1953f8c7-3648-40d3-83ed-72a26d20e6ec@www.fastmail.com \
--to=linus.bjornstam@veryfast.biz \
--cc=dak@gnu.org \
--cc=guile-devel@gnu.org \
--cc=hanwenn@gmail.com \
/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).