Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92012 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92792 invoked from network); 30 Mar 2016 08:32:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2016 08:32:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 207.46.100.136 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 207.46.100.136 mail-by2on0136.outbound.protection.outlook.com Received: from [207.46.100.136] ([207.46.100.136:53834] helo=na01-by2-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2D/21-24137-D0F8BF65 for ; Wed, 30 Mar 2016 03:32:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=unOdR7U8nDCkrL9Cy6Tntz1t3WR//QOAD/L3iempCok=; b=NRqNFTKHBWkOiHI9O3KTFTZw+F/rhXh1j1rWRMDz8deZWhZkUTBT91Ra8fT/3jcAQ6w8RdLHO44FKSSeNGYJHTnIFTgCiA0ooH0ddULY/XTlOjLEoUAczs4X3Ugrob4tM7rzfAX4dCETIImY78IDQH69J/npKLzEms0AU9P1huU= Authentication-Results: php.net; dkim=none (message not signed) header.d=none;php.net; dmarc=none action=none header.from=zend.com; Received: from tpl2.home (92.62.57.172) by CY1PR0201MB1786.namprd02.prod.outlook.com (10.163.55.19) with Microsoft SMTP Server (TLS) id 15.1.447.15; Wed, 30 Mar 2016 08:32:08 +0000 To: Joe Watkins References: <56FB7096.9090602@zend.com> CC: Pierre Joye , PHP internals , Philip Sturgeon , "krakjoe@php.net" Message-ID: <56FB8EFA.5020108@zend.com> Date: Wed, 30 Mar 2016 11:31:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------080809090906010504070807" X-Originating-IP: [92.62.57.172] X-ClientProxiedBy: VI1PR07CA0117.eurprd07.prod.outlook.com (10.165.229.171) To CY1PR0201MB1786.namprd02.prod.outlook.com (10.163.55.19) X-MS-Office365-Filtering-Correlation-Id: 7049a848-03e8-4a62-990a-08d35875c916 X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1786;2:ngxuWC2WQ2lOkByXCRYF/xPoHaaYdOua8ee3L76yFaQZERHRpv635dse4W+20G8r9dQunkrJwuYjVTrnn+C42V+o9P+iDCoCdbZEda/x8JcMxSZTg8qAxNExdXb1w0JtMscR19UQiEjKH6bmIQOvqAQJgWu5OZd9oWhZbK6EegwtiHqm5+GLnlDv7Atmtto8;3:32C7sEpYTbwwT+rmpYrO0yRIvACuOqHfDO4LifTBcO3J/NY1qFtWcIrmkNoMk8EgE7Usg+Ougyzl3kYdfSgLitKSS0w5ifLPSB3H8URDRU+MB03YS3jtkCwGq2qqfkzF X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB1786; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1786;25:0mDJY14djXX0KGByK3jXQQ8TAJX+M6E4aScaTSM5LLQfwQfhp2GS5/pSLg4cFXd8MQmOPVFthUAZtXodlji4MiX/XtvtJ1Q8qV7jwuUl1diJYKKJA2HSSOWv883afDn09CY9qWyTxwfg1d1PrjdkDlSU5ESTEVPYNtaysQdi6eS4G4hMlZxkM8SKuyfknmVdH8l5HTT9mHJnsj+GM+cvShYGy6hnKSnOG4DbZIjYEJ0aG6m1eTfuha5F5t2pKtuBEsCdqe4ZNGImlfQxBzRLYsLAbaHJezb76rJKw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xUGDZ1YGqE/RJzQpRHRTl9zrdhOWXbX3wt1vbnakZUmNwbwlcX2/Yi2MhIi3MLAHKemJWEg3p4jXmiHHAgXo6R9Sn/6HUvSgscWO7at5eAjBWAB6S33J/n/wSo1enqf595u1TvHXDlQNdKh2HpaI+PoMycsKGqVry3yxzXFBhtccuB/JnxTtDA9lTfNLs+Q3UWS9/VviByC3XEmH09EQq1arnZ1YkdxX4ekORJtLpdVvjGeJQ3pl5rLr38sZtDMIg4A+4eXn/0DeuaaS4hVMMLK3PBcSMN182Qlf/5gOQKoa X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046);SRVR:CY1PR0201MB1786;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB1786; X-Forefront-PRVS: 08978A8F5C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(24454002)(377454003)(2906002)(16799955002)(77096005)(64126003)(4326007)(1096002)(42186005)(83506001)(80316001)(19580395003)(19580405001)(5004730100002)(270700001)(3846002)(586003)(6116002)(76176999)(54356999)(50986999)(84326002)(87266999)(65816999)(36756003)(189998001)(92566002)(16236675004)(86362001)(4001350100001)(110136002)(512874002)(66066001)(65956001)(93886004)(81166005)(33656002)(5008740100001)(2950100001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0201MB1786;H:tpl2.home;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR0201MB1786;23:luJD6LCX8ZY+um6sjM4avFezz7vV3UjYPSUUW5p?= =?us-ascii?Q?5Qakl2p7RfAShHsBa1NC3UkVy5agFcYe4Z/lietZuk5Xw3tnfEp45aje+wm4?= =?us-ascii?Q?mwC1mijj27eAx+1UJWs4SAow5KyIYbLJ0SRR4O76z9M3OFHZsdvyi28b2rDQ?= =?us-ascii?Q?m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VjAl0uVQIPmdsAYnmu?= =?us-ascii?Q?1BvfVeftW1a+wrVx05V54eq7W1A6H?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1786;5:i+HwF2a/YOZz4P4r+bjiSGaNo6F5vmBwj8gbtWrSH+8iDi04b74dq1jBSzSk53YGi/0BxB4Q8l4Ijq+4SX/0q6t2+oPNxWmJkvZG2eiU7paoM7KW2lpahwUf3temB3ug6Rq6w6jgt3/n+qRoMuss7w==;24:bCgMu2qfzu8jFdsJE8h6QuZkPDwuRyhs2X4KFTPEda4HUWViQZGBwMRC/k1bc7XRtnb4m+Qnqtry2XBOhzZdoNQmvWmZlS+sJmUfLDju8qM= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2016 08:32:08.2021 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB1786 Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: dmitry@zend.com (Dmitry Stogov) --------------080809090906010504070807 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit On 03/30/2016 10:50 AM, Joe Watkins wrote: > Morning Dmitry, > > > If we use one rule for arguments, why should we invent others. > Properties are going to be nullable only if you explicitly initialise > them with NULL. > > We didn't really invent anything, you are comparing them to > parameters, but not return values ... strangely ... Return types don't have default values :) > > Return values are not implicitly nullable, and a few people have been > designing RFC's to tackle this issue by introducing expicitly nullable > types, or union types. I know. Missing the ability to mix objects with null is a big problem, but it's unrelated. > > This code: > > class Foo { > > public function getBar() : int { > return $this->bar; > } > > private $bar; > } > > $foo = new Foo(); > > var_dump($foo->getBar()); > > Should provide the same guarantees that this code does: > > class Foo { > public int $bar; > } > > $foo = new Foo(); > > var_dump($foo->bar); > > In either case, an exception will be raised. > > Given the following code: > > class Foo { > > public function getBar() : int { > return $this->bar; > } > > private $bar = null; > } > > $foo = new Foo(); > > $foo->getBar(); > > We throw an exception, because null is not a valid int, and types are > not implicitly nullable, even if parameters, and untyped properties > are ... > > class Foo { > public int $bar = null; > } > > $foo = new Foo(); > > var_dump($foo->bar); > > Again, we raise an error, but much earlier this time ( we should all > agree earlier is better). class Foo { public $bar; function foo (int $bar = null) { // <-- this already works fine $this->bar = $bar; } } class Foo { public int $bar = null; // <- with your approach, this is prohibited function foo (int $bar = null) { $this->bar = $bar; // <-- this won't work } } > > What we have done is apply existing rules in a way that makes sense, > the only thing we invented is the rule that null is never a valid value. Both views may make sense. > > We invented that rule first to make return types and property types > consistent, and, because without it, the guarantee that you will > always get a variable of the correct type is gone, and your code is > filled with null checks. Nobody require to use "nullable" types. It's just a feature that we already may use for parameters, and miss for return values yet. > > There is value in nullable types, but they must only be explicitly > nullable, in exactly the same way that return values should be, and we > simply don't have syntax to support that at the moment. Why can't we reuse the existing explicit syntax for parameters? > > I hope this makes some of these decisions clearer ... One more thought about implicit initialization values. (int(0) for int instead of IS_UNDEF). I'm not sure if this RFC is going to be accepted yet, but lets think we will also implement type hinting for arrays. e.g. "array $a[40];" would create a packed array of integers with 40 elements. I would prefer to have all elements initialized by int(0) instead of IS_UNDEF. In this case we won't have to use zvals (and Buckets) for elements at all, and will able to narrow this type to native C array "long a[40];" This would safe 3/4 of memory required for array, and improve data locality. Actually, this is exactly the same for properties. Thanks. Dmitry. > > Cheers > Joe > > > > > On Wed, Mar 30, 2016 at 7:22 AM, Dmitry Stogov > wrote: > > > > On 03/30/2016 08:13 AM, Joe Watkins wrote: > > Morning Dmitry, > > So, I quickly reviewed the RFC and patch. > > Static properties, and mixed declarations, are now > explained in the RFC. > > Thanks. I'm not agree with decisions, but RFC is more complete now. > It would be great to have "static" typed properties at the same > time, but this may be more difficult. > Mixed declarations decision looks wrong to me, but right to some > others. From implementation point of view, it's not a big problem > to change it. > > > I made a couple of changes to the fetch_obj_w stuff, I'd > be grateful if > you could review that ... I didn't think I had got all possible > combinations, should be bit better, and drier ... > > The overflow related stuff, I'll fix and explain in the > RFC, but I'll > let you have a go at perf stuff, and other outstanding things > now ... > > */me leaves patch alone* > > > OK. I'll try to do something today. > > Thanks. Dmitry. > > > > Cheers > Joe > > On Wed, Mar 30, 2016 at 5:26 AM, Joe Watkins > > wrote: > > Morning Pieere, Dmitry, all ... > > Actually it's not so simple ... for object properties we > have ASSIGN_OBJ > opcode, but we don't have a special opcode for static > properties, and > ASSIGN doesn't have any information about where the var > came from, and nor > should it have that information ... > > I'm going to stick the original decision, static > properties don't belong > until typed variables are a thing ... > > Cheers > Joe > > On Wed, Mar 30, 2016 at 4:57 AM, Pierre Joye > > wrote: > > On Mar 30, 2016 10:17 AM, "Joe Watkins" > > > wrote: > > Morning Dmitry, > > 1) static typed properties are prohibited. why? > > Feels like that's a separate feature, static > properties are as good as > makes no difference, global variables. > > Instance properties, the engine has good control > over their > > manipulation, > > for static properties it doesn't, it's not > impossible, but feels > > separate. > > Internally different but from users perspective it is > the same (a class > property). It would be nice to support that at the > same time to avoid > confusion. > > > > --------------080809090906010504070807--