ADR-callable-v1: Any Expression of a Function Type Can Be Called, Its ( on the Same Line: same(inc)(1), fs[0](2), (make())(3)

Status: Accepted Date: November 29, 2026 (supervisor, by ADR-317 D2 and Part I 5.4; #1042) Answers: whether a call may apply to a call’s result and to any other expression whose type is a function, or only to a name and a method (#1042) Supersedes / Related: Part I 5.4 (a function type stands wherever a type does: a result, a let, an element of a list; D1 lets each of them be called where it stands); ADR-317 D1, D2 (a call’s ( is on the line of what it calls, read as the [ of an index; unchanged, and it is what keeps D1 from reading a new line as a call); ADR-135 D3 (a [ at the start of a line begins a literal; an index already follows any expression); ADR-277 (a parameter that is code has the type fn(A) -> R); ADR-lambdas-v2 D5 (an untyped lambda takes its type from the first typed place it is handed to)

1. Question

May a call apply to any expression whose type is a function, same(inc)(1), fs[0](2), (make())(3), or only to a name and a method?

A function may return a function value and a list may hold them (Part I 5.4), but the parser refuses a call written directly after a call’s result (Expected } here, but found () and after a parenthesised expression, and the checker cannot type a call after an index (NK1245). The value then has to be bound by a let first, for no reason the reader can see. No record refused the form and none allowed it.

2. How others do it

Language / tool Its answer What it costs there Source
Rust a call applies to any expression of a callable type, f(a)(b), (self.f)(x) a field that holds a closure needs parentheses, (s.f)(x), to tell it from a method from memory, not checked
Go, Kotlin, Swift f(a)(b); a ( on the next line begins a new statement nothing beyond the newline rule from memory, not checked
Python, JavaScript f(a)(b), fs[0](2) JavaScript reads a ( on the next line as a call (the ASI hazard) from memory, not checked

What does not transfer: JavaScript’s hazard, which ADR-317 already rules out for Nikaia.

3. Options, weighed

Option A — Do nothing: a function value is bound by a let before it is called

let add = adder(3)
println(f"{add(1)}")

Option B — A call applies to any postfix expression of a function type, its ( on the same line

println(f"{adder(3)(1)} {fs[0](2)} {(make())(3)}")

Option C — B, but only on a call’s result

println(f"{adder(3)(1)}")      // fs[0](2) still refused

Weighed

  D1 the special case pays, not the common one D2 the compiler works, not the developer D3 no cost for the common case D4 consistent with itself If it is wrong
A the reader pays a name for every function value used once the developer names what the compiler could call none no: an index follows any expression, a call only a name nothing to undo
B nothing is paid by a program that does not write it the parser and the checker do the work none yes: ( follows what [ follows (ADR-317 D2) a form that parsed would stop parsing
C as B, for the one place as B none no: two rules where [ has one as B

4. Decision

Option B. D4 decided it: ADR-317 D2 reads a call’s ( as the rule for an index’s [, and an index already follows any expression (make()[1], xs[1][0], (make())[0] run today). The one hazard of B, a ( on the next line read as a call, is ruled out by ADR-317 D1.

D1 — A call applies to any postfix expression whose type is a function.

A name, a path, a method’s result, a call’s result, an index and a parenthesised expression may each be called where their type is fn(A) -> R: same(inc)(1), fs[0](2), (make())(3). The ( stands on the line of what it calls (ADR-317 D1); a ( that begins a line begins what is written there. A call applies the same way inside an f"…" hole.

D2 — A call of something that is not a function is refused, naming its type.

Where the expression before ( is not of a function type, the call is refused with a message that names the type it is, instead of a type the compiler cannot tell (NK1245).

Rejected: A, because it makes a function value the one value that has to be named before it is used where its type is wanted; C, because it is a second rule beside the one [ already follows, and an element of a list of functions is as natural to call as a result.

5. Consequences

This site is open source. Improve this page.