Re: Scalar type hinting
| From: | Kris Craig | Date: | Wed, 29 Feb 2012 01:40:09 +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-58316@lists.php.net to get a copy of this message | ||
I wouldn't mind that, though I'm concerned that it may not be sellable
because some people on here have expressed a strong opinion that this
shouldn't throw anything more than a notice or a warning at most, something
that I and others strongly disagree with. The logical approach, to me at
least, is to follow the example of include() and require(); i.e. they're
both identical except that one throws a scary error while the other one is
just a warning.
I'm fine with just throwing E_RECOVERABLE_ERROR, though I fear that may
alienate too many people for us to be able to get this through. Though
it's possible I might be overestimating that factor.
--Kris
On Tue, Feb 28, 2012 at 5:17 PM, John Crenshaw <johncrenshaw@priacta.com>wrote:
> > On Tue, Feb 28, 2012 at 3:03 PM, Rick WIdmer <vchkpw@developersdesk.com
> >wrote:
> >
> > > On 2/28/2012 2:58 PM, Kris Craig wrote:
> > >
> > > strong int $a = "1"; // Converts to 1. May or may not throw an error
> > > (I'm
> > >> still on the fence).
> > >>
> > >
> > > It this is an error, it is no longer PHP.
> > >
> >
> > @Rick Though I'm not sure I'd agree with the overly broad "it is no
> longer PHP" hyperbole, I think the basic point that it would be a
> significant departure from the current model has merit. So ok, you've
> convinced me.
> That example should not throw any errors. I'm officially no longer on the
> fence with that. =)
> >
> > --Kris
>
> OK, if we're all on the same page there, I think this means that there is
> no significant difference between the "strong int" and "weak int" in your
> proposal (the only remaining difference being the level of error raised
> when it cannot be converted, which IMO is not substantial enough to deserve
> a keyword.) I'd prefer to just pick one error level to use
> (E_RECOVERABLE_ERROR would be the most consistent) and keep everything
> simple.
>
> John Crenshaw
> Priacta, Inc.
>