Skip to content

Commit 6b90a78

Browse files
committed
REflow and clarification
1 parent 8a10fbd commit 6b90a78

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

doc/Language/traps.pod6

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,12 +1595,14 @@ method TOP ($/ is copy) { my $foo = ~$/; my $v = $foo ~~ /foo/; }
15951595
15961596
=head2 Using certain names for rules/token/regexes
15971597
1598-
Grammars are classes.
1598+
Grammars are actually a type of classes.
15991599
16001600
grammar G {};
16011601
say G.^mro; # OUTPUT: «((G) (Grammar) (Match) (Capture) (Cool) (Any) (Mu))␤»
16021602
1603-
C<^mro> prints the class hierarchy of this empty grammar, showing all the superclasses. And these superclasses have their very own methods. Defining a method in that grammar might clash with the ones inhabiting the class hierarchy:
1603+
C<^mro> prints the class hierarchy of this empty grammar, showing all the
1604+
superclasses. And these superclasses have their very own methods. Defining a
1605+
method in that grammar might clash with the ones inhabiting the class hierarchy:
16041606
16051607
=begin code :skit-test<throws exception>
16061608
grammar g {
@@ -1613,9 +1615,18 @@ say g.parse('defined');
16131615
# /tmp/dZ3evir0pb line 1␤ in block <unit> at /tmp/dZ3evir0pb line 1␤␤»
16141616
=end code
16151617
1616-
C«item» seems innocuous enough, but it is a L<C<sub> defined in class C<Mu>|/routine/item>. The message is a bit cryptic and totally unrelated to that fact, but that is why this is listed as a trap. In general, all subs defined in any part of the hierarchy are going to cause problems; some methods will too. For instance, C<CREATE>, C<take> and C<defined> (which are defined in L<Mu>). In general, multi methods and simple methods will not have any problem, but it might not be a good practice to use them as rule names.
1617-
1618-
Also avoid L<phasers|/language/objects#Object_Construction> for rule/token/regex names: C<TWEAK>, C<BUILD>, C<BUILD-ALL> will throw another kind of exception if you do that: C<Cannot find method 'match': no method cache and no .^find_method>, once again only slightly related to what is actually going on.
1618+
C«item» seems innocuous enough, but it is a L<C<sub> defined in class
1619+
C<Mu>|/routine/item>. The message is a bit cryptic and totally unrelated to that
1620+
fact, but that is why this is listed as a trap. In general, all subs defined in
1621+
any part of the hierarchy are going to cause problems; some methods will too.
1622+
For instance, C<CREATE>, C<take> and C<defined> (which are defined in L<Mu>). In
1623+
general, multi methods and simple methods will not have any problem, but it
1624+
might not be a good practice to use them as rule names.
1625+
1626+
Also avoid L<phasers|/language/objects#Object_Construction> for rule/token/regex
1627+
names: C<TWEAK>, C<BUILD>, C<BUILD-ALL> will throw another kind of exception if
1628+
you do that: C<Cannot find method 'match': no method cache and no
1629+
.^find_method>, once again only slightly related to what is actually going on.
16191630
16201631
=head1 Unfortunate generalization
16211632

0 commit comments

Comments
 (0)