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.

179 <strong>zl</strong> :displace<br />

<strong>zl</strong>:displace form expansion Function<br />

Replaces the car and cdr of form so that it looks like:<br />

(s i : d i sp 1 aced original-form expansion)<br />

form must be a list. original-form is equal to form but has a different toplevel<br />

cons so that the replacing mentioned above does not affect it.<br />

si:displaced is a macro, which returns the caddr of its own macro form.<br />

So when the si:displaced form is given to the evaluator, it "expands" to expansion.<br />

z1:displace returns expansion.<br />

<strong>zl</strong>:dlet ((variable-pattern value-pattern) ... ) body... Special Form<br />

Binds variables to values, using de struc turing, and evaluates the body<br />

forms in the context of those bindings. In place of a variable to be assigned,<br />

you can provide a tree of variables. The value to be assigned must<br />

be a tree of the same shape. The trees are destructured into their component<br />

parts, and each variable is assigned to the corresponding part of the<br />

value tree.<br />

First the value-patterns are evaluated. If a variable-pattern is a symbol, it<br />

is bound to the result of eValuating the corresponding value-pattern. If<br />

variable-pattern is a tree, the result of evaluating value-pattern should be a<br />

tree of the same shape. The trees are de structured, and each variable that<br />

is a component of variable-pattern is bound to the value that is the corresponding<br />

element of the tree that results from evaluating value-pattern.<br />

The bindings happen in parallel; all the value-patterns are evaluated before<br />

any variables are bound. Finally, the body forms are evaluated sequentially,<br />

the old values of the variables are restored, and the result of the last<br />

body form is returned. Example:<br />

(2l:dlet (((a b) '((x y) 2))<br />

(c 'd))<br />

(values a b c))<br />

I<br />

returns (x y), z, and d.<br />

z1:dlet* ((variable-pattern value-pattern) ... ) body... Special Form<br />

Binds variables to values, using de structuring, and evaluates the body<br />

forms in the context of those bindings. In place of a variable to be assigned,<br />

you can provide a tree of variables. The value to be assigned must<br />

be a tree of the same shape. The trees are destructured into their component<br />

parts, and each variable is assigned to the corresponding part of the<br />

value tree.<br />

The first value-pattern is evaluated. If variable-pattern is a symbol, it is<br />

bound to the result of evaluating value-pattern. If variable-pattern is a tree,<br />

the result of evaluating value-pattern should be a tree of the same shape.<br />

The trees are destructured, and each variable that is a component of

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

Saved successfully!

Ooh no, something went wrong!