Re: [PHP4BETA] no reverse fetch of arrays is BAD!

From: Date: Wed, 23 Feb 2000 08:11:42 +0000
Subject: Re: [PHP4BETA] no reverse fetch of arrays is BAD!
References: 1 2 3  Groups: php.version4 
Request: Send a blank email to php-version4+get-10702@lists.php.net to get a copy of this message
hi! Faisal Nasim wrote: [skip] > : > $x[-1] = 30; > : > print $x[-1]; // 30, doesn't seem to affect any positive index > : > > : > Is that a feature? > : > : I think that negative indeces maybe a useful feature, because a few > : languages have this > : already (notably MUMPS AFAIK). > > And don't forget Perl! > I don't agree! Perl supposes negative indeces as offset from the end of an array. > : The main difficulty for the such implementation in "C" or derived > : languages is the method of calculating "effective address". IMHO the PHP > > I was thinking of getting the total count of the array and doing some > very simple arithmetic calculation if the index < 0. > > probably: array [ total - (+INDEX) ] > > But, there is a major diff b/w perl and php: > > perl: $x[10] = "test"; // size of @x is 11 > perl: $x[10] = "test"; // size of $x is 1 > > Which creates a new question: > > Is there a way to detect the upper bound of an array? > SURE! for both upper and lower: reset()/end() then key() :-) [skip] > > PHP is an interpreted language, and should make use full > use of small (but cool and useful!) features this! It's a better that PHP will not follow by steps of Java and its ugly p-code machine. -- WBR, Yury Bokhoncovich, SysAdmin at FIS.

« previous php.version4 (#10702) next »