Parsing null terminated strings in a binary.

James Hague james.hague@REDACTED
Thu Jan 13 15:49:04 CET 2005


Raimo Niskanen wrote

>This will not build any sub-binaries until the zero is found.

As an aside, I have become enamored of this style of programming even
for processing lists.  For example, consider the problem of parsing a
number out of a string.  I count the number of elements that are ASCII
digits, then when I don't find any more digits I grab all of them at
once with lists:sublist.  This hides all of the list building inside
lists:sublist.  I won't argue that this is faster, because it is
certainly somewhat slower than building the list as you go (I did some
timings).  But it opens the door for a faster implementation of
lists:sublist, possibly as a BIF, which somehow pleases me even though
I don't ever expect it to happen.

James



More information about the erlang-questions mailing list