Bad Argument, (Bug or something I'm missing).
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
Chris Cook <cookchr... @gmail.com>
Date: Mon, 1 Oct 2012 09:11:45 +0100
Local: Mon, Oct 1 2012 4:11 am
Subject: [erlang-questions] Bad Argument, (Bug or something I'm missing).
Morning list,
I have,
Erlang R15B01 (erts-5.9.1) [source] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
1> List = "89234789234jhk2hk234892789fauky324978".
"89234789234jhk2hk234892789fauky324978"
2> <<List, <<"-">>/binary>>.
** exception error: bad argument
But when I write it as this,
3> <<"89234789234jhk2hk234892789fauky324978", <<"-">>/binary>>.
<<"89234789234jhk2hk234892789fauky324978-">>
I get the result I expected to get from the above 1 & 2. Could someone
please explain what is going wrong and why, because I'm very confused
with it.
Regards
Chris Cook.
_______________________________________________
erlang-questions mailing list
erlang-questi... @erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Lukas Larsson <lu... @erlang-solutions.com>
Date: Mon, 1 Oct 2012 10:43:53 +0200
Local: Mon, Oct 1 2012 4:43 am
Subject: Re: [erlang-questions] Bad Argument, (Bug or something I'm missing).
Hi,
If you just do
2> L = "a",<<L>>.
** exception error: bad argument
You get the same behaviour. When you do <<"a">> it is just syntactic
sugar for << <<97>>/binary >>. However when passing the value as a
variable you do not get the syntactic sugar help so you have to do
this:
3> L = "a",<<(list_to_binary(L))/binary>>.
<<"a">>
or something to that effect to get the correct result. Hope that makes sense.
Lukas
On Mon, Oct 1, 2012 at 10:11 AM, Chris Cook <cookchr
... @gmail.com> wrote:
> Morning list,
> I have,
> Erlang R15B01 (erts-5.9.1) [source] [async-threads:0] [hipe] [kernel-poll:false]
> Eshell V5.9.1 (abort with ^G)
> 1> List = "89234789234jhk2hk234892789fauky324978".
> "89234789234jhk2hk234892789fauky324978"
> 2> <<List, <<"-">>/binary>>.
> ** exception error: bad argument
> But when I write it as this,
> 3> <<"89234789234jhk2hk234892789fauky324978", <<"-">>/binary>>.
> <<"89234789234jhk2hk234892789fauky324978-">>
> I get the result I expected to get from the above 1 & 2. Could someone
> please explain what is going wrong and why, because I'm very confused
> with it.
> Regards
> Chris Cook.
> _______________________________________________
> erlang-questions mailing list
> erlang-questi... @erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
erlang-questi... @erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Jesse Gumm <g... @sigma-star.com>
Date: Mon, 1 Oct 2012 03:46:51 -0500
Local: Mon, Oct 1 2012 4:46 am
Subject: Re: [erlang-questions] Bad Argument, (Bug or something I'm missing).
Hi,
You just need to convert List to a binary first with list_to_binary.
The <<"something">> syntax is just a friendly way to make binary literals.
But it does not perform automatic casting of lists.
Further, the extra << >> you're wrapping around "-" is unnecessary.
Example:
> L = "123456",
> B = list_to_binary(L),
> <<B/binary,"-">>.
Will yield:
<<"123456-">>
Hope that helps.
Take it easy,
-Jesse
--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm
On Oct 1, 2012 3:11 AM, "Chris Cook" <cookchr... @gmail.com> wrote:
> Morning list,
> I have,
> Erlang R15B01 (erts-5.9.1) [source] [async-threads:0] [hipe]
> [kernel-poll:false]
> Eshell V5.9.1 (abort with ^G)
> 1> List = "89234789234jhk2hk234892789fauky324978".
> "89234789234jhk2hk234892789fauky324978"
> 2> <<List, <<"-">>/binary>>.
> ** exception error: bad argument
> But when I write it as this,
> 3> <<"89234789234jhk2hk234892789fauky324978", <<"-">>/binary>>.
> <<"89234789234jhk2hk234892789fauky324978-">>
> I get the result I expected to get from the above 1 & 2. Could someone
> please explain what is going wrong and why, because I'm very confused
> with it.
> Regards
> Chris Cook.
> _______________________________________________
> erlang-questions mailing list
> erlang-questi... @erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
erlang-questi... @erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Junior White <efi... @gmail.com>
Date: Thu, 11 Oct 2012 12:20:28 +0800
Local: Thurs, Oct 11 2012 12:20 am
Subject: Re: [erlang-questions] Bad Argument, (Bug or something I'm missing).
hi,
This behave makes me confused too.
On Mon, Oct 1, 2012 at 4:46 PM, Jesse Gumm <g
... @sigma-star.com> wrote:
> Hi,
> You just need to convert List to a binary first with list_to_binary.
> The <<"something">> syntax is just a friendly way to make binary literals.
> But it does not perform automatic casting of lists.
> Further, the extra << >> you're wrapping around "-" is unnecessary.
> Example:
> > L = "123456",
> > B = list_to_binary(L),
> > <<B/binary,"-">>.
> Will yield:
> <<"123456-">>
> Hope that helps.
> Take it easy,
> -Jesse
> --
> Jesse Gumm
> Owner, Sigma Star Systems
> 414.940.4866 || sigma-star.com || @jessegumm
> On Oct 1, 2012 3:11 AM, "Chris Cook" <cookchr... @gmail.com> wrote:
>> Morning list,
>> I have,
>> Erlang R15B01 (erts-5.9.1) [source] [async-threads:0] [hipe]
>> [kernel-poll:false]
>> Eshell V5.9.1 (abort with ^G)
>> 1> List = "89234789234jhk2hk234892789fauky324978".
>> "89234789234jhk2hk234892789fauky324978"
>> 2> <<List, <<"-">>/binary>>.
>> ** exception error: bad argument
>> But when I write it as this,
>> 3> <<"89234789234jhk2hk234892789fauky324978", <<"-">>/binary>>.
>> <<"89234789234jhk2hk234892789fauky324978-">>
>> I get the result I expected to get from the above 1 & 2. Could someone
>> please explain what is going wrong and why, because I'm very confused
>> with it.
>> Regards
>> Chris Cook.
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questi... @erlang.org
>> http://erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questi... @erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
erlang-questi... @erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Joe Armstrong <erl... @gmail.com>
Date: Thu, 11 Oct 2012 19:54:07 +0200
Local: Thurs, Oct 11 2012 1:54 pm
Subject: Re: [erlang-questions] Bad Argument, (Bug or something I'm missing).
1> L = "hello".
"hello"
2> << L, " world" >>.
** exception error: bad argument
3>
3> B = <<"hello">>.
<<"hello">>
4> << B, " world" >>.
** exception error: bad argument
5> << B/binary, " world" >>.
<<"hello world">>
<< X1 X2 ... >> constructs a binary. The X's can be literal strings
"....." or Var/Descriptor.
Its described in section 7.16 of the erlang reference manual
http://www.erlang.org/doc/reference_manual/expressions.html#id77949
Cheers
/Joe
On Mon, Oct 1, 2012 at 10:11 AM, Chris Cook <cookchr
... @gmail.com> wrote:
> Morning list,
> I have,
> Erlang R15B01 (erts-5.9.1) [source] [async-threads:0] [hipe] [kernel-poll:false]
> Eshell V5.9.1 (abort with ^G)
> 1> List = "89234789234jhk2hk234892789fauky324978".
> "89234789234jhk2hk234892789fauky324978"
> 2> <<List, <<"-">>/binary>>.
> ** exception error: bad argument
> But when I write it as this,
> 3> <<"89234789234jhk2hk234892789fauky324978", <<"-">>/binary>>.
> <<"89234789234jhk2hk234892789fauky324978-">>
> I get the result I expected to get from the above 1 & 2. Could someone
> please explain what is going wrong and why, because I'm very confused
> with it.
> Regards
> Chris Cook.
> _______________________________________________
> erlang-questions mailing list
> erlang-questi... @erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
erlang-questi... @erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
You must
Sign in before you can post messages.
You do not have the permission required to post.