Fixed arity
Fixed arity binds application: every invocable with a first-class $name
form — builtin, prelude function, user binding — takes a fixed number of value
arguments. There is no variadic application and no defaulted parameter.
Arity is part of a computation’s type. Under call-by-push-value a function consumes a fixed sequence of value arguments; a variable count would make application irregular, and would leave a reified primitive’s type undefined (builtins).
An entry that takes an argv is not applied, so the rule does not reach it.
An external command, an intercepted operation, and a command-shaped builtin
take an argv, not a curried argument sequence: an intercepted operation takes
as many arguments as the call site writes, and echo is variadic over a list
of strings, typed List String -> Command. Host-supplied base frames share
that argv convention and the one type [String] → Command. An argv manifest
row carries no type rule, so no other base-frame result can be declared.
detach is instead a native value builtin of fixed arity three:
String → String → [String] → F [pid: Int, desc: String]. Its program’s
arguments are one list value, so write detach 'nap' sleep [...$xs], not a
spread into application. It supports $detach and partial application, and
is stubbed by a value binding, not a handler (builtins).
The manifest is authored as two, and arity is the consequence. A native
table entry declares its arguments, so it has an arity — the curry-spine depth
of its scheme, which is the one place any arity is read from
(Decl::fixed_arity, a usize for every entry there) — and it is a
first-class native value. A base-frame manifest row takes an argv instead, so
the argv half has no arity at all: the row is a base frame on the handler
stack, whose arguments arrive as an argv like any command’s
(builtins, exec). So
$name exists exactly where an arity does, by construction rather than by
agreement between a declaration and a check.
Arity binds application; it does not bind writing a name. A builtin is a
function and functions curry, so supplying fewer arguments than the arity is
not an error — it is the residual function, and let f = length,
let f = to-json and let f = range 1 all bind one. A bare name and $name
agree about this; they differ only in that the first is a command and the
second a value.
What is refused is a discarded value that is still waiting for an
argument. A computation whose value is thrown away must be ready to run, not
a function: nothing will ever supply the rest of it, so it cannot have run, and
the statement did nothing. A value is discarded in exactly two places — a
non-tail part of a sequence, and the program itself, whose only surviving trace
is its status. A sequence’s tail is not discarded: it is the block’s value,
and { |x| $x } is a block whose value is a function.
That is not a rule about builtins, and not a new one. It is the demand a
pipeline stage already met — a stage must be a computation
ready to run, not an arrow still waiting — generalised from a stage to any
discarded value. Both readings name the verb when they can: bare cd is
cd expected 1 argument, got 0, rather than an anonymous shape mismatch.
So the two rules are about different things, which is why they do not conflict:
arity binds application, and readiness binds discarding. Over-application is
the arity rule’s business (upper "a" "b" is one T0050, the surplus
inferred but unified against nothing, so a single slip earns a single
diagnostic); under-application is nobody’s until the value is dropped.
That split is the interception rule too. A table entry is a native seeded
into the base env scope, which resolution reaches before the handler stack, so
no installed handler intercepts it under its bare name, and none reaches it at
all — ^name resolves to the external command, skipping the handler stack
entirely. A base-frame row is a frame at the bottom of that stack, so a user
frame stacks above it and every bare call arrives there first. Handleability is
therefore nothing an entry states about itself; it is which half of the
manifest holds it.
A spread is the notation of an argv. ...$xs splices a list into an argv,
so it may be written only where an argv exists: a command, an external, a base
frame, or a handled command name. A value takes its arguments by application at
a declared arity, so it has no argv and ... has nothing to spread into. A
spread in a value’s argument position is refused before the run: at
elaboration (P0001) when the head is written as a value or names a lexically
bound one, and as T0056 (SpreadIntoApplication) when a bare head resolves
at check time to a builtin or a session binding. A list literal’s spread ([1, ...$xs, 2]) and a
rest-pattern ([first, ...rest]) are a different construct, building and
taking apart a list rather than an argument sequence, and this rule leaves them
alone.
The discipline survives at that boundary by packing, not by banning.
render_handler_args (core/src/shell/evaluator/machine.rs) hands a handler its arguments
as one list value — [argv] for a per-name entry, [name, argv] for a
catch-all — every element rendered as it is packed, so a variadic operation is
consumed by a block typed U([String] → Command); the catch-all is
U(String → [String] → Command)
(handler-dispatch, exec).
These types depend on neither the handler’s name nor Σ.
Variable arity is a surface phenomenon; at the value level it is always a list
of strings. The call’s argument gate belongs to the head, not its handler:
Σ supplies a base frame’s in-shell gate; every other command name keeps the
external gate, handled or not. Lexical bindings select application instead.
No handler scheme is persisted, and installing a handler cannot change typing.
Optionality is data too, never a hole in an argument list: an
open variant (`some v /
`none), passed as an ordinary value. The caller always supplies every
argument; the value it supplies may carry presence or absence, and no
signature spells an argument the call site may leave out.
This is a hard rule, not a stylistic preference. Do not introduce variadic
application, a splat parameter, a defaulted argument on a function or prelude
binding, a spread in a value’s argument position, or a first-class $name for
an entry that takes an argv.