Discussion of Common Lisp
3 posts • Page 1 of 1
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:
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.
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)))