[chuck-users] sociative polydimenional arrays

Spencer Salazar ssalazar at CS.Princeton.EDU
Tue Nov 21 14:11:49 EST 2006


Hi Kassen,
Your understanding of of multi-dimensional arrays is correct.  This  
bug seems to occur because ChucK uses a different instruction for  
accessing multidimensional arrays, which seems to disregard  
associative/string indices.  This is something that can hopefully be  
cleaned up pretty quickly.

One quick fix for this goes as follows:

int bar[3][8];

3 => bar[0][0];

5 => (bar[0])["test"];

<<< bar[0][0] >>>;
<<< (bar[0])["test"] >>>;

But ideally one would not need to use parentheses to enforce correct  
array access behavior.

Thanks for reporting this.

spencer

On Nov 21, 2006, at 12:00 PM, Kassen wrote:

> Hi list, some more arrays for fun and (potential?) profit....
>
> //this goes well;
> int foo[8];
> 3 => foo[0];
> 5 => foo["test"];
>
> //let's make sure
> <<< foo[0] >>>;
> <<< foo["test"] >>>;
>
> //that was fun!
> //lets do it again in 2D!
>
> //fine
> int bar[3][8];
>
> //fine
> 3 => bar[0][0];
>
> //not so fine
> 5 => bar[0]["test"];
>
> //we never get here
> <<< foo[0][0] >>>;
> <<< foo[0]["test"] >>>;
>
>
> Why is this? Is this a bug? Missing feature? Complete  
> misunderstanding of how to combine polydimentional arrays and  
> sociative-ness?
>
> ChucK claims foo goes out of bounds but I suspect it's either a bug  
> or a syntax error because frankly I can't see how I could prevent
>  5 => bar[0]["test"]; from going out of bounds.
>
> 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