BrowserREPL-button-tip-on BrowserREPL-button-tip-off

EditButtonTip 2026-10-28

Experimental features

Preview of upcoming new language features available for user evaluation

During Raku development, new features are often made available for users as experimental before their design is completed. Eventually these features may be made part of the Raku specification, or removed. To use these features, one uses the experimental pragma in program source code, for example, like this:

use experimental :cached;
Code

These are the features that, for the time being, are experimental.

pack§

Pack is a feature that allows binary serialization of general data structures, and is inherited from Perl's pack. The pack order creates a Buf by packing data structures in a certain way given by a packing string with the options shown in the description of unpack. You turn it on by inserting this pragma at the beginning of your program:

use experimental :pack;
Code

For instance, we can pack numbers interpreting them as hexadecimal (H) with the pattern repeating until there are no more elements (*):

use experimental :pack;
say pack("H*", "414243").contents;# OUTPUT: «(65 66 67)␤»
Code

There is a corresponding unpack routine that does exactly the opposite.

use experimental :pack;
my $buf=Buf.new(65,66,67);
say $buf.unpack("H*"); # OUTPUT: «414243␤»
Code

Not all of the symbols above are guaranteed to be implemented, and the roadmap does not include a fixed date for getting out of that stage.

Please see also documentation for pack and unpack in the Blob page.

macros§

Note: Versions of Rakudo starting with 2026.09 no longer support experimental macros. Future development of macros is expected to continue with the RakuAST compiler backend.

cached§

The following pragma:

use experimental :cached;
Code

turns on the is cached trait, which stores the result of a routine call, returning the same value if called with the same arguments.

It can be used when heavy calculations are involved, as in this sample that uses amicable numbers, taken from the 2018 Advent Calendar:

use experimental :cached;

sub aliquot-parts( $number ) is cached {
    (^$number).grep: $number %% *;
}

sub infix:<amic>( $m, $n ) {
    $m == aliquot-parts($n).sum &&
    $n == aliquot-parts($m).sum;
}

# Taken from https://en.wikipedia.org/wiki/Amicable_numbers
my @numbers = [2620, 2924, 5020, 5564, 6232, 6368, 66928, 66992];

say "Aliquot parts of $_ are ", aliquot-parts $_ for @numbers;

for @numbers X @numbers -> @pair {
    say "@pair[0] and @pair[1] are ",
        @pair[0] amic @pair[1]??" "!!"not ", "amicable";
}
Code

This code caches the computation of the aliquot parts, so that when the amic operator is called, it's only computed once; as a matter of fact, the first loop which prints these aliquot parts will be the only one that actually perform the computation.

See also the description of the trait for additional information and examples.

Note: This feature is not thread-safe.

rakuast§

The pragma:

use experimental :rakuast;
Code

makes the RakuAST package and its classes available for use in language versions before 6.e.