Re: Is "-init" really needed?

2017-08-10 Thread Jean-Daniel
> Le 10 août 2017 à 16:09, Charles Srstka a écrit : > >> On Aug 10, 2017, at 8:59 AM, Alastair Houghton >> wrote: >> >> On 10 Aug 2017, at 14:57, gerti-cocoa...@bitart.com >> wrote: >>> >>> On Aug

Re: Is "-init" really needed?

2017-08-10 Thread John McCall
> On Aug 10, 2017, at 11:13 AM, Charles Srstka wrote: >> On Aug 10, 2017, at 9:44 AM, Alastair Houghton >> wrote: >> >> On 10 Aug 2017, at 15:24, Jeremy Hughes > > wrote:

Re: Is "-init" really needed?

2017-08-10 Thread Charles Srstka
> On Aug 10, 2017, at 9:44 AM, Alastair Houghton > wrote: > > On 10 Aug 2017, at 15:24, Jeremy Hughes > wrote: >> >>> On 10 Aug 2017, at 15:15, Alastair Houghton >>

Re: Is "-init" really needed?

2017-08-10 Thread Alastair Houghton
On 10 Aug 2017, at 15:24, Jeremy Hughes wrote: > >> On 10 Aug 2017, at 15:15, Alastair Houghton >> wrote: >> >> On 10 Aug 2017, at 15:09, Charles Srstka wrote: >>> >>> They’re equivalent syntactically, but

Re: Is "-init" really needed?

2017-08-10 Thread Jeremy Hughes
> On 10 Aug 2017, at 15:15, Alastair Houghton > wrote: > > On 10 Aug 2017, at 15:09, Charles Srstka wrote: >> >> They’re equivalent syntactically, but performance-wise, +array and friends >> will cause the object to be put into an

Re: Is "-init" really needed?

2017-08-10 Thread Alastair Houghton
On 10 Aug 2017, at 15:09, Charles Srstka wrote: > > They’re equivalent syntactically, but performance-wise, +array and friends > will cause the object to be put into an autorelease pool. Therefore, +new is > better for performance. Not with ARC they don’t. The ARC

Re: Is "-init" really needed?

2017-08-10 Thread Charles Srstka
> On Aug 10, 2017, at 8:59 AM, Alastair Houghton > wrote: > > On 10 Aug 2017, at 14:57, gerti-cocoa...@bitart.com > wrote: >> >> On Aug 10, 2017, at 02:18, Alastair Houghton >> wrote: >>> >>>

Re: Is "-init" really needed?

2017-08-10 Thread Alastair Houghton
On 10 Aug 2017, at 14:57, gerti-cocoa...@bitart.com wrote: > > On Aug 10, 2017, at 02:18, Alastair Houghton > wrote: >> >> Personally I *would* still discourage +new in favour of class-specific >> convenience constructors because I think it’s less expressive and

Re: Is "-init" really needed?

