Hi! You are everywhere :P

2016-04-17 6:28 GMT-04:00 Lin Yo-An <cornelius.h...@gmail.com>:
> I think it will be better if union type is only allowed in the "type"
> statement, like what you described in your RFC.
>
> type Iterable = Array <http://www.php.net/array> | Traversable;
>
> If we can always pre-define the types.
>
> And only allow just one type for each function parameter in the function
> prototype, then, I think the performance impact of type checking in the
> runtime might be able to be reduced.
>
> In other words, you predefine the union type before you used them, and the
> union types can be reused in different functions, you don't write a lot
> union type in function prototype.

Performance issues aside, the ability to inline type expressions on
function signatures --- function myMethod(A|B $arg){...} --- can be "nice"
because it allows us to keep type definitions *private*. Assuming that a
named type could be reused by third party code (as public API) and that may
not always be the intended.

Of course this would be much better addressed with first class packages
where interfaces, classes, types etc can have their visibility defined. But
until we get there, having the type expressions on argument lists may be
useful.

Cheers,
Márcio

Reply via email to