Re: [RFC Discussion] Typed Properties
| From: | guilhermeblanco@gmail.com | Date: | Thu, 31 Mar 2016 18:24:09 +0000 |
| Subject: | Re: [RFC Discussion] Typed Properties | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92054@lists.php.net to get a copy of this message | ||
My code version is not complete, as the references changed when you include
the optional_type.
It shouldn't be hard to change though... like $$ = $3 and also hold $2
somewhere.
On Thu, Mar 31, 2016 at 2:09 PM, Zeev Suraski <zeev@zend.com> wrote:
>
> > On 31 במרץ 2016, at 20:48, "guilhermeblanco@gmail.com" <
> guilhermeblanco@gmail.com> wrote:
> >
> > To me it's simply as that:
> >
> >
> > class_statement:
> > variable_modifiers optional_type property_list ';' { $$ = $2;
> > $$->attr = $1 }
> > | ...
> >
> > property_list:
> > property_list ',' property { $$ = zend_ast_list_add($1, $3); }
> > | property { $$ = 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).
> >
>
> Exactly (code version).
>
> >> 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?
> >>
>
> Exactly (human version :)
>
> Zeev
>
--
Guilherme Blanco
MSN: guilhermeblanco@hotmail.com
GTalk: guilhermeblanco
Toronto - ON/Canada