[erlang-questions] Improve $handle_undefined_function

Björn-Egil Dahlberg egil@REDACTED
Thu Jan 24 18:31:27 CET 2013

On 2013-01-24 18:12, Robert Virding wrote:
>     Some of the stuff in our stdlib, like providing zero-index based
>     access everywhere is hard to "backport" to Erlang. And other stuff
>     like the Enum module, which is a bunch of functions meant to work
>     on any enumerable data structure, like lists, dicts, etc, requires
>     protocols.
> What is it with zero-based indexes that make people so morbidly 
> fascinated by them. If you are talking *offsets* then I agree that 
> zero-based is fine, it's saying how far away something is from a some 
> point. But here we are talking *indexes*, you know like first, second, 
> third, etc. No indexes start at one! And don' go on about how C does 
> it because C doesn't have arrays and indexes it has pointers and 
> offsets, foo[3] is just syntactic sugar for *foo+3. And don't go on 
> about how much easier it is to count from zero, I don't buy that, we 
> can all add and subtract one without problems. Or at least I hope so.
> I think the OTP group made a bad decision *indexing* binaries from 
> zero instead of one like the rest of erlang. It is both wrong and 
> makes the system inconsistent.

I can see your point. I tend to think of indexing binaries as "indexing 
char arrays" and everything else as "indexing erlang terms".

> So to go on about this but there are some sensible things you can 
> criticize Erlang for and indexing from one is not one of them. (And 
> not really the syntax either, and this comes from the creator of LFE)

IMHO: I think not having zero-based indexing in Erlang was a *big* 
mistake. I can see where it comes from, but still .. it's a pain knowing 
that I have to do +1/-1 to make certain algorithms function properly.

Btw, when you say "the OTP group made a bad decision", exactly who are 
you referring too? Yourself? Isn't these decisions from CS-lab? 
Certainly way before my time =)

// Björn-Egil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130124/f48aa6b7/attachment.htm>

More information about the erlang-questions mailing list