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 Marc Nieper-Wißkirchen 25 Jan 2025 20:29 UTC

Am Sa., 25. Jan. 2025 um 21:25 Uhr schrieb Jakub T. Jankiewicz <xxxxxx@onet.pl>:
>
>
>
> 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.

This I understand; my question is why one would ask for lexical syntax
instead of just calling a procedure as in the (gensym) example.

The SRFI exports (generate-uninterned-symbol) as a replacement for
(gensym) so you can just put this ordinary procedure call in place of
(gensym).

Marc