Skip to content

compile eval

TurtleKitty edited this page May 11, 2019 · 2 revisions

compile-eval

This allows the programmer to define variables and procedures for use by operators during compile time. The things so defined will disappear before runtime.

; without compile-eval

(def x 1)

(proc adder (n)
   (+ n 10))

(op make-11 ()
   (adder x))

(make-11) ; (compile-error (undefined-symbol adder "Name not defined."))
; with compile-eval

(compile-eval
   (def x 1)

   (proc adder (n) 
      (+ n 10)))

(op make-11 ()
   (adder x)) 

(make-11) ; 11

x         ; (runtime-error (undefined-symbol x "Name not defined."))
Clone this wiki locally