mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-21 20:12:51 -08:00
84 lines
2.1 KiB
Text
84 lines
2.1 KiB
Text
@node Defun preprocessor
|
|
@section Defun preprocessor
|
|
|
|
@cindex Defun preprocessor
|
|
The defun preprocessor allows for convenient definition of Lisp
|
|
functions with optional and keyword arguments and the use of Lisp
|
|
symbols in ECL's own C source code. It generates the C code necessary
|
|
to use optional function arguments and to access symbols in ECL's
|
|
builtin symbol table.
|
|
|
|
Usage:
|
|
@verbatim
|
|
dpp [in-file [out-file]]
|
|
@end verbatim
|
|
|
|
The file named in-file is preprocessed and the output will be
|
|
written to the file whose name is out-file. If in-file is "-"
|
|
program is read from standard input, while if out-file is "-"
|
|
C-program is written to standard output.
|
|
|
|
The function definition:
|
|
|
|
@exindex dpp: function definition
|
|
@verbatim
|
|
@(defun name ({var}*
|
|
[&optional {var | (var [initform [svar]])}*]
|
|
[&rest var]
|
|
[&key {var |
|
|
({var | (keyword var)} [initform [svar]])}*
|
|
[&allow_other_keys]]
|
|
[&aux {var | (var [initform])}*])
|
|
|
|
C-declaration
|
|
|
|
@ {
|
|
|
|
C-body
|
|
|
|
} @)
|
|
@end verbatim
|
|
|
|
name is the name of the lisp function
|
|
|
|
&optional may be abbreviated as &o.@*
|
|
&rest may be abbreviated as &r.@*
|
|
&key may be abbreviated as &k.@*
|
|
&allow_other_keys may be abbreviated as &aok.@*
|
|
&aux may be abbreviated as &a.
|
|
|
|
Each variable becomes a C variable.
|
|
|
|
Each supplied-p parameter becomes a boolean C variable.
|
|
|
|
Initforms are C expressions.
|
|
If an expression contains non-alphanumeric characters,
|
|
it should be surrounded by backquotes (`).
|
|
|
|
|
|
Function return:
|
|
@verbatim
|
|
@(return {form}*);
|
|
@end verbatim
|
|
|
|
Return function expands into a lexical block @verb{|{}|}, so if it's
|
|
used inside IF/ELSE, then it should be enclosed, even if we
|
|
use sole @verb{|@(return);|}, because ";" will be treated as the next
|
|
instruction.
|
|
|
|
Symbols:
|
|
|
|
@verbatim
|
|
@'name'
|
|
@end verbatim
|
|
|
|
Expands into a C statement, whole value is the given symbol
|
|
from symbols_list.h
|
|
|
|
@verbatim
|
|
@[name]
|
|
@end verbatim
|
|
|
|
Expands into a C statement, whole value is a fixnum
|
|
corresponding to the index in the builtin symbols table of the
|
|
given symbol from symbols_list.h. Used for handling type errors.
|