CEP-0012: Generic Syntax and Const Generics¶
Rejected
Indefinitely rejected proposal for generic syntax beyond explicit comptime parameters and for broader const generics. Catalyst uses explicit comptime parameters as its generic mechanism.
Summary¶
Catalyst will not add dedicated generic syntax or broader const-generic forms on top of the explicit comptime parameter model.
Generics are ordinary functions, contracts, and type factories with explicit comptime parameters. This keeps type-level computation inspectable and avoids a separate template language.
Example¶
Rejected shape:
const Matrix[T: Type, rows: usize, cols: usize] = struct {
values: [rows * cols]T
}
The accepted direction stays explicit:
fn Matrix(comptime T: Type, comptime rows: usize, comptime cols: usize) => Type {
return struct {
values: [rows * cols]T
}
}
Motivation¶
Explicit comptime parameters can become noisy for common type and value parameters, but dedicated generic syntax would create a second spelling for the same semantic model and would make declarations, diagnostics, and reflection less uniform.
Broader const generics also need boundaries around which value types can participate in type identity, specialization, layout, diagnostics, and cache keys. Catalyst keeps those values explicit ordinary comptime parameters instead of adding a separate const-generic syntax family.
Rejected Direction¶
The rejected direction would have added syntax that lowers to explicit semantic parameters or reflected metadata that tooling can inspect.
This is not being pursued indefinitely:
- generic parameter syntax beyond
comptime T: Type; - const-generic value kinds and equality rules;
- how generic parameter defaults interact with explicit and inferred arguments;
- display and reflection of generic parameters;
- diagnostics for ambiguous or unsupported generic arguments.
V1 Compatibility¶
Catalyst keeps explicit comptime parameters as the generic mechanism. Generic parameter inference is tracked by CEP-0016 and must preserve explicit comptime declarations as the canonical source form. Type members and standalone type qualifiers are separate proposals.