Page 1 of 1

,. vs ,@

Posted: Sun Dec 14, 2014 9:07 am
by filfil
Is there a difference between ,. and ,@?

Thanx!

Re: ,. vs ,@

Posted: Sun Dec 14, 2014 12:01 pm
by David Mullen
Common Lisp has non-destructive and destructive versions of some functions—REVERSE and NREVERSE, for example. So the backquote syntax has ",." (destructive) and ",@" (non-destructive). Some simple examples of how the backquote syntax expands to regular call forms:

Code: Select all

? '`(foo ,@bar)
(LIST* 'FOO BAR)
? '`(foo ,.bar)
(LIST* 'FOO BAR)
? '`(foo ,@bar ,baz)
(LIST* 'FOO (APPEND BAR (LIST BAZ)))
? '`(foo ,.bar ,baz)
(LIST* 'FOO (NCONC BAR (LIST BAZ)))
In the first two forms, ",." versus ",@" makes no difference because the BAR is in the tail position. But in the latter two forms, ",@" uses APPEND and ",." uses NCONC. The destructive version would be okay if you knew the list being spliced was safe to modify—i.e. without trampling on somebody else's data.

Re: ,. vs ,@

Posted: Sun Dec 14, 2014 4:45 pm
by filfil
Thank you!