Types, classes & roles

Native types — int / num / str

Divergent

Fixed-width machine types, with one Raku++ difference on native arrays.

Lowercase int, num, and str are native types — fixed-width machine values without the object wrapper of Int/Num/Str. Native scalars behave the same in Raku++ and Rakudo; native arrays differ in their type (see the divergence).

Native scalars #

A native scalar holds a machine value but introspects as its boxed type.

my int $x = 5;
say $x;
say $x.WHAT;
Output
5
(Int)

Native arrays hold the values fine #

my int @a = 1, 2, 3;
say @a;
Output
[1 2 3]

Divergence: the native-array type #

A my int @a is a genuinely unboxed array[int] in Rakudo, but Raku++ represents it as the boxed Array[int]. The contents are identical; only the type object differs.

my int @a = 1, 2, 3;
say @a.WHAT;
ExpressionRakudo (reference)Raku++
(my int @a).WHAT(array[int])(Array[int])
Run the block to see Raku++'s result. This is a representation difference — the array works either way.

Notes #