Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92007 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76097 invoked from network); 30 Mar 2016 06:08:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2016 06:08:19 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 157.56.110.133 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 157.56.110.133 mail-bn1on0133.outbound.protection.outlook.com Received: from [157.56.110.133] ([157.56.110.133:42496] helo=na01-bn1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/6E-24137-05D6BF65 for ; Wed, 30 Mar 2016 01:08:18 -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=1WADX5cZC4UiPan4NHoFhc6LBOcwLUdvdrseJNKtmLE=; b=Gv9PBpCXlauAvkpWCLicYZL7cFmBltQb8EOAL8FN7MNvhBse1NgKApZ220uOf4EJHbOYXTH75eHN7B7Nyelk/LbvzdDY/feuZndhDl3Xg+vzH5rOd1TVjGHvONhe/wgdvvMSkEEed6Z4ozYANAUugVfzXY3IarkjC5ZJkn1Pnu4= Authentication-Results: lists.php.net; dkim=none (message not signed) header.d=none;lists.php.net; dmarc=none action=none header.from=zend.com; Received: from tpl2.home (92.62.57.172) by SN1PR0201MB1790.namprd02.prod.outlook.com (10.162.228.20) with Microsoft SMTP Server (TLS) id 15.1.443.12; Wed, 30 Mar 2016 06:08:10 +0000 To: Joe Watkins References: <1458153695.3969.16.camel@kuechenschabe> <3F.70.02405.6803BE65@pb1.pair.com> <56F01545.8080008@gmail.com> <56F14572.701@gmail.com> <56F15EF5.80006@telia.com> <56F16023.1010002@gmail.com> CC: Phil Sturgeon , "krakjoe@php.net" , "internals@lists.php.net" Message-ID: <56FB6D3B.1050405@zend.com> Date: Wed, 30 Mar 2016 09:07:55 +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="------------060404000805050105050300" X-Originating-IP: [92.62.57.172] X-ClientProxiedBy: DB5PR02CA0026.eurprd02.prod.outlook.com (25.161.237.36) To SN1PR0201MB1790.namprd02.prod.outlook.com (25.162.228.20) X-MS-Office365-Filtering-Correlation-Id: 1eaea85e-de78-4162-b80b-08d35861ad15 X-Microsoft-Exchange-Diagnostics: 1;SN1PR0201MB1790;2:Rfdm7k+0waDxrnXOFh6UOzaVuUjz6r3OQZ8UIN/zV3xedCwFCLMTfNEsMPAvpbZmma3o0Se7c9Thuh1iT3RkfdmKKfSMhC6yzKvThGuzgAy1i28kfBnB8XX1Qe3QQ9V5Qqyx5YT/AsHfpgJGmZjWj2pqBxEy9GPgYHcl9CWzpM5FNjHa8KHs3la0l4NGb73t;3:0pSXpqO4cOskX3ZZXNPQ8ZWedn2sisMRkWSCh0c2iyPB5Zx/jMyht05eLZ+8bfhN3z8gQOFx/BGaK1y+hHmJWAP6VKSFfV9NzYHZmUVCkZ+h1TzdE6wlNMsNdmEPY7Nw X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0201MB1790; X-Microsoft-Exchange-Diagnostics: 1;SN1PR0201MB1790;25:lm7WN2HYT5JLnKtHqxpXgzNzCqRrkPGeSFaYTH/nAG94YWFL3G5TNQPfqKjtQJ4k+XIygFDdQtffnWftAQnJ35C3LEV+z0jOYuqOkNUk2WOcOEBbNwFiwB32Pw1lZdtbFN/q8qIkxiRmuM6bMXokZn7R9KZGkpXK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eEwkY1N2XZbWux1GVzXV24OkHVb5nBQvPXthRcuW4LIKxBIfsp2hZbnKhsVl30Pybuc64Z+sptzFVTHc55BV7chy5vnflgMrO3+jh9SYNqbfoO6fX2d4DlYcgXmQBWK2gX57rqxdEtkj9pfKC9JJIniiuqBOHuUM9vFqp0Wn7+DZsohlsV/84hR9gKrrikivYM+Zd8U1h8xDPmFQtqoa;4:AI9UFqkqmCgxm6lnHrZ9k/S4YaS7mBqElRr4yxA6aY1LuLyCm8tpjn4cY4O7ojW8ARsIDdY2uk1hraviInoM3FhQJSmmz3ioEHffPEjUFAFtrrIqvlD/UlxfMYXWJHQ7G4YIQ1L1G15yIRcuayVa6mUSo9Agsp099n1xFNer0NuMDsxA8CYpKxjho0vNCiAiDLA83GBgxFsHOVO7wa5MrJCI85VUcOlmcUbdtcnWFtFMejRVbjvOoXVwMy+rWgNZZ7dart6UsJeWMG/237n2iHAr4Q+lJqqiv+XrRtaOy0d4Fq7diecBA8kC122+CjN0XA1V48K7+usH59evtLoXYT0eYFzKWl3W/ztqSjahNLAQtllnrUXibR3YA+M8Z7rN 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:SN1PR0201MB1790;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0201MB1790; X-Forefront-PRVS: 08978A8F5C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(43544003)(377454003)(24454002)(16799955002)(65816999)(87266999)(54356999)(50986999)(76176999)(270700001)(15188155005)(189998001)(86362001)(4326007)(5004730100002)(84326002)(1096002)(64126003)(4001350100001)(83506001)(19580405001)(65806001)(110136002)(66066001)(586003)(81166005)(6116002)(3846002)(512874002)(36756003)(93886004)(92566002)(5008740100001)(19617315012)(3900700001)(33656002)(77096005)(15975445007)(561944003)(42186005)(2950100001)(2906002)(16236675004);DIR:OUT;SFP:1102;SCL:1;SRVR:SN1PR0201MB1790;H:tpl2.home;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR0201MB1790;23:72AKVJi5gLx+FnlRgBZ6b6YVmSHUEk48t4tcfLZ?= =?us-ascii?Q?45X/5Uz9QpcBWsUUCfi3bF1g1ajl9Zaz+PHbg3bQmX1L6IsOU4MPqZNjrhTE?= =?us-ascii?Q?dJLPKFfX5v9A/PS2FqiRf5XioKC4xRMIkNuuk7PIst/R8+aiFJ3OE5V0O48L?= =?us-ascii?Q?LXUwDVyf64bX5QrPu0QDebrZs0Z85J5SWZbhUa8mZ7VmjYU7UBWTahY4cWg9?= =?us-ascii?Q?ufPMshTnpAWdPylE0/0SJHY4durkC/o1jLs68CUHz9ccFrBPAUyBXPp9UnSc?= =?us-ascii?Q?jLaStm/jcdSeDwUh12uGG47qmoBKhIKGzlpZEaHTjs9J/yvy+65Eeqi+rqdY?= =?us-ascii?Q?pNuFmZzuT4vauMB+5rrmH9MjrlBrQr8aON2kQJeLc8+AB5i6lqJT0opgS8sD?= =?us-ascii?Q?LCmghzCQNd/so7mJBowLbWe++zXluFp1Fk/yc05TO6lpK3RSMqYGfET3AoPE?= =?us-ascii?Q?dE1lsTLFABUmB6wX8PHcMW255Ut1P8+SDxH8CCsehLs9XipQCuIx+03IAVVH?= =?us-ascii?Q?ss/nmeOuVk2kpiYMxQDf3AG6fs8BM9qEUbma17Y1KNrdp8zIlIjeLXrLQMAG?= =?us-ascii?Q?Gwb1Y/pN80oFrHgarBzNN+l6Lma7pfNNnNpptjYScpkToaKl3A1Do44h6RLR?= =?us-ascii?Q?dve6+w+XVcOuHDy3WbkR4rltaXJqm0aXasthwGkzLH0NzMqpUACXe7Hxpzyl?= =?us-ascii?Q?176iQXAnFtmR2AZlJLs924OpbdYkozd7mSrybyN91Mtyets1DUQycLTtAUqL?= =?us-ascii?Q?PV5lOmdjVTG7JV4FUi/VtP+CuWiU25FM22ZTc3x6cJWaDxy9ImCfnW66mryx?= =?us-ascii?Q?QdW790/QLdrCWYO3WOF+DbfC4qxKTdgGQ1O60WvfMdLMrJ9f1KfZvQq3LZus?= =?us-ascii?Q?VjYkxMIPPc4cZ0qwTpMsT8SjL2JP5Oy3rNPe/Kg5vhfhcXxt8DBnLhxwwjd5?= =?us-ascii?Q?1mZwyxMOSs0st9Emw4IqFiErCORRlPJPYAa6fGI4fLL8+hY/yEgs5tCn1BaI?= =?us-ascii?Q?nN5OeMzwPTMKB4De6jLPGY1YwHTUshyIX7QOY6xDbDVjpQ/GKzbCsjpVA+p+?= =?us-ascii?Q?kuUte2Hk0v4MdBZQHmO/Dqtnl7sruVK5+e4GY7xboY8UfkSb84mTk1vT8bLX?= =?us-ascii?Q?GW8c9KCOtJDkcTS49yFlxdX4lamX4kg2LpxkjATCClSsBpAooHm6FrawzSNo?= =?us-ascii?Q?kr1NtJi6ISR5Oze0=3D?= X-Microsoft-Exchange-Diagnostics: 1;SN1PR0201MB1790;5:UngLs83O0d3vwoitxjyMXdRwX9XU57cGa+N1TsYhqVg64Krho2iM2Zs28821zeAl+q5dM91+iR8Akf3MJBjL+QDSSLWM6dsDiPwr7INEkmVxKbIOtcAJBPJ/0njvW09k8fhY4u3ogrHKBQqqdL7iqA==;24:JxSTsEqxHeXxbor9XWBKyBHK2BLhVrKMCLUaAYaaeeBR7Xq06fK3V5iPAq92fijleKorbgO+WvNSVEK07mn7hhgYi0vwSmdqxdtOg4SXnBc= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2016 06:08:10.7543 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0201MB1790 Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: dmitry@zend.com (Dmitry Stogov) --------------060404000805050105050300 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit On 03/30/2016 06:16 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. From the user perspective there is not a lot of difference between regular and static properties. > Instance properties, the engine has good control over their > manipulation, for static properties it doesn't, it's not impossible, > but feels separate. so this is an implementation problem. > > > 2) The handling of multiple properties in the same declaration > statement is inconsistent. > > This feels consistent to me .. in other languages where the type is > required, it makes sense to assume the type is implied. > > In a language where the type is optional, public int $foo, $bar; feels > ambiguous to me. But this is the valid syntax for others. And this is going to be yet another reason to blame PHP. > > > 3) We already have nullable arguments without any special syntax. We > should reuse the similar approach for properties. > > Making properties implicitly nullable defeats the object of trying to > provide type safety. > > Null is never a valid value for a typed property, if it were, you > would never be sure of the type of variable you are getting, and would > have to litter your code with is_null checks. 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. > > > I think it might be better to implicitly initialize them according > to type (if default value is not provided): bool by false, int by 0, > double by 0.0, string by "" (interned), array by [] (immutable), > objects by NULL (always nullable). > > Definitely not, lying about the default value isn't a good idea. > > There are times when 0 is as valid as 1, or any other value for an int. > > If you have declared that you know the type of the property, and you > write code that accesses that property before there is any possible > chance you have set the property, that's a programming error. > > We should not hide that error with a default value, or by allowing the > engine to return null. Your arguments may make sense, but PHP never required property initialization. Introducing orthogonal rules for typed properties seems strange. > > > We can't change property_info->type_ce for internal properties, > because they are shared between threads. > > I'm not sure what to do about that ... will think ... may be it's possible to make a special pass at the end of MINIT to initialize all property_info->type_ce, for all internal classes. > 6) and 7) and 8) just sound like bugs ... will look at those ... > > 9) I always intended to leave that to you :) I'll spend some time trying to find a good solution. Thanks. Dmitry. > > Cheers > Joe > > > On Tue, Mar 29, 2016 at 11:59 PM, Dmitry Stogov > wrote: > > Hi, > > Reviewing the patch sources I found few inconsistent decisions not > mentioned in RFC. > > 1) static typed properties are prohibited. why? > > 2) The handling of multiple properties in the same declaration > statement is inconsistent. > > public int $bar, string $qux; // this works > > public int $bar, $qux; //this emits error: Untyped > property A::$qux must not be mixed with typed properties > > It's better to allow type only before first property in the list > and apply them to all of them (like C, Java and others). > Is this just an implementation issue? > > 3) We already have nullable arguments without any special syntax. > We should reuse the similar approach for properties. > > public int $num = null; > > 4) There's a mess with initialization of typed properties. (typed > properties are initialized by IS_UNDEF, untyped by IS_NULL). > I think it might be better to implicitly initialize them according > to type (if default value is not provided): bool by false, int by > 0, double by 0.0, string by "" (interned), array by [] > (immutable), objects by NULL (always nullable). > > Also I found a number of implementation problems: > > 5) We can't change property_info->type_ce for internal properties, > because they are shared between threads. > Can property of Internal class have a type of user class? This > would lead to crash on second request. > > 6) $x->a++; doesn't throw on overflow > > 7) ++$a->a; and += throw on overflow, but change the property > value to "float" > > 8) Reference handling in ZEND_FETCH_OBJ_W is not robust. At least, > EXT_NOP or TICK may be inserted before next ASSIGN_REF. Handling > of ZEND_ADD_ARRAY_ELEMENT and ZEND_YIELD is too pessimistic, > missing support for SEND_REF and may be others. > > 9) Often calls to zend_object_fetch_property_type_info() are not > good for performance. Currently FETCH_OBJ_X cache "offset" to > property, in general we may go back and cache address of > "property_info", but this is going to decrease performance for > each property access. It would be great to find a better solution. > May be using zval.reserved. > > I assume, I didn't find all problems yet. > > I think, both RFC and implementation have problems. > I may try to help with implementation. > (9) is the most difficult problem, and I'll try to solve it first. > Do you see any problems with updating RFC with (2), (3), (4)? > (1) would also make proposal more consistent, but I assume you got > some troubles implementing it and I don't know about them yet. > > Thanks. Dmitry. > > > ________________________________________ > From: Dmitry Stogov > > Sent: Tuesday, March 29, 2016 19:24 > To: Joe Watkins > Cc: Phil Sturgeon; krakjoe@php.net ; > internals@lists.php.net > Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties > > Thanks. I'll start tomorrow morning and will try to send you > update by the evening, > > ________________________________ > From: Joe Watkins > > Sent: Tuesday, March 29, 2016 19:18 > To: Dmitry Stogov > Cc: Phil Sturgeon; krakjoe@php.net ; > internals@lists.php.net > Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties > > Hi Dmitry, > > The patch is pretty close to complete. > > When you start to dig a bit further, you'll notice that I > prepared for using cached pointers to prop info, but, I'm not sure > how to allocate those as the handlers are using the currently > allocated slots so differently. > > I also patched opcache, but it's probably wrong (or not good > enough, not sure what to do about type_ce). > > Please do start working on the patch, that would be great ... > I'll leave it alone for you to do your thing :) > > Cheers > Joe > > On Tue, Mar 29, 2016 at 5:12 PM, Dmitry Stogov >> wrote: > Hi Phil, hi Joe, > > Is your patch complete? > > I took just a brief review yet, and I would like to make a deep > check once again (and may be optimization). > I saw, the patch makes some slowdown, but less than I expected. > If you are not going to modify the patch in next two days, I would > start working on it tomorrow. > > RFC itself looks fine. > > Thanks. Dmitry. > > ________________________________________ > From: Phil Sturgeon >> > Sent: Tuesday, March 29, 2016 18:32 > To: Andrey Andreev > Cc: internals@lists.php.net > > > Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties > > I'd like to thank everyone for their feedback on this RFC! > > It looks like the majority of concerns were solved during the course > of this discussion, which is great news. > > The RFC has been expanded in a few areas to take care of a few other > concerns, so please go and review it and let me know if you have any > feedback. > > https://wiki.php.net/rfc/typed-properties > > Voting will start in a few days. > > Cheers, > Phil > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --------------060404000805050105050300--