[erlang-questions] String/List question

Oliver Mason <>
Wed Sep 3 12:23:40 CEST 2008


Hi,

I'm currently working on a module to parse/generate YAML files in
Erlang.  The parsing bit is fine for lists and maps, but with the
generation bit (which I though ought to be easier) I have a problem,
and I don't know if there's a solution.

When looking at a list I would usually write each element out
separately, and recursively in the case of embedded lists.  However,
as strings are lists, they get written out as lists of numbers.  Which
for pure serialisation would not be a problem, but if you want to edit
the file by hand, or exchange it with a non-Erlang system, then it
becomes a real problem.

Do I need to abandon this, and go for something like {string. "This is
a string"} to represent strings?  I'd rather not, as it breaks
compatibility with the standard library modules, but I cannot easily
think of a way to distinguish between strings and lists of numbers in
the ASCII letter ranges.

Any ideas?

Thanks,
Oliver



More information about the erlang-questions mailing list