Skip to content

Commit d71a426

Browse files
authored
Methods in a class that is hidden don't get *%_ (#4032)
Adds a note to the `is hidden` docs to explain that methods in a class declared with `is hidden` don't get the `*%_` parameter and explain why. See https://stackoverflow.com/a/71088429/ https://raku.org/archive/doc/design/apo/A12.html#Interface%20Consistency and https://design.raku.org/S12.html#Interface_Consistency
1 parent 58d7b1a commit d71a426

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/Language/typesystem.pod6

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,8 @@ L<re-dispatching|/language/functions#Re-dispatching>.
490490
method n { self.A::m }
491491
};
492492
493-
B.new.m;
494-
B.new.n;
495-
# OUTPUT: «i am hidden␤»
493+
B.new.m; # No output
494+
B.new.n; # OUTPUT: «i am hidden␤»
496495
497496
The trait C<is hidden> allows a class to hide itself from
498497
L<re-dispatching|/language/functions#Re-dispatching>.
@@ -505,9 +504,15 @@ L<re-dispatching|/language/functions#Re-dispatching>.
505504
method n { self.A::m }
506505
}
507506
508-
B.new.m;
509-
B.new.n;
510-
# OUTPUT: «i am hidden␤»
507+
B.new.m; # No output
508+
B.new.n; # OUTPUT: «i am hidden␤»
509+
510+
Classes declared with C<is hidden> also generate slightly different method
511+
signatures. To facilitate re-dispatch, typical methods are automatically
512+
provided with an extra C<*%_> parameter that L<captures extra named
513+
arguments|/type/Method#index-entry-extra_named_arguments>. Because classes
514+
declared with C<is hidden> don't participate in re-dispatch, their methods don't
515+
receive this extra parameter.
511516
512517
=head3 trait C<trusts>
513518

doc/Type/Method.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ without a class is the need to use `&` to invoke them in the latter case. In
3939
case any other sigil is used in the definition, as in the first example, that
4040
sigil can also be used.
4141
42-
X<|extra named arguments>
42+
X<|extra named arguments>X<|*%_ (extra named arguments)>
4343
Methods automatically capture extra named arguments into the special variable C<%_>,
4444
where other types of C<Routine> will throw at runtime. So
4545

0 commit comments

Comments
 (0)