@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
@example
@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
@end example

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:
@example
@verbatim
        @(return {form}*);
@end verbatim
@end example

Return function expands into a lexical block @code{@{@}}, so if it's
used inside @code{if/else}, then it should be enclosed, even if we
use sole @code{@@(return);}, because ";" will be treated as the next
instruction.

Symbols:

@example
@verbatim
@'name'
@end verbatim
@end example

Expands into a C statement, whole value is the given symbol
from @file{symbols_list.h}

@example
@verbatim
@[name]
@end verbatim
@end example

Expands into a C statement, whole value is a fixnum corresponding to the
index in the builtin symbols table of the given symbol from
@file{symbols_list.h}. Used for handling type errors.
