Skip to content

CEP-0028: Comptime Resource Limits

Draft

Draft proposal for source-level comptime quota controls. V1 resource limits are compiler robustness policy, not source semantics.

Summary

Catalyst should eventually decide whether source can configure comptime step, branch, recursion, memory, or time limits.

V1 compilers may impose limits, but source code cannot raise or tune them.

Example

Possible future shape:

@comptime_limits(steps: 20_000_000, memory: 64 * 1024 * 1024)
const table = generate_lookup_table()

The proposal must decide whether limits live in source, build configuration, package policy, or some combination.

Motivation

Large generated tables, validation passes, and deliberate metaprogramming may need more comptime resources than ordinary code. Source-level controls can improve reproducibility, but they can also turn compile cost into an API hazard.

Proposed Direction

The proposal should cover:

  • which resource limits can be configured;
  • source syntax or build configuration location;
  • whether limits are per expression, declaration, module, or package;
  • diagnostics for exhaustion;
  • interaction with caching and incremental builds;
  • profile or toolchain policy limits.

V1 Compatibility

V1 has no source syntax for raising comptime limits. Resource exhaustion during comptime is a deterministic compile error.