Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Bad Argument, (Bug or something I'm missing).
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
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:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chris Cook  
View profile  
 More options Oct 1 2012, 4:11 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lukas Larsson  
View profile  
 More options Oct 1 2012, 4:44 am
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

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jesse Gumm  
View profile  
 More options Oct 1 2012, 4:46 am
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:

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Junior White  
View profile  
 More options Oct 11 2012, 12:20 am
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.

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joe Armstrong  
View profile  
 More options Oct 11 2012, 1:54 pm
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

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »