flan/test/programs/fn-in-struct.flan

17 lines
834 B
Plaintext

;; ZII fills an omitted field with all-bytes-zero, and a zeroed function value
;; is a null pointer — the one kind of zero that is not a value the type can
;; have. Every other type's zero is one: 0, false, an empty slice, None, a
;; union's first case. So it is refused where the field is written rather than
;; left to crash at the call, and the same rule covers a global, a fixed
;; array's element and (zeroed).
;;
;; The zero is the whole objection: a capturing value's environment belongs to
;; the collector and may be kept anywhere, and (Option (Fn ...)) is the field
;; that holds one — see fn-escape.flan.
;;
;; A (CFn ...) field is not refused: every call through one tests for null and
;; signals NullCall, so its zero is an empty slot — fn-cfn-table.flan.
(defstruct Ops [run (Fn [i32] i32)])
(defn main [] i32 0)