[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnustep/base modifications for OSX
From: |
Richard Frith-Macdonald |
Subject: |
Re: gnustep/base modifications for OSX |
Date: |
Tue, 28 Jan 2003 18:30:22 +0000 |
On Tuesday, January 28, 2003, at 05:24 pm, David Ayers wrote:
Hello Richard,
I've also been biten by this a lot, and I've been thinking about it
very hard, but I don't think it's that "simple" as you suggest. In
fact I really don't understand how Apple code is working under these
conditions.
We have a state of undefined semantics (deep/shallow) for
copyWithZone: (and therefor copy) and mutableCopyWithZone: (and
therefor mutableCopy). It might be well defined if you have simple
collections that you can require "applications" (or in this case
libraries) to use initWithArray:copyItems:, which will send "copy" to
the contents, if the flag is YES. But if the contents are again
collection classes then you just simply have undefined behavior
(depending on the concrete class) for the contents.
The *bug* is that you can't really allow undefined semantics for such
fundamental and in this case recursive messages for a class clusters.
(I dare say this breaks object orientation.)
I've also been thinking about this a lot but haven't come up with a
solution that would (a) solve the problem and (b) be compatible with
the arbitrary behavior that OS X seems to introduce. In fact I would
say that if OS X apps don't assume anything, that we do find a
consistent behavior in favor of being compatible with the
"undocumented" behavior of certain subclasses. In practice this is
not going to work either though, unless we never collections within
collections.
We should at least give it alot of though. I really believe that
Apple has broken something here. Maybe it would be worthwhile to file
a bug report showing this.
I think in practice, MacOS-X mostly does what I consider the sensible
thing ... copies are really shallow ... even though the abstract copy
methods are deep and they reserve the right to have concrete classes do
anything!
If we adopted the convention that all collection copies are shallow, we
could add a few new methods for deep copies.
Shallow copies are 'safe' in that they don't cause recursion, and are
obviously quicker than deep ones ...
which is why I think that standard behavior should be shallow copy.
The question of how a deep copy would deal with a recursive data
structure remains though.