John Porter wrote: > Chaim Frenkel wrote: > > > > Removing -1 as a valid result, could be a breakage (if someone is > > doing something weird with a negative result) > > What, like using it as an index into a substr? > Bad Code is its own reward, my friend. > > > $foo = "flabergasted"; > > substr($foo, index($foo, 'abc'), 20); # Returns undef > > One should never do this, regardless of what index() returns on > failure. Now, if index() threw an exception on failture, you'd > be o.k. But I don't think we want that... That's exactly why it would be nice if index _did_ throw an exception on failure, then you could write code this way, and catch the failures without needing to check return values for the error code case before proceeding with the real case. -- Glenn ===== There are two kinds of people, those who finish what they start, and so on... -- Robert Byrne _____NetZero Free Internet Access and Email______ http://www.netzero.net/download/index.html
- Re: RFC 213 (v1) rindex and index should return undef on... Chaim Frenkel
- Re: RFC 213 (v1) rindex and index should return und... Nathan Torkington
- Re: RFC 213 (v1) rindex and index should return... Chaim Frenkel
- Re: RFC 213 (v1) rindex and index should re... Nathan Torkington
- Re: RFC 213 (v1) rindex and index shoul... Nathan Torkington
- Re: RFC 213 (v1) rindex and index ... Chaim Frenkel
- Re: RFC 213 (v1) rindex and in... Glenn Linderman
- Re: RFC 213 (v1) rindex and in... John Porter
- Re: RFC 213 (v1) rindex and in... Glenn Linderman
- Re: RFC 213 (v1) rindex and index should return und... John Porter
- Re: RFC 213 (v1) rindex and index should return... Glenn Linderman
- Re: RFC 213 (v1) rindex and index should re... Chaim Frenkel
- Re: RFC 213 (v1) rindex and index shoul... Glenn Linderman
- Re: RFC 213 (v1) rindex and index ... Chaim Frenkel
- Re: RFC 213 (v1) rindex and in... Glenn Linderman
- Re: RFC 213 (v1) rindex and in... John Porter
- Re: RFC 213 (v1) rindex and in... Glenn Linderman
- Re: RFC 213 (v1) rindex and in... Nathan Torkington
- Re: RFC 213 (v1) rindex and index should return... Chaim Frenkel