Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

&aux

&aux

type: keyword
location: built-in
source file: xleval.c
Common LISP compatible: yes
supported on: all machines

SYNTAX

&aux [ <aux-var> | (   ) ] ...
        <aux-var>       -       auxiliary variable 
        <aux-value>     -       auxiliary variable initialization

DESCRIPTION

In XLISP, there are several times that you define a formal argument list for a body of code (like DEFUN, DEFMACRO, :ANSWER and LAMBDA). The <aux-var> variables are a mechanism for you to define variables local to the function or operation definition. If there is an optional <aux-value>, they will be set to that value on entry to the body of code. Otherwise, they are initialized to NIL. At the end of the function or operation execution, these local symbols and their values are are removed.

EXAMPLES

(defun my-add                           ; define function MY-ADD
  (num1 &rest num-list &aux sum)        ;   with 1 arg, rest, 1 aux var
  (setq sum num1)                       ;   clear SUM
  (dotimes (i (length num-list) )       ;   loop through rest list
     (setq sum (+ sum (car num-list)))  ;      add the number to sum
     (setq num-list (cdr num-list)))    ;      and remove num from list
  sum)                                  ;   return sum when finished
(my-add 1 2 3 4)                        ; returns 10
(my-add 5 5 5 5 5)                      ; returns 25
(defun more-keys                        ; define MORE-KEYS
        ( a                             ;   with 1 parameter A          
          &aux b                        ;   with local var B
               (c 99)                   ;        local var C= 99
               (d T)  )                 ;        local var D= T
        (format T "a=~a " a)            ;   body of the function
        (format T "b=~a " b)            ;
        (format T "c=~a " c)            ;
        (format T "d=~a " d))           ;
(more-keys "hi")                        ; prints a=hi b=NIL c=99 d=T


Go to the first, previous, next, last section, table of contents.