Re: $foo[0][0] versus $foo[0;0]

2008-07-17 Thread Nicholas Clark
On Wed, Jul 16, 2008 at 10:04:03AM -0700, Larry Wall wrote:
 On Sun, Jul 13, 2008 at 02:17:10PM -0500, Adrian Kreher wrote:
 : Hi,
 : 
 : I'm reviewing the tests in S09, and the file 
 : t/spec/S02-builtin_data_types/multi_dimensional_array.t uses the [0][0]  
 : indexing format interchangeably with [0;0].
 : 
 : These two formats mean two different things, correct? The [0][0] form isn't 
 : mentioned much in the spec, nor is [0;0] or if they interact somehow.
 
 I think they should come out to meaning the same thing, though the
 [0][0] form may be less efficient if it has to temporarily construct
 a slice of the next dimension of the array.  On the other hand, a
 naïve implementation of the multidimensional subscripter might just do
 the same thing internally for the semicolon, so it could be a wash.

Would it be counter-productive to specify that the implementation is allowed
to compile time optimise [$a][$b] etc to [$a;$b] etc?

I'm assuming that it is allowed for the implementation of a multidmentional
array to have different semantics for [$a][$b] and [$a;$b], but that seems
to violate good sense, much like overloading a class in Perl 5 (or any other
language) such that (++$a) and ($a + 1) are not the same.

Nicholas Clark


Re: $foo[0][0] versus $foo[0;0]

2008-07-16 Thread Larry Wall
On Sun, Jul 13, 2008 at 02:17:10PM -0500, Adrian Kreher wrote:
: Hi,
: 
: I'm reviewing the tests in S09, and the file 
: t/spec/S02-builtin_data_types/multi_dimensional_array.t uses the [0][0]  
: indexing format interchangeably with [0;0].
: 
: These two formats mean two different things, correct? The [0][0] form isn't 
: mentioned much in the spec, nor is [0;0] or if they interact somehow.

I think they should come out to meaning the same thing, though the
[0][0] form may be less efficient if it has to temporarily construct
a slice of the next dimension of the array.  On the other hand, a
naïve implementation of the multidimensional subscripter might just do
the same thing internally for the semicolon, so it could be a wash.

Larry