Re: Request Feedback for Instance Variable Sugar RFC
| From: | Stelian Mocanita | Date: | Mon, 09 Mar 2015 13:31:40 +0000 |
| Subject: | Re: Request Feedback for Instance Variable Sugar RFC | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-84471@lists.php.net to get a copy of this message | ||
Hi Shawn,
My opinion is that even though the "@" operator should be deprecated in
further along the line removed, it should not be repurposed for anything,
it has too much legacy imho.
While a shortcut might be a good idea, I personally favour the $this->var
syntax just for muscle memory if nothing else.
Stelian
On Mon, Mar 9, 2015 at 11:54 AM, reeze <reeze@php.net> wrote:
> Hi,
>
> On 9 March 2015 at 17:43, 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
> > * Status: In Discussion
> >
> > ===== Summary =====
> >
> > In order to access instance variables, one must use the
$this->©ÇD
> > {Ï€®OÿУ prefix.
> > The problem with this is that it reduces expressiveness in the language
> and
> > increases the amount of unnecessary decoration, reducing readability.
> >
>
> This might decrease readability, since we already comfortable with the
> syntax $this->something, in my opinion
>
>
> > 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;
> >
>
> this is a BC break. this is the same as constant number + $amount. so this
> syntax is not feasible.
>
>
> > }
> > }
> > </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
> >
>
>
>
> --
> Reeze Xia
> http://reeze.cn
>