Re: why Obj-C
Re: why Obj-C
- Subject: Re: why Obj-C
- From: Chris Purcell <email@hidden>
- Date: Fri, 5 Apr 2002 10:57:35 +0100
You're right in this example, but as I recall, if bAsA->foo() is
invoked in A's constructor, it will call A::foo(), on the grounds
that it's not safe to use B::foo() before the object's B-ness has
been initialized. (No jokes, please, about the object's "A-ness.")
This is consistent with C++'s highly protective design and
philosophy, but different from Java and Objective-C.
Yes.
In Objective-C, [bAsA foo] would *always* call [B -foo] no matter
where it's called.
Yes, and as a result it is recommended you make no self calls during an
object's init methods, as they may access data in a superclass that has
not yet been initialized. The exception is generally calling self's
designated initializer (as that is supposed to be called), and possibly
accessors if you can guarantee that no superclass will ever override
them to do something unexpected. But in general, there is no way of
ensuring you call the code you yourself have written!
I would say the C++ way makes sense when considered like this.
Kritter out
_______________________________________________
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.