Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92049 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69082 invoked from network); 31 Mar 2016 16:19:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2016 16:19:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.29 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.29 out5-smtp.messagingengine.com Received: from [66.111.4.29] ([66.111.4.29:59541] helo=out5-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/7B-13629-B1E4DF65 for ; Thu, 31 Mar 2016 11:19:39 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id EF7772257E for ; Thu, 31 Mar 2016 12:19:36 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Thu, 31 Mar 2016 12:19:36 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=0EarDVO2DwopcCK YoMlqJivoA8U=; b=FK9GCj+Tw/1UFnVJ8XJbrNNRXk5linN/jXQ+zAxcVqUkz8D Y7TkvLaCMU54kZxqmqQfFGHxuZiPurgUjSWDSXSoK9/cLZoI6UtFjKsRyVIuKWY5 0JewjClLA0TB1j5EtGMQhmx0U2lB7M912WaiylN8uFQW7rLGfVKgUpGC9NoU= X-Sasl-enc: GRltrRyMjmaS+rp1T2RsHjRSEPfHwaWNpKjYzNyKVhM+ 1459441176 Received: from Crells-MacBook-Pro.local (unknown [63.250.249.138]) by mail.messagingengine.com (Postfix) with ESMTPA id B3F02C0001B for ; Thu, 31 Mar 2016 12:19:36 -0400 (EDT) To: internals@lists.php.net References: <56F16023.1010002@gmail.com> <56FC4ED6.6050701@telia.com> <56FCE6C9.1050302@zend.com> Message-ID: <56FD4E18.7070703@garfieldtech.com> Date: Thu, 31 Mar 2016 11:19:36 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: larry@garfieldtech.com (Larry Garfield) On 3/31/16 8:01 AM, Zeev Suraski wrote: > >> -----Original Message----- >> From: Joe Watkins [mailto:pthreads@pthreads.org] >> Sent: Thursday, March 31, 2016 3:41 PM >> To: Dmitry Stogov >> Cc: Björn Larsson ; Phil Sturgeon >> ; Krakjo ; PHP internals >> >> Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties >> >> 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. >> >>> You say - C, C++, Java, HHVM, etc - all made worse decision? OK >> No. C, C++, C#, and Java had a different decision to make. > I don't think the decision is fundamentally different. It's fundamentally very similar if not identical. > >> [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. > Because we're dealing with a single statement, and we already have the concept that a modifier for that statement is enforced throughout the statement - I don't see how whether that modifier is mandatory or not makes any meaningful difference. Having an access modifier affect the entire statement, while a type modifier affecting only the variable next to it - is extremely inconsistent. > > If > > Private Person $p, Car $c; > > works, why shouldn't: > Private Person $p, public Car $c; > > Work as well? > > In addition to being inconsistent, it also calls for poor coding practices - mixing typed and untyped declarations in a single statement - as well as different types in a single declaration. In that context, what drove other languages to pick their syntax and force developers to separate declaration of different variables types into different statements - applies exactly in the same manner for all other languages, us included. > > Zeev Honestly I never even realized that you could put multiple declarations on a single line, have never done so, and would reject code from any of my projects that did so as poor style. :-) That said, since it is legal I agree that it should be kept unambiguous and consistent. From what Zeev is saying, the following seems like a reasonable rule: You get ONE visibility modifier and ONE type statement per declaration, and both must come at the beginning, period. That is, the following are legal: public int $a, $b; protected $a, $b; var int $a, $b; And always apply across the entire line, period. The following are all syntax errors: public int $a, string $b; var int $a, protected $b; private $a, float $b; That seems fairly easy for a reader to follow, reasonably consistent, and I presume straightforward to implement (not being a C developer I hand-wave that part...). If you want to do something more complex... make it multiple statements. That's why multiple statements exist. Zeev, is that an accurate summary of what you're arguing? -- --Larry Garfield