Skip to content

Commit 92a6c1f

Browse files
committed
Document the Positional/Associative .STORE method
1 parent 8a07177 commit 92a6c1f

File tree

3 files changed

+68
-5
lines changed

3 files changed

+68
-5
lines changed

doc/Language/subscripts.pod6

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,22 @@ sense, so don't feel compelled to implement it. If you don't, users will
849849
get an appropriate error message when they try to bind to a positional slot
850850
of an object of this type.
851851
852+
=head2 method STORE
853+
854+
=comment When modifying this section, please also adapt the STORE
855+
section in Associative accordingly as they are very similar.
856+
857+
method STORE (::?CLASS:D: values, :$initialize)
858+
859+
This method should only be supplied if you want to support the:
860+
861+
my @a is Foo = 1,2,3;
862+
863+
syntax for binding your implementation of the C<Positional> role.
864+
865+
Should accept the values to (re-)initialize the object with. The optional
866+
named parameter will contain a C<True> value when the method is called on
867+
the object for the first time. Should return the invocant.
852868
853869
=head2 Methods to implement for associative subscripting
854870
@@ -959,6 +975,24 @@ sense, so don't feel compelled to implement it. If you don't, users will
959975
get an appropriate error message when they try to bind to an associative
960976
slot of an object of this type.
961977
978+
=head3 method STORE
979+
980+
=comment When modifying this section, please also adapt the STORE
981+
section in Positional accordingly as they are very similar.
982+
983+
method STORE (::?CLASS:D: values, :$initialize)
984+
985+
This method should only be supplied if you want to support the:
986+
987+
my %h is Foo = a => 42, b => 666;
988+
989+
syntax for binding your implementation of the C<Associative> role.
990+
991+
Should accept the values to (re-)initialize the object with, which either
992+
could consist of C<Pair>s, or separate key/value pairs. The optional
993+
named parameter will contain a C<True> value when the method is called on
994+
the object for the first time. Should return the invocant.
995+
962996
=end pod
963997

964998
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

doc/Type/Associative.pod6

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,31 @@ you use the parametrized version of Associative.
7070
7171
=head2 method AT-KEY
7272
73-
method AT-KEY(key) { }
73+
method AT-KEY(key)
7474
7575
Should return the value / container at the given key.
7676
7777
=head2 method EXISTS-KEY
7878
79-
method EXISTS-KEY(key) { }
79+
method EXISTS-KEY(key)
8080
8181
Should return a C<Bool> indicating whether the given key actually has a value.
8282
83+
=head2 method STORE
84+
85+
method STORE(values, :$initialize)
86+
87+
This method should only be supplied if you want to support the:
88+
89+
my %h is Foo = a => 42, b => 666;
90+
91+
syntax for binding your implementation of the C<Associative> role.
92+
93+
Should accept the values to (re-)initialize the object with, which either
94+
could consist of C<Pair>s, or separate key/value pairs. The optional
95+
named parameter will contain a C<True> value when the method is called on
96+
the object for the first time. Should return the invocant.
97+
8398
=head1 See also
8499
85100
See L<Methods to implement for positional subscripting|https://docs.perl6.org/language/subscripts#Methods_to_implement_for_associative_subscripting> for information about additional methods that can be implemented for the C<Associative> role.

doc/Type/Positional.pod6

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,37 @@ to L<Mu>.
2323
2424
=head2 method elems
2525
26-
method elems() { }
26+
method elems()
2727
2828
Should return the number of available elements in the instantiated object.
2929
3030
=head2 method AT-POS
3131
32-
method AT-POS(position) { }
32+
method AT-POS(position)
3333
3434
Should return the value / container at the given position.
3535
3636
=head2 method EXISTS-POS
3737
38-
method EXISTS-POS(position) { }
38+
method EXISTS-POS(position)
3939
4040
Should return a C<Bool> indicating whether the given position actually has a
4141
value.
4242
43+
=head2 method STORE
44+
45+
method STORE(values, :$initialize)
46+
47+
This method should only be supplied if you want to support the:
48+
49+
my @a is Foo = 1,2,3;
50+
51+
syntax for binding your implementation of the C<Positional> role.
52+
53+
Should accept the values to (re-)initialize the object with. The optional
54+
named parameter will contain a C<True> value when the method is called on
55+
the object for the first time. Should return the invocant.
56+
4357
=head1 See also
4458
4559
See L<Methods to implement for positional subscripting|https://docs.perl6.org/language/subscripts#Methods_to_implement_for_positional_subscripting> for information about additional methods that can be implemented for the C<Positional> role.

0 commit comments

Comments
 (0)