lua-users home
lua-l archive

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

Counting fingers and cows, ja ja, thats the usual example. But, how often do you count data? One date, two data, three data.. 

On the other hand we have plenty of 0-based indizes in our everyday lives, due to practical reasons, we just tend to avoid calling the base the zero-th item.

Houses: So many houses the ground floor is ground floor, or floor 0. Yes, I'm aware, albeit I've never seen one of those myself, there are houses supposedly in countries (US), where the ground floor is floor 1. Anyway, billions otherwhere are not particually confused with floor 0 or "G" as they call it or have problems counting floors ground zero . The first floor being one floor above ground makes sense. And the cellar being -1. And the difference between -1 and 1 to be 2, etc.

Time: The first hour of a day on a digital clock in 24h mode is hour 0 (after midnight). Also something billions of people can get their head around without being programmers. It would be very detrimental if after 23:59 comes 01:01 eh make that 24:60 as the last minute of the day, if team 1 would have had their way in time keeping.

Similary we measure our age with completed years, starting with year 0 and many other measuring devices start their units with 0. Where one is after the first completed unit.

Now I find this whole "natural" thing argument mood. Nowadays, anyone for whom Lua is not the first and the last programming language is likely to come from or go to zero based systems. So is it "natural" for programmers having to switch?

About the index vs. offset argument: doesn't work, as soon you want a slice of anything, the index becomes an offset anyway.

About the argument  it easy to work around.. Yes. Well 100% of the stuff discussed here is easy to work around. With some userdata and C extension at worst. What can Lua 5.3 do what 5.1 didn't? Stuff got better and easier and leaves up more ressources to work on the actual projects. I applaud that. But nothing was impossible previously.. just needed more working around.

I agree however, for Lua it's too late anway. However, please  just don't preach that "natural" thing. It's not true, just see it, it is that way, because it is that way and any change would disrupt the already existing ecosystem too much not being worth it.

To cycle back to my original reply. If you do 1-based system, then please just do it all the way. Don't mix it. Analogical I couldn't really care much if an API uses CamelCase or underscore_separating. But if an API mixes both, thats terrible.

Kind regards

On Tue, Apr 3, 2018 at 9:15 PM, Jorge <> wrote:
On 03/04/18 10:25, Oliver Kroth wrote:
When I count things, let's say, cows, I start with the first cow and say "one", second cow "two",  third cow counted "three"...
I would not start with the first cow and say "zero", I say "zero" when there is no cow at all.
A zero-th cow is the cow in the empty corral, and actually "not a cow"...

I actually pulled this one on a pushy undergrad student. I made him count fingers. "Now, point me the first finger, the number one. Have you noticed 'third' and 'three' sound very similar? Is it coincidence or is there a reason?".