Procedures, Arity, Application, and apply

Fixed and dotted-arity closures use lexical scope, deterministic argument evaluation, and one application dispatcher shared by direct calls and apply.

At a glance

LISPEX
(define (sum first . rest) (apply + first rest))
(sum 1 2 3 4)

Result

OUTPUT
10

Current guarantees

  • Arity mismatch is E302 before the procedure body starts.
  • A dotted rest parameter receives a fresh proper list of remaining arguments.
  • apply accepts explicit leading arguments plus one final proper list and preserves tail position.

Boundaries

  • Applying a non-procedure is E301; an improper final apply list is a list-domain error.
  • Host apply is not used to execute guest closures.