-
Notifications
You must be signed in to change notification settings - Fork 0
Type declarations
circular17 edited this page Oct 9, 2023
·
4 revisions
A type declaration is introduced with the type
keyword:
type vec2 float*float // defines the type vec2 to be a tuple of two floats
var u = #vec2 (12.5, 8) // sets a new variable of type vec2 with its values
Records can be defined the same way and have specific features of inheritance.
Generics are defined with the generic parameters and dash as a prefix:
type<T> vec3 T^3 // defines vec3 to be a tuple of three values of some type T
var v = #int-vec3 (1, 2, 3)
An alias is similar except that the name is not part of the type, it is rather a shorthand.