• 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: nil messaging? Is it safe?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nil messaging? Is it safe?


  • Subject: Re: nil messaging? Is it safe?
  • From: Nat! <email@hidden>
  • Date: Sat, 28 Sep 2002 14:34:16 +0200

Am Freitag, 27.09.02 um 18:14 Uhr schrieb Simon Stapleton:

From: Greg Parker <email@hidden>
Reply-To: email@hidden

<snippage>

* id, pointer, int: returns 0 or nil
* float, double: returns some random value
* long long (8 bytes): returns some random value with the 4 least-
significant bytes zero
* structs: returns some random value.
The undocumented zero value for int return probably won't change any time
soon, because too much code depends on this. Be wary of float, double, and
long long results, which are definitely not set to zero even though int is.


I fail to see how this is random, although I can see how it is destined to failure on platforms where float and double aren't magically 4 bytes long (or, to be more general, the same size as the number of zero bytes returned). I must have missed something here, I feel.


For one doubles are actually 8 bytes long.

The problem is that if your calling code expect's as return value a floating point value it reads a different PPC register than if it's an integer/pointer value. But only the (one) integer register is zeroed. If you message nil and expect a FP value, the return value will be some crap left over from a previous FP operation and not 0.0.

Ciao
Nat!

Jedenfalls sind zehn Fehlstarts hintereinander [E. Fuchs]
ein sehr interessanter Beweis
fuer unsere Theorie
von der natuerlichen Ueberlegenheit des Dezimalsystems
_______________________________________________
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.

References: 
 >Re: nil messaging? Is it safe? (From: Simon Stapleton <email@hidden>)

  • Prev by Date: Re: NSImageView scrolling
  • Next by Date: Re: IntraApp communication....
  • Previous by thread: Re: nil messaging? Is it safe?
  • Next by thread: Re: nil messaging? Is it safe?
  • Index(es):
    • Date
    • Thread