string literal in binary construction

Romain Lenglet <>
Wed Jul 26 04:46:57 CEST 2006


Robert Virding wrote:
> >>L = [1, 2, [<<"hello">>, 3] ],
> >><<A:32, L/iolist, B/binary>>
> >
> > I am assuming you mean that L is an iolist and the binary
> > should contain the bytes in it. I have two comments:
> >
> > 1. I don't really see the point as you can use
> > list_to_binary/1 instead.
> >
> > 2. What would it mean in a pattern where you are matching a
> > binary? Get back a binary? Or a random iolist containing he
> > same bytes. It would violate a fundamental invariant which
> > is that if use a pattern to build an object you can use the
> > same pattern to pull the object apart and get back the same
> > objects.

Actually, I asked myself the exact same questions, just seconds 
after posting my message. And I went to the same conclusion that 
this idea was dumb. ;-)

-- 
Romain LENGLET



More information about the erlang-questions mailing list