[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string:sub
- From: joao lobato <btnfdp.lobato@...>
- Date: Sat, 6 Mar 2010 21:10:15 +0000
On 3/6/10, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> If s:sub(5,4) is valid then s:sub(1,0) should be valid too.
>
> Sure. s:sub(1,n) is the prefix of 's' with length 'n', so zero must be
> a valid index to allow the empty prefix. zero is not negative, so it
> counts from the beginning.
>
> -- Roberto
>
It's just that since s:sub(2,n) doesn't mean "the substring of 's'
with length 'n' starting at the second position of 's'", it just feels
that your point is a happy coincidence rather than a particular case
of a rule.
I feel like I managed to misuse the "principle of [Roberto's] least
surprise" and break list etiquette.
- References:
- string:sub, David Burgess
- Re: string:sub, David Burgess
- Re: string:sub, Erik Lindroos
- Re: string:sub, David Burgess
- Re: string:sub, Enrico Colombini
- Re: string:sub, spir
- Re: string:sub, Scott Vokes
- Re: string:sub, joao lobato
- Re: string:sub, Shmuel Zeigerman
- Re: string:sub, Roberto Ierusalimschy