The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Newsgroups: perl.perl6.language
From: ydbx...@yahoo.com (Paul)
Date: Wed, 23 Apr 2003 06:47:05 -0700 (PDT)
Local: Wed, Apr 23 2003 9:47 am
Subject: Re: * vs **
--- Larry Wall <la...@wall.org> wrote: > On Tue, Apr 22, 2003 at 02:51:46PM -0700, Paul wrote: yeah, I know. And I know ** was not. I was just wondering out loud > : S6: > : === > : <quote> > : The unary prefix operator * flattens its operand (which allows > : the elements of an array to be used as an argument list). The * > : operator also causes its operand -- and any subsequent arguments > : in the argument list -- to be evaluated in list context. > : > : sub foo($x, $y, $z) {...} # expects three scalars > : @onetothree = 1..3; # array stores three scalars > : > : foo(1,2,3); # okay: three args found > : foo(@onetothree); # error: only one arg > : foo(*@onetothree); # okay: (array) flattened to 3 args > : > : The * operator flattens lazily -- the array is only flattened if > : flattening is actually required within the subroutine. To flatten > : before the list is even passed into the subroutine, use the unary > : prefix ** operator: > : > : foo(**@onetothree); # array flattened before &foo called > : > : </quote> > : === > : > : So is ** actually a seperately implemented operator, or is that the > * > : op working on the return from the * op, like the way Larry > : suggested the ref-of-ref operator, \\ ? :) > Er, that was a joke... about how it would work in more detail, and phrased it horribly as usual. :) > * and ** are identical insofar as they defeat signatures and impose See? That makes me think that **@x is similar to *(*(@x)). > list context on the rest of the arguments in the list. The only > difference is that for ** there's an extra internal call to flatten() > or some such that un-lazifies anything lazy in the list. > Larry Similar, but still implemented seperately? Or is using the one effectively like using the other aside from precedence twiddling with the parens? Either way, the important things to know: Hmm, maybe I should put one of those on my shopping list next to the tuits.... __________________________________________________ You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||