New features for brave users
During Perl 6 development, new features are often made available for users to experimental with before their design is completed. Eventually these features may be made part of the Perl 6 specification. To use these features, one uses the
experimental pragma in program source code, for example, like this:
use experimental :macros;
Following is a list of current experimental features and a short description of each feature's purpose or a link to more details about its use. (Note: Features marked "[TBD]" are to be defined later.)
Is available in release 2017.02. To use:
use experimental :collation;
coll and the collate method are affected by the $*COLLATION variable, while unicmp is not. Unlike the cmp operator which sorts according to codepoint, unicmp and coll sort according to how most users would expect.
use experimental :collation;say 'a' unicmp 'Z'; # Lesssay 'a' cmp 'Z'; # More
coll and the collate method are both configurable by setting the $*COLLATION variable.
You can use the collate method similar to how one would use the sort method.
use experimental :collation;say ('a', 'Z').sort; # (Z a)say ('a', 'Z').collate; # (a Z)say <ä a o ö>.collate; # (a ä o ö)my = 'aa' => 'value', 'Za' => 'second';say .collate; # (aa => value Za => second);
There are four collation levels which are all configurable.
While the Primary, Secondary and Tertiary mean different things for different scripts, for the Latin script used in English they mostly correspond with Primary being Alphabetic, Secondary being Diacritics and Tertiary being Case.
In the below example you can see how when we disable tertiary collation which in Latin script generally is for case, and also disable quaternary which breaks any ties by checking the codepoint values of the strings, we get Same back for A and a:
use experimental :collation;.set(:quaternary(False), :tertiary(False));say 'a' coll 'A'; # Same
Note the collation features, especially the $*COLLATION API could change at any time