> -----Original Message-----
> From: Joe Watkins [mailto:[email protected]]
> Sent: Thursday, March 31, 2016 3:41 PM
> To: Dmitry Stogov <[email protected]>
> Cc: Björn Larsson <[email protected]>; Phil Sturgeon
> <[email protected]>; Krakjo <[email protected]>; PHP internals
> <[email protected]>
> 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

Reply via email to