Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92052 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90426 invoked from network); 31 Mar 2016 17:48:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2016 17:48:21 -0000 Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.177 as permitted sender) X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 209.85.214.177 mail-ob0-f177.google.com Received: from [209.85.214.177] ([209.85.214.177:36210] helo=mail-ob0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/E1-15473-4E26DF65 for ; Thu, 31 Mar 2016 12:48:20 -0500 Received: by mail-ob0-f177.google.com with SMTP id m7so32234390obh.3 for ; Thu, 31 Mar 2016 10:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+9Y4XxXTTlD5AS+7Z52UC4KDj2GgBUBHJIS+PQp0h94=; b=rxfhpTeRbWXauOUlxwUY2uUGsB0dV35F2/vFkP/2isg859QMMQipc4G/KZQWjP+LP6 mODl60+ySbOw1hO4nR0ziK9JGL8ZcyAEsN5rtutQgghgMDWKItNCAihSDcQYjlTHbR+A L5jKJhH4ceHQpJmTq2DCGZGVvjbskesG8hNh6Ws97KyijGml8h8r5F6ey1YTHMQJfAVq 6FpFCWCsYzDKGvWel4f9Zyy+g10k6vYR8poDpDEixYd0157S8psNyhbOt5D54ew5Y+Ye eMDBDn5ksJLRmc7KD+PuQCmjgfUX+mo1Cujr2MDMs/vNSn1GVWq2/sYhvk8MxCB5bNTR NUjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+9Y4XxXTTlD5AS+7Z52UC4KDj2GgBUBHJIS+PQp0h94=; b=OkjY81SYxERSXH/zt+GSs5N7Hp7KRgGl4CvMj71SC0hG/9a5EBOk4CziKl6Do3cHja PujKgmjnGLMw/PdftqBMgnQvl2ahvkE7LBuxDmemeXdLDnz7lkbUUc8wNf1eStSPJYyP DcpnIBqLUqQRf85pYSnDmcx/DPiaf8eCIpUf44R8H7xTffpUcFRUOA1l5q2NCyTPYXjE w/LMxsR/ehKDvdI5WuzWiiJmPR2AafJSmFRt24LrOjlkWt+ZAToUFkUu6mu9OaNTSs/u 3jMIRFFPP659YyxDUn+LsbwMOE6Np/Pdu2QIukZ/PRmRT7Ean3tBmCUJIM7vHNa4gbCh TN9A== X-Gm-Message-State: AD7BkJIKh2KuZqMbR7vJQUJdbLZ1sug9G0i9LkN89x0tchz07B4ItjwzAJN3RA7l6O53yXO6nvY/I/zks1KOhw== X-Received: by 10.182.165.67 with SMTP id yw3mr84961obb.45.1459446497364; Thu, 31 Mar 2016 10:48:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.38.162 with HTTP; Thu, 31 Mar 2016 10:47:57 -0700 (PDT) In-Reply-To: <56FD4E18.7070703@garfieldtech.com> References: <56F16023.1010002@gmail.com> <56FC4ED6.6050701@telia.com> <56FCE6C9.1050302@zend.com> <56FD4E18.7070703@garfieldtech.com> Date: Thu, 31 Mar 2016 13:47:57 -0400 Message-ID: To: Larry Garfield Cc: PHP internals Content-Type: multipart/alternative; boundary=001a11c2e9640b5074052f5bdef7 Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: guilhermeblanco@gmail.com ("guilhermeblanco@gmail.com") --001a11c2e9640b5074052f5bdef7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable To me it's simply as that: class_statement: variable_modifiers optional_type property_list ';' { $$ =3D $2; $$->attr =3D $1 } | ... property_list: property_list ',' property { $$ =3D zend_ast_list_add($1, $3); } | property { $$ =3D zend_ast_create_list(1, ZEND_AST_PROP_DECL, $1); = } ; I think this makes the concept more palatable compared to others and other languages (single type declaration per statement). Regards, On Thu, Mar 31, 2016 at 12:19 PM, Larry Garfield wrote: > 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=C3=B6rn 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 ma= kes >> 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, wh= at >> drove other languages to pick their syntax and force developers to separ= ate >> 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 o= n > 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 lega= l: > > 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-wa= ve > 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 > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Guilherme Blanco MSN: guilhermeblanco@hotmail.com GTalk: guilhermeblanco Toronto - ON/Canada --001a11c2e9640b5074052f5bdef7--