On Tue, November 7, 2006 4:19 am, Ron Korving wrote:
I wouldn't like E_NOTICE. I agree that the result should be a NULL
value if
a conversion fails,
Assume, for the sake of argument, that someday one's type-hint could be:
function foo ([NULL | int] $bar){
}
Also assume the paramter passed to $bar is '42'
Then is converting to NULL really the right answer?...
I don't have a BETTER answer, mind you...
Seems to me, though, that if you're willing to turn on type-hinting,
and you restrict your function to accept only [NULL | int], then I'd
be more happy with PHP throwing something bigger than E_NOTICE and
converting the input to NULL and carrying on...
Seems to me, that once you commit to the type-hinting, a failed
conversion oughta be E_ERROR...
I don't see a point in a hint called "mixed" either. You might as well
not
use a hint for that particular function parameter.
You may need [mixed] if the PHP Manual under-documents what return
values occur in the case of errors (which is the current
state-of-the-art, really) and you don't know for sure what is going to
come back, but you want something there, just so you know it's "not
right yet"
Sometime after that the facility to make the hints become enforcers.
There would be a published list of conversion mechanisms (the
equivalent PHP function in effect). You could potentially allow user
defined conversions for user defined types though I would see this
as
a WIBNI, rather than a MH.
WIBNI?
MH?
[shrug]
I get the gist from context, but may be missing details... :-)