Re: Property Accessors v1.2 : Typehints / Accessor Syntax

From: Date: Wed, 17 Oct 2012 10:34:27 +0000
Subject: Re: Property Accessors v1.2 : Typehints / Accessor Syntax
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-63494@lists.php.net to get a copy of this message
On Mon, Oct 15, 2012 at 2:11 PM, Clint Priest <cpriest@zerocue.com> wrote: > So the above would actually introduce an get/set accessor rather than a > property, correct? Preferably it would a faster C based implementation for the check, but in principle it could also use accessors to achieve the goal. > If we were to abandon the long form ( set(DateTime > $date) { ... } ) and go back to the original syntax, then the only way to > "type hint" would be with no custom accessor logic, which I don't think > makes sense. Why? My point was that you could use that syntax with accessors too, just like you can in C#: public DateTime $date { get { ... } set { ... } } I don't know whether this is better or worse though. I like it because it would be consistent between typehinted properties without accessors and typehinted properties with accessors. But I can see how people don't like the magic $value variable. > I can agree though that the even further abbreviated syntax -> get/set > accessor would be nice, however many have already pointed out that these > "equivalents" reduce clarity, especially for the less "up to speed" of the > developers. If they were to encounter that, they may have to really do some > digging to realize that it’s a "super auto implemented" accessor. They don't really need to know that they are auto implemented accessors (where would it make a difference?) Maybe they won't even be accessors. It's just an implementation detail. From looking at it, it's just a property with a type, just like you know it from C++, C#, Java or whatever. Nikita

« previous php.internals (#63494) next »