Re: Property Accessors 1.2 for Final Review before Vote

From: Date: Wed, 02 Jan 2013 21:18:54 +0000
Subject: Re: Property Accessors 1.2 for Final Review before Vote
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 1/2/2013 12:44 PM, Philip Graham wrote:
I am confused by one thing about the RFC. There is a section for default accessor implementations where you specify an accessor without a body, however many of the examples omit the isset and unset accessors. I would assuming that omitting an accessor would provide the automagic implementation. If this is the case what is the need for the special syntax? If this is not the case then what is the effect of omitting an accessor? Omitting get/set declaration (and body) makes the property read only or write only.
Omitting isset/unset has the same effect as declaring it without a body. This is described in the RFC under Automatic Implementations with this line: Note that isset/unset implementations will always be provided if they are not defined or if they are explicitly auto-defined (as above).
I do see that omitting the setter creates a read-only property, however I think the syntax would be less ambiguous and easier to use by introducing a readonly keyword:
     class MyClass
     {
         public readonly $myProp {
             // ...
         }
     }
This would also eliminate the need for additional syntax for default accessors. There is one problem I see with this however, what happens when a setter is provided for a readonly property? If this has already been discussed, please accept my apologies and maybe provide a link to the discussion. This point of contention was discussed ad nauseam and nobody wanted the read-only/write-only keywords, they were removed from 1.1 -> 1.2
Please see this document: https://wiki.php.net/rfc/propertygetsetsyntax-as-implemented/change-requests Which documents all points of contention from 1.1 and what their resolution was.
Regards, Philip On Wed, Jan 2, 2013 at 6:36 AM, Clint Priest <[email protected]> wrote:
Here is the updated RFC incorporating the feedback from previous rounds of discussion. https://wiki.php.net/rfc/**propertynot getsetsyntax-v1.2<https://wiki.php.net/rfc/propertygetsetsyntax-v1.2> I'm posting it for final review so I can move to voting on Jan 7th. Please note that the current fork is not quite up-to-date with the RFC but will be within a few more days. -Clint -- -Clint -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
-- -Clint

Thread (52 messages)

« previous php.internals (#64487) next »