2017-08-10 Thread gerti-cocoadev
> On Aug 10, 2017, at 02:18, Alastair Houghton > wrote: > > Personally I *would* still discourage +new in favour of class-specific > convenience constructors because I think it’s less expressive and also less > consistent (e.g. +array is better, in my opinion,

Re: Is "-init" really needed?

2017-08-10 Thread Alastair Houghton
On 10 Aug 2017, at 00:28, Doug Hill wrote: > >> - Performance - it incurs an extra message send (which would have been an >> issue back in the day) > > +new requires no extra message. It's just a shorthand for [[SomeClassname > alloc] init] Er, yes it does. It sends a

Re: Is "-init" really needed?

2017-08-09 Thread Leo
I love "new". Why type more and clutter your code when you don't have to. Cheers, Leo On 8/8/17 12:45 PM, Alex Zavatone wrote: I see it creeping back in to use with some people, but IMO, new bears too many references to other languages’ use of new. It seems too close to how it would be

Re: Is "-init" really needed?

2017-08-09 Thread Doug Hill
> On Aug 8, 2017, at 2:15 PM, Uli Kusterer wrote: > > On 8. Aug 2017, at 18:38, Doug Hill wrote: >> As others have mentioned, I too have never seen any evidence or statements >> from Apple that discourages +new or -init. Or designated

Re: Is "-init" really needed?

2017-08-09 Thread Doug Hill
> On Aug 9, 2017, at 3:01 AM, Alastair Houghton > wrote: > > On 8 Aug 2017, at 17:38, Doug Hill wrote: >> >> As others have mentioned, I too have never seen any evidence or statements >> from Apple that discourages +new or -init. > > I

Re: Is "-init" really needed?

2017-08-09 Thread Alastair Houghton
On 8 Aug 2017, at 17:38, Doug Hill wrote: > > As others have mentioned, I too have never seen any evidence or statements > from Apple that discourages +new or -init. I suspect it was ObjC programmers themselves rather than Apple/NeXT that discouraged it. As for why, well

Re: Is "-init" really needed?

2017-08-08 Thread Uli Kusterer
On 8. Aug 2017, at 18:38, Doug Hill wrote: > As others have mentioned, I too have never seen any evidence or statements > from Apple that discourages +new or -init. Or designated initializers. I never said anything about init or designated initializers. In fact, ObjC

Re: Is "-init" really needed?

2017-08-08 Thread Steve Mills
On Aug 08, 2017, at 12:35 PM, Jeff Szuhay wrote: On Aug 8, 2017, at 10:12 AM, Steve Mills wrote: It's a term that's part of the language, so use it. I know what language I'm typing in, so I'm not going to confuse [NSThing new] with "new CPlusPlusClass". Even

Re: Is "-init" really needed?

2017-08-08 Thread Alex Zavatone
> On Aug 8, 2017, at 12:35 PM, Quincey Morris > wrote: > > I don’t have a problem with using “new” vs. alloc/init, but there are a > couple of technical issues hiding behind this, though in current practice > they make little difference. > > 1. NSObject

Re: Is "-init" really needed?

2017-08-08 Thread Quincey Morris
I don’t have a problem with using “new” vs. alloc/init, but there are a couple of technical issues hiding behind this, though in current practice they make little difference. 1. NSObject has “new” with a standard meaning. That means you can use “new” on any subclass where it’s OK to use the

Re: Is "-init" really needed?

2017-08-08 Thread Jeff Szuhay
> On Aug 8, 2017, at 10:12 AM, Steve Mills wrote: > > It's a term that's part of the language, so use it. I know what language I'm > typing in, so I'm not going to confuse [NSThing new] with "new > CPlusPlusClass". Even if I did lose my mind and not understand what I'm >

Re: Is "-init" really needed?

2017-08-08 Thread Steve Mills
> On Aug 8, 2017, at 11:45, Alex Zavatone wrote: > > I see it creeping back in to use with some people, but IMO, new bears too > many references to other languages’ use of new. > > It seems too close to how it would be used in other languages and may imply > things that aren’t

Re: Is "-init" really needed?

2017-08-08 Thread Alex Zavatone
I see it creeping back in to use with some people, but IMO, new bears too many references to other languages’ use of new. It seems too close to how it would be used in other languages and may imply things that aren’t the best. I think it’s a case of, “well in the olden days, new was used for

Re: Is "-init" really needed?

2017-08-08 Thread Doug Hill
As others have mentioned, I too have never seen any evidence or statements from Apple that discourages +new or -init. Or designated initializers. The Objective-C Programming Guide from Apple describes very well all of the above and the reasoning behind using them. Please point to evidence, such

Re: Is "-init" really needed?

2017-08-08 Thread gerti-cocoadev
Unlike with Swift, in Objective-C it is to no small part the developers who drive how the language evolves. +new used to be the canonical initializer in the very olden days. But then folks wanted a better distinction between object allocation and object initialization to make memory management

Re: Is "-init" really needed?

2017-08-08 Thread Steve Mills
> On Aug 8, 2017, at 05:13, Uli Kusterer wrote: > > Apple have gone back and forth on this AFAIR. +new was actually the > pre-retain/release way to create an object. So it has been discouraged since > ... OpenStep, I think? But it was never formally deprecated,

Re: Is "-init" really needed?

2017-08-08 Thread Uli Kusterer
On 8. Aug 2017, at 02:23, Carl Hoefs wrote: > Is the use of +new discouraged also? Apple have gone back and forth on this AFAIR. +new was actually the pre-retain/release way to create an object. So it has been discouraged since ... OpenStep, I think? But it was

Re: Is "-init" really needed?

2017-08-07 Thread Jens Alfke
> On Aug 7, 2017, at 5:23 PM, Carl Hoefs wrote: > > Is the use of +new discouraged also? No, I use it all the time. It’s simply shorthand for [[XXX alloc] init]. These days with ARC, I tend to use +new instead of factory class methods — e.g. [NSMutableArray

Re: Is "-init" really needed?

2017-08-07 Thread Carl Hoefs
> On Aug 7, 2017, at 5:17 PM, じょいすじょん > wrote: > >> >> On Aug 8, 2017, at 9:09, Jens Alfke wrote: >> >> >>> On Aug 7, 2017, at 5:02 PM, David Hoerl wrote: >>> >>> But then I though - heck, if Foo has NSObject as its

Re: Is "-init" really needed?

2017-08-07 Thread じょいすじょん
> On Aug 8, 2017, at 9:09, Jens Alfke wrote: > > >> On Aug 7, 2017, at 5:02 PM, David Hoerl wrote: >> >> But then I though - heck, if Foo has NSObject as its super class, gee, maybe >> -init isn't really need. I mean, if all of Foo's ivars and properties

Re: Is "-init" really needed?

2017-08-07 Thread Greg Parker
> On Aug 7, 2017, at 5:02 PM, David Hoerl wrote: > > I recently saw some code where an object was alloced but there was no init: > > Foo *foo = [Foo alloc]; > foo.bar = ... > > My blood pressure soared! My pulse quickened! I started breathing rapidly! > > But then I though

Re: Is "-init" really needed?

2017-08-07 Thread Jens Alfke
> On Aug 7, 2017, at 5:02 PM, David Hoerl wrote: > > But then I though - heck, if Foo has NSObject as its super class, gee, maybe > -init isn't really need. I mean, if all of Foo's ivars and properties are > initialized, its a shortcut, right. -[NSObject init] happens to be a