Debian Codegraph @

src/doc/manual/developer-guide/dpp.txi

raw
1 @node Defun preprocessor
2 @section Defun preprocessor
3
4 @cindex Defun preprocessor
5 The defun preprocessor allows for convenient definition of Lisp
6 functions with optional and keyword arguments and the use of Lisp
7 symbols in ECL's own C source code. It generates the C code necessary
8 to use optional function arguments and to access symbols in ECL's
9 builtin symbol table.
10
11 Usage:
12 @verbatim
13 dpp [in-file [out-file]]
14 @end verbatim
15
16 The file named in-file is preprocessed and the output will be
17 written to the file whose name is out-file. If in-file is "-"
18 program is read from standard input, while if out-file is "-"
19 C-program is written to standard output.
20
21 The function definition:
22
23 @exindex dpp: function definition
24 @example
25 @verbatim
26 @(defun name ({var}*
27 [&optional {var | (var [initform [svar]])}*]
28 [&rest var]
29 [&key {var |
30 ({var | (keyword var)} [initform [svar]])}*
31 [&allow_other_keys]]
32 [&aux {var | (var [initform])}*])
33
34 C-declaration
35
36 @ {
37
38 C-body
39
40 } @)
41 @end verbatim
42 @end example
43
44 name is the name of the lisp function
45
46 &optional may be abbreviated as &o.@*
47 &rest may be abbreviated as &r.@*
48 &key may be abbreviated as &k.@*
49 &allow_other_keys may be abbreviated as &aok.@*
50 &aux may be abbreviated as &a.
51
52 Each variable becomes a C variable.
53
54 Each supplied-p parameter becomes a boolean C variable.
55
56 Initforms are C expressions.
57 If an expression contains non-alphanumeric characters,
58 it should be surrounded by backquotes (`).
59
60
61 Function return:
62 @example
63 @verbatim
64 @(return {form}*);
65 @end verbatim
66 @end example
67
68 Return function expands into a lexical block @code{@{@}}, so if it's
69 used inside @code{if/else}, then it should be enclosed, even if we
70 use sole @code{@@(return);}, because ";" will be treated as the next
71 instruction.
72
73 Symbols:
74
75 @example
76 @verbatim
77 @'name'
78 @end verbatim
79 @end example
80
81 Expands into a C statement, whole value is the given symbol
82 from @file{symbols_list.h}
83
84 @example
85 @verbatim
86 @[name]
87 @end verbatim
88 @end example
89
90 Expands into a C statement, whole value is a fixnum corresponding to the
91 index in the builtin symbols table of the given symbol from
92 @file{symbols_list.h}. Used for handling type errors.