Skip to main content

Data types

Mélodium is a strongly typed language, in order to provide design reliability and possibilities for internal optimization of the execution engine.

Core Types

Mélodium have following core types:

Unsigned integersSigned integersFloating point numbersTextLogic
u8i8f32charbyte
u16i16f64stringbool
u32i32void
u64i64
u128i128

Additional types

In addition to the basic types natively available through the Mélodium language, libraries can provide their own types. These types can represent functional data specific to use cases, and be used in the same way as any other type through processing.

The standard library also provides some additional types, such as the Map type.

note

The options Option<…> and vectors Vec<…> are not additional types but components of the Mélodium language itself.

Constant and variable parameters

Parameters are either constant or variable.

The constant parameters have the characteristic of having a value which will not change during the entire execution of a program, and will in particular be the same across all the tracks in which it is used.

The variables parameters have values that may differ from one track to another. This is particularly the case when these parameters come from contexts.

The processing parameters can be variable or constant, declared as follows:

treatment my_treatment(var foo: string, var bar: Vec<u16>, const baz: i64) { /* … */ }

By default, processes have variable parameters, which makes the previous declaration equivalent to:

treatment my_treatment(foo: string, bar: Vec<u16>, const baz: i64) { /* … */ }

Unlike processing, models only accept constant parameters. Processing instantiating parameterized models is therefore likely to require the constancy of certain parameters.

model MyModel(const something: i64) { /* … */ }
// Note: The `const` qualifier is optional on model parameters.

treatment my_treatment(foo: string, bar: Vec<u16>, const baz: i64)
model myInstanciedModel: MyModel(something = baz)
{ /* … */ }