On Thu, Sep 01, 2005 at 08:09:41PM -0700, Yitzchak Scott-Thoennes wrote: > On Thu, Sep 01, 2005 at 09:20:07PM -0400, Rick Delaney wrote: > > On Thu, Sep 01, 2005 at 05:41:36PM -0700, Yitzchak Scott-Thoennes wrote: > > > On Wed, Aug 31, 2005 at 06:07:11AM -0700, japhy @ perlmonk. org wrote: > > > > sub foo { ...; return @data } > > > > > > > > my $x = (foo())[0][1]; > > > > > > > > which would have the same effect as > > > > > > > > my @return = foo(); > > > > my $x = $return[0][1]; > > > > > > > > However, it's a syntax error. > > [...] > > > I don't see any reason not to just make it legal syntax instead: > > > > > > What is > > > > my $x = (foo())[0..5][1]; > > > > supposed to mean? I know it will return (foo())[5][1] but is it a good > > idea to support this syntax when it looks it might mean some kind of > > multidimensional slice? To me it looks like > > > > map { (foo())[$_][1] } 0 .. 5; > > I don't see any difference between your case above and > > my $x = (foo())[0..5]; > > which also doesn't warn. > > > And if that syntax is ok, why not > > > > my $x = @array[0..5][1]; > > Because I couldn't conceive of a use for it? There is separate syntax > for getting a single element or multiple elements of an array or hash, > but only one syntax for both cases for a list. > > > ? I think a warning is in order at least. We already have > > "Multidimensional syntax %s not supported" for > > > > $array[0,1][1]; > > A warning would be good, but I don't think it's necessary before applying > my patch, and presumably it would also apply to > > @array[0..5]->[1];
I mean (foo())[0..5]->[1]; > whereas > > @array[ (0..5)[-1] ]->[1]; I mean ( (foo())[0..5] )[-1]->[1] > shouldn't warn with or without the ->. To summarize, the issue of slices of whatever kind being used in a scalar context is a separate issue from whether the -> should be required before dereferences following a list slice.