• 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: Bindings, NSNumber equal to NIL and performing mathematical operations issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings, NSNumber equal to NIL and performing mathematical operations issue


  • Subject: Re: Bindings, NSNumber equal to NIL and performing mathematical operations issue
  • From: Ondra Cada <email@hidden>
  • Date: Fri, 6 May 2005 20:00:50 +0200

Clark,

On 6.5.2005, at 15:34, Clark Cox wrote:

There really isn't. Unless you're expecting an object pointer, or
you're ignoring the return value, do not send messages to nil.

Ahem... that sounds a bit too positive :)

Do not *ever* try to send messages to nil if the return values is a float or a struct.

On the other hand, you *can* (mind you, I am not saying you should, but you *can* indeed) send messages to nil with int or BOOL (or long) return values without any problem in a foreseeable future. Of course, doing that, one should keep in mind it just *might* one day bring problems. The actual probability though is very, very small. And it should be pointed out such code did work all right ten years ago in NeXTStep on Motorola 68K-based machines, and does work all right now.

http://www.livejournal.com/community/macosxdev/86254.html

Whilst in theory a different way of returning pointers and integers may come, I would dare to argue that, given the existing *vast* codebase which depends on things like


BOOL hasTitle=[[[self window] title] length]>0; // or even directly "hasTitle= [[[self window] title] length];"!

working properly regardless there is a window or title at all, the actual danger of any Apple compiler of a foreseeable future breaks this compatibility is small enough to be quite negligible. Greater danger with GNUStep, that's agreed.
---
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: 
 >Bindings, NSNumber equal to NIL and performing mathematical operations issue (From: Eric Hochmeister <email@hidden>)
 >Re: Bindings, NSNumber equal to NIL and performing mathematical operations issue (From: Ricky Sharp <email@hidden>)
 >Re: Bindings, NSNumber equal to NIL and performing mathematical operations issue (From: Eric Hochmeister <email@hidden>)
 >Re: Bindings, NSNumber equal to NIL and performing mathematical operations issue (From: Clark Cox <email@hidden>)

  • Prev by Date: Re: A Question about [[self superview] doSomething]
  • Next by Date: Re: Function to write to one pixel
  • Previous by thread: Re: Bindings, NSNumber equal to NIL and performing mathematical operations issue
  • Next by thread: Re: Bindings, NSNumber equal to NIL and performing mathematical operations issue
  • Index(es):
    • Date
    • Thread