Next: , Previous: cursor-twitch, Up: GCL Reference


7.2.31 defun

(defun NAME (ARG1 ...) [DOCSTRING] EXPR1 ...)
Define a named lambda-expression, that is: define NAME to evaluate to the lambda-expression (lambda (ARG1 ...) (EXPR1 ...)) when called as a function. Also, install DOCSTRING as response to the commands (help NAME) and (morehelp NAME). Note that DOCSTRING need not contain the command-synopsis, it is generated automatically. EXPR1 cannot be a string if DOCSTRING is omitted; it would be interpreted as the doc-string. The return value of (defun ...) is the function name. Functions can be recursive and self-modifying. It is possible to redefine builtin-functions, in this case the old definition is still available under the name -builtin-OLDNAME-. Argument values may be altered by setq; the new binding is discarded after evaluation of the surrounding defun-body. The special keywords &optional and &rest have the same meaning as for anonymous lambda-expression, see there. See (lambda ...). See (setq ...). See (let ...).