On Oct 26, 2010, at 2:33 PM, Rick Mann wrote:
> Sure seems like a conceptual inconsistency, but I guess whoever designed the 
> language thought it was too expensive to return a zeroed struct.

It's an artifact of C compatibility. On each architecture, Objective-C messages 
follow the same parameter-passing rules as C function calls. On all modern 
architectures, the rules for returning a struct mean that objc_msgSend() has no 
way to know how big the returned struct is supposed to be, so it can't zero it. 

A few years ago we prototyped a compiler that added the nil check at the call 
site instead. Doing that everywhere was too expensive in terms of code size, 
but doing it for structs only might be practical.


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to