string literal in binary construction

Romain Lenglet rlenglet@REDACTED
Thu Jul 13 10:18:20 CEST 2006


Claes Wikstrom wrote:
> Romain Lenglet wrote:
> > Vance Shipley wrote:
> >> 1> <<"123">>.
> >
> > This is syntactic sugar for <<$1, $2, $3>>.
> >
> >> <<"123">>
> >> 2> String = "123".
> >> "123"
> >> 3> <<String>>.
> >> ** exited: {badarg,[{erl_eval,expr,3}]} **
> >
> > Use list_to_binary(String) instead.
>
> Hmmm
>
> <<A:32, String/string, B/binary>>
>
> would certainly be useful (easy to implement too)

Or even better:

L = [1, 2, [<<"hello">>, 3] ],
<<A:32, L/iolist, B/binary>>

-- 
Romain LENGLET



More information about the erlang-questions mailing list