Skip to content
TurtleKitty edited this page Jan 29, 2016 · 4 revisions

thunk

Syntactic sugar for (λ () ...). It creates a function of no arguments from the expressions.

(def x 1)

(def incrementer
    (thunk
        (set! x x.inc)
        (sys.say x)))    ; (λ () (set! x x.inc) (sys.say x))

(incrementer)
2
(incrementer)
3
(incrementer)
4
Clone this wiki locally