Re: Types on the right or on the left
| From: | Andrea Faulds | Date: | Mon, 03 Nov 2014 15:39:46 +0000 |
| Subject: | Re: Types on the right or on the left | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78580@lists.php.net to get a copy of this message | ||
> On 3 Nov 2014, at 15:07, Robert Stoll <php@tutteli.ch> wrote:
>
> It adds the type hint on the right hand side of the function (of the identifier). In contrast
> to parameters where the
> type hint is placed on the left hand side of the identifier.
> Mixing both, having some types on the left and others on the right, seems like another
> inconsistency in the language
> design to me.
These inconsistencies exist for two reasons:
- Opposition to doing it the other way
- Hack already doing it this way
I don’t think
function void foo(); will happen, since that’s been previously
rejected as it breaks gripping for “function foo”. Similarly, I don’t think public $foo:
Foo; will happen, given Hack does it as public Foo $foo;.
PHP doesn’t need more inconsistency, sure, but we must be practical here. It is bad if PHP and
Hack have the same feature with different syntax, it will cause developer confusion and further
segment the communities. It is bad if we don’t get return type hinting because the
“consistent” syntax would upset some people.
--
Andrea Faulds
http://ajf.me/