[erlang-questions] Improve $handle_undefined_function
Loïc Hoguin
essen@REDACTED
Thu Jan 24 18:21:43 CET 2013
On 01/24/2013 06:12 PM, 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.
There are only two hard problems in computer science: cache
invalidation, naming things, and off by one errors.
> 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.
But then you can write:
<< _:Pos/binary, C, _/binary >>.
Alternative would be to -1/+1 all the time.
--
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu
More information about the erlang-questions
mailing list