std.string.indexOf with an optional start-at parameter?

KennyTM~ kennytm at gmail.com
Sun Apr 3 13:56:50 PDT 2011


On Apr 4, 11 04:07, Aleksandar Ružičić wrote:
>> You mean Python and Ruby.
>>
>>   - Javascript does not support negative index. In fact, JS has no true
>> arrays, it only has associative array.
>>   - PHP does not support negative index. http://ideone.com/8MZ2T
>
> I was talking about javascript's String.prototype.indexOf () and php's
> strpos functions, not about array indexing.

I see.

> But even for that I wasn't correct :/. Negative start-at index is
> avaliable for substr (both, in php and js), that's why I have confused
> it with indexOf (I thought these things are consistent..)
>

PHP will never be consistent. ;)

> And javascript _does_ have true arrays, but it _doesn't_ have true
> associative arrays (those are object literals).
>

I would not call it a true array if it is indexed by string internally. 
Anyway, this is not the main point.

>> This does not mean negative index is useless (I use it all the time when
>> programming in Python), but D shouldn't add a feature just because other
>> languages have it, or even you think that language had it.
>
> I know, I was just expressing my opinion (what I would like to see in
> a language, I never programmed in phyton or perl, so I was thinking
> that negative indices for array indexing are not supported in any
> language that I know of), I wasn't proposing a new feature :)

Right.


More information about the Digitalmars-d mailing list