>>>>> "LP" == Luke Palmer <[EMAIL PROTECTED]> writes:
LP> On 10/9/05, Uri Guttman <[EMAIL PROTECTED]> wrote: >> >>>>> "IB" == Ingo Blechschmidt <[EMAIL PROTECTED]> writes: IB> sub foo ($a) {...} >> >> works for me. but what about lists and arrays? >> >> my @z = ( 'a', 1 ) ; >> foo( @z ) # $a = [ 'a', 1 ] ?? LP> Yep. >> my @z = ( a => 1 ) ; >> foo( @z ) # $a = pair( a => 1 ) or does that need * too? LP> $a = [ a => 1 ] LP> You passed an array. The parameter gets an array. right. and it has one pair inside. >> same questions for lists (this shows a nested sub call) >> >> sub bar { return ( a => 1 ) } >> foo( bar() ) # i would expect $a == ( a => 1 ) since there is >> # no * >> >> foo( *bar() ) # i would expect $a == 1 LP> Yeah, I think your expectations are correct. LP> Basically, * takes whatever kind of object it is (array, hash, pair) LP> and pretends that you wrote its contents literally into the argument LP> list. that is a succinct statement of how * work but you also have to describe the cases with pairs and such and no *. and what about the case that ingo said needed *hash()? i think a list of all the know variations (* and no *) should be done to keep the behavior clear to all. just more of the examples we have so far and what gets set in the args for each. it will also make it easier to create tests for these and to get this into pugs. uri -- Uri Guttman ------ [EMAIL PROTECTED] -------- http://www.stemsystems.com --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org