Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-26 Thread Aaron Sherman
On Fri, 2004-03-26 at 15:20, Luke Palmer wrote: > When writing Perl 5, I always find myself writing @{ more often than @$. > Maybe it's just a bad habit that I don't tend to use a lot of > intermediate variables. Well, one of the big problems with Perl 5's dereferencing is that it's painful to cr

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-26 Thread Luke Palmer
Larry Wall writes: > On Fri, Mar 26, 2004 at 09:41:23AM -0700, Luke Palmer wrote: > : Is @{$foo} going away? More specifically, how do I write that map if > : $baz is some more complex expression, and I don't want to use * (say I > : want to adhere if map decides to change its signature to take a

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-26 Thread Larry Wall
On Fri, Mar 26, 2004 at 09:41:23AM -0700, Luke Palmer wrote: : Okay, good. So this is correct: : : my $baz = @foo; : @bar = map { ... } @$baz; : : (to be equivalent of mapping over @foo)? Yes, that's correct. : Is @{$foo} going away? More specifically, how do I write that map if : $ba

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-26 Thread Luke Palmer
Juerd writes: > Larry Wall skribis 2004-03-25 12:33 (-0800): > > On Thu, Mar 25, 2004 at 11:35:46AM -0800, Brent 'Dax' Royal-Gordon wrote: > > : Larry Wall wrote: > > : > say @bar.elems;# prints 1 > > : C? Not C? > > It's just a "println" spelled Huffmanly. > > Can't we instead just hav

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-26 Thread Juerd
Larry Wall skribis 2004-03-25 12:33 (-0800): > On Thu, Mar 25, 2004 at 11:35:46AM -0800, Brent 'Dax' Royal-Gordon wrote: > : Larry Wall wrote: > : > say @bar.elems; # prints 1 > : C? Not C? > It's just a "println" spelled Huffmanly. What happened to the principle that things that work

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-26 Thread Luke Palmer
Larry Wall writes: > : Also, how does the use of *$foo differ from @$foo here? Is the later > : going away? (I'd think that horrible, for the same reason as above: C > : is confusing because it's not always clear what you get when you *.) > > No, @$foo is not going away. You can write it that

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-26 Thread Mark J. Reed
On 2004-03-26 at 08:16:07, Larry Wall wrote: > And "say" isn't in there because of APL or PHP. It's actually inspired > by something worse in Ruby. Presumably by "something worse" you mean "puts"? Not a great name, to be sure, but it does have a venerable tradition behind it. :) I do like ha

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-26 Thread Larry Wall
On Fri, Mar 26, 2004 at 08:59:36AM +0100, James Mastros wrote: : Larry Wall wrote: : >Yes, * was originally a no-op in list context, but I think now we can : >use it to deref a list that would otherwise not interpolate itself. : >It maps better onto how a C programmer thinks, and if in scalar : >co

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-26 Thread James Mastros
Larry Wall wrote: Yes, * was originally a no-op in list context, but I think now we can use it to deref a list that would otherwise not interpolate itself. It maps better onto how a C programmer thinks, and if in scalar context it also happens to defer the signature checking to use the interpolated

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-25 Thread Larry Wall
On Thu, Mar 25, 2004 at 11:35:46AM -0800, Brent 'Dax' Royal-Gordon wrote: : Larry Wall wrote: : > say @bar.elems;# prints 1 : : C? Not C? It's just a "println" spelled Huffmanly. Larry

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-25 Thread Brent 'Dax' Royal-Gordon
Larry Wall wrote: say @bar.elems; # prints 1 C? Not C? -- Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker Oceania has always been at war with Eastasia.

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-25 Thread Larry Wall
On Thu, Mar 25, 2004 at 08:42:53AM -0700, Luke Palmer wrote: : Aaron Sherman writes: : > More to the point is there ever a reason to want any array ref in list : > context to NOT explode other than []? I can't think of any. : > : > push @a, $b : > : > Is it too non-obvious that if $b is an ar

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-25 Thread Luke Palmer
Aaron Sherman writes: > I would expect [] to force itself into scalar context anyway. Is there > ever a reason to want otherwise? Clearly the entire point of [] is to > create a scalar array ref from a list of arguments. > > More to the point is there ever a reason to want any array ref in list >

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-25 Thread Aaron Sherman
On Tue, 2004-03-23 at 13:11, Goplat wrote: > @(...) is the "list context" operator in S3. I hope array references won't > explode in list context, that would be very annoying when making > multi-dimentional arrays: > > @foo = ([1, 2], [3, 4]) # oops, would be (1, 2, 3, 4) > @foo = ($([1, 2]

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-23 Thread Goplat
--- Smylers <[EMAIL PROTECTED]> wrote: > Luke Palmer writes: > > > for @(@ranges[1]) -> $i { > > Oooh, where did that dereferencing syntax come from, using parens rather > than braces? @(...) is the "list context" operator in S3. I hope array references won't explode in list context, that wo

Re: Dereferencing Syntax (Was: Outer product considered useful)

2004-03-23 Thread Brent 'Dax' Royal-Gordon
Smylers wrote: Luke Palmer writes: for @(@ranges[1]) -> $i { Oooh, where did that dereferencing syntax come from, using parens rather than braces? It isn't a dereferencing syntax--it's a context-forcing syntax (one I'm intimately familiar with), which forces @ranges[1] into list context. Wh