LISP: WHEN
C: EWhen
[M][CLTL 7]
SYNOPSIS:
when test {form}*
DESCRIPTION:
When a form
(when test form1 form2 ...)
is encountered, the test is evaluated first.
If the result of the test clause is not nil, then the forms in the when body constitute an implicit progn. The forms will be evaluated from the first to the last. The value of the last one will be returned as the result of the form.when.
If the result is nil, then no form is evaluated, and nil is returned.
NOTES:
when
is typically used for its side effects. That is, the value of a when form is traditionally not used.If the return value of a conditional form is relevant, then it may be stylistically more appropriate to use and or if.
Here is a quick summary of some equivalences with other conditional constructs:
(when p x y z) == (and p (progn x y z))
(when p x y z) == (cond (p x y z))
(when p x y z) == (if p (progn x y z) nil)
(when p x y z) == (unless (not p) x y z)
LISP: WITH-OPEN-FILE
[M][CLTL]
SYNOPSIS:
with-open-file (stream filename {options}*) {declarations}* {form)*
DESCRIPTION:
This macro, defined in wofile.lsp, is a form in which a file is open, available for processing, and then closed on exit or when a throw occurs. This is more desirable than using open and close since it is guaranteed that the file will be closed on exit from the form, either normal are abnormal; file handles are a limited resource on most systems and DOS is no exception.
The forms of the body are evaluated in sequence as an implicit progn with the stream' variable bound to the result of calling open with options. Essentially, the options are evaluated and used as keyword arguments to open. An unwind-protect is wrapped around the body of the macro in order to catch abnormal exits.
The filename argument is the name of the file to process; as usual it can be a string or a symbol.
NOTES:
To use this macro you must load the file wofile.lsp, which is installed in the LISP installation directory.
Specials currently do not work with multiple-value-bind, which is part of this macro, so special declarations should not be used with this right now.
LISP: WRITE
C: L_Write
min args: 1
max args: 2
[F][CLTL 22]
SYNOPSIS:
write object &key :stream :escape :radix :base
:pretty :level :length :case :gensym :array
DESCRIPTION:
The printed representation of object is written to the output stream specified by :stream, which defaults to the value of *standard-output*.
The other keyword arguments specify values used to control the generation of the printed representation. Each defaults to the value of the corresponding global variable: See *print-escape*, *print-radix*, *print-base*, *print-pretty*, *print-level*, *print-length*, *print-case*, *print-gensym*, and *print-array*. (This is the means by which these variables affect printing operations: supplying default values for the write function.) write returns object.
NOTES:
Not all of the keywords are supported yet, only the ones which have corresponding manual entries for the global variable.
LISP: WRITE-CHAR
C: L_WrCh
min args: 1
max args: 2
[F][CLTL 22]
SYNOPSIS:
write-char character &optional output-stream
DESCRIPTION:
write-char
outputs the character to output-stream, and returns character.LISP: WRITE-LINE
C: L_WrLine
min args: 0
max args: 1
[F][CLTL 22]
SYNOPSIS:
write-line string &optional output-stream &key :start :end
DESCRIPTION:
write-line
does the same thing as write-string, but then outputs a newline afterwards. The string is returned (not the substring delimited by :start and :end). This function is significantly more efficient than an explicit loop using write-char.LISP: WRITE-STRING
C: L_WrStr
min args: 0
max args: 1
[F][CLTL 22]
SYNOPSIS:
write-string string &optional output-stream &key :start :end
DESCRIPTION:
write-string
writes the characters of the specified substring of string to the output-stream. The :start and :end parameters delimit a substring of string in the usual manner (see Chapter 14).The string is returned (not the substring delimited by :start and :end).
This function is significantly more efficient than an explicit loop using write-char.