17.05.2015 Views

zl:1 - FTP

zl:1 - FTP

zl:1 - FTP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

~7 oddp<br />

oddp integer Function<br />

Returns t if integer is odd, otherwise nil. If integer is not an integer, oddp<br />

signals an error.<br />

For a table of related items: See the section "Numeric Property-checking<br />

Predicates" in Symbolics Common Lisp: Language Concepts.<br />

once-only variable-list &body body<br />

A once-only form looks like:<br />

(once-onl y var-list<br />

forml<br />

form2<br />

... )<br />

Macro<br />

var-list is a list of variables. once-only is usually used in macros where<br />

these variables are Lisp forms. The forms are a Lisp program that<br />

presumably uses the values of those variables. When the form resulting<br />

from the expansion of the once-only is evaluated, it fIrst inspects the<br />

values of each of the variables in var-list; these values are assumed to be<br />

Lisp forms. It binds each variable either to its current value, if the current<br />

value is a trivial form, or to a generated symbol. Next, once-only<br />

e,·aluates the forms, in this new binding environment, and when they have<br />

been evaluated it undoes the bindings. The result of the evaluation of the<br />

last form is presumed to be a Lisp form, typically the expansion of a<br />

macro. If all of the variables had been bound to trivial forms, then<br />

once-only just returns that result. Otherwise, once-only returns the result<br />

wrapped in a lambda-combination that binds the generated symbols to the<br />

result of evaluating the respective nontrivial forms.<br />

The effect is that the program produced by evaluating the once-only form<br />

is coded in such a way that it only evaluates each form once, unless evaluation<br />

of the form has no side effects, for each of the forms that were the<br />

values of variables in var-list. At the same time, no unnecessary lambdabinding<br />

appears in this program, but the body of the once-only is not cluttered<br />

up with extraneous code to decide whether or not to introduce<br />

lambda-binding in the program it constructs.<br />

Note well: while once-only attempts to prevent multiple evaluation, it does<br />

not necessarily preserve the order of evaluation of the forms! Since it<br />

generates the new bindings, the evaluation of complex forms (for which a<br />

new variable needs to be created) may be moved ahead of the evaluation of<br />

simple forms (such as variable references). once-only does not solve all of<br />

the problems mentioned in this section.<br />

I

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!