• 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: why Obj-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: why Obj-C
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: copyPath command doesn't copy as the Finder. Help!
  • Next by Date: NSComboBoxCell in a NSTableView
  • Previous by thread: Re: why Obj-C
  • Next by thread: Re: why Obj-C
  • Index(es):
    • Date
    • Thread