ch2_1_splice-unquote
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ch2_1_splice-unquote [2021/04/18 04:43] – admin | ch2_1_splice-unquote [2022/03/06 11:37] (current) – admin | ||
---|---|---|---|
Line 3: | Line 3: | ||
Splice-unquote form expects one argument. Like unquote, it is ignored if it appears outside of backquoted list. Under backquoted list it works just like unquote, with the difference when the unquoted item evaluates to list. In that case the elements of the list are spliced into the containing backquoted list. The splice-unqoute has the special character '', | Splice-unquote form expects one argument. Like unquote, it is ignored if it appears outside of backquoted list. Under backquoted list it works just like unquote, with the difference when the unquoted item evaluates to list. In that case the elements of the list are spliced into the containing backquoted list. The splice-unqoute has the special character '', | ||
- | We have seen following example for unquote: | + | We have seen following example for '' |
<code lisp> | <code lisp> | ||
Line 10: | Line 10: | ||
</ | </ | ||
- | With splice-unqoute, we will get this: | + | With '' |
<code lisp> | <code lisp> | ||
Line 17: | Line 17: | ||
</ | </ | ||
- | The elements of the spliced-in sublist are freshly consed, which means that when we are splicing an existing list, it will not be modified. | + | The elements of the spliced-in sublist are freshly consed, which means that when we are splicing an existing list, it will not be modified. Since version 1.2.9.1 we can also splice cyclic or dotted lists: In the freshly consed copy, for cyclic lists it will break the cycle, and for dotted lists simply ignores the danglig atom. |
<code lisp> | <code lisp> | ||
>(setq b (list 'c ' | >(setq b (list 'c ' | ||
- | (C D) | + | (C D) ; this is it |
- | ; this is it | + | |
>`(a ,@b e f) | >`(a ,@b e f) | ||
(A C D E F) ; elements of list (C D) spliced-in | (A C D E F) ; elements of list (C D) spliced-in | ||
Line 30: | Line 30: | ||
</ | </ | ||
- | Note that when splice-unqoute | + | Note that when '' |
<code lisp> | <code lisp> | ||
Line 36: | Line 36: | ||
(1 (2 3) 4) ; list (2 3) is sublist | (1 (2 3) 4) ; list (2 3) is sublist | ||
- | >(list 1 ,(list 2 3) 4) ; with comma out of backqoute .. | + | >(list 1 ,(list 2 3) 4) ; with comma outside |
(1 (2 3) 4) ; .. just gives the same result | (1 (2 3) 4) ; .. just gives the same result | ||
- | >(list 1 ,@(list 2 3) 4) ; and comma-at | + | >(list 1 ,@(list 2 3) 4) ; and comma-at |
(1 (2 3) 4) ; .. same result, will not splice | (1 (2 3) 4) ; .. same result, will not splice | ||
</ | </ | ||
- | The forms BACKQUOTE, UNQUOTE and SPLICE-UNQUOTE are useful for writing macros. | + | The forms '' |
ch2_1_splice-unquote.1618742580.txt.gz · Last modified: 2021/04/18 04:43 by admin