HellyerP wrote: > This week I was fortunate enough to hear Damian speak twice, once on > everything and once on Perl6. Damian, it was tremendous of you to come > and speak to us in London - thank-you very much.
It was my pleasure. > If he's coming to a city near you, book > your seats now. The Munich YAPC is next, I think. Not quite. Belfast next week. Zurich the week after. Then Munich. > [1] subs with prebound arguments: will they behave as though their > parameter list were declared exactly like their ancestor but with the > bound parameter bodily removed? Yes. > [2] There was a rumour that we may be able to overload subroutines. How > will this interact with prebinding? > > &foo = sub( ; $alpha, @beta ) { print "array" } > &foo = sub( ; $alpha, %beta ) { print "hash" } > > foo( $x, @y ); # array > foo( $x, %z ); # hash > foo( $x ); # ambiguity error > foo( @y ); # array, $alpha is undef > > &bar = &foo.assuming( beta => [ 1, 2 ] ); > bar(); # array, $alpha is undef Yes. > # will this create overloaded versions of baz? > &baz = &foo.assuming( alpha => 0 ); I hope so. :-) > [3] How is more than one argument prebound? > > &foo = sub ( $alpha, $beta, $gamma ) { ... } > > # chaining should work. > &bar = &foo.assuming( alpha => 1 ).assuming( beta => 2 ); > > # or ought that to be one assumption with a HASH? > &bar = &foo.assuming( { alpha => 1, beta => 2 } ); > > # or even just a list of PAIRs? > &bar = &foo.assuming( alpha => 1, beta => 2 ); The third version is best. The first version also works. The second probably doesn't work. > [4] Fancy fors > > If we want to traverse two arrays, we can do this > > for @alpha, @beta { ... } > > and it will exhaust alpha before we get the first element of beta. Yes. > The only undefs seen in the block are those that exist in the arrays. > Alternately, <groan> this > > for @alpha ; @beta { ... } > > will alternate between elements of @alpha, binding each to the magic > topic $_ in turn. If the arrays are not of equal length, then the > shorter one will be 'padded' with undef until the longer one is > exhausted. So if I wanted the alternation without being affected by the > padding, I would write something like this: > > for @alpha ; @beta { > next unless defined; > ... > } Probably. But there might well be a special dispensation that two (or more) streams feeding one variable only alternate between those streams that are not exhausted. Damian