• 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: NSObject Exercise comments?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSObject Exercise comments?


  • Subject: Re: NSObject Exercise comments?
  • From: Ondra Cada <email@hidden>
  • Date: Tue, 13 Dec 2005 00:44:07 +0100

Ahem...

On 12.12.2005, at 20:53, Andy Lee wrote:

Is that so? I thought that was one of the coolest points of Cocoa, honestly. You certainly still see it throughout Apple's classes.

Is that true?

Yup.

Back in the early NextStep days all methods implicitly returned self if you didn't return something explicitly, the way Smalltalk does. (Probably that should be "all methods with id return values.") I thought that default behavior was removed from Objective-C as a language feature

Not the slightest bit. See me not-so-old post, which kind of precisely answered this:

===
I know that there was a convention were the original object was returned when ever possible, so that one could 'chain' method calls together. But I think this is discouraged now.

Cocoa uses now a conversion "if there's nothing to return, don't return anything", the very reason being DO: with distributed objects which communicate betwixt threads or processes or even computers through a network, a void return can be *vastly* more efficient than an ignored object return.

The new convention is thus reasonable in a generic case. Though, for a concrete class which is never intended to be used with DO nor re- used heavily, I personally (!) would think that the convenience of the original NeXTStep convention (i.e., "if there's nothing to return, return self for easy chaining") should win.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Re: NSObject Exercise comments? (From: Lee Cullens <email@hidden>)
 >Re: NSObject Exercise comments? (From: Andreas Mayer <email@hidden>)
 >Re: NSObject Exercise comments? (From: John Stiles <email@hidden>)
 >Re: NSObject Exercise comments? (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: NSObject Exercise comments?
  • Next by Date: Shadowed text view
  • Previous by thread: Re: NSObject Exercise comments?
  • Next by thread: Re: NSObject Exercise comments?
  • Index(es):
    • Date
    • Thread