The native
package declarator is a Rakudo Perl 6 compiler implementation detail rather than part of the Perl 6 language. Some mechanism was needed to express the relationship between the language runtime and types like int32
and num64
declared in the Perl 6 standard library. A different type of meta-object was needed for natives, and since package declarators (like class
and role
) work by being mapped to a particular type of meta-object, introducing a native
package declarator for this purpose was a neat way to bootstrap that bit of the Perl 6 type system.
Use of native
outside of the standard library was never intended (which I can say with confidence, because I invented the mechanism). Given the performance sensitivity of native types, Perl 6 compiler developers should likely be given maximum freedom to choose how they define them, and to be able to refine that over time. There's no certainty that the native
declarator will exist forevermore in Rakudo, nor that any future Perl 6 compiler developers will choose to do things in the same way.
If wanting an alias to a native type name, just use constant
:
constant smallish = int;
Since constant
is evaluated at compile time, this symbol can then be used just like any other type. There's no functionality otherwise available through native
that isn't already exposed by types available in Perl 6 or the NativeCall
library.