Vau is just like lambda, except it doesn't evaluate its arguments, and receives the lexical environment in which it is called.
Vau's syntax is (vau operands environment . body).
Lambda's syntax is (lambda arguments . body).
((vau x e x) foo) ==> (foo)
((vau x e e) foo) ==> #[environment]
You can also destructure the operands:
((vau (x y z) e z) foo bar baz) ==> baz
And if you want to get at the actual value of an operand, you use eval, which takes a form and an environment as parameters:
(def msg "Hello world!")
((vau (x) e (eval x e)) msg) ==> "Hello world!"
Note: you can try out these expressions at the Virtua REPL.
No comments:
Post a Comment