[Top][All Lists]

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

Having trouble with syntax-source

From: Mitchell Kember
Subject: Having trouble with syntax-source
Date: Fri, 22 Apr 2022 12:51:27 -0400


I'm having trouble using syntax-source in a macro.

Here's what I have:

    (import (rnrs (6)))
    (define-syntax foo
      (lambda (x)
        (syntax-case x ()
          ((_ e)
             (display (syntax-source #'e))
             #'(display (syntax-source #'e)))))))
    (foo (list 1))

Displaying the syntax-source works the first time during macro
expansion, but not the second time in the result of the macro:

    $ guile --no-auto-compile --r6rs
    ((filename . (line . 13) (column . 5))
    2 (primitive-load "/path/to/")
    In ice-9/eval.scm:
    191:35 1 (_ #f)
    In unknown file:
    0 (syntax-source (#<syntax list> #<syntax 1>))

    ERROR: In procedure syntax-source:
    In procedure syntax-source: Wrong type argument in position 1
(expecting syntax object): (#<syntax list> #<syntax 1>)

I've tried the same thing in Racket and Chez Scheme and it works fine there:

Is there some way to fix it for Guile? (Ideally in a way that also
works for Racket and Chez, since I'm in a codebase that targets all of


reply via email to

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