Skip to content

Commit

Permalink
Skip-tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
threadless-screw committed Oct 2, 2018
1 parent fb1820d commit 30597d7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/Language/syntax.pod6
Expand Up @@ -292,9 +292,11 @@ Similarly, sets of operators work together in various syntactic categories with
like C<prefix>, C<infix>, C<postfix>, etc. The long, official names of these operators
often contain characters that are excluded from ordinary identifiers:
=begin code :skip-test
infix:<+> # the official name of the operator in $a + $b
infix:<*> # the official name of the operator in $a * $b
infix:«<=» # the official name of the operator in $a <= $b
=end code
For all such uses, you can append one or more "colon pairs" to an ordinary identifier
to create a so-called I<extended identifier>. When appended to an identifier (that is,
Expand Down Expand Up @@ -327,52 +329,64 @@ so C<infix:<+>> and C<infix:<->> are two different operators. The bracketing
characters used, however, do not count as part of the name; only the quoted data
matters. So these are all the same name:
=begin code :skip-test
infix:<+>
infix:<<+>>
infix:«+»
infix:['+']
infix:('+')
=end code
Similarly, all of this works:
=begin code :skip-test
my $foo:bar<baz> = 'quux';
say $foo:bar«baz»; # OUTPUT: «quux␤»
my $take-me:<home> = 'When the glory has no end';
say $take-me:['home']; # OUTPUT: «When the glory has no end␤»
my $foo:bar<2> = 5;
say $foo:bar(1+1); # OUTPUT: «5␤»
=end code
Where an extended identifier comprises two or more colon pairs, their order
is generally significant:
=begin code :skip-test
my $a:b<c>:d<e> = 100;
my $a:d<e>:b<c> = 200;
say $a:b<c>:d<e>; # OUTPUT: «100␤», NOT: «200␤»
=end code
An exception to this rule is I<module versioning>; so these identifiers
effectively name the same module:
=begin code :skip-test
use ThatModule:auth<Somebody>:ver<2.7.18.28.18>
use ThatModule:ver<2.7.18.28.18>:auth<Somebody>
=end code
Furthermore, the adverbial form in extended identifiers supports
compile-time interpolation, which mandates the use of
L<constants|/language/terms#Constants> for the interpolation values:
=begin code :skip-test
constant $c = 42; # Constant binds to Int; $-sigil enables interpolation
my $a:foo<42> = "answer";
say $a:foo«$c»; # OUTPUT: «answer␤»
=end code
Although quoting bracketing constructs are generally interchangeable
in the context of identifiers, they are not identical. In particular,
angle brackets C«< >» (which mimic single quote interpolation
characteristics) cannot be used for the interpolation of constant
names.
=begin code :skip-test
constant $what = 'are';
my @we:<are>= <the champions>;
say @we:«$what»; # OUTPUT: «[the champions]␤»
say @we:<$what>; # Compilation error: Variable '@we:<$what>' is not declared
=end code
=head3 Compound identifiers
Expand Down

0 comments on commit 30597d7

Please sign in to comment.