Re: Request Feedback for Instance Variable Sugar RFC

From: Date: Mon, 09 Mar 2015 10:52:30 +0000
Subject: Re: Request Feedback for Instance Variable Sugar RFC
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-84461@lists.php.net to get a copy of this message
Hey Shane, The @ symbol in PHP is currently an error control operator[1]. Does that mean you will be reassigning the error control operator to another character? [1]: http://php.net/manual/en/language.operators.errorcontrol.php On Monday, March 9, 2015, Shawn McCool <shawn@heybigname.com> wrote: > I've never submitted an RFC. Whether or not you're interested in the > feature, please consider giving me feedback on the RFC itself so that I can > better understand how to succeed in the process. > > ====== PHP RFC: Instance Variable Sugar ====== > * Version: 0.1 > * Date: 2015-03-09 > * Author: Shawn McCool, shawn@heybigname.com <javascript:;> > * Status: In Discussion > > ===== Summary ===== > > 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. > > This RFC proposes a single character syntax sugar form of > $this->. > Instead, an @ can be used to reference instance variables. > > The @ replaces the normal $ variable prefix. > > ===== Example ===== > > <file php MyClass.php> > <?php > class Addition { > private $number > > public function __construct($number) { > @number = $number; > } > > public function original() { > return @number; > } > > public function addTo($amount) { > return @number + $amount; > } > } > </file> > > ===== Backwards Compatibility ===== > > Leave $this-> available. > > ===== Proposed PHP Version(s) ===== > > This is proposed for the next PHP x, currently PHP 7. > > -- > Shawn McCool | Big Name > shawn@heybigname.com <javascript:;> > heybigname.com >

« previous php.internals (#84461) next »