XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

comma-at


Type:   -   reader expansion
Source:   -   xlcont.c, xlread.c

Syntax

(comma-at expr)
expr - an expression which is evaluated within a backquoted expression

Description

A backquote special form returns an expression unevaluated, except that portions of the expression may be evaluated when they are preceeded by a comma [,] or 'comma-at' [,@]. 'comma-at' will evaluate the portion of the expression that the comma-at preceeds. The portion needs to be a list. The list is spliced into the expression. If the portion is not a list, 'comma-at' will splice in nothing.

Examples

(setq box 'stuff-inside)                 ; BOX contains STUFF-INSIDE
(print box)                              ; prints STUFF-INSIDE
(quote (i have the box))                 ; returns (I HAVE THE BOX)
(backquote (i have the box))             ; returns (I HAVE THE BOX)
(backquote (I have (comma box)))         ; returns (I HAVE STUFF-INSIDE)
(backquote (I have the ,@box))           ; returns (I HAVE THE)
(setq automobile '(a van))               ; set up AUTOMOBILE
(backquote (I have automobile))          ; returns (I HAVE AUTOMOBILE)
(backquote (I have (comma automobile)))  ; returns (I HAVE (A VAN))
(backquote (I have ,@automobile))        ; returns (I HAVE A VAN)
`(I have ,@automobile)                   ; returns (I HAVE A VAN)

Read macro: XLISP supports the normal read macro of a comma [,@] as a short-hand method of writing the 'comma-at' read-expansion.

Note: backquote , comma and 'comma-at' are very useful in defining macros via defmacro.

See the comma-at reader expansion in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next