Changeset 9959 for docs/Perl6/FAQ
- Timestamp:
- 04/15/06 17:08:02 (3 years ago)
- Files:
-
- 1 modified
-
docs/Perl6/FAQ/Capture.pod (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
docs/Perl6/FAQ/Capture.pod
r9958 r9959 36 36 Here's how Captures look like deferred argument lists: 37 37 38 sub make_car (Str $model, Str $color? = "black", Int $doors = 4); 39 my $car_cap = \("Model T", doors => 2); # some positional, some named 38 sub make_car ( 39 Str $model, 40 Str $color = "black", 41 Int $doors = 4 42 ) { ... } 43 44 # some positional, some named 45 my $car_cap = \("Model T", doors => 2); 40 46 41 47 # passing the opaque Capture as actual function arguments … … 91 97 =head2 What about multimethod dispatch and cases where there is more than one invocant? 92 98 93 There's always one invocant, but it may be an Array of several values (see below). 99 In the argument list (Capture), there is always zero or one invocant I<argument>. 100 101 Multimethod dispatch governs cases where multiple invocant I<parameters> are 102 declared in the parameter list (Signature); each of them may bind to the invocant 103 argument, or one of the positional arguments. 94 104 95 105 =head2 What happens when a named argument is repeated? … … 113 123 114 124 The prefix C<*> method casts an object into a Capture object, and merges it 115 into the Capture being currentlyconstructed (e.g. an argument list):125 into the Capture currently being constructed (e.g. an argument list): 116 126 117 127 my $cap = \(1, 2, x=>42); … … 162 172 @y[][][]; 163 173 164 =head2 Does this mean I can't have something akin to a ref rence to a reference?174 =head2 Does this mean I can't have something akin to a reference to a reference? 165 175 166 176 You can, as a Capture can contain another capture object in its invocant slot: … … 232 242 @y.elems; # 1 233 243 234 The behaviours below are similar to Perl 5 as well:244 The cases below are similar to Perl 5 as well: 235 245 236 246 $x.push(0); # works - $x.elems becomes 4
