Re: Request Feedback for Instance Variable Sugar RFC

From: Date: Mon, 09 Mar 2015 21:26:54 +0000
Subject: Re: Request Feedback for Instance Variable Sugar RFC
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-84485@lists.php.net to get a copy of this message
On 9 March 2015 09:43:32 GMT, Shawn McCool <shawn@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, -- Rowan Collins [IMSoP]

« previous php.internals (#84485) next »