Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97446 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61680 invoked from network); 19 Dec 2016 23:02:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Dec 2016 23:02:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=ilija.tovilo@me.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ilija.tovilo@me.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain me.com designates 17.172.80.95 as permitted sender) X-PHP-List-Original-Sender: ilija.tovilo@me.com X-Host-Fingerprint: 17.172.80.95 st11p00im-asmtp001.me.com Received: from [17.172.80.95] ([17.172.80.95:59513] helo=st11p00im-asmtp001.me.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 27/B3-36089-61768585 for ; Mon, 19 Dec 2016 18:02:47 -0500 Received: from process-dkim-sign-daemon.st11p00im-asmtp001.me.com by st11p00im-asmtp001.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) id <0OIG00F00FOQ1Y00@st11p00im-asmtp001.me.com> for internals@lists.php.net; Mon, 19 Dec 2016 23:02:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a; t=1482188563; bh=EBaNmsi74zBTaxmu5xp49UML1Jd6MxZYudWl4ZR2pCY=; h=Date:From:To:Message-id:Subject:MIME-version:Content-type; b=QfEJ/JJ6rH3o48mVPwhzvuSj8LKaBlltRj5kZBFlNXs83upkdgg9mTsvQ11fDAj6C VdnOsnldA7azQXT3RIEt8y8uFZT54Psl+bI5WRKzsI1vEzdDEWbTNSgWlJed4WNe6s HUZABbLXHsUuGtcrbmENsyJ8IQb23P1FbzQAFteHo/RsddoXGgv7SO65qY4mzRsMEi nTxIDbMLi9JoCTz36hzsJZUJiZQ3J49jQyhcJdgkUj9aF6y1jfHhkfxCqJX/jxry0S gWUgpn0SCGM5kataOwothVYHiGv+kWoNyADg6rmpnKE1QkgKTDOUsT7+ZXyl/92RHY Fre6xN39gIYxQ== Received: from [192.168.178.58] (adsl-84-226-160-7.adslplus.ch [84.226.160.7]) by st11p00im-asmtp001.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) with ESMTPSA id <0OIG00LZ1G0GXE20@st11p00im-asmtp001.me.com>; Mon, 19 Dec 2016 23:02:42 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-12-19_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=72 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1612190230 Date: Tue, 20 Dec 2016 00:02:05 +0100 To: Larry Garfield Cc: internals@lists.php.net Message-ID: In-reply-to: References: <6d4632cb-93b3-4237-a803-6b7ec13dae4a@Spark> X-Readdle-Message-ID: dac2004c-c137-4531-b658-4ebc6314b47d@Spark MIME-version: 1.0 Content-type: multipart/alternative; boundary=58586710_327b23c6_25c Subject: Re: [PHP-DEV] Revisit RFC =?utf-8?Q?=E2=80=9CProperty_?=Accessors Syntax =?utf-8?Q?1.2=E2=80=9D?= From: ilija.tovilo@me.com --58586710_327b23c6_25c Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I see, that makes a lot of sense. Sadly, I am neither a C developer nor d= o I understand the PHP interpreter codebase in the slightest. At least I now understand why the R=46C was rejected, maybe that will com= fort me when I cry myself to sleep tonight :P On 19 Dec 2016, 23:47 +0100, Larry Garfield , w= rote: > On 12/19/2016 02:57 PM, ilija.tovilo=40me.com wrote: > > Hi everyone > > > > There was an R=46C about a C=23-like property syntax almost four year= s ago that got declined: > > https://wiki.php.net/rfc/propertygetsetsyntax-v1.2 > > > > It failed by only 2-3 votes. In my opinion, PHP is still in need of t= his feature as it would make the language much more expressive. Let me st= art by defining the problem. =46irst of all, almost all PHP frameworks hi= de their variables behind getters and setters. Here are some of the reaso= ns why that is a good idea, I=E2=80=99m sure there are many more: > > > > - Ability to sanitize input > > - Ability to lazily load data when requested (getter was called) > > - Ability to expose only getter or setter publicly > > - Easily mockable accessors for unit tests > > - Ability to execute arbitrary code when accessors are called > > - Modifiable business logic without breaking the API > > > > Here are some of the negatives, though there are probably more here a= s well: > > > > - Large boilerplate for normal getters/setters > > - Inconsistent syntax for reading/writing data > > - Calling a method for setting data instead of using the more intuiti= ve =60=3D=60 operator > > - Calling a method for accessing foreign variables while accessing pr= ivate variables directly > > - Inability to use built in assignment operators like .=3D, +=3D, -=3D= , etc. > > - Disregard of the DRY principle > > > > The positives clearly outweigh the negatives as they are mostly synta= ctical. This is probably why using getters/setters everywhere has been a = good-enough solution for such a long time. Because of that, just like the= positives, the negatives have become a part of the language. Clearly, ab= andoning getters and setters is no option for anyone. Nonetheless, the R=46= C I linked above offers a way to get rid of the negatives without sacrifi= cing any of the positives. > > > > Are there still any people who would like to see this happening just = as much as I do=3F > > I=E2=80=99m wondering if some of the people who have voted against th= e R=46C might have changed their opinion or vice versa. > > > > Many thanks for reading=21 > > > > Regards, > > Ilija > > As I understand it from those involved, most people did want that > feature. I still do. :-) However, there is as of yet no confirmed way > to add it without more of a performance hit than many folks are willing= > to accept. That is, it's not the concept people object to, just the > implementation. > > If someone can figure out how to make that work with a small enough > performance hit (where 0 would be ideal, but I don't know if that's eve= n > possible), that person would make a lot of devs (including me) very ver= y > happy. I am, sadly, not such a person. > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --58586710_327b23c6_25c--