Evaluator Functions¶
- function evaluate/evaluate src [args]¶
evaluate Idio source code src in the context of evaluation environment eenv and return intermediate code for the code generator
- Param src:
Idio source code
- Type src:
Abstract Syntax Tree
- Param eenv:
evaluation environment, defaults to a new instance
- Type eenv:
struct-instance, optional
- function symbol-value sym mod [default]¶
Return the value of sym in mod or default if supplied
- Param sym:
symbol to query
- Type sym:
symbol
- Param mod:
module to query
- Type mod:
module or name
- Param default:
(optional) value to return if sym is not defined in mod
- Type defined:
any
- Return:
value or default
- template cond-expand clauses¶
cond-expand
reduces clauses to the firstcond_expand_clause
where the clause’sfeature_requirement
is truecond-expand
is a template and so, in effect, it reduces the set of clauses supplied to just the first that is true.The
feature_requirement
for each clause in clauses is constructed from the presence offeature_identifier
s or logical combinations of those features. The features themselves are set by idio or can be augmented by users.The clauses for
cond-expand
are interpreted as the (SRFI-0) grammarconditional_expansion_form
:conditional_expansion_form ::= (cond-expand
cond_expand_clause
+) | (cond-expandcond_expand_clause
* (else expression*)) cond_expand_clause ::= (feature_requirement
expression*) feature_requirement ::=feature_identifier
| (andfeature_requirement
*) | (orfeature_requirement
*) | (notfeature_requirement
) feature_identifier ::= a symbol or string, see below- Example:
Several tests of standard library calls in libc differ between operating systems. We can specialize as appropriate and
cond-expand
results in just a singlelibc-wrap-error-load
expression in the byte code.(cond-expand ((or "uname/sysname/FreeBSD" "uname/sysname/OpenBSD" "uname/sysname/Darwin") { libc-wrap-error-load "libc-wrap-errors/EGID-set-invalid-gid.idio" "Operation not permitted" EPERM "setegid" }) (else { libc-wrap-error-load "libc-wrap-errors/EGID-set-invalid-gid.idio" "Invalid argument" EINVAL "setegid" }) )
See also
- function %add-feature f¶
add feature f to Idio features
- Param f:
feature to add
- Type f:
symbol or string
- Return:
new list of features
Last built at 2024-12-21T07:10:37Z+0000 from 62cca4c (dev) for Idio 0.3.b.6