Re: NSLog(@"%@",[NSProxy class]);
Re: NSLog(@"%@",[NSProxy class]);
- Subject: Re: NSLog(@"%@",[NSProxy class]);
- From: Philippe Mougin <email@hidden>
- Date: Sun, 12 Mar 2006 14:10:18 +0100
glenn andreas wrote :
[...]
How do you figure that NSProxy is broken?
It is documented to implement exactly 4 class methods (and being a
root class inherits nothing more) - and "+ description" is not one
of them (like it is for NSObject).
Remember that instance methods defined in a root class are also
available on the class object itself. The Objective-C documentation
states:
"Normally, class objects can perform only class methods. But instance
methods defined in the root class are a special case. They define an
interface to the runtime system that all objects inherit. Class
objects are full-fledged objects and need to share the same interface."
and
"When a class object receives a message that it can’t respond to with
a class method, the runtime system determines whether there’s a root
instance method that can respond. The only instance methods that a
class object can perform are those defined in the root class, and
only if there’s no class method that can do the job."
Thus, the NSProxy class object should correctly respond to the
instance methods it defines (this includes -description but also the
methods declared in the NSObject protocol, since NSProxy adopts it).
Currently, it does not. This means it is broken.
Additionally, I'd like to insist on the fact that even without this
rule the NSProxy class/metaclass system would be broken. Indeed,
currently the superclass of the NSProxy metaclass is NSProxy. This is
a logical error. Think about it: it means that the NSProxy class
itself is a kind of proxy, which is conceptually incorrect. NSProxy
instances are proxies, but we don't want the NSProxy class itself to
be a proxy. From a conceptual and logical point of view this is
meaningless (and concretely the result is that the current NSProxy
class object is generally useless, for no good reason).
While it makes sense, in an object-oriented language, for the concept
of object (e.g., the NSObject class) to be itself an object (e.g., to
be instance of a metaclass that inherits from NSObject), it make no
sense for the concept of proxy (e.g., the NSProxy class) to be itself
a proxy. It should be a regular object. We are not in a proxy-
oriented language (where all things would be proxies), but in an
object-oriented language (things are objects).
Best,
Philippe Mougin
http://www.fscript.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden