Skip to content

CEP-0015: Named Arguments

Draft

Draft proposal for named arguments, named attribute arguments, and named/positional mixing. V1 calls are positional only.

Summary

Catalyst should eventually support named arguments for function and attribute calls, but only after deciding whether parameter names are part of public API compatibility.

V1 retains parameter names and destructuring patterns for diagnostics, documentation, and reflection metadata. They do not affect function type identity or call shape.

Example

Possible future shape:

fn resize(width: i32, height: i32, preserve_aspect: bool) Image { ... }

const icon = resize(width: 64, height: 64, preserve_aspect: true)

For attributes, the same question appears as named attribute arguments:

@deprecated(message: "Use draw_v2", since: "2.0")
fn draw() { ... }

Motivation

Named arguments can improve call-site readability, especially for APIs with several same-typed parameters or configuration-style attributes. They also affect:

  • documentation and source navigation;
  • parameter-name stability as public API;
  • default parameter omission rules;
  • named/positional mixing;
  • attribute reflection, where V1 already preserves optional argument names for future compatibility.

Proposed Direction

The proposal should cover:

  • whether named arguments are allowed for all functions or only declarations that opt in;
  • whether parameter names are public API compatibility;
  • named/positional mixing rules;
  • omission rules when defaults exist;
  • duplicate, unknown, and reordered argument diagnostics;
  • named attribute arguments using the same call model;
  • reflection shape for accepted named arguments;
  • interaction with destructured parameters.

Destructuring Boundary

Destructuring remains binding syntax. Named arguments should target source parameters, not destructured internal bindings. External labels for destructured parameters need explicit design rather than falling out of destructuring syntax accidentally.

V1 Compatibility

V1 calls are positional. Accepted V1 attribute calls have AttributeArg.name == null, and ordinary function parameter names are metadata only.