[chuck-users] float and float[]

Adam Tindale adamtindale at hotmail.com
Sat Nov 11 23:30:12 EST 2006


Hi,

The error that I get is this:

[newtest.ck]:line(9): cannot assign '@=>' on types 'int[]' @=> 'float 
[]'...
[newtest.ck]:line(9): ...(reason: --- incompatible types for assignment)

What is happening is that the implicit cast of an int to a float that  
happens in non-array land isn't happening inside of the array.  
Remember that if you put a number on the left then you are  
initializing the values and if you put the numbers in the bracket  
beside the type you are declaring the size of the array.

// an array of size 1 with a value of 9
[9] @=> int foo[];
// sparse array with a size of 9 with the value 1 at index 0
[1] @=>int bar[9];

You seem to be a bit confused about the meaning of these lines. But  
yes, there is a bug there, just not the one you thought.

--art


On 11-Nov-06, at 12:23 PM, Kassen wrote:

> Hi, list,
>
> I find ChucK's reaction to the following lines rather surprising.
>
> //this works, obviously
> 1.0 => float foo;
> //this is fine with chuck as well
> 1 => float bar;
>
> //this works as well, also obviously
> [1.0] @=> float fooray[];
> //then why does this cause a error?
> [1] @=> float barray[];
>
> Is this intentional and if so could we considder a more readable  
> error?
> Right now this last line gives a error that looks (to me) like the  
> dimentions of a multi-dimentional array don't add up which is a bit  
> confusing
>
> Yours,
> Kas.
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users





More information about the chuck-users mailing list