Re: Objective-C runtime questions
Re: Objective-C runtime questions
- Subject: Re: Objective-C runtime questions
- From: Clark Cox <email@hidden>
- Date: Sun, 27 Feb 2005 20:44:47 -0500
On Sun, 27 Feb 2005 14:54:25 +0100, Stéphane Sudre <email@hidden> wrote:
> I was reading the old NeXT Developer's Library documentation entitled:
> "Object-Oriented Programming and the Objective-C Language" and I came
> across 2 points I'm wondering about:
>
> - it is stated that the default returned value of a message sent to nil
> for a method which returns an object is nil but that it is undefined if
> the method does not return an object.
>
> My experience has been somehow that 0 was returned in such cases. Is it
> just good luck?
It is just luck, but many people rely on it. This is because, on PPC,
the same register (r3 I believe) is used for pointer returns as well
integers. So returning a nil object also returns a zero for int, char,
long and short. But this won't hold true for other types (i.e. float,
double, structures, long long, etc.).
However, if Apple ever changes chips (or updates the obj-c runtime to
work with 64-bit pointers), all of this could go out the window.
--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
_______________________________________________
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