[chuck-users] Passing classes to functions

Adam Tindale adamtindale at hotmail.com
Fri Oct 2 03:38:27 EDT 2009

Hi All,

I was doing some work and created some bugs that I ironed out when I
discovered something: when non-primitive types are passed to functions
they are passed by reference and not by value! I include a test so you
can see what I mean.

I hope somebody find this useful.


class test{
 0 => int val;

test obj1;
// obj2 is a reference to obj1
test obj2 @=> obj1;

<<< obj1.val , "original object">>>;
<<< obj2.val , "reference to original">>>;

2 => obj2.val;

<<< obj1.val , "original object">>>;
<<< obj2.val , "reference to original">>>;

fun void testclasspassing(test i)
    <<< i.val, "in function" >>>;


More information about the chuck-users mailing list