lua-users home
lua-l archive

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


> string.byte has a variable number of returns, and the maximum number
> is the string length (returning all characters):

>> =string.byte("ab", 1, 5)
> 97      98
>> =string.byte("a", 1, 2)
> 97

> It seems natural that, when the string size is zero, it returns zero
> values.

In Lua "to return zero values" is the same as to return nil. "No
value" is artifact of C API.

In my experience distinction between "no value" and nil is confusing.
Especially for users who write in Lua and do not care about C
implementation.

Why core Lua libraries handle "nil" and "no value" separately?

Alexander.