flan/test/programs/fn-capture.flan

12 lines
479 B
Plaintext

;; Capture does not exist. An fn is lifted into a function of its own and is
;; handed nothing but its parameters, so a reference to a local of the
;; enclosing function is refused by name rather than resolved to something it
;; did not mean. spec-memory.md's capture cases, and escaping closures with
;; them, are deferred; this is the refusal that says so where it happens.
(defn use [f (Fn [] i32)] i32 (f))
(defn main [] i32
(let [n 7]
(println (use (fn [] n))))
0)