I have no opinion about how it gets implemented under the hood - I thought we were just discussing the syntax. I most likely don't know enough about the innards of PHP it carry on that discussion.
But by userspace definitions, are you referring to the fact that getters and setters would compile down to actual methods? I have no strong feelings about that one way or the other - as long as the reflection API reports what was defined in the source code, rather than reflecting the underlying accessor-methods as actual methods. (something that doesn't seem to be true for traits...) I don't know if that's meaningful or relevant to you, but I think that's all I can contribute to that discussion... On Wed, Dec 7, 2011 at 1:11 PM, Will Fitch <will.fi...@gmail.com> wrote: > The difference being *where* the functionality gets mapped. It's not > about making something "look like something else", it's about requiring > more userspace definitions. Functionality within get {} and set {} can > (and should IMO) be implemented outside of userspace code. Whether that > means another union within op_array or a completely new structure mapped to > a property zval and bitmap added to the zend_uchar type identifying it as > an accessor.... I'm saying be creative - don't just implement something > halfway for the sake of getting it done. > > > On Dec 7, 2011, at 12:50 PM, Rasmus Schultz wrote: > > >> if we're attempting to get around __set/get, let's not replace them with > > more method implementations > > > > I don't understand this argument. Accessors are methods - making them > look > > like something else won't change that fact. > > > > In C#, type-hinted properties with automatic getters/setters actually > > compile down to two method implementations, while implemented > > getters/settings do the same, substituting "value" for whatever is > required > > to access the auto-implemented backing field. > > > > > > On Tue, Dec 6, 2011 at 9:26 AM, Will Fitch <will.fi...@gmail.com> wrote: > > > >> > >> On Dec 6, 2011, at 8:58 AM, Rasmus Schultz wrote: > >> > >>> I agree with all of those points - the extra indentation looks messy, > and > >>> yes, type hints are important. It does fit better with PHP in general. > >>> > >>> It would be nice to also have support for automatic backing fields in > >>> addition though - so something simple like this: > >>> > >>> class BlogPost > >>> { > >>> private $_author; > >>> > >>> public get author() > >>> { > >>> return $this->_author; > >>> } > >>> > >>> public set author(Person $value) > >>> { > >>> $this->_author = $value; > >>> } > >>> } > >> > >> I don't like this approach. All efforts (which I'm currently part of) > to > >> implement type hinting return values will be compromised. If you want > to > >> implement accessors, keep them within a syntax that makes sense. > >> Personally, I support the C# style as much as possible. Methods are > >> already overused for purposes they shouldn't be, so if we're attempting > to > >> get around __set/get, let's not replace them with more method > >> implementations. > >> > >> > >