On Mon, Apr 17, 2023, 1:11 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>     ELISP> (macroexpand '`(,@(list 1 2) a b c d))
>>     (append (list 1 2) '(a b c d))
>>     ELISP> (macroexpand '`(a b c d ,@(list 1 2)))
>>     (cons 'a (cons 'b (cons 'c (cons 'd (list 1 2)))))
>>     ELISP>
> Why is the former more efficient than the latter?

One allocates N₁+N₂ cons cells, then other only allocates N₁ cons-cells.
This is true regardless of how we macroexpand and byte-compile the code.
This only makes a diference for code that's executed several times
(i.e. not at toplevel).

I see - what you meant by "such ,@" was when the preceding elements are constant.  

I've seen a veteran Lisp programmer get bitten by side-effecting a list constructed with that feature of backquote.  

Lynn