Re: Control the order of expansion of syntax-case macros

Vivien Kraus <[email protected]>
Newsgroups gmane.lisp.guile.user
Message-ID <[email protected]>
Hello!

Le vendredi 20 décembre 2024 à 10:15 +0100, Maxime Devos a écrit :
> (define-syntax hello
>   (lambda (stx)
>     (syntax-case stx ()
>       (_
>        (begin
>          (format (current-error-port) "Hello!\n")
>          (datum->syntax #f "hello"))))))
>  
> You can simplify this to:
>  
> (define-syntax hello
>   (lambda (stx)
>      (format (current-error-port) "Hello!\n")
>      (datum->syntax #f "hello")))

This was an eye-opening moment for me: syntax-case is its own thing and
I don’t need the full define-syntax / lambda / syntax-case combo.

> I wonder, did you copy-paste all four blocks (both the define-syntax
> forms and the ,expand) at the same time, or one-by-one?

Oops, I was evaluating everything at once, so I did not notice the
format took place at definition time.

> Another option is to just let ‘hello’ and ‘world’ be procedure (that
> happen to accept syntax and produce syntax)

I’ll have to examine my new options now that I can think outside the
define-syntax / lambda / syntax-case box.

Anyway, thank you again for your help.

Best regards,

Vivien
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.