mun icon indicating copy to clipboard operation
mun copied to clipboard

Compile-time `const` values

Open Wodann opened this issue 5 years ago • 2 comments

Similar to Rust's const we want to introduce compile-time constants using the const keyword. E.g.:

const UPPER_CAST_CONST: usize = 5;

Wodann avatar Jun 02 '20 09:06 Wodann

Some thoughts on the implementation:

  • We can create IR constants that are compiled into the source that uses it
  • We can create a function (or a memory location really) that holds the value of the constant (which can then be patched at will)
  • Type changes also require code changes so that shouldn't be an issue.
  • With the not hotreloading case, we simply create an IR constant.

baszalmstra avatar Jun 02 '20 11:06 baszalmstra

A maybe more interesting topic is what we allow as the value of a constant? We don't have anything like constexpr yet.

baszalmstra avatar Jun 02 '20 11:06 baszalmstra