- Start Date: 2015-01-15
- RFC PR: (leave this empty)
- Rust Issue: (leave this empty)
Allow “typeless constants” which sidestep the issue of having to have separate
constants per-type. This help ergonomics in the case of the common C pattern
#define for constants.
The biggest pain this intends to solve is
#define based constants.
Additionally, some C APIs, such as OpenGL, often
typedef to an intrinsic
integer type but due to integer promotion rules in C, functions that take that
typedef as a parameter will accept an
int, even if the
typedef is to an
unsigned int. This causes FFI usability issues for automatically generated
or precise bindings.
Change the syntax of
const_item : CONST id EQ expr | CONST id COLON type EQ expr
When the optional type is not provided, the
const is said to be "typeless"
expr can only be a numeric literal. When such a
const is used, its
type will be a new
ty_infer which is either an
IntVar or a
depending on which kind of literal the
This is roughly similar to what Go does.
Status quo isn’t too bad, but it does become annoying.