On Wed, 2005-03-16 at 10:31, Markus Laire wrote:
> What should index("Hello", "", 999) return in perl6?
> 
> In perl5 that returns 5, but IMHO -1 would be right result.

Urk... exception?

Seriously, if you give index a position that is off the end of the
string, your options should be:

a. Extend the string
b. Fail silently
c. Throw an exception

a. is kind of non-Perlish. b. is Perl 5ish, but I'm not convinced it's
the right solution in all cases. In this case, specifically, I think it
should be c. (perhaps with some "use nonfatal" that causes library
functions to fail more gracefully).

That said, the current Perl 5 behavior is very broken. You should never
return <POS unless it's a negative number flagging failure.

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback


Reply via email to