Re: Type hinting
| From: | Lukas Kahwe Smith | Date: | Wed, 09 Jun 2010 10:08:52 +0000 |
| Subject: | Re: Type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48700@lists.php.net to get a copy of this message | ||
On 09.06.2010, at 12:01, André Rømcke wrote:
> Example:
> function fetchById( int $id, bool $asObject = true )
>
> If weak type hints are accepted, type hints would be useless in this case as
> consumer can do something strange as fetchById( true, 'foo' ) (Obviously I'm
> not saying anyone would do this intentionally, but in a large application
> you might not have full oversight and can unintentionally pass variables of
> wrong type or in wrong order causing issues to surface much later as there
> are no strict type checks that would detect the mistake immediately while
> developing).
please read RFC's you comment on (well the following was added to the RFC 2 or maybe even 3
weeks ago):
in your above example there would be data loss in the type cast and therefore there would not be
silent auto casting.
again there is only silent automatic casting being proposed in the case of when there is no data
loss:
"1" <=> 1
but "1abc" would not silently cast to 1
etc.
anyway .. can we conclude this discussion? probably best if someone who is more or less impartial
would handle the call fore vote and figure out some sensible way to let people vote on the various
solutions that are proposed.
regards,
Lukas Kahwe Smith
mls@pooteeweet.org