Skip to content

Variables

Gustav Sterbrant edited this page Oct 14, 2024 · 2 revisions

Declaration

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.

Conversion

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.

Clone this wiki locally