Re: Type hinting

From: Date: Mon, 24 May 2010 05:58:28 +0000
Subject: Re: Type hinting
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-48420@lists.php.net to get a copy of this message
On 24 May 2010 13:09, Zeev Suraski <zeev@zend.com> wrote: > I see three key options going forward: > 1.  Implement the table along the lines of what it looks like now, perhaps > with minor changes. > 2.  Implement identical conversion rules to the ones that exist in PHP; That > effectively turns type hinting into scalar casting operators (not saying > that's a bad thing!) > 3.  Implement identical conversion rules to the ones that exist in PHP, > except for when they really suck.  Namely, lose the array->scalar > conversions and silent conversions of non-numeric strings to numbers. Given this is a new feature, my preference is #1, with the addition of the scalar and numeric hints mentioned upthread for less strict checking. I see scalar type hinting as a way of saying "I want a variable of type X", not "I want a variable that may have been lossily coerced into type X"; the developers mentioned in the RFC who are presently unaware of PHP's typing system strike me as being unlikely to use type hinting regardless of how it's implemented. That said, I don't think #3 would be the end of the world, either. My vote is admittedly a little selfish; it just doesn't line up as well as #1 with what I'd actually want to use scalar type hinting for. Adam

« previous php.internals (#48420) next »