[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: 1-based indexing in Lua
- From: Ahmed Charles <acharles@...>
- Date: Tue, 3 Apr 2018 21:06:43 +0000
On 4/3/2018 8:39 AM, Roberto Ierusalimschy wrote:
>> Written before I was born, EWD831 (http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html) describes why 0 based ranges are superior better than I can. It has nothing to do with programming languages and everything to do with math.
> If we are to follow that kind of argument, I am sure we will find plenty
> of reasons to dump decimal numbers from programmig languages in favor of
> hexadecimal numbers: faster to read/write, shorter, full control of each
> bit, etc; clearly superior.
> For some strange reason, however, most languages still support decimal
> numbers, and even stranger, most programmers still use them. Come on,
> we are programmers, not children any more. Let us start counting zero
> to F, instead of 1 to 10.
This argument isn't analogous because programming languages can support
both types of numbers but only one type of range definition can be
supported. Most languages allow programmers the choice, because it's
fairly easy to do so.
> As a more concrete example, the floor division is way superior than the
> round-to-zero division used by C and copied by many languages. But I
> don't hear people whining all the time about division in those languages.
This is more analogous and if there were a discussion about division
semantics on a mailing list I monitor, I'd probably support floor division.
More importantly though, a consequence of the design of Lua is that the
empty range is specified by [1, 0] rather than [1, 1) or [0, 0). That's
mentioned as part of EWD's argument and does ring true as being sub-optimal.
One of the things I've always admired about you and the rest of the Lua
time is that you seem very open to the acknowledging mistakes in Lua's
design. That doesn't mean you should believe this is one, but this
response seems more defensive than I would've expected.