> (base) mattei@mbp-touch-bar Scheme-PLUS-for-Guile % guile
> GNU Guile 3.0.8.99-f3ea8
> Copyright (C) 1995-2022 Free Software Foundation, Inc.
> 
> Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
> This program is free software, and you are welcome to redistribute it
> under certain conditions; type `,show c' for details.
> 
> Enter `,help' for help.
> scheme@(guile-user)> (define-syntax test-it
>    (lambda (stx)
>     (syntax-case stx ()
>     ((_ term1)
>      (with-syntax ((var (syntax->datum #'term1)))
>        #'var)))))
> scheme@(guile-user)> (test-it (+ 2 3))
> While compiling expression:
> Syntax error:
> unknown file:#f:#f: encountered raw symbol in macro output in subform + of
> (test-it (+ 2 3))


As the error message says, your macro contains the raw symbol `term1`.
The expression (syntax->datum #'term1) is equivalent to 'term1 .
What's raising the error is not with-syntax itself, it's the fact
that a hygienic macro must return syntax objects, and a raw
symbol is not a syntax object. Kawa and Racket probably have some
fallback where the macro becomes non-hygienic when it returns
raw symbols. But R6RS makes it clear that this is not standard
Scheme. See

https://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-13.html#node_sec_12.2

"""
a syntax object is:

- a pair of syntax objects,
- a vector of syntax objects,
- a nonpair, nonvector, nonsymbol value, or
- a wrapped syntax object
"""

"""
A transformation procedure is a procedure that must accept one argument, a
wrapped syntax object (section 12.2) representing the input, and return a syntax
object (section 12.2) representing the output. 
"""


Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to