you guys are great, this is the stuff i have been looking for.
On Fri, Sep 10, 2004 at 11:20:02AM +0200, Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum wrote:
Keep in mind that a += b; is actually just a shorthand for a = a + b;
So, nothing is done to the array previously referenced by a.
i was aware of that. this is what got me wondering what all thit talk about growing arrays is about, when you can't actually grow them.
As for things happening on the C level, the computation a+b actualy _does_ modify the array referenced by a destructively, _iff_ there are no additional references to it.
ahhh, that's the secret.
If one really wanted, it would be possible to make a function that destructively resizes an array regardless of the number of references
i just had the scary thought of solving this with a new "reference" type: (probably not a good idea)
array bar; reference foo=refernce(bar); // references are constant reference foo=bar; // i like this one better, otherwise it would be // possible to create references of references foo=({ 2 }); // any changes after the instantiation change the // referd variable foo+=({ 1 }); // also changes bar
greetings, martin.