Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum wrote:
The things is though, that it isn't array a which loses the weak flag. Addition of two arrays creates a _completely new_ array, which is then stored in the variable a. Since the weak flag is on the array and not the variable, a will refer to a weak array after the operation only if the newly created array is also weak.
So, should addition between a weak array and another (weak?) array also yield a weak array? We have three possible cases:
- weak + non-weak
- non-weak + weak
- weak + weak
At least for case 1 and 3, getting a weak array back seems useful, but I'm not sure there are no pitfalls that could result from this...
I'm aware of this. Perhaps have a way of operating with a weak-valued object to flag that you want the resulting (newly created objects) to inherit any (and all) weak keys/values present in the operation, regardles of case 1, 2 or 3? Not sure what this would look like though, but it would introduce some kind of new syntax, leaving the old syntax as it is today (without new pitfalls).
Uhm... or maybe I should simply make a new class simulating the array type, overloading the `+ `- etc operations. I can see that there might be cases when you don't want the flag to be passed along, but in my case, I always want it for all such operations I do on the array.
//K