Binaries and "strings"
Steve Davis
steven.charles.davis@REDACTED
Fri Feb 26 23:53:01 CET 2010
My thanks for the additional elucidation and explanation. It did
intrigue me.
For sure, there are exceptionally intelligent decisions all the way
through the language and platform of which this is just one example.
Regards,
Steve
On Feb 26, 4:42 pm, Robert Virding <rvird...@REDACTED> wrote:
> On 26 February 2010 23:33, Steve Davis <steven.charles.da...@REDACTED> wrote:
>
> > Found this binary behavior interesting:
>
> > 1> <<"one", "two">>.
> > <<"onetwo">>
>
> This creates a binary containing the characters (bytes) of the two string.
>
> > 2> <<"one" "two">>.
> > <<"onetwo">>
>
> Here the two string are concatenated to one already in the parser, so
> you are actually writing <<"abcdef">>. This is feature is useful as it
> allows you to split a long string into many sub strings without extra
> computational cost.
>
> You can also write "abc" ++ "def" in code and the compiler will
> optimise away the ++. It can always do this if the first argument to
> ++ is a list literal.
>
> Robert
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> Seehttp://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscr...@REDACTED
More information about the erlang-questions
mailing list