This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

,. vs ,@

3 posts · 3449 views

Is there a difference between ,. and ,@?

Thanx!

Re: ,. vs ,@

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:
? '`(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 ,@

Thank you!