3 ms·
Erlang strings is just a syntactic sugar over lists. 1> [104,105]. "hi" 2> [$h,$i]. [104,105] 3> "hi". "hi" Which is efficient for some us
by nivertech 16y ago
Erlang strings is just a syntactic sugar over lists.
1> [104,105].
"hi"
2> [$h,$i].
[104,105]
3> "hi".
"hi"
Which is efficient for some uses (i.e. iterating over UTF32 characters) and inefficient for others (high memory usage).
You can always use:
* atoms - for interned strings or enums
* binaries - for memory efficiency (i.e. UTF8 byte sequences)
* IO-lists - for efficient appending and IO.
What I would like is a per-module compiler directive/pragma, which will turn every "string" into <<"string">>, while @"string" will remain syntax sugar for list.