enlightware / enlightware/ferlium
Add module-level constants
- Dominant language
- Rust
- Stars
- 14
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Ferlium now supports trait associated constants for literal values, but there is no way to define ordinary module-level constants. This would be useful for library/domain constants that are not naturally tied to a trait.
## Proposed syntax
```ferlium
const DEFAULT_CAPACITY: int = 16;
pub const PI: float = 3.141592653589793;
```
Type annotation may be required in the first version, or optional if inference is straightforward.
## Initial scope
- Module items only.
- Public/private visibility, like functions and types.
- Immutable values.
- Initializer restricted to literal values, matching associated consts.
- No general compile-time expression evaluation.
- No local constants.
- No generic constants.
- No dependency graph or initialization order beyond literal storage.
## Future extension
A later feature could support const expressions such as:
```
pub const TAU: float = 2.0 * PI;
```
That should be designed separately, because it requires compile-time evaluation rules, cycle detection, purity/effect restrictions, trait/operator handling, and diagnostics.
Contributor guide
Assessment
This issue has not been assessed yet.