On Fri, May 28, 2010 at 11:04, Lukas Kahwe Smith <m...@pooteeweet.org> wrote:
> In the weak type hinting RFC the conversion rules are pretty clear to me, 
> anything that converts without data loss goes through, anything else does not 
> convert silently (or even fails if we want to be so strict, depending on 
> which approach we prefer). I personally prefer the cleaned up conversion 
> rules from the RFC (and would love if we could figure out some way to do 
> something similar for the entire type juggeling in PHP). However I can also 
> accept if we simply stick with the same rules as PHP has atm (albeit still 
> with the addition that a cast that causes data loss would not happen silently
>

My biggest problem with the "weak type hinting" approach is the
inconsistency with the current array type hint.
Currently if you pass int(42) to an array type hint it will fail. For
the "weak type hint" it will cast it to whatever was hinted.

This is inconsistent with our current userland (array) casting, where
(array)42 ends up being array(42);
And same with passing an array(42) to a boolean hint, which with the
(bool) cast returns bool(true).
And what if I pass int(42) to boolean hint? Its an obvious dataloss,
should that trigger a warning message or fail?

The edgecases for the "weak type hinting" are way to many and
inconsistent with the rest of our casting structure, so adding more
inconsistencies by introducing other type of type hinting makes type
hinting in general inconsistent with eachother - leading to even more
pain.

I want the "strict type hinting" because it is consistent with the
current type hinting implementation, and I don't have to deal with any
warnings or weirdness. I either get the exact data I wanted or it
fails. I have other means of casting data, and I can pick myself how I
cast it (with or without dataloss, with or without warnings).

-Hannes

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

Reply via email to