-
Notifications
You must be signed in to change notification settings - Fork 0
Variables
Gustav Sterbrant edited this page Oct 14, 2024
·
2 revisions
To declare a variable with GPULang you can take several routes.
Declare a variable with an explicit type, uninitialized:
var color : f32x4;
Declare a variable with an inferred type:
const color = f32x4(r,g,b,a);
Declare a variable with an explicit type, initialized through conversion
const color : f32x4 = 1.0f;
GPULang doesn't offer lazy type inference. The type must be known on the same statement where the variable is declared.
GPULang offers a few conversion methods for ease of use. By default, implicit conversion is enabled but can be disabled with the disallowImplicitConversion
flag passed to the compiler. Explicit conversions are encouraged, since all conversions generate potentially unnecessary code.