User Tools

Site Tools


ch2_1_unquote

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ch2_1_unquote [2021/04/18 03:46] – created adminch2_1_unquote [2022/02/25 01:47] (current) admin
Line 6: Line 6:
 >(setq b 3)       ; set value of symbol B >(setq b 3)       ; set value of symbol B
 3 3
->`(a ,b c)        ; unquoted b+>`(a ,b c)        ; unquoted B in backquouted list
 (A 3 C)           ; symbols A and C are not evaled, but B is (A 3 C)           ; symbols A and C are not evaled, but B is
-</code> +</code>
  
 +The last command is expanded to 
  
 +<code lisp>
 +>(backquote (a (unquote b) c))
 +</code>
 +
 +Following example was shown for backquote:
  
 <code lisp> <code lisp>
->(setq b 3)       ; set value of symbol B +>`(a ,(+ 1 2) c)    backquoted list 
-+(A 3 C)             form (+ 1 2) evaluated
->`(a ,c)        unquoted b +
-(A 3 C)           symbols A and C not evaled, but B is+
 </code>  </code> 
 +
 +If the evaluated element results in list, with unquoting it becomes sub-list of the backqouted list.
 +
 +<code lisp>
 +>`(a ,(list 1 2) c)    ; function LIST produces list
 +(A (1 2) C)            ; list (1 2) as sublist
 +</code> 
 +
 +Important is that if we unqoute pre-existing list, this original list will become sublist, not a copy. ''SPLICE-UNQUOTE'' is different in this. 
 +
 +See splice-unquote for further refinement. The forms ''BACKQUOTE'', ''UNQUOTE'' and ''SPLICE-UNQUOTE'' are useful for writing macros.
 +
 +
ch2_1_unquote.1618739162.txt.gz · Last modified: 2021/04/18 03:46 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki