[Top][All Lists]

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

Re: unhandled constant?

From: David Kastrup
Subject: Re: unhandled constant?
Date: Sat, 01 Feb 2020 12:09:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Linus Björnstam <address@hidden> writes:

> Guile1.8's macros are run-time macros: they are executed directly and
> not transformed to output code that is then compiled. That is the
> reason why your code works: to newer guiles the (inner ...) is only
> available at expansion time. The macro output is trying to call code
> that does not exist at runtime!
> For this to be working code the (inner ...) function needs to be
> available in the macro expansion. I didn't read through exactly what
> you are trying to do, but try outputting a let:
> `(let ((inner (lambda (n v) (set ! ...))))
>   (inner ,name ,value))
> I doubt you can make the old code work in newer guiles, since I doubt
> any scheme is a s lax about expansion time and macro time separation.

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
         (make-var n v)
  `(,inner ',name ,value))
(define-session foo 1)
(display decl)

as stated, the local function "inner" is defined at macro time, but the
`(,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

Can you clarify?

David Kastrup

reply via email to

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