With almost C++ level performance and homoiconicity it seems really sweet and I'd love to see it used instead of Go. Though 1-indexed arrays are definitely annoying as fuck...
With almost C++ level performance and homoiconicity it seems really sweet and I'd love to see it used instead of Go. Though 1-indexed arrays are definitely annoying as fuck...
baremodule MyWay
ref(x::AbstractArray, i::Int) = Base.ref(x,i+1)
ref(args...) = Base.ref(args...)
end
is not that far away (I'm oversimplifying a little, but not much).
However, please don't do this as it breaks coherence within the community. I found 1-based indexes annoying at first, but have grown quite fond of them since.However what I've found from doing lots of Lua programming, is that I just don't notice very much in practice.
To some degree, at least, I guess this reflects that one writes different sorts of code in different programming languages. The sort of offset-based address calculations one might do a lot in C just don't seem to happen very much in Lua.
So while my natural inclination is to dislike 1-based arrays, I no longer consider them an automatic demerit....
"Mainly, Regex and Binary indexes are zero-based, List and Tuple are one-based."
I don't remember now but one of the collections in stdlib is zero-based too. It's much worse to be inconsistent than to choose 0 or 1-based indexes for everything.
Yep, array: http://www.erlang.org/doc/man/array.html
It's definitely a mess.
> lists:nth(1, [a, b, c]).
a
> lists:nth(0, [a, b, c]).
** exception error: no function clause matching
lists:nth(0,[a,b,c]) (lists.erl, line 117)