Re: Good idea/bad idea?
Re: Good idea/bad idea?
- Subject: Re: Good idea/bad idea?
- From: John McCall <email@hidden>
- Date: Thu, 24 Apr 2014 10:37:32 -0700
On Apr 24, 2014, at 9:53 AM, Alex Zavatone <email@hidden> wrote:
> What worried me was that I've never seen this used in Objective-C in this manner. I've always used the ? operator to color the backgrounds of cells with alternating row colors. It seemed like a stretch to actually use it to achieve lazy instantiation and was wondering if there were any terrible demons I'd be summoning from the bowels of the compiler if we actually thought of using this approach.
No, it’s a supported feature across all types; we had to invent some interesting machinery a few years back to make it work consistently, akin to what we have to do for compound assignment on an Objective-C property reference, but that’s been in and stable for a long time.
Anyway, it even works on non-POD C++ types, if you’re into that — although if you’re hyper-sensitive to performance, be aware that (unlike the normal ternary operator) it is not possible to construct the left operand directly into the result because of some subtle order-of-destruction issues, and so there does have to be an unelidable copy/move.
John.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden