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@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