Next: iklib syntaxes stale, Previous: iklib syntaxes dynenv, Up: iklib syntaxes [Index]
Compilers act upon “compilation units”, which for Vicare are:
R6RS libraries, R6RS programs, symbolic expressions handed to
eval
; the latter includes standalone expressions typed at the
REPL. Under Vicare:
this scenario is somewhat different from the one of languages like C, which make use of object files that allow inlining of functions defined in other files.
Sometimes we do want to always integrate expressions, even across
compilation unit boundaries; for this purpose Vicare provides
define-inline
to integrate expressions and
define-integrable
to integrate functions.
Similar to define
, but create a binding for an expression that is
always expanded inline and can neither be invoked recursively
nor used as function argument. This syntax only defines a
syntax embedding the source code of the expression in a syntax object.
(define-inline (incr x) (+ x 1)) (incr 2) ⇒ 3
In the example above, we can think of (incr 2)
as expanding to:
(let ((x 2)) (+ x 1))
Similar to define
, but create a binding that is always expanded
inline and can be both invoked recursively and used as function
argument. This syntax defines both a syntax and a function, with the
syntax embedding the source code of the function in a syntax object.
(define-integrable (incr x) (+ x 1)) (incr 2) ⇒ 3 (map incr '(10 20 30))) ⇒ (11 21 31)
In the example above, we can think of (incr 2)
as expanding to:
((lambda (x) (+ x 1)) 2)
Next: iklib syntaxes stale, Previous: iklib syntaxes dynenv, Up: iklib syntaxes [Index]