Stas Malyshev wrote (on 15/07/2014):
Hi!

That's only a problem if you frame the new hints as "a type of implicit
cast". If they were to be described in relation to existing
functionality, I'd describe them as a new type of *explicit* cast, but
How they are explicit cast if you're not explicitly casing anything?

I was thinking of them as explicit within the function definition, rather than within the calling code. I guess a cast always explicitly happens *somewhere*, so it's a matter of interpretation, but this is the rough equivalence which made me think of it as explicit:

function foo(int $bar) {
}
function foo($bar) {
    $bar = (int)$bar;
}

In contrast, if you write '123' + '456', you never mention "int" at all, but an implicit cast happens to both arguments.

as mentioned elsewhere, I'd be happy for them to exist outside of
function signatures too as a new notion of "strict cast".
That's exactly what I want to avoid - having several forms of casts with
different rules. One is good, two is kind of OK, three is too much.

As far as I know there's only one set of rules at the moment, and I'm suggesting adding a second. So, "kind of OK". Unless I'm missing something about what we currently have.


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to