• 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
object.struct.element as lvalue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

object.struct.element as lvalue


  • Subject: object.struct.element as lvalue
  • From: Matt Neuburg <email@hidden>
  • Date: Tue, 22 Jan 2013 11:03:32 -0800

We have dot-syntax for accessors, and we have dot-syntax for struct elements, and we can chain them, but not as an lvalue. It is legal to say

 x = object.struct.element

and

 object.struct = f

and

 struct.element = x

but not

 object.struct.element = x

I suppose this is because you can't use the very same accessor as a getter and a setter simultaneously, but really it's quite obvious what this means: it means means

 temp = object.struct
 temp.element = x
 object.struct = temp

So *why* can't the compiler just allow it to mean that, instead of making me write it all out by hand? There's no ambiguity as far as I can tell. The ARC compiler is supplying plenty of code behind the scenes, including temporary variables, so surely it wouldn't be onerous to do the same sort of thing here. m.

--
matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com


_______________________________________________

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

  • Follow-Ups:
    • Re: object.struct.element as lvalue
      • From: John McCall <email@hidden>
  • Prev by Date: Re: How to avoid warning?
  • Next by Date: Re: How to avoid warning?
  • Previous by thread: Re: How do I use CGDisplayCapture() to capture an NSOpenGLView in a XIB?
  • Next by thread: Re: object.struct.element as lvalue
  • Index(es):
    • Date
    • Thread