Usage with macros Jakub T. Jankiewicz (25 Jan 2025 13:38 UTC)
Re: Usage with macros Jakub T. Jankiewicz (25 Jan 2025 14:34 UTC)
Re: Usage with macros Wolfgang Corcoran-Mathe (25 Jan 2025 17:57 UTC)
Re: Usage with macros Marc Nieper-Wißkirchen (25 Jan 2025 18:11 UTC)
Re: Usage with macros Jakub T. Jankiewicz (25 Jan 2025 20:25 UTC)
Re: Usage with macros Marc Nieper-Wißkirchen (25 Jan 2025 20:30 UTC)
Re: Usage with macros Jakub T. Jankiewicz (26 Jan 2025 00:01 UTC)

Re: Usage with macros Jakub T. Jankiewicz 25 Jan 2025 20:25 UTC


On Sat, 25 Jan 2025 19:11:12 +0100
Marc Nieper-Wißkirchen <xxxxxx@gmail.com> wrote:

> I don't understand why one would want to use lexical syntax in this example.
>
> For example, I don't ask for lexical syntax, say #$foo, that evaluates
> to, say, a freshly generated list containing the symbol foo. You would
> just write (list 'foo).

This is exactly the same as with lisp macros with gensyms, Common Lisp is
even included in the SRFI.

(define-macro (when test-expr . body)
  (let ((test (gensym)))      ; or :|test| instead of (gensym)
    `(let ((,test ,test-expr))
       (if ,test
           (begin
             ,@body)))))

This is simple use case for gensym in lisp macros (and Some scheme
implementations also support lisp macros), in reality you don't need to save
the test-expr in variable, but you have to if you want to create anaphoric
macros, or if you want to use given expression twice.

And from my understanding uninterned symbols are just replacement of gensyms.

Also if this suppose to be used with Macros, I would love to see an example of
usage with syntax-rules, if there is any.

--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me
https://lips.js.org
https://koduj.org