On Sat, Mar 8, 2014 at 5:45 PM, Gregory Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Ian Kelly wrote:
>>> I already mentioned this earlier in the thread, but a balanced binary
>> tree might implement += as node insertion and then return a different
>> object if the balancing causes the root node to change.
>>> That would be a really bad way to design a binary tree
> implementation. What if there is another reference to
> the tree somewhere? It's still going to be referring to
> the old root object, and will have an incoherent view
> of the data -- partly old and partly new.
>> If you're going to have a mutable tree, it needs to be
> encapsulated in a stable top-level object.
Well, as I parenthetically noted the first time I brought it up,
"whether this is good design is tangential; it's a possible design".
The language shouldn't be written such that only those designs deemed
"good" by some external committee can be implemented. What you
dismiss as "really bad" may be exactly what somebody else needs, and
maybe they intend that there won't be other references.