[erlang-questions] [eeps] EEP 9

Fredrik Svahn fredrik.svahn@REDACTED
Sat Mar 8 00:20:39 CET 2008

Thanks for looking and commenting on the EEP. Please see answers below.

On Fri, Mar 7, 2008 at 9:43 AM, Per Gustafsson <per.gustafsson@REDACTED> wrote:
> Very good work, but I do have some comments:
>  Just as for lists and strings I think that there should be two different
>  modules one which just operates on binaries and one that operates on
>  binaries which are really strings. This module seems to be first of
>  these two for the most part so functions that only makes sense if the
>  binaries are strings should probably reside in some other module. The
>  string_as_binary module could have more or less exactly the same API as
>  string and similar modules could be defined for utf8, utf16 and utf32 if
>  necessary.

Agreed, I will update the EEP and split it into two modules. I prefer
the name binary_string over string_as_binary.

>  *  to_upper(Binary1) -> Binary2
>     to_lower(Binary1) -> Binary2
>  Should be in the string_as_binary module


>  * binary_to_atom(Binary) -> Atom
>    atom_to_binary(Atom) -> Binary
>  As you write these should probably be in the erlang module along with
>  binary_to_existing_atom(Binary) -> Atom

I will change the EEP to say so.

>  * unsigned_to_bin(Integer)-> Binary
>  What does this function do? Does it create the shortest possible binary
>  in which the unsigned integer would fit?


>  better names might be
>    binary:from_unsigned(Integer) -> Binary
>    binary:to_unsigned(Binary) -> Integer

Good suggestions. I will change it names.

>  * nth(N, Bin) -> Value
>  To also satisfy 0-indexers there should probably be a
>    nth0(N, Bin) -> Value
>  just as in the lists module

I can't find a nth0 in lists, at least not in R12B.

3> lists:nth(1, "ABC").
4> lists:nth0(1, "ABC").
** exception error: undefined function lists:nth0/2

BR /Fredrik

More information about the erlang-questions mailing list