source: project/wiki/man/5/TODO/Non-standard macros and special forms @ 35323

Last change on this file since 35323 was 35323, checked in by felix, 3 months ago

manual: more links changed, added R5RS page (or should it be R7RS?)

File size: 4.0 KB
Line 
1[[tags: manual]]
2
3[[toc:]]
4
5== Non-standard macros and special forms
6
7=== Conditional forms
8
9==== select
10
11<macro>(select EXP ((KEY ...) EXP1 ...) ... [(else EXPn ...)])</macro>
12
13This is similar to {{case}}, but the keys are evaluated.
14
15=== Other forms
16
17==== assert
18
19<macro>(assert EXP [STRING ARG ...])</macro>
20
21Signals an error if {{EXP}} evaluates to false. An optional message
22{{STRING}} and arguments {{ARG ...}} may be supplied to give a
23more informative error-message.  If compiled in ''unsafe'' mode (either
24by specifying the {{-unsafe}} compiler option or by declaring
25{{(unsafe)}}), then this expression expands to an unspecified value.
26The result is the value of {{EXP}}.
27
28
29==== cond-expand
30
31<macro>(cond-expand FEATURE-CLAUSE ...)</macro>
32
33Expands by selecting feature clauses. This form is allowed to appear in non-toplevel expressions.
34
35Predefined feature-identifiers are "situation" specific:
36
37; compile : {{chicken}}, {{compiling}}, {{library}}, {{eval}}, {{extras}}, {{regex}}, {{srfi-0}}, {{srfi-2}}, {{srfi-4}}, {{srfi-6}}, {{srfi-8}}, {{srfi-9}}, {{srfi-10}}, {{srfi-11}}, {{srfi-12}}, {{srfi-15}}, {{srfi-16}}, {{srfi-17}}, {{srfi-23}}, {{srfi-26}}, {{srfi-28}}, {{srfi-30}}, {{srfi-31}}, {{srfi-39}}, {{srfi-55}}, {{srfi-61}}, {{srfi-62}}
38
39; load : {{chicken}}, {{extras}}, {{srfi-0}}, {{srfi-2}}, {{srfi-6}}, {{srfi-8}}, {{srfi-9}}, {{srfi-10}}, {{srfi-12}}, {{srfi-17}}, {{srfi-23}}, {{srfi-28}}, {{srfi-30}}, {{srfi-39}}, {{srfi-55}}, {{srfi-61}}, {{srfi-62}}. {{library}} is implicit.
40
41; eval : {{csi}}, {{chicken}}, {{extras}}, {{srfi-0}}, {{srfi-2}}, {{srfi-6}}, {{srfi-8}}, {{srfi-9}}, {{srfi-10}}, {{srfi-11}}, {{srfi-12}}, {{srfi-15}}, {{srfi-16}}, {{srfi-17}}, {{srfi-23}}, {{srfi-26}}, {{srfi-28}}, {{srfi-30}}, {{srfi-31}}, {{srfi-39}}, {{srfi-55}}, {{srfi-61}}, {{srfi-62}}. {{library}} is implicit.
42
43The following feature-identifier classes are available in all situations:
44{{(machine-byte-order)}}, {{(machine-type)}}, {{(software-type)}},
45{{(software-version)}}, where the actual feature-identifier is platform
46dependent.
47
48In addition the following feature-identifiers may exist: {{cross-chicken}},
49{{dload}}, {{manyargs}}, {{ptables}}.
50
51For further information, see the documentation for
52[[http://srfi.schemers.org/srfi-0/srfi-0.html|SRFI-0]].
53
54==== ensure
55
56<macro>(ensure PREDICATE EXP [ARGUMENTS ...])</macro>
57
58Evaluates the expression {{EXP}} and applies the one-argument
59procedure {{PREDICATE}} to the result. If the predicate returns
60{{#f}} an error is signaled, otherwise the result of {{EXP}}
61is returned.  If compiled in ''unsafe'' mode (either by specifying
62the {{-unsafe}} compiler option or by declaring {{(unsafe)}}),
63then this expression expands to an unspecified value.  If specified,
64the optional {{ARGUMENTS}} are used as arguments to the invocation
65of the error-signalling code, as in {{(error ARGUMENTS ...)}}. If
66no {{ARGUMENTS}} are given, a generic error message is displayed
67with the offending value and {{PREDICATE}} expression.
68
69==== eval-when
70
71<macro>(eval-when (SITUATION ...) EXP ...)</macro>
72
73Controls evaluation/compilation of subforms. {{SITUATION}} should
74be one of the symbols {{eval}}, {{compile}} or {{load}}.
75When encountered in the evaluator, and the situation specifier
76{{eval}} is not given, then this form is not evaluated and an
77unspecified value is returned.  When encountered while compiling code,
78and the situation specifier {{compile}} is given, then this form is
79evaluated at compile-time.  When encountered while compiling code, and the
80situation specifier {{load}} is not given, then this form is ignored
81and an expression resulting into an unspecified value is compiled instead.
82
83The following table should make this clearer:
84
85<table>
86<tr><th></th><th>In compiled code</th><th>In interpreted code</th></tr>
87<tr><td>{{eval}}</td><td>ignore</td><td>evaluate</td></tr>
88<tr><td>{{compile}}</td><td>evaluate at compile time</td><td>ignore</td></tr>
89<tr><td>{{load}}</td><td>compile as normal</td><td>ignore</td></tr>
90</table>
91
92==== time
93
94
95---
96Previous: [[Extensions to the standard]]
97
98Next: [[Non-standard read syntax]]
Note: See TracBrowser for help on using the repository browser.