guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unhandled constant?


From: Linus Björnstam
Subject: Re: unhandled constant?
Date: Sat, 01 Feb 2020 14:16:36 +0100
User-agent: Cyrus-JMAP/3.1.7-781-gfc16016-fmstable-20200127v1

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]