[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [objc-improvements] Warnings when compiling GNUStep

From: Nat!
Subject: Re: [objc-improvements] Warnings when compiling GNUStep
Date: Thu, 4 Sep 2003 01:54:11 +0200

Am 03.09.2003 um 02:17 schrieb Ziemowit Laski:
What should we do?  I see 3 choices:
(1) Leave things as they are. Users will be able to suppress the above warning by casting the receiver to the root class (in above case, '(NSObject *)'). (2) Build a list of all plausible root classes (i.e., classes without superclasses), and consult all instance methods for those classes when dispatching messages to
(3) Treat messages to 'Class' the same way we treat messages to 'id', i.e., consult all class and instance methods available. This is what the compiler appears to
      have done until now (in its mercurial and buggy way).

Personally, I like types (and compiler's warnings about them) :-), so I'd advocate we stick with (1), but we could also do (3). I'd really, really hate to have to implement (2), however.
Not only is it extra work, but it will adversely affect compile time.

I'd vote for 3. Casting is so Java and non-Objective-C IMO.

in which case one _could_ make the argument that any method named 'alloc' should be treated specially by the compiler, i.e., as having a return type covariant with the receiver. What do you think? If we don't teach the compiler about 'alloc', then it is perfectly within its right to complain in this case also, unless we change foregoing to read

   [(ClassName *)[ClassName alloc] init...]

I think teaching the compiler about specific "special methods" makes things just more obscure in the long run. The problem as I understand it only occurs if someone codes:

        - (Foo *) initWithString:(NSString *) s
        - (Bar *) initWithString:(NSString *) s

right ? In this case one should have written (id) anyway :)

Just my opinion

This is your life
and it's ending one minute at a time.  -- Palahniuk

reply via email to

[Prev in Thread] Current Thread [Next in Thread]