CEP-0034: Comptime-Only Contract Operations¶
Draft
Draft proposal for contract operations callable only during comptime evaluation. V1 contract operations are runtime-callable unless guarded out of a surface.
Summary¶
Catalyst should eventually decide whether contracts can declare operations that exist only for comptime checking, reflection, or metadata computation.
V1 supports contract operation guards and dyn-safety surface selection, but it does not add a separate comptime-only operation category.
Example¶
Possible future shape:
const BinarySerializable = contract {
comptime fn schema(comptime Self: Type) Schema
fn write(self: *const Self, writer: *Writer) Error!void
}
The schema operation would participate in conformance and generic tooling without becoming a runtime method or dyn vtable slot.
Motivation¶
Comptime-only operations could express associated metadata, laws, validation hooks, or code generation helpers without becoming runtime vtable slots. They need clear interaction with static dispatch, dyn-safety, and reflection.
Proposed Direction¶
The proposal should cover:
- source syntax for comptime-only operations;
- whether implementations must provide them;
- how they are called from generic code;
- whether they participate in conformance;
- reflection and diagnostics;
- interaction with generated declarations and type members.
V1 Compatibility¶
V1 uses ordinary contract operations and guards. Operation-level comptime parameters are not dyn-safe, and comptime-only contract operations remain deferred.