Skip to content
TurtleKitty edited this page May 11, 2019 · 2 revisions

thunk

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

(def x (cell 0))

(def incrementer
   (thunk
      x.inc!
      (say x.get)))

(incrementer)  ; 1
(incrementer)  ; 2
(incrementer)  ; 3
Clone this wiki locally