lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> On 01 Oct 2016, at 00:58, Hisham <h@hisham.hm> wrote:
> 
>> PS: My personal favorite would be to just error() if the starting index was
>> 0. Would help catch tons of off-by-ones.
> 
> For what is worth, I don't remember _ever_ having had trouble with the
> 0 index in string functions, or do I remember people posting about it
> on the list, so I've never seen these "tons of off-by-ones" in
> practice.
> 
> -- Hisham
> 

Same here, I actually like this behaviour, as it saves me “tons of off-by-ones” checks/validations in my code. Simply because the off-by-one edge-case is gracefully handled and returns the empty string.

It’s one of those typical things that in-theory might be off, but make the language so easy to work with (allowing trailing comma’s in table constructors is another one for example).

Thijs