National Institute of Advanced Industrial Science and Technology (AIST) This page is a page of the former research institute. We stopped updating on March 31.2001.
E-mail to webmaster (Japanese) E-mail to webmaster (English)
next up previous contents index
Next: Sequencing and Lets Up: Control Structures Previous: Control Structures

Conditionals

Although and, or and cond are advised to be macros by Common Lisp, they are implemented as special forms in EusLisp to improve the interpreting performance.

  and {form}* [special]

  or {form}* [special]   if test then [else] [special]   when test forms [macro]
  • Unlike if, when and unless allow you to write multiple forms which are executed when test holds (when) or does not unless. On the other hand, these macros cannot have the else forms.
  unless test forms [macro]
  • is equivalent to (when (not test) . forms).
  cond (test {form}*)* [special]
  • Arbitrary number of cond-clauses can follow cond. In each clause, the first form, that is test, is evaluated. If it is non-nil, the rest of the forms in that clause are evaluated sequentially, and the last value is returned. If no forms are given after the test, the value of the test is returned. When the test fails, next clause is tried until a test which is evaluated to non-nil is found or all clauses are exhausted. In the latter case, cond returns NIL.
  case key {({label | ({lab}*) {form}*)}* [macro]
  • For the clause whose label matches with key, forms are evaluated and the last value is returned. Equality between key and label is tested with eq or memq, not with equal.

next up previous contents index
Next: Sequencing and Lets Up: Control Structures Previous: Control Structures

Hirofumi Nakagaki
Fri Mar 22 12:46:38 JST 1996