Request Feedback for Instance Variable Sugar RFC

From: Date: Mon, 09 Mar 2015 09:43:32 +0000
Subject: Request Feedback for Instance Variable Sugar RFC
Groups: php.internals 
Request: Send a blank email to internals+get-84460@lists.php.net to get a copy of this message
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 * 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 heybigname.com

« previous php.internals (#84460) next »