Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84475 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86992 invoked from network); 9 Mar 2015 14:11:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2015 14:11:55 -0000 Authentication-Results: pb1.pair.com header.from=shawn@heybigname.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=shawn@heybigname.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain heybigname.com designates 74.125.82.181 as permitted sender) X-PHP-List-Original-Sender: shawn@heybigname.com X-Host-Fingerprint: 74.125.82.181 mail-we0-f181.google.com Received: from [74.125.82.181] ([74.125.82.181:35511] helo=mail-we0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 75/80-18276-A2AADF45 for ; Mon, 09 Mar 2015 09:11:54 -0500 Received: by wesw55 with SMTP id w55so11908785wes.2 for ; Mon, 09 Mar 2015 07:11:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=Hg2llU7utI3XYlhO17rf33T4gwWP639XT/gQLC9ZwYc=; b=Rx08r3YYFkNn/LcEh2N2Shc7RErRt63ha15kPZphqYRA9Xy0oY93Ypqgw9jmY1ItAg KlnvuMQDWkdubhJoMh5cnkFim9aU9thMS5ROTGx1ucOFl8tDcgHrQZADG8DfvV1oIT+d /DdQ61l7zB5wy7HjNBNuGCwPDddQ2FvlVUGv0JD0RD+OVSeEZRzFlnxIiyoBS8aHUyJR QggM4c4bQDInCy2AgXzizazfP7xIGcvuC60oiFAZfUJNurcqF3EBKHrwxw23X/djDYXT mxGydpL5GMcHz1XH00w4qQ6HW3ZJPVNeaJDibFsFUIjRgfIMNYHJftUH9INL2WR+50VR qCgw== X-Gm-Message-State: ALoCoQkDn6JXOxaQRz8Kb6JhUbTuhCeJHJx2Cf1Bq+jAI6vcppjHoI9LMGiEQYi06wP2bRwrMCab X-Received: by 10.180.76.178 with SMTP id l18mr59180485wiw.36.1425910311337; Mon, 09 Mar 2015 07:11:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.180.19.10 with HTTP; Mon, 9 Mar 2015 07:11:31 -0700 (PDT) X-Originating-IP: [82.217.95.45] In-Reply-To: References: Date: Mon, 9 Mar 2015 15:11:31 +0100 Message-ID: To: Mike Dugan Cc: PHP internals list Content-Type: multipart/alternative; boundary=f46d0438938796d7850510db9db9 Subject: Re: [PHP-DEV] Request Feedback for Instance Variable Sugar RFC From: shawn@heybigname.com (Shawn McCool) --f46d0438938796d7850510db9db9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I guess that if I thought that PHP would change its scoping, I would have tried for that. On Mon, Mar 9, 2015 at 3:11 PM, Mike Dugan wrote: > Why not use regular variable naming ($foo) and check the object for > accessible instance vars before looking for locally scoped vars? I=E2=80= =99ve no > idea how the community would feel about it, but that might be a feasible > approach to getting rid of $this-> > > -- > Mike Dugan > mike@dugan.io > http://dugan.io > > On March 9, 2015 at 10:00:03 AM, Shawn McCool (shawn@heybigname.com) > wrote: > > There's a cultural disposition against re-purposing a symbol from one > major version to the next. Let's consider that as fact and move on. > > If I wanted to provide syntactic sugar to replace a symbol with $this-> s= o > that our code can become more expressive if we choose to use it, how woul= d > you recommend implementing that? > > @ is not going to be a _real_ option. But what about.. > > :number =3D $number; > > :add(:number, $number); > > or some other character? > > > > On Mon, Mar 9, 2015 at 2:56 PM, Mike Dugan wrote: > >> Sure, they should be separated into two equally impossible to pass >> RFCs. >> >> Just a suggestion based on what I=E2=80=99ve seen here before :) >> >> However, do you see a reasonable alternative way to achieve this type of >> improvement? >> >> >> I=E2=80=99m not sure if you mean the syntax in general or more specifica= lly the >> declare-with-$ / use-with-@ issue I took with it? >> >> -- >> Mike Dugan >> mike@dugan.io >> http://dugan.io >> >> On March 9, 2015 at 9:51:20 AM, Shawn McCool (shawn@heybigname.com) >> wrote: >> >> Sure, they should be separated into two equally impossible to pass >> RFCs. However, do you see a reasonable alternative way to achieve this t= ype >> of improvement? >> >> On Mon, Mar 9, 2015 at 2:48 PM, Mike Dugan wrote: >> >>> Shawn & Stellan, >>> >>> (Apologies if this gets delivered twice, had to confirm myself on the >>> mailing list again) >>> >>> Agreed, @ shouldn=E2=80=99t be repurposed as a macro (or anything). Tha= t would >>> lead to a huge amount of confusion for quite a while, but especially du= ring >>> the early days of 7. I=E2=80=99m also not a fan of declaring the field = with dollar >>> sign prefix but using it with an @ prefix (or any other prefix for that >>> matter). >>> >>> These should probably be separated into two separate RFCs - >>> deprecating/removing @ error suppression, and pending that one being >>> accepted the @ instance var macro could then be sent along. >>> >>> -- >>> Mike Dugan >>> mike@dugan.io >>> http://dugan.io >>> >>> On March 9, 2015 at 9:32:23 AM, Stelian Mocanita (stelianm@php.net) >>> wrote: >>> >>> 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 anythin= g, >>> it has too much legacy imho. >>> >>> While a shortcut might be a good idea, I personally favour the $this->v= ar >>> syntax just for muscle memory if nothing else. >>> >>> Stelian >>> >>> On Mon, Mar 9, 2015 at 11:54 AM, reeze wrote: >>> >>> > Hi, >>> > >>> > On 9 March 2015 at 17:43, Shawn McCool wrote: >>> > >>> > > I've never submitted an RFC. Whether or not you're interested in th= e >>> > > feature, please consider giving me feedback on the RFC itself so >>> that I >>> > can >>> > > better understand how to succeed in the process. >>> > > >>> > > =3D=3D=3D=3D=3D=3D PHP RFC: Instance Variable Sugar =3D=3D=3D=3D=3D= =3D >>> > > * Version: 0.1 >>> > > * Date: 2015-03-09 >>> > > * Author: Shawn McCool, shawn@heybigname.com >>> > > * Status: In Discussion >>> > > >>> > > =3D=3D=3D=3D=3D Summary =3D=3D=3D=3D=3D >>> > > >>> > > 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 readabilit= y. >>> > > >>> > >>> > This might decrease readability, since we already comfortable with th= e >>> > 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. >>> > >>> > >>> > > =3D=3D=3D=3D=3D Example =3D=3D=3D=3D=3D >>> > > >>> > > >>> > > >> > > class Addition { >>> > > private $number >>> > > >>> > > public function __construct($number) { >>> > > @number =3D $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. >>> > >>> > >>> > > } >>> > > } >>> > > >>> > > >>> > > =3D=3D=3D=3D=3D Backwards Compatibility =3D=3D=3D=3D=3D >>> > > >>> > > Leave `$this->` available. >>> > > >>> > > =3D=3D=3D=3D=3D Proposed PHP Version(s) =3D=3D=3D=3D=3D >>> > > >>> > > 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 >>> > >>> >>> >> >> >> -- >> Shawn McCool | Big Name >> shawn@heybigname.com >> heybigname.com >> >> > > > -- > Shawn McCool | Big Name > shawn@heybigname.com > heybigname.com > > --=20 Shawn McCool | Big Name shawn@heybigname.com heybigname.com --f46d0438938796d7850510db9db9--