Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92046 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36495 invoked from network); 31 Mar 2016 12:51:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2016 12:51:29 -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.110.135 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 157.56.110.135 mail-bn1on0135.outbound.protection.outlook.com Received: from [157.56.110.135] ([157.56.110.135:18138] helo=na01-bn1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/E4-13629-C4D1DF65 for ; Thu, 31 Mar 2016 07:51:28 -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=UuEITAMLqLAnDEOWCHR1dV/vjslXCh/+MNo+a+dxIDM=; b=PRlHnCyseAn26W85iKzamXyUdFmsg6JibIwCh+a2HWlkrdwMN4BWOdDC9gACbOSZ88SFtc+gQpNqTbIvxYSAWUoko2RyrMVsnyctWCXrpIM9UCdv4ovVk0WozUuHHJM0+daSaG5b6LXuHSBElyjvDae3QaqTL6CHe+8MeoVNdPc= 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 SN1PR0201MB1791.namprd02.prod.outlook.com (10.162.228.21) with Microsoft SMTP Server (TLS) id 15.1.443.12; Thu, 31 Mar 2016 12:51:19 +0000 To: Joe Watkins References: <56F14572.701@gmail.com> <56F15EF5.80006@telia.com> <56F16023.1010002@gmail.com> <56FC4ED6.6050701@telia.com> <56FCE6C9.1050302@zend.com> CC: =?UTF-8?Q?Bj=c3=b6rn_Larsson?= , Phil Sturgeon , Krakjo , PHP internals Message-ID: <56FD1D38.7050504@zend.com> Date: Thu, 31 Mar 2016 15:51:04 +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="------------050807080204060508050603" X-Originating-IP: [92.62.57.172] X-ClientProxiedBy: VI1PR06CA0041.eurprd06.prod.outlook.com (25.162.116.179) To SN1PR0201MB1791.namprd02.prod.outlook.com (25.162.228.21) X-MS-Office365-Filtering-Correlation-Id: 767e00fe-fb74-4bb7-1b69-08d3596328b8 X-Microsoft-Exchange-Diagnostics: 1;SN1PR0201MB1791;2:rubFY9m45cJaarwPubGa+K9T5ksPsEvm0CawyLUiqWKQ9SdyHKQtOWjGZToKxQtH7QEPMH3/z79LPZ/ZZ4wkJGMpBiqDHny+ivmtILXe5VTQDnK85+29dLbM8ms5J/7rd/5CwQydOVFDkcsTBBXrAv2k5iEtx93HSjcC4RYWKQZwYiK7yIg17VGzrUTAZVVY;3:ln/k/cnFnAVf8Gm2oh1laQ6jzodYip/t4oy/NuM7P+fkiKWQzhn5THU5QO36wKGssS/sSc0uXzqsgQpcpvCt+AYEc7gJM5YHu0i06HsHGeHOHlwOgEaTu0vftx3gLWZx X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0201MB1791; X-Microsoft-Exchange-Diagnostics: 1;SN1PR0201MB1791;25:Uh8ibgxYb2SI4YZRAS8Q9mAZB9pb33LHqVQR3UcLVmEBAGFvX29cmrU/ziRzQuBAgQpAxKrBwTss+LiQwZMPYTN2+9p9JG6KEYKtZm/TXoRwM7GaE2OBllu0oTMgq0hcZ90IEPYAfGl4Gjjo6H9NHVpqXTStZ0m44sIq5lF+dRUV7uTj35Fsemv1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6oqG8CWPG4krbwcqa2dncVTIIsPSrWMSV9PZc1Ct3nd+NLjjKDyOOVQQWyl9IEAH06miytnsddU9Ies+xoM4sgRBOfG1YNSiAs;4:tfq88Pdf8WYIoi2yLREHVp0G4yGffIqoKjOlXleplkuc1lCfc194aY+YqW/e6+b2DtBfFzRS2bxNxW82dxUbcN06K2Dpjh+oM9OgItYAx2f7YhxhXozDcCTV+2wq1zu5Dg3mY+qHgLoKwBw/L7rBD0OQDdS+0Re7EUIUSP408ftpiFZHkYPgiovjX/xfEnXjZdmcLoq/RyVAKUBqvYMDgELh4KITfvTjB+K/Mii6E22Q9aUsdyQhEu4ISqSo6xkG3630QDUupGkrgTousgPsgiHkxrZNV66v50kG4FNpfSc1G9Z8QiU1Jt6X92CU2tOhoctYb3nzahkqSkNsrRxGYrbPfkBEuQu+dr68tjg41j8prBGgrOq4kcI2AxRLZskj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:SN1PR0201MB1791;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0201MB1791; X-Forefront-PRVS: 0898A6E028 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(377454003)(377424004)(24454002)(52314003)(92566002)(81166005)(84326002)(5008740100001)(6116002)(19580405001)(189998001)(19580395003)(80316001)(1096002)(110136002)(3846002)(42186005)(86362001)(16799955002)(586003)(50986999)(76176999)(93886004)(19617315012)(77096005)(5004730100002)(65816999)(33656002)(15975445007)(2950100001)(16236675004)(64126003)(65956001)(66066001)(54356999)(512874002)(87266999)(65806001)(4326007)(2906002)(59896002)(36756003);DIR:OUT;SFP:1102;SCL:1;SRVR:SN1PR0201MB1791;H:tpl2.home;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR0201MB1791;23:Qdy955rgmBjkZnuVwlsyTLuroiEDLvVP8HJVPyi?= =?us-ascii?Q?ZEXMNBSUBIofpwWJntM/o6oW3RozB5shSn840hUbj+WjFI0SlaxPQLw1H5Am?= =?us-ascii?Q?VvX8vtNoBk9tJmk8Td0kt5KMvExFvmtTULm5C+g4uCf0RSgA2OSGNRnLq579?= =?us-ascii?Q?tXYL/+BNS2+wZj+6linZemSO6XOE1HWhnSG/GhLIuTaafF4hGpOgQh2vlqWC?= =?us-ascii?Q?zwsORa44791SOjC1RvLPBJw6Nl1UOptGSVeMgFxKpsHrgbe31VBnBKe31YTK?= =?us-ascii?Q?F+4BlYote585ctjTLRqCP2j6xvPpIB+bUGTxegh209Tpoi5oMYURhfy48VjI?= =?us-ascii?Q?lyajFQdi3WP2Hvj4qogDMSljNYgufsxqN21eSlyOwa4HsRKgv7fMcsEvSSsC?= =?us-ascii?Q?sSbI9ETxqB4I9HF4HQr0fuCvk25ToMhZAFc6yDaBB5BmZ23XG/5QAwc7xgKT?= =?us-ascii?Q?TMlMI4h0kwR1Ai1aWdI6KgUe9tXkpH+x5Ov9vxo0JpxTbuCBaBSuni90YXTF?= =?us-ascii?Q?bBnyE19jWi6V6cNm7gPMVa4MNu++khWHvmxGpdRTXB9I33m+27FIqY0pXzGG?= =?us-ascii?Q?Ut6j0KVT0P7DPFVLw+XAM88emQGJdAoeJ49JABP6SvaMNz+djiC/yZr0eKNc?= =?us-ascii?Q?RdzloCU9M1NIIn9KTsPhI7m37BD6ZK49ma6ttSq/rOdxVbLROue5RpktpN+3?= =?us-ascii?Q?8A4i3m6Si3xsA0u6/v994oketehlO+8oUGe+O7MspTsenygJNH8/ChhT1M6/?= =?us-ascii?Q?Bq2bKDyb7ESGIgoWHssatA+B8qkWT4mr4bVqdallfPnByE14TuFA47qIrNzy?= =?us-ascii?Q?of6RO/BCFoC/4LNX9wYKj/T08FWcsBp1RajlBEVWmqSnFHKBqDtifHYHrkfk?= =?us-ascii?Q?h5wX01tjj3myDYWacEhk4I1Q+6jaYFc1WetPyqe7ajn8pfx4Ay0QQTJKZE9+?= =?us-ascii?Q?WwdfW3xCIFd9MWfzo6oJTRZX3OCo8Abfovaxb09YviOopeoJF6WaPGHxQG1W?= =?us-ascii?Q?tcjxqloANHXATJaMoxje575b9K+RTBe+9stYG6b0mHPfzJxBH4Z/4zG6kWPB?= =?us-ascii?Q?aIpEZR18rDf7qTJ7OOjx06hrQxXluGg2YpmOLQWRNDOYl1hkCA4rjXnADKyV?= =?us-ascii?Q?xN8Jj+Fy7MxXixWaLKWDGrrJyB95zjT8K?= X-Microsoft-Exchange-Diagnostics: 1;SN1PR0201MB1791;5:rXy9LDCP8eHkJdHR91DQVbCkAyhIb6NyC+1jI8gUrjS392qjUaCZFD/9elc+Y+p4G9IgH3Utp+ZV50mTpyuFoKvhfriAQS2MDrVWMgAwucT36ADWxPAnBNhymiLrJRGttpYHVAUZYN1eiVI7OZrkOg==;24:O+mTphdQmCBKPKtvVkSepSlxrEFti/eFjyydXhYyr0GCAA4w6N9tC8yToxc0LdMhvjGGK4tlWCOsUDi03MIpoCqYKx9MctjnGgmZKlF+akk= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2016 12:51:19.4784 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0201MB1791 Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: dmitry@zend.com (Dmitry Stogov) --------------050807080204060508050603 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit On 03/31/2016 03:40 PM, Joe Watkins wrote: > Morning Dmitry, > > > This should be a error. I also think, that "public" might > > be omitted, and it should be possible to write "int $bar, $foo" > > Omitting public might be nice, but also totally separate, you should > be able to omit it for untyped properties too. Right. We may use "var $a, $b;". > > > You say - C, C++, Java, HHVM, etc - all made worse decision? OK > > No. C, C++, C#, and Java had a different decision to make. > > [public] int foo, bar; > > It is obvious that bar is an int in any of those languages precisely > because it necessarily has a type. > > Why we should jump to the same conclusion, in a system where > properties do not necessarily have types is not clear to me. Just not to confuse programmers with uncommon grouping behavior. Thanks. Dmitry. > > Cheers > Joe > > > > On Thu, Mar 31, 2016 at 9:58 AM, Dmitry Stogov > wrote: > > > > 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 >> >> > > --------------050807080204060508050603--