[apologies to anyone who received this twice... the bonehead at the keyboard
left the subject blank. <grin>]
> 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.
>
> The Perl6 overview was useful; it reviewed and unified bits of the design
> that my brain had misplaced. The LTU&E talk was brilliant, entertaining,
> and maniacal. If he's coming to a city near you, book your seats now.
> The Munich YAPC is next, I think.
>
> I used my one question foolishly, so here's a handful more. In the grand
> tradition of perl6 roulette, I will try to answer them myself, and cross
> my fingers over the syntax. Of course, they're more confirmations of my
> view of the world than they are questions... kindly confirm or deny as
> appropriate.
>
> Thank-you,
> Philip
>
>
> [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?
>
> &foo = sub ( ; $alpha, $beta, $gamma ) {
> print "$alpha, $beta, $gamma";
> }
>
> foo( 1, 2, 3 ); # 1, 2, 3
> foo( { alpha => 1, beta => 2 } ); # 1, 2, undef
> foo( { alpha => 1, delta => 4 } ); # error, bad parameter
>
> &bar = &foo.assuming( beta => 1.5 );
> # behaves as though declared: sub ( ; $alpha, $gamma ) ...
>
> bar( 1, 2 ); # 1, 1.5, 2
> bar( { gamma => 2 } ); # undef, 1.5, 2
> bar( { beta => 2 } ); # error, bad parameter
>
>
>
> [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
>
> # will this create overloaded versions of baz?
> &baz = &foo.assuming( alpha => 0 );
>
> baz( @y ); # array, $alpha is 0
> baz( %z ); # hash, $alpha is 0
>
>
> [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 );
>
>
> [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.
> 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;
> ...
> }
>
>
>
> That's the lot, thanks for reading this far.
>
>
Disclaimer
This communication together with any attachments transmitted with it ('this E-mail')
is intended only for the use of the addressee and may contain information which is
privileged and confidential. If the reader of this E-mail is not the intended
recipient or the employee or agent responsible for delivering it to the intended
recipient you are notified that any use of this E-mail is prohibited. Addressees
should ensure this E-mail is checked for viruses. The Carphone Warehouse Group PLC
makes no representations as regards the absence of viruses in this E-mail. If you have
received this E-mail in error please notify our ISe Response Team immediately by
telephone on + 44 (0)20 8896 5828 or via E-mail at [EMAIL PROTECTED] Please then
immediately destroy this E-mail and any copies of it.
Please feel free to visit our website:
UK
http://www.carphonewarehouse.com
Group
http://www.phonehouse.com