Chris Suter wrote:
The proper way to solve this, in my opinion, is to allow a way of specifying that the return type varies depending on the class it's implemented on i.e. define the alloc method in such a way so that the compiler knows that -[<class> alloc] returns an object of type <class>. Something similar could be used for [NSString string] and [NSMutableString string] which have a similar problem (they return an id, rather than an NSString or NSMutableString).


We think so too.

<rdar://problem/4909520> ER: Declare that an instance method's return type is the same as the receiver's declared type. <rdar://problem/4909545> ER: Declare that a class method's return type is the type of instances of the receiver.

The latter is the one that applies to +alloc. It returns an instance of the receiver object - which itself is a class - or some subclass thereof. The former is for things like -init, where the receiver type and the return type are the same.

There are a few binary- and source-compatibility issues to worry about, but the biggest reason this hasn't been done yet is simple lack of time.


--
Greg Parker     [EMAIL PROTECTED]     Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to