Skip to content

Commit

Permalink
Stick to actual Rakudo signatures
Browse files Browse the repository at this point in the history
In these cases it's probably not so bad to have less meaningful 
parameter names
because these subroutines just implement indirection.
  • Loading branch information
dumarchie committed Nov 14, 2021
1 parent 7b1ca20 commit 81af567
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions doc/Type/independent-routines.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,9 @@ Routines that manipulate arrays and other mutable collections.
Defined as:
multi sub pop(@collection) is raw
multi sub pop(@a) is raw
Calls method C<pop> on the C<Positional> collection. That method is supposed to
Calls method C<pop> on the C<Positional> argument. That method is supposed to
remove and return the last element, or return a L<C<Failure>|/type/Failure> if
the collection is empty.
Expand All @@ -1213,9 +1213,9 @@ for an example.
Defined as:
multi sub shift(@collection) is raw
multi sub shift(@a) is raw
Calls method C<shift> on the C<Positional> collection. That method, on
Calls method C<shift> on the C<Positional> argument. That method, on
a mutable collection that actually implements it (such as an
L<C<Array>|/routine/shift#(Array)_method_shift> or a
L<C<Buf>|/routine/shift#(Buf)_method_shift>), is supposed to remove
Expand All @@ -1235,40 +1235,41 @@ say shift @a; # ERROR: «Cannot shift from an empty Array[Int]␤»
Defined as:
multi sub push(\collection, **@values is raw)
multi sub push(\collection, \arg)
multi sub push(\a, **@b is raw)
multi sub push(\a, \b)
Calls method C<push> on the collection, which is supposed to add the provided
values to the end of the collection or parts thereof. See the documentation of
the L<C<Hash> method|/routine/push#(Hash)_method_push> for an example where
Calls method C<push> on the first argument, passing the remaining arguments.
Method C<push> is supposed to add the provided values to the end of the
collection or parts thereof. See the documentation of the
L<C<Hash> method|/routine/push#(Hash)_method_push> for an example where
indirection via this subroutine can be helpful.
The C<push> method of the collection is supposed to flatten all arguments of
type C<Slip>. Therefore, if you want to implement a conforming method for a new
collection type, it should behave as if its signature was just:
The C<push> method is supposed to flatten all arguments of type C<Slip>.
Therefore, if you want to implement a conforming method for a new collection
type, it should behave as if its signature was just:
multi method push(::?CLASS:D: **@values --> ::?CLASS:D)
multi method push(::?CLASS:D: **@values is raw --> ::?CLASS:D)
Autovivification to an instance of the new type is L<provided by the default
base class|/routine/append#(Any)_method_append> if the new type implements the
C<Positional> role. If the new type is not C<Positional>, autovivification can
be implemented by an additional multi method with a signature like
be supported by an adding a multi method with a signature like
multi method push(::?CLASS:U: **@values --> ::?CLASS:D)
multi method push(::?CLASS:U: **@values is raw --> ::?CLASS:D)
=head2 sub append
Defined as:
multi sub append(\collection, **@values is raw)
multi sub append(\collection, \arg)
multi sub append(\a, **@b is raw)
multi sub append(\a, \b)
Calls method C<append> on the collection, which is supposed to add the provided
values to the end of the collection or parts thereof. Unlike method C<push>,
method C<append> should follow the L<single argument
rule|/language/functions#Slurpy_conventions>. So if you want to implement a
conforming method C<append> for a new collection type, it should behave as if
its signature was just:
Calls method C<append> on the first argument, passing the remaining arguments.
Method C<append> is supposed to add the provided values to the end of the
collection or parts thereof. Unlike method C<push>, method C<append> should
follow the L<single argument rule|/language/functions#Slurpy_conventions>. So
if you want to implement a conforming method C<append> for a new collection
type, it should behave as if its signature was just:
multi method append(::?CLASS:D: +values --> ::?CLASS:D)
Expand Down

0 comments on commit 81af567

Please sign in to comment.