[erlang-questions] What is the correct representation of text in erlang programs?

Robert Virding <>
Tue Apr 14 18:11:12 CEST 2009


I think you are really looking at two different problems here:

1. How to represent external, for example JSON, data in a suitable way, more
specifically how to be able to see the difference between sequences and
strings both represented by lists.

2. What is a good representation of "strings" in Erlang.

They are different problems. I personally feel that within an app you
generally know what types of data you are working on, if a list is a string
or a, well, list. If not you should probably think over how your app is
designed.

The problem of representing external data in a suitable way should, of
course, be handled by the boundary layer, and once past that there should be
no ambiguity.

This is not saying that strings as lists of integers is the best way of
representing them, but rather that not properly disambiguating strings and
lists in the boundary layer is not a reason not to represent strings as
lists.

Maybe there should be a character type, but think of the problems involved
in introducing it. Not for the implementors my you, but for most existing
apps. At least when using lists you don't have to worry about the internal
representation as you would always have to do when using binaries, or
another C-string like equivalent.

IMAO,
Robert

2009/4/13 Steve Davis <>

>
>
> On Apr 13, 4:39 pm, Steve Davis <>
> wrote:
> > So would it be fair to say that, as a general design principle for
> > representing strings in erlang terms then a binary representation is
> > far more preferable than a "list of integers"?
> >
>
> Additionally
>
> 1) do people tend to agree with Joe's guidance in that exchange
> re:couchdb, and if so why isn't it plastered all over the tutorials?
> 3) Shouldn't the word "string" be banned from the debate about text in
> erlang apart from as a reference to a specific foreign data type?
> 3) Are my questions too trite?
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090414/005c55cf/attachment.html>


More information about the erlang-questions mailing list