On 03/09/2015 04:26 PM, Rowan Collins wrote:
On 9 March 2015 09:43:32 GMT, Shawn McCool <sh...@heybigname.com> wrote:

In order to access instance variables, one must use the `$this->`
prefix.
The problem with this is that it reduces expressiveness in the language
and
increases the amount of unnecessary decoration, reducing readability.
I disagree with this premise. The $this here is not just decorative syntax, it's 
an actual variable, which can be passed around just like any other variable. The 
-> is then the standard way of accessing a property or method, applied to that 
variable.

This is beautifully simple, and expresses what's going on perfectly: if you look at $this->foo, and 
ask "which foo is being referenced here?", the answer is clearly "the one which is a 
property of $this".

The only places I can see value in a shorthand are in constructors and setters, 
where you're just copying from one name to another ($this->foo = $foo). But the 
part that's redundant there is the variable/property names, not the $this, so what 
you need is getter/setter support, or shorthand constructors (you should be able 
to find previous RFCs for both).

Regards,

I concur. I don't see much advantage of a short hand in this case, but I would love to see someone pick up both the property RFC (which implied short-hand getter/setters) and shorthand constructors. (It's undoubtedly too late for 7.0, but they'd be great additions for 7.1.)

--Larry Garfield

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to