itch.io is community of indie game creators and players

Devlogs

v1.2.4 constants and parameter default values

MotC
A downloadable tool

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
    Sep 17, 2024
Download MotC
Leave a comment