[erlang-questions] [eeps] EEP 9

Vlad Balin gaperton@REDACTED
Sat Mar 8 18:06:14 CET 2008


Yes, and there are another idea, which would lead to more general approach.

If we allow these functions to work on iolists (!)  we could keep just
single module "strings". That would be ideal approach from the
application's programmer:

1) Concatenation of binaries is more expensive than making iolist out
of 2 binaries. Therefore, we'll take benefit of extremely cheap string
concatenations.
2) Function split can be used to reformat iolist. Quite intellegent
operation, which is more general than just strings manipulation.

I understand that this approach require more effort to implement than
original proposal, but
1) It features backward compatibility with strings module.
2) It opens extended possibilities working with binary strings, which
are not present in current languages, making Erlang one of the most
advancel language for string manipulations. Such as "lazy" string
concatenations with iolists.

2008/3/8, Vlad Balin <gaperton@REDACTED>:
> One more issue. Take this function as an example.
>
>  split(Binary, SplitKeys) -> List
>             Binary = binary()
>             SplitKeys = binary() | [binary()]
>
>
>  Wouldn't it be useful to allow integers in SplitKeys in place of
>  binaries? We can treat them as 1-byte binaries (should be easy to
>  implement), and it will make code more readable in cases when keys
>  consist of 1 character.
>
>  With this option, we can just write
>
>  split( Buffer, "\n " )
>
>  instead of
>
>  > binary:match(<<"hello, world\n">>,[<<"\n">>,<<" ">>]).
>
>  It can be applied to many functions in this module, and it should
>  increase code readability in general.
>
>  Thanks,
>
> Vlad.
>



More information about the erlang-questions mailing list