Direction 31: Effects never hide in a value
Resolves tension 1 of the comparison-synthesis-draft. A closure that captures a capability would do I/O that no signature shows, which breaks direction 15 and lets a “no capabilities” package act through stored callbacks (Q17).
The rule (Bosque’s, adopted):
- Anonymous functions (
fn(x) ... end) appear only as call arguments. They are never bound to a name, stored in a struct, or returned. - Their captures are read-only.
- Named
fns are top-level and capture nothing, so a named function used as a value carries its capabilities in its own signature.
cs.filter(fn(c) db.exists?(c.id, within: 50.ms) end) # ok: dies when filter returns
pred = fn(c) db.exists?(c.id) end # error: anonymous fn bound to a name
fn make_reader(fs: Fs) : fn(Path) : Bytes ... end # error: returns an anonymous fn
handlers = [on_refund] # ok: named fn, effects in its signatureConsequence: a captured capability cannot outlive the call, so the enclosing function’s signature still bounds every effect. Narrowing (fs.scoped(...), pick 13) is unaffected: it returns a capability, not a closure.
Cost: no currying, no stored closures. “Call me later” in Mo is a process and a message (direction 14).
Reopen if: measurement under direction 28 shows agents need returned closures; the fallback is System C-style function types that record captures.