Expansion of double backticks and commas

Steve Haflich shaflich at gmail.com
Fri Feb 10 20:45:18 UTC 2023


You're thinking about this in an improper and potentially confusing way.
You use words like "copy" and "discard" characters, as if this were an
issue about text editing.  It is not.

Backquote notation is a way of writing run-time code that fills in a
certain template, allowing that code to be notated in a way more helpful
and visible to the programmer than if he had to write that code himself.
Your use of "evaluates" is also misleading, since the reader only READs and
nothing here is EVALUATEd.  It is entirely as if a backquote form is
replaced by the runtime code that would have the specified result, and the
ANS permits the backquote-generated replacement code to be anything that
has the same effect.  (However, many bq implementations expand into
alternately-named equivalent internal functions, such as sys::bq-list,
sys::bq-cons) so that the pretty printer can recognise bq expansions and
attempt to reconstruct something equivalent to the original notation when
one of these source-code forms needs be printed in a development
environment.)



On Fri, Feb 10, 2023 at 12:16 PM Andrea Monaco <andrea.monaco at autistici.org>
wrote:

>
> I see that SBCL expands this way:
>
>
> ``(,,@'(0 1 2) ,3) -> `(,0 ,1 ,2 ,3)
>
>
> so apparently the second comma is consumed while the first one is copied
> before each element of the spliced list.
>
> This behavior seems peculiar to sbcl, as clisp evaluates that form to
> (LIST* 0 1 2 '(3)) and gcl to (LIST 0 1 2 3): they both discard the
> other backtick-comma pair.
>
>
> I wonder what ANSI says on the matter.  Does any of the two behaviors,
> the sbcl's and the clisp/gcl's, follows from the basic rules, for
> example those in
> http://www.lispworks.com/documentation/HyperSpec/Body/02_df.htm?
>
> I'd appreciate any help.  Thanks,
>
>
>
> Andrea Monaco
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/pro/attachments/20230210/eb4f92b7/attachment.html>


More information about the pro mailing list