1. Found on HN: Again on 0-based vs. 1-based indexing

Blog post: Again on 0-based vs. 1-based indexing (HN discussion)

Lua blog post: Lua, a misunderstood language (HN discussion)

-Greg

new topic     » topic index » view message » categorize

2. Re: Found on HN: Again on 0-based vs. 1-based indexing

Euphoria and Lua have a lot of similarties. I prefer 0-based indexing, but I know Euphoria uses 1 as the starting point. Still I like Eu the most out of all the programming languages I've tried.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Found on HN: Again on 0-based vs. 1-based indexing

Another detailed attempt: http://enchantia.com/software/graphapp/doc/tech/arrays1.html

Concludes with "no clear winner", except for interoperability.

(Dunno about you, but the occasional -1 on the odd c_func() just doesn't really bother me anymore.)

The following languages use 1-based indices: Algol, AWK, COBOL, Euphoria, Fortran, Julia, Lua, Pascal, Phix, Smalltalk

The following languages allow negative indices: Perl, Phix, PowerShell, Python, Ruby

(Dang - I keep on posting this without saying what I came here to say...)

In a language with both 0-based indices and negative indices, apart from the disjoin of a[0] rather than a[1] as first vs. a[-1] as last,
there is no sensible value that eg find() can return that is a non-functional index, whereas in Phix, find() can return 0 and that won't accidentally retrieve the wrong element.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu