lua-users home
lua-l archive

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




Le mer. 8 mai 2019 à 16:00, Coda Highland <chighland@gmail.com> a écrit :
On Tue, May 7, 2019 at 10:00 PM Philippe Verdy <verdy_p@wanadoo.fr> wrote:
abs(n) is as much arbitrary as the number of digits, i.e. roughly log10(abs(n) for integers...

Agreed; log10(abs(n)) is a halfway reasonable but still arbitrary choice that still carries the notion of "size".
 
Also I agree that length == 0 is valid to represent an empty set, but it's still not a valid Lua sequence number.

I'm not sure what you mean by a "sequence number". Do you mean an index? Well of course it isn't. There are no valid indexes into an empty sequence, because it's empty. Why would you EXPECT 0 to be valid? Why does that even matter for anything?

a "sequence number" is almost synonymous here from "index", but "index" is ambiguous as it relates to any table/array that may be indexed ("index" is really a synonymous of "key" which has arbitrary type in Lua). I used "sequence number" because it is related to the definition of sequences which are contiguous spans of non-zero positive integers.

My first reply was related to the fact that you have accepted the "index" 0 which is not a valid sequence number (as returned by ipairs, or used as character positions in strings, which are a compact form of table whose keys are also restricted to non-zero positive integers that also form a sequence of "characters", which do not really exist in Lua because they are represented also by strings of length 1, but that have an accessible code, which is a positive-or-zero integer).

Reread yoiur initial message to which I first replied, you'll notice the error you made in it and why I replied.