Skip to content

Commit 8666fe3

Browse files
committed
[Parameter] elaborate on parcel and capture params, raiph++
1 parent b7e4919 commit 8666fe3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/Parameter.pod

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,26 @@ Returns C<True> for optional parameters.
4545
4646
Returns C<True> for parcel parameters.
4747
48-
sub f(\$parcel, $non-parcel) { }
48+
sub f(\$parcel) {
49+
$parcel = 5;
50+
}
51+
f(my $x); # works
52+
f(42); # dies in the assignment
53+
54+
Parcel parameters bind either a variable or a value passed to it, with
55+
no decontainerization happen. That means that if a variable was passed
56+
to it, you can assign to the parameter. This is different from
57+
L<rw|#rw>-parameter which can only bind to variables, never to values.
4958
5059
=head2 capture
5160
5261
Returns C<True> for parameters that capture the rest of the argument list.
5362
5463
sub f(\capture) { }
5564
65+
Capture parameters do not force any context on the values passed bound
66+
to them, which is why they cannot have sigils.
67+
5668
=head2 rw
5769
5870
Returns C<True> for C<is rw> parameters.

0 commit comments

Comments
 (0)