Skip to content

Types

Types can be declared through the use of the type keyword, like so:

type SomeType
    x i32
    y i32
    z i32
end

Note that Scar types are not compatible with the C ABI, in order to have C ABI compatible structs/types, you need to prepend the extern keyword to the type. So for example:

extern type Packed
    some_value       ref(u8)
    some_other_value f64
end

Functions can be declared on types, in a form of namespacing. This is not methods. There are no methods in Scar, data cannot have behaviour.

An example of type-level namespacing on functions:

def SomeType.some_function(x SomeType)
    @print("{p}\n", {x})
end