User Tools

Site Tools


ch2_1_unquote

This is an old revision of the document!


UNQUOTE

Unquote form expect one argument. If unquote appears outside of backquoted list, it is ignored, and the argument is evaluated normally. But within a backquoted list, or any of its sub-lists, we can switch some symbols or sub-lists back to code mode with unquote character , (comma), which reader expands to unquote form.

>(setq b 3)       ; set value of symbol B
3
>`(a ,b c)        ; unquoted b
(A 3 C)           ; symbols A and C are not evaled, but B is

The last command is equivalent to

>(backquote (a (unquote b) c))

Following example was shown for backquote:

>`(a ,(+ 1 2) c)    ; backquoted list
(A 3 C)             ; form (+ 1 2) evaluated

If the evaluated element results in list, with unquoting it becomes sub-list of the backqouted list:

>`(a ,(list 1 2) c)    ; function LIST produces list
(A (1 2) C)            ; list (1 2) as sublist

See splice-unquote.

ch2_1_unquote.1618739752.txt.gz · Last modified: 2021/04/18 03:55 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki