/
experimental.pod6
82 lines (56 loc) 路 2.68 KB
/
experimental.pod6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
=begin pod :tag<perl6>
=TITLE Experimental Features
=SUBTITLE 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 C<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.)
=comment The following should be a table but formatting in tables is
not yet rendered properly.
=item X<B<cache>|cache> [TBD]
=item X<B<macros>|macros> [TBD]
=item X<B<pack>|pack> [TBD]
=head1 Collation
Is available in release 2017.02. To use:
use experimental :collation;
Allows the use of the X<B<unicmp>|unicmp, Routine> and X<B<coll>|coll, method> operators.
Also allows the use of the X<B<collate>|collate> method. unicmp and coll are like cmp, except
it implements the Unicode Collation Algorithm.
B<coll> and the B<collate> method are affected by the X<B<$*COLLATION>|$*COLLATION>
variable, while B<unicmp> is not.
Unlike the cmp operator which sorts according to codepoint, B<unicmp> and
B<coll> sort according to how most users would expect.
use experimental :collation;
say 'a' unicmp 'Z'; # Less
say 'a' cmp 'Z'; # More
B<coll> and the B<collate> method are both configurable by setting the
B<$*COLLATION> variable.
=head2 collate (method)
You can use the collate method similar to how one would use the B<sort> method.
use experimental :collation;
say ('a', 'Z').sort; # (Z a)
say ('a', 'Z').collate; # (a Z)
say <盲 a o 枚>.collate; # (a 盲 o 枚)
my %hash = 'aa' => 'value', 'Za' => 'second';
say %hash.collate; # (aa => value Za => second);
=head2 Collation Levels
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 B<Same> back
for B<A> and B<a>:
use experimental :collation;
$*COLLATION.set(:quaternary(False), :tertiary(False));
say 'a' coll 'A'; # Same
B<Note the collation features, especially the $*COLLATION API could change
at any time>
=end pod