Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94195 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37369 invoked from network); 22 Jun 2016 13:06:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jun 2016 13:06:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.52 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.52 mail-wm0-f52.google.com Received: from [74.125.82.52] ([74.125.82.52:35330] helo=mail-wm0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/DD-43024-64D8A675 for ; Wed, 22 Jun 2016 09:06:15 -0400 Received: by mail-wm0-f52.google.com with SMTP id v199so86780848wmv.0 for ; Wed, 22 Jun 2016 06:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=NAZOEAyIJRW1zBP4Hhy8EIUqu7MlLOmFtOxkqjrhiw4=; b=TwbzWx4ybelVTWTEMZlpYLiKz+IaTw48J7bE/3lVG5r3zW2Su1UXzPJ64O8vx/Q1pL AkJoGTfa9DjGAHQy1zNiFierhLc8gy1rR6gfM/9HIUFLoy174rkh1jbfaA3pahdoJKoJ ScLO8EyxgE5d6JbN6o1LZQGo9eN6nNFl/I/V2Lj8yOPmBKmy/eGe14A4zO7YTkd1ohyV GUwwqmtKjcqHZ16Pr61qQ5o7QWcThGIqKfc8jlUKfJrHHMeBtTEKHU8++5iLDflVbACW HUGZBuLpYigEDLlP45358kRSQ7n6+kJfpZDwf0usImT8UuBHAXm1R/xcxySLCmK0Zgk/ ucYQ== 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:date :message-id:subject:from:to:cc; bh=NAZOEAyIJRW1zBP4Hhy8EIUqu7MlLOmFtOxkqjrhiw4=; b=Bmq6xR9CUCtBPxomFGyAdcZAUoBrYfNTtW/i9Kh71DrhlWBrIVJiYlO5klH1QnKnF5 PwWCz5jJhVRimoz3+mDcxk9n22kNrKT3RNcx1Jc4La0AVwMOU7kFKxqgDvEQaO2dTCjE pmp60NAB8Gc1ypd0b7N5JIVp7u4KO/zsm2Mgz8Umkmm1dL6Laed8DUNji2YyPBvdjcvE 6nmlNgc0qLw/ruuQ/vJkciYw3joBZyT7NOk6NcO0W/DmtAjVhQ9YA/U1x7+Rd309xPtS tqd/8uqKLJMbR65S1BMEdxlKQLx7X8gc+E6CQGs4iJzEd85Xc8uYS0z36WEaGwuaYTrC 4duQ== X-Gm-Message-State: ALyK8tLRkE8zGZuLRlKfSNvGFmC2neyqQJpRHQRdVdJWDzYijqSuy5TAK06gzlBdp9CF4bQZWH/lOKHU/xwGGQ== MIME-Version: 1.0 X-Received: by 10.28.97.4 with SMTP id v4mr8279596wmb.71.1466600771954; Wed, 22 Jun 2016 06:06:11 -0700 (PDT) Received: by 10.194.123.104 with HTTP; Wed, 22 Jun 2016 06:06:10 -0700 (PDT) Received: by 10.194.123.104 with HTTP; Wed, 22 Jun 2016 06:06:10 -0700 (PDT) In-Reply-To: References: Date: Wed, 22 Jun 2016 15:06:10 +0200 Message-ID: To: =?UTF-8?Q?Micha=C5=82_Brzuchalski?= Cc: Philip Sturgeon , Yasuo Ohgaki , Dmitry Stogov , Joe Watkins , PHP internals , Rasmus Schultz Content-Type: multipart/alternative; boundary=001a1148da7e0a312a0535dd9a74 Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: ocramius@gmail.com (Marco Pivetta) --001a1148da7e0a312a0535dd9a74 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Top-posting due to mobile conn. I voted no due to flaws introduced in the language by the current RFC. The performance impact is irrelevant. On Jun 22, 2016 11:38, "Micha=C5=82 Brzuchalski" w= rote: > Hi, > > I may don't have voting privileges but as an 10yr PHP development > practitioner I can't believe that such big and awesome feature like Typed > Properties minimally can't have enought votes to be a part of PHP languag= e > (26/(26+16) =3D 62% and that's not enoght to 2/3+1vote). > There are plenty of places where type hinting actually exists and looks > like Typed Properties can be great complement of type system in PHP > language with the ability to still be so dynamic language as it is right > now. > The impact of 0.1% (or even more) of performance IMHO should not have no > significant meaning. > Someone earlier wrote that properties types should be ensured by framewor= ks > - but that doesn't never happen, the impact on performance while > dynamically type checking inside setters would be few times greates than > this patch impact. Not to mention the fact that the feature itself sugges= ts > good practice. > Without it, we will still have setters/getters hell, and there will newer > be safe frameworks instad there will always be some hack's inside > subclasses or some other ways. > Without it, PHP will newer be aqualed such as Java, C# even Hack language= - > there still will continue to be a big gap, due to the lack of type hintin= g. > Sure you could say start to code in Hack it has type safier system, it ha= s > generics, annotations and other features which from time to time are in P= HP > RFC's but most of time they are declined and Hack lacks of great IDE > support like PHPStorm which I use and love because of refactor, code > styling, run&debug etc. > PHP language has poor type safety and IMHO without such patches it will > never evolve into type safety programming language. > > Regards, > -- > Micha=C5=82 Brzuchalski > > 2016-06-13 11:40 GMT+02:00 Joe Watkins : > > > Morning, > > > > > This wouldn't affect the performance of untyped properties at all. > > > > There are extra instructions in that code. > > > > When the code you have is only 5 instructions, adding 1 more instructio= n > > makes a 20% increase in instructions ... > > > > That is what we are looking at in these micro benchmarks; The number of > > instructions is so small, that even the small difference is measurable. > > > > Of course you can measure the difference, and obviously there are going > to > > be more instructions, but we should only care about what effects real > world > > code. > > > > This doesn't effect real world code. > > > > Cheers > > Joe > > > > On Sun, Jun 12, 2016 at 2:03 PM, Rasmus Schultz > > wrote: > > > > > Pretend I know (basically) nothing about how PHP was implemented, > because > > > I don't ;-) > > > > > > But I don't understand why regular property updates should be affecte= d > by > > > this at all? > > > > > > If I had to implement type-checked properties in plain PHP, I would d= o > > > something like this... > > > > > > /** > > > * @property int $price > > > */ > > > class Product > > > { > > > private $_price; > > > > > > public function __set($name, $value) { > > > if ($name =3D=3D=3D "price") { > > > if (!is_int($value)) { > > > throw new UnexpectedValueException("..."); > > > } > > > $this->_price =3D $price; > > > return; > > > } > > > throw new RuntimeException("undefined property {$name}"); > > > } > > > > > > public function __get($name) { > > > return $this->{"_{$name}"}; > > > } > > > } > > > > > > I would have guessed an implementation of type-checked properties wou= ld > > > work in much the same way. > > > > > > Of course, it wouldn't use "_" as a prefix for the underlying propert= y, > > > but some other magic byte, much like how private properties are > > internally > > > prefixed with a magic byte, right? > > > > > > This wouldn't affect the performance of untyped properties at all. > > > > > > Of course typed property writes would be more expensive, but that's t= o > be > > > expected. > > > > > > > > > On Sat, Jun 11, 2016 at 3:45 AM, Yasuo Ohgaki > > wrote: > > > > > >> Hi Dmitry, > > >> > > >> On Fri, Jun 10, 2016 at 9:37 PM, Dmitry Stogov > wrote: > > >> > I hardly worked on implementation of this patch for a week, but I > > still > > >> don't like it. > > >> > > > >> > It makes 15% slowdown on each property update in existing PHP code > > >> (without types), and I don't see a way to improve this. > > >> > > > >> > Update of typed properties is going to be even more expensive. > > >> > > > >> > Benchmark results are included into RFC (and not changed with the > > >> latest version of the patch). > > >> > > > >> > > > >> > -1. > > >> > > >> If we are concerned about performance, DbC would be the only solutio= n > > >> for this kind of problem. i.e. Validate fully during development, do > > >> minimum validation on production. DbC helps type inference also. The= re > > >> may not be enough time for discussion, but do you think there is > > >> enough time for implementation? I suppose implementation is > > >> straightforward, so it might be OK to have RFC w/o implementation. W= e > > >> have 2 options anyway. It's waste of time for having 2 > > >> implementations. Would you like to proceed the RFC for 7.1? > > >> > > >> Regards, > > >> > > >> -- > > >> Yasuo Ohgaki > > >> yohgaki@ohgaki.net > > >> > > >> -- > > >> PHP Internals - PHP Runtime Development Mailing List > > >> To unsubscribe, visit: http://www.php.net/unsub.php > > >> > > >> > > > > > > > > > -- > pozdrawiam > -- > Micha=C5=82 Brzuchalski > --001a1148da7e0a312a0535dd9a74--