Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92039 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99291 invoked from network); 31 Mar 2016 08:59:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2016 08:59:14 -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 157.56.111.115 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 157.56.111.115 mail-bn1bon0115.outbound.protection.outlook.com Received: from [157.56.111.115] ([157.56.111.115:62628] helo=na01-bn1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/91-24828-ED6ECF65 for ; Thu, 31 Mar 2016 03:59:13 -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=XNvhABlOkBFNrFgdOBiUnZHYV4VKSSqTuiyL5IjExKE=; b=jTiwcCvTiom8v2S0Hdfkcpmyymnp1kc/WQ+rRJoO2gN78z5gG3/HhGbvoTdaje4617fnyqNNEMu6pbOvstmTavheRaV4zaO7/j0+gwdu2mjLPymfbfqA+z/u85WrguF57s10NbjvkcopbYjcPBTXcMDeUpj5RkHiIOGsh5Dvs9A= 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 BLUPR0201MB1778.namprd02.prod.outlook.com (10.162.239.12) with Microsoft SMTP Server (TLS) id 15.1.447.15; Thu, 31 Mar 2016 08:59:05 +0000 To: Joe Watkins , =?UTF-8?Q?Bj=c3=b6rn_Larsson?= References: <3F.70.02405.6803BE65@pb1.pair.com> <56F01545.8080008@gmail.com> <56F14572.701@gmail.com> <56F15EF5.80006@telia.com> <56F16023.1010002@gmail.com> <56FC4ED6.6050701@telia.com> CC: Phil Sturgeon , Krakjo , PHP internals Message-ID: <56FCE6C9.1050302@zend.com> Date: Thu, 31 Mar 2016 11:58:49 +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="------------070103060202010203010303" X-Originating-IP: [92.62.57.172] X-ClientProxiedBy: VI1PR07CA0021.eurprd07.prod.outlook.com (10.163.160.159) To BLUPR0201MB1778.namprd02.prod.outlook.com (10.162.239.12) X-MS-Office365-Filtering-Correlation-Id: 253029ed-cc66-4037-76b3-08d35942b738 X-Microsoft-Exchange-Diagnostics: 1;BLUPR0201MB1778;2:IFVKTVKpqCZttKncDg7dEvFmfOPqcXTKMEP+8G2GLS12vLP/+ARieAnosC0tsqe6y84jQxNZYm6jlztmRYZ+ActckIhFyw1D3RoqVPJIVaQdRP90QRDmXdo52CsmiwCbEGH7eZOOVSTtP3542ms9WrW8Nok7GYzlwUr8q/ewRu7P5XLi8Ov+Q0lzl3gWI2Mi;3:kWNmaX/EAZWSm0ETP2JSUMbzu2BUWQS/unp0wyDP6dtQsGAoD+qpG8Kz0qxOAC3/H7/RLJZoE31QWNwMEliY8L1xl4MmKXlncGcGsbE1YCuNxGwlFi6s/sXUSstcfAvr X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0201MB1778; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0201MB1778;25:ob1cwi2yS9w94Lsy1C1yyBeYP+ULAa00Oc5kNAfCLKLmC4rDHP+liizr2d51uZREPh53QcPSgoKafgcpktgfrGdViMFI0oWWOmNNehWe1+EIWJ70uZipvqv8XOqlxgJVDo2LuMnzPsFOLwOlysajdlVhyDJzIvmVzDPgK5QJwUW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/5vbWoIaokqZb79hAVOyx+isOACNWFR2SYx/K8aM7WgNhR67FRRszF45ibP/VtJtGDOD6jCrvWzsTmMhnYtQOrrHqdUIxpDjxyglj22QGRjg4GOS9gCWyOjbOYZJ9iDrI3O2hq7ot5IhRiUIYSm2elU1MIcatdX0hmQPxKF9KktgDukAYs;4:ztQP0bl3lJ9jV8/dWV717fm9nJNZCigRuokIEhc24C2wHiS67WJ6GKr6hkHJmiGDrPq8eR52nWO196zOXQi+5EMMTU9OmIziedJP4VL3l0aZcAQCOa7tBkM1HfNZC9Df6+1ynr+ai2W58kaJTd81iNqeb0KrADGRCWLolwb11W5KC0DSCPfYpmUbv0tM8xBYJTD4fiuZtq9pX883YGYmTo8JM25UU4SrmIUhuH4vmNjLMThc/Bexqsc5RmiJAYVSQ405dkH8Rq1Wc15zNs+gni/d2tom0mOMEd9bHdL5EKEsb/J+Iu7g4usswOTWekjHmArNJPi/NwBUfw9Z2vEyYoUDRkB0BrnkGuGoS64IFDFKJZTJ78UrrSsInx3HdFPA 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)(10201501046)(3002001);SRVR:BLUPR0201MB1778;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0201MB1778; X-Forefront-PRVS: 0898A6E028 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(377454003)(377424004)(52314003)(24454002)(36756003)(2950100001)(42186005)(5004730100002)(586003)(4001350100001)(33656002)(50986999)(19580395003)(16799955002)(5001770100001)(16236675004)(5008740100001)(81166005)(19617315012)(84326002)(4326007)(2906002)(19580405001)(83506001)(93886004)(80316001)(65806001)(66066001)(86362001)(92566002)(3846002)(512874002)(1096002)(15975445007)(189998001)(54356999)(76176999)(65816999)(77096005)(6116002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR0201MB1778;H:tpl2.home;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0201MB1778;23:OG82JJ+l7S2JJhL0brJbdQ1LSLbHZBnkTO8EIlj?= =?us-ascii?Q?CXFaODv1bwZHEDis5o5olDrxc2w+lL+0M1SEpmRTilxgeEPaFHFo7kVzI9LK?= =?us-ascii?Q?jNFJlZRmmOHH5qa3u9eLFmHh0eCgYVimSmvs6qFnxJBBHm7E/3PDMjL63mEH?= =?us-ascii?Q?XN+l4JACT2XOK5XQt01gcmRVT4kY+qe7eYa8LF5yZd8yLOatAxIlbyE74Sih?= =?us-ascii?Q?FDRQtS3rYtegf7fqxkj0YevM74SuP4Bn4dWDtatoHanHvfEo2CbX5mAabY7+?= =?us-ascii?Q?I+J+WQs8xBtzv9MQ7D96hU/fCs4PayD0N7heHGyLjO1bCOaxbwvX6LJEfRLE?= =?us-ascii?Q?+s3m6kD8y+u3fKIjB0sgpXXeC7T+HRuDzEsm3SnZtphenOU9yi6YcuEFUTGC?= =?us-ascii?Q?8kQK6GFhhLpTWzQocRUrgBNevDPlsKhvS0xW4mKDbLH2+LcrcFeSleu6h5Ub?= =?us-ascii?Q?Zzeej8gJkxNWckHITeL5V7iQZ79yWw5HwIggeb+Mgd1lAsIqEieFbRpYSpSr?= =?us-ascii?Q?2r4pS/05LVuExLXtKXupZIvO91nSPnGFoMDW2xSVAs32p6BP/UM1iRHo2eMM?= =?us-ascii?Q?d46W6/uUKosGWd6oEyYhLCdHw2mFTE4mJy5bicYcLOYYbasXvCyENJ9u5W1I?= =?us-ascii?Q?EW2GB51s2ERjpWHw9EM4Tfa80HFkFWilmuHUcJqNUyBqVxdl7XtzMCWtjI00?= =?us-ascii?Q?xz54noBe++pADzmwEEoyitZpM8mtNxXnZYcs8t49RlnrU0pYYWI0Dxyn0XO2?= =?us-ascii?Q?JCSbluX4YGwRVXsJHVXs3JQw2tPPsEr5EUGQ1Vu3dtfnmDGLN+/Y55v0RBup?= =?us-ascii?Q?BwtHh/4iacWoVjIXkuWsOSrtGYceCXZqCfPiDIbNcm2F1BJIE4v2aN5A0wKu?= =?us-ascii?Q?47whY4tL/k7huJ5SINKhpgXKi8KzCX6yMV8tjbD4MvPYjq762/dlilfwwHTJ?= =?us-ascii?Q?Lq1opQWAM3taX7ucYkmf0LKgSFHNKrM22c/W96bfnPnhL4gA5jQuiOiQCnL/?= =?us-ascii?Q?Y1HWkqZxSnQuR6/Q0pbI3b7zDB3lSNYgTPInOo5K2FyX0GGYwBG6qEFX9JoL?= =?us-ascii?Q?uTEjnCHSA77fJwoMIrbnMiDH59c3vskw1OiUcNMFmRuUQP1OMg8Uc53oB7LB?= =?us-ascii?Q?9qvVk2N8i1Bw=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR0201MB1778;5:v+L0PcL23TUGllvGjBp5BPzM5hJLP+wp1nsTv4mfRFEuGh5YIFKfZcKb9iXrB1I11c4t2e3wSlv/dNkLE2GPbk5QMFva9Lqn479GsmKO8HdYhWtZZEFYaE8K5Mn9eWryXVOwZX4ySZFahxn6bU+ifQ==;24:ykxzFHUUOhcMNqqcsSsRB1KfqqDXZJIrxM+dU6T6m5RDu+0AFK+veW5/RBwzMjc2dg/R4K3LPXkTAK0xtCGDJD8tSsNl8K4yUoaw6X9Br1I= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2016 08:59:05.3672 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0201MB1778 Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: dmitry@zend.com (Dmitry Stogov) --------------070103060202010203010303 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit On 03/31/2016 11:34 AM, Joe Watkins wrote: > Morning, > > > Given that public is implied for all properties above there > > is a value in having the same rule for type. > > public $bar, int $foo; > > What does this mean? > > If it's not an error, what does this mean ? This should be a error. I also think, that "public" might be omitted, and it should be possible to write "int $bar, $foo". > > public $bar, int $foo, $qux; > > If it's an error, why is it an error ? > > Both of these examples are just as ambiguous as > > public int $foo, $bar, $qux; You say - C, C++, Java, HHVM, etc - all made worse decision? OK... > > Access modifiers are assumed to apply to all declarations in a group, > because that's what grouping is actually for. > > We don't need to make grouping about types, we need to make type > declarations unambiguous. Very strange grouping decision. At least your opinion is questionable and except for other languages, you see a number of opponents on @internals. Thanks. Dmitry. > > > Anyway, in Hack following syntax passes: https://3v4l.org/3tUu9 > > Hack does not consider types implicitly nullable. > > class Foo { > public int $int = null; > public stdClass $std = null; > } > > things.php:3:10,12: Wrong type hint (Typing[4110]) > things.php:3:10,12: This is an int > things.php:3:21,24: It is incompatible with a nullable type > things.php:4:10,17: Wrong type hint (Typing[4110]) > things.php:4:10,17: This is an object of type stdClass > things.php:4:26,29: It is incompatible with a nullable type > > function foo(int $int = null, stdClass $std = null) {} > > things.php:2:18,21: Wrong type hint (Typing[4110]) > things.php:2:14,16: This is an int > things.php:2:25,28: It is incompatible with a nullable type > things.php:2:40,43: Wrong type hint (Typing[4110]) > things.php:2:31,38: This is an object of type stdClass > things.php:2:47,50: It is incompatible with a nullable type > > HHVM doesn't care about types ... we don't compare our type system to > that ... > > Cheers > Joe > > On Wed, Mar 30, 2016 at 11:10 PM, Björn Larsson > > wrote: > > Den 2016-03-30 kl. 05:16, skrev Joe Watkins: > > 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. > > Good that it's clarified in the RFC since one could easily > believe that it's possible to set type for a static property. > > > 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. > > Given that public is implied for all properties above there > is a value in having the same rule for type. > > > 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. > > Maybe good to clarify difference towards default parameters? > Anyway, in Hack following syntax passes: https://3v4l.org/3tUu9 > > > 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. > > Don't have a strong opinion on this one, can see both views. > Maybe a bit affected by programming in Java recently, having > a slightly more positive attitude towards default values ;-) > > Regards //Björn Larsson > > --------------070103060202010203010303--