18 messages in net.php.lists.internalsRe: [PHP-DEV] [PATCH] Scalar type hin...
FromSent OnAttachments
Hannes MagnussonNov 3, 2006 10:00 am.txt
PierreNov 3, 2006 10:39 am 
Marcus BoergerNov 3, 2006 10:46 am 
Ron KorvingNov 3, 2006 10:48 am 
Ilia AlshanetskyNov 3, 2006 11:06 am 
PierreNov 3, 2006 11:12 am 
Zeev SuraskiNov 3, 2006 12:34 pm 
Brian MoonNov 3, 2006 2:45 pm 
Richard LynchNov 6, 2006 12:18 pm 
Markus FischerNov 6, 2006 11:00 pm 
Richard QuadlingNov 7, 2006 1:26 am 
Ron KorvingNov 7, 2006 2:19 am 
Richard QuadlingNov 7, 2006 2:39 am 
Christian SchneiderNov 7, 2006 6:45 am 
Richard QuadlingNov 7, 2006 7:33 am 
Richard LynchNov 7, 2006 10:45 am 
Richard QuadlingNov 8, 2006 1:37 am 
Derick RethansNov 15, 2006 12:19 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [PHP-DEV] [PATCH] Scalar type hinting ;)Actions...
From:Richard Lynch (ce@l-i-e.com)
Date:Nov 7, 2006 10:45:14 am
List:net.php.lists.internals

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... :-)