[erlang-questions] Erlang Syntax and "Patterns" (Again)

Richard A. O'Keefe ok@REDACTED
Thu Mar 17 01:46:00 CET 2016



On 17/03/16 1:31 pm, Steve Davis wrote:
> I do have an issue that “strings are just lists of integers” was maybe a wrong path that led to many criticisms. Pattern matching a decode from a binary message is simplified greatly were “strings” defined to be binaries not lists (as I have spoken on before).

Anything unfamiliar, whether right or wrong, is going to "lead to many 
criticisms".
Many functional languages have represented strings as lists of atoms or 
integers,
and there are two important reasons for this:
  (1) lists have a very large number of operations defined on them and are
     extremely easy to process, so this made strings easy to process
  (2) the space argument (you mean you take 8 bytes per character shock 
horror)
     had some force in the days of 4 MB machines; in the days of 21-bit 
characters
     and 16 GB machines, it has much less force.  But if space was an issue,
     strings were the wrong data type anyway.  (In fact strings are 
wrong any time
     you have structure in the contents that you need to be aware of.)

I don't understand your statement about pattern matching from binary 
messages.

It would be absurd to think that ANY abstract data type had to be 
represented in
one and ONLY one way.  The classical pointer-to-NUL-terminated-array-of-char
is not the only and not always the best representation for strings in C, 
and the
classical list-of-character-codes is not the only and not always the 
best representation
of strings in Erlang.  Yawn.




More information about the erlang-questions mailing list