From: Adrian Howard Date: 2007-07-19T18:13:56+09:00 Subject: Re: The Pebble in the Ruby Shoe (taken off-list since wandering way OT :-) On 17 Jul 2007, at 20:03, Chad Perrin wrote: > On Tue, Jul 17, 2007 at 10:43:35PM +0900, Adrian Howard wrote: >> >> Perl's misfeature is pretty different - it's a global rather than a >> per-array thing. Being able to say "this particular array has indices >> -10 -> 10 is considerably more useful than saying "every array starts >> at -10" :-) > > News to me. Would you point me at more information on the topic, > please? In the perl world we have the $[ variable (see perldoc perlvar for gory details) that resets the index of the first element. As the documentation says "Its use is highly discouraged.". I'd imagine that it's primary motivation for inclusion was to make compatability with awk easier in early perl's (which also has 1 indexing). For example: my @array = ( 1 .. 10 ); $[ = 0; print @array[5], "\n"; $[ = 1; print @array[5], "\n"; $[ = 2; print @array[5], "\n"; would produce 6 5 4 Spooky action at a distance. Scary. Fortran (or those versions that support it anyway) allow you to specify the indices of a particular array - so for example you could have real temperature(-100:100) to make an array of real values with indices from -100 to 100. So you can make the indices of your array match the indices of your domain - if that would make your life easier :-) See for some examples. Cheers, Adrian