v1.2.4 constants and parameter default values


v1.2.4 has been released with a couple of nice-to-have language features:

  • int, float, bool and strings can be declared as constants, e.g.: const int MAX = 10;
  • Parameters can be declared with default values, e.g.: string[] splitString(string str, string separator = ",") { ...

Constants and parameters can be literals (10, "foo", true), other constants (including built-in ones like MATH_PI), or expressions (const LEFT_BUTTON = BASE_BUTTON + 0x01;). Essentially they must evaluate to a constant value at compile time.

Constant/default expressions cannot contain function calls (even if the result is deterministic).

Array, struct and library type parameters (like Image, Data) can have default values, but that default value can only be "null".


Under the hood, the compiler is now better at collapsing constant expressions at compile time, meaning they will compile to more compact and efficient code.

Files

motc-1.2.4.zip 4.7 MB
87 days ago

Get MotC

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.