data conversion

Core conversion behavior via kind annotations and explicit target kinds.

Overview

Mech supports conversion between kinds as part of core evaluation, especially when a binding includes a kind annotation.

Conversion by kind annotation

When a variable is defined with a kind annotation, the initializer is converted to the target kind if a conversion path exists.

{Error(Error:"x := 42 %% converts integer literal to f64":[1:1, 1:53), [1:1, 1:21))}name<string>:=123

If no conversion exists, definition fails with a kind/conversion error.

Structured conversions

Conversions apply beyond scalars when supported:

  • scalar -> scalar (numeric/string/bool where defined)

  • scalar -> matrix (with target matrix kind)

  • matrix -> matrix (element kind conversion)

  • matrix -> table and table -> matrix (shape/kind compatible)