Skip to content

Latest commit

 

History

History
11 lines (7 loc) · 1.04 KB

eval.md

File metadata and controls

11 lines (7 loc) · 1.04 KB

eval

(eval form)

Evaluates a form -- typically a list produced by read, read-from-string, or quoting -- in the global environment and returns its result. Works in all three backends: the interpreter evaluates directly, while the JVM and WASM compilers emit a small runtime tree-walking interpreter that shares the compiled value representation. Top-level globals defined by the compiled program are mirrored into the eval environment, so an eval'd expression can see them; an eval'd assignment of one is seen by the compiled code too, and a special variable answers its current dynamic binding.

(eval '(+ 1 2)) ; => 3

Quoting the form keeps it unevaluated until eval runs it; (eval (read-from-string "(* 6 7)")) returns 42. A quoted form that defines a structure, a class, a generic function, a method or a macro, binds parameters with a lambda-list keyword, or calls a macro of the program is compiled with the program instead, since the compiled runtime could not run it.