Skip to content

Commit

Permalink
Talk about collections rather than containers
Browse files Browse the repository at this point in the history
In Raku parlance, a container generally refers to a scalar container. 
Arrays
and hashes are mutable _collections_ that store values in scalar 
containers. To
avoid confusion it's better to refer to these composite types as 
collections.
  • Loading branch information
dumarchie committed Nov 13, 2021
1 parent 8c3e724 commit 7b1ca20
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions doc/Type/independent-routines.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -1194,17 +1194,17 @@ hashes, whose use is advised.
=head1 Array manipulation
Routines that manipulate arrays and other containers.
Routines that manipulate arrays and other mutable collections.
=head2 sub pop
Defined as:
multi sub pop(@container) is raw
multi sub pop(@collection) is raw
Calls method C<pop> on the C<Positional> container. That method is supposed to
Calls method C<pop> on the C<Positional> collection. That method is supposed to
remove and return the last element, or return a L<C<Failure>|/type/Failure> if
the container is empty.
the collection is empty.
See the documentation of the L<C<Array> method|/routine/pop#(Array)_method_pop>
for an example.
Expand All @@ -1213,14 +1213,14 @@ for an example.
Defined as:
multi sub shift(@container) is raw
multi sub shift(@collection) is raw
Calls method C<shift> on the C<Positional> container. That method, on
a mutable container that actually implements it (such as an
Calls method C<shift> on the C<Positional> collection. 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
and return the first element, or return a L<C<Failure>|/type/Failure> if the
container is empty.
collection is empty.
Example:
Expand All @@ -1235,17 +1235,17 @@ say shift @a; # ERROR: «Cannot shift from an empty Array[Int]␤»
Defined as:
multi sub push(\container, **@values is raw)
multi sub push(\container, \arg)
multi sub push(\collection, **@values is raw)
multi sub push(\collection, \arg)
Calls method C<push> on the container, which is supposed to add the provided
values to the end of the container or parts thereof. See the documentation of
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
indirection via this subroutine can be helpful.
The C<push> method of the container is supposed to flatten all arguments of type
C<Slip>. Therefore, if you want to implement a conforming method for a new
container type, it should behave as if its signature was just:
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:
multi method push(::?CLASS:D: **@values --> ::?CLASS:D)
Expand All @@ -1260,15 +1260,15 @@ be implemented by an additional multi method with a signature like
Defined as:
multi sub append(\container, **@values is raw)
multi sub append(\container, \arg)
multi sub append(\collection, **@values is raw)
multi sub append(\collection, \arg)
Calls method C<append> on the container, which is supposed to add the provided
values to the end of the container or parts thereof. Unlike method C<push>,
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 container type, it should behave as if its
signature was just:
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 7b1ca20

Please sign in to comment.