discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Problem with my first app


From: Philippe C.D. Robert
Subject: Re: Problem with my first app
Date: Sun, 14 Oct 2001 22:49:03 +0200

On Sun, 14 Oct 2001 21:20:13 +0100 (BST)
Nicola Pero <nicola@brainstorm.co.uk> wrote:
> > menu = AUTORELEASE ([NSMenu new]); 
> > 
> > BTW the method 'new' does actually alloc/init using the designated 
> > initialiser - it is a 'deprecated' method 
> > (NeXT wanted to remove it switching from NS 2.x to 3.0,
> > but at the end they did not because of legacy stuff ), 
> > so it is better to use alloc/init directly.
> 
> new is not at all deprecated and is in widespread use.
> 
> if you don't like it, that's another matter, and we can discuss about it
> (I could even agree with you), but please give newcomers a fair and
> neutral description of the state of things ... it's perfectly good and
> normal and standard to use +new (and similar methods) in Objective-C code.

That is exactly what I am doing...;-)

'new' - as I mentioned - is only in the OpenStep (and late NS 3.x ) API because 
of legacy support. But this is not enough reasoning in that case, I agree. I 
also explained what 'new' does in a 'fair and neutral way' - and here begin the 
problems:

- you do not know what new exactly does by looking at the name
- it is not exactly the same as in C++ thus misleading to newcomers coming from 
that part of the world
- engineering wise, alloc/init is much more beautiful because it separates 
allocation and initialisation. If you ever did C++ coding you know why this is 
a plus!
- The docu is ambiguous: "Allocates a new instance of the receiving class, 
sends it an init message, and returns the initialized object." Does this mean 
it always calls init or do subclasses correctly call the super class' 
designated initialiser? The docu says "sometimes"... For existing classes this 
is not a real problem but what is expected from your subclasses...?
- Subclassing is a problem, because 'new' sometimes does not only alloc/init 
but also other things ( see the NSObject docu )...

But I have to agree that it is not deprecated in the common sense (it is still 
part of the API), I should have made the clearer in my first email. I guess it 
belongs into the same category as the RELEASE/AUTORELEASE/... macros, but that 
is another story...

-Phil
-- 
Philippe C.D. Robert
Software Engineer
Silicon Graphics, Inc.



reply via email to

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