Re: Scalar type hinting
| From: | Kris Craig | Date: | Thu, 01 Mar 2012 01:46:25 +0000 |
| Subject: | Re: Scalar type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-58379@lists.php.net to get a copy of this message | ||
I was thinking something more along the lines of simply throwing an error
if, say, (int) $a != $a.... *if *$a is defined as an integer.
--Kris
On Wed, Feb 29, 2012 at 5:16 PM, John Crenshaw <johncrenshaw@priacta.com>wrote:
> > -----Original Message-----
> > From: Kris Craig [mailto:kris.craig@gmail.com]
> >
> > @Richard I think you made a very good point. Should we treat a float =>
> int mismatch the same as we would a string => int mismatch, or should the
> former fail more gracefully? I can see good arguments for both.
> >
> > --Kris
>
> I'm beginning to think that the type hinting question is too closely
> related to the dirty secrets of type juggling to resolve them separately.
> You may have to either discard consistency, or else fix the problem of
> silent bizarre conversions at the same time ('foo'==0, '123abc'=123).
> Fixing the conversions is a BC break though.
>
> John Crenshaw
> Priacta, Inc.
>