• 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: Thomas Lachand-Robert <email@hidden>
  • Date: Tue, 9 Apr 2002 16:03:31 +0200

Le mardi 9 avril 2002, ` 02:36 , Marcel Weiher a icrit :
On Tuesday, April 9, 2002, at 12:32 Uhr, Ondra Cada wrote:
On Tuesday, April 9, 2002, at 03:28 , John C. Randolph wrote:
foo = [[MyClass alloc] initWithSomeOtherObject:[OtherClass randomObject]
];

foo=MyClass->alloc()->initWithSomeOtherObject(OtherClass->randomObject()
)
;

Sure, this works, but let's see what the good doctor has to say on this subject:

[snip]

I find this observation to be exactly on the mark. Yes, it is probably odd at first, but for some reason the Objective-C syntax seems to allow more complex expressions to be handled more clearly, similar to the way that Objective-C allows us to handle greater program complexity more clearly.


Actually this doesn't really work and is certainly bad C++ style.
If you write
foo = MyClass->alloc()->initWithSomeOtherObject(OtherClass()->randomObject(
))
the programm will crash if any of the function returns a null pointer.

For this reason, a good C++ programmer will do something like:
MyClass *p = MyClass->alloc();
if (p) {
Other *q = OtherClass();
if (q) {
p-> initWithSomeOtherObject( q->randomObject() );
//continue...
}
}

This means that basically you cannot nest calls to dynamic objects in C++, except being imprudent. There is a similar problem in Java.

One of the great features of Obj-C is that it permit calls to null pointers. This is a strong requirement for nesting calls. So the probem is not really related to the syntax of these languages.


Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
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: Brian Stern <email@hidden>
References: 
 >Re: why Obj-C (From: Marcel Weiher <email@hidden>)

  • Prev by Date: Re: UInt32 and ==
  • Next by Date: Re: UInt32 and ==
  • Previous by thread: Re: why Obj-C
  • Next by thread: Re: why Obj-C
  • Index(es):
    • Date
    • Thread