[erlang-questions] Strings as Lists
Wed Feb 13 14:57:03 CET 2008
On Feb 13, 2008 5:00 AM, Zvi <> wrote:
> Still there is a need for standard string datatype, which will be good for
> 90% of uses and it should be accepted by all standard libs.
If you ask me, that is string(). It is good for the majority of uses.
> * <<"ABC">>, instead of "ABC"
Yes, this is a bit annoying to type.
I'm not the biggest fan of the syntactical appearance of binary
I have been pondering the use of LEFT and RIGHT-POINTING DOUBLE ANGLE
QUOTATION MARK in latin1 as shorthand for <<"">>. Of course, I realize
that ~99,8% (everyone but me :) of all erlang users dont want
non-ascii characters in the syntax, even though Erlang source code is
specified to be in latin1.
> * <<S1/bytes,S2/bytes>> instead of S1++S2
[S1,S2] and then do iolist_to_binary/1 if you need it flat.
> * using file:delete(binary_to_list(Filename)) instead of
Why handle filenames as binaries?
> > - list of words and a word-dictionary (features quicker scanning of
> > ...words, efficient storage too)
> I want to implement something like this, but using atoms for words. Is this
> a good idea?
Go with your own dictionary and word ids. Erlang handles small
integers as fixnums so they're as efficient to compare as atoms.
If you have an a-priori known dictionary then you can of course map to atoms.
> How Ragel is better, than other lexical analysers? Do you use it primarily
> because it's parsing binary input, why Erlang leexer working with lists?
Leex is very cool and I have been playing with it some. It generates
erlang code which is good. I mostly see it as the solution for parsing
I want non-greedy matching, and also some push down automata support.
Ragel can do this. With it you can parse quoted strings as a single
token, and still have incremental parsing (i.e. in chunks). The fact
that you generate C code from Ragel can also be beneficial in speed
but of course risky. The higher-level programming of using Ragel can
hopefully decrease risk of security problems.
I'm really just experimenting with Ragel as a tool. I still suck at it
after having spent ~6 hours or so with it.
More information about the erlang-questions