[chuck-users] .cap() for multi-dimensional arrays

Kassen signal.automatique at gmail.com
Mon Oct 1 05:49:53 EDT 2007

On 10/1/07, Martin Ahnelöv <operagasten at gmail.com> wrote:

Eh? What are you... Hm... Okay, I can see your point now. You're right.
> Since we are dealing with arrays, every array inside foo[i] will be of
> equal length; it's not like we are dealing with lists where every slot
> is just a reference to another object.
> Good thinking there.

It gets very useful. Suppose we have two positive integers X and Y in a file
so that;
array[X][Y] @=> Foo.foo_array;
Foo foo;

public class Foo
static int foo_array[][];

fun void bar(int blah)

Because Foo is a public class holding a static array the array needs to be
instantiated outside of the class or there will be errors. Now if Foo.bar()
does something to that array it becomes quite important to determine what
it's dimensions are, however, both X and Y are outside of Foo's namespace
and it's quite possible that there will be many instances of Foo that are in
different files altogether which won't have X or Y.

At that point the .cap()'s of multi-dimensional arrays become very
interesting so I thought I'd share because it's not in the manual nor does
my workaround look very nice. Also; this took a while to figure out and it
makes no sense for others to spend that time too.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20071001/0430e05f/attachment.htm 

More information about the chuck-users mailing list