On Mar 13, 2008, at 12:03 PM, David Ayers wrote:
Fred Kiefer schrieb:
I only follow this discussion with out any deeper knowledge of the
subject, so my suggestion may be utter nonsense. But to me it seems
that
NSAutoreleasePool does the right thing. It seems wrong to me to
return a
different selector from +instanceMethodForSelector: than from
-methodForSelector:.
If one would call:
[[aFaultedObject class] instanceMethodForSelector:@selector(release)];
one would actually get the implementation of the unfaulted object.
Yet if one would call that method directly on the faulted object,
you'd
get undefined behavior (ie most likely some kind of memory
corruption if
ivars are being accessed before some other method happens to fire the
fault).
But what NSAutoreleasePool was doing is:
[GSObjCClass(aFaultedObject)
instanceMethodForSelector:@selector(release)];
When this optimization was introduced I had to add the
implementation to
EOFault even though it shouldn't be needed. But since most other code
never saw the EOFault class (as they call -class instead of
GSObjCClass()), didn't use +instanceMethodForSelecotor: but called
methods which would trigger forwardInvocation: (just like
methodForSelector: does) that didn't much matter.
Seems to me like this deserves a comment in -emptyPool, so it doesn't
get broken inadvertently (again).
One thing I've noticed while looking at GNUstep is some strange ways
of doing things, like this, where it is not immediately evident why
the normal pattern/idiom is not being used. It would be nice if all
such things were clearly commented, so that it would be easier to know
that the oddity was intentional rather than accidental. For instance
in GSWeb I see occurrences of the following, which I had convinced
myself is wrong:
+(void)dealloc
{
...
[[self superclass]dealloc]; // should be [super dealloc]
}
-Tim
_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev