• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: isa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: isa


  • Subject: Re: isa
  • From: Phillip Morelock <email@hidden>
  • Date: Sun, 02 Jun 2002 21:16:11 -0700

On 6/2/02 7:23 PM, "Aram Greenman" <email@hidden> wrote:

> On Sunday, June 2, 2002, at 01:23 AM, Marcel Weiher wrote:
>
>>
>> On Saturday, June 1, 2002, at 11:22 Uhr, Aram Greenman wrote:
>>
>>> The thread where this originally came up (re. ObjC inits vs. C++
>>> constructors) had to do with sending messages to self in an
>>> initalizer, which is _usually_ a bad idea,
>>
>> No. In Objective-C it is not "usually" considered a bad idea at all.
>>
>>> since it is possible the method called might access unitialized
>>> instance variables, depending on where you are in the initializer
>>> chain.
>>
>> Well, don't call methods that might access uninitialized instance
>> variables, then!
>
> Yes, of course, but what if (probably the third time this has been
> brought up between this thread and the previous one) class A sends [self
> foo] in -init or whatever its designated initializer is. -[A foo]
> doesn't access any uninitialized instance variables. A is later
> subclassed by A', which overrides -foo with an implementation which
> accesses instance variables declared in A' (and therefore will _always_
> be uninitialized when -[A init] is called by -[A' init]). Now the
> seemingly safe message [self foo] in -[A init] could potentially cause
> unexpected behavior.

self = [super init];

fillup "the newbie" morelock


>
> I admit that this is _not_ that big of a deal, and is avoidable by
> common sense and documentation, however, IMHO it is better to provide
> for the possibility that someone (possibly yourself) might subclass your
> class without looking at the code in question or reading your comments.
>
> Aram
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: isa (From: Aram Greenman <email@hidden>)

  • Prev by Date: Re: isa
  • Next by Date: Re: isa
  • Previous by thread: Re: isa
  • Next by thread: Re: isa
  • Index(es):
    • Date
    • Thread