kraftwerk1611 wrote
Hi
When evaluating an expression containing array like b[j] as a single term, do we expect the result to be an address of memory location or the actual value stored at that location?
thanks.
Setting b[j] puts the expression value in word
j of array
b. It the expression is an object, that value is the object's address.
Reading b[j] returns the value stored in word
j of array
b. This value will be an address if an object was stored in the array.
var Array b;
var MyClass me;
let b=Array.new(10);
let b[0] = 17;
do Output.printInt(b[0]); // prints 17
let b[1] = "test";
do Output.printString(b[1]); // prints "test"
do Output.printInt(b[1]); // prints address of String object containing "test"
let b[2] = MyClass.new(); // rerurns a new MyClass object and stores it.
let me = b[2]
do me.myMethod(); // applies myMethod() to the object strored in b[2]
--Mark