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

Aleksandar Ružičić ruzicic.aleksandar at gmail.com
Sun Apr 3 13:07:53 PDT 2011


> 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.
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..)

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

> 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 :)


More information about the Digitalmars-d mailing list