RE: [PHP-DEV] Scalar type hinting
| From: | Zeev Suraski | Date: | Wed, 29 Feb 2012 21:09:55 +0000 |
| Subject: | RE: [PHP-DEV] Scalar type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-58351@lists.php.net to get a copy of this message | ||
Guys,
I've followed this thread silently so far, and I'm wondering what changed over the last
~1.5years that warrants a new discussion into that matter.
I think the previous discussion ended with a pretty clear directive that strict typing has no place
in PHP. Rasmus said about the proposal back then "They aren't hints. It is strict typing
and in its current form I would ask you guys not to call the 5.4 release PHP." - which put in
one sentence what several others (myself included) put in many more words. So the
'strong'/'firm'/'strict'/whatnot version of what is being discussed
here, should probably not be discussed at all. We've been through it, and rejected it.
Back when we rejected strict typing, we also 'killed' the other RFC[*] that was born out
of that old discussion - the 'weak' auto-conversion RFC. If I recall correctly, it was
for two reasons - one was that the proponents of the strict typing said they'll firmly object
weak typing, and the other is that this RFC still had some issues that didn't seem obvious to
hammer out (main one I recall is that sticking to PHP's standard type juggling rules meant that
feature wasn't very useful, and we didn't feel very comfortable introducing brand new type
juggling rules just for that feature). If you want to revive that discussion, I suggest you take a
look at that RFC - confine yourselves to only work on stuff that stands a chance to get accepted (no
strict typing) - and try to come up with good answers to the open questions. No point in redoing
the whole discussion from scratch.
Zeev
[*]https://wiki.php.net/rfc/typecheckingstrictandweak
> -----Original Message-----
> From: Kris Craig [mailto:kris.craig@gmail.com]
> Sent: Tuesday, February 28, 2012 11:58 PM
> To: John Crenshaw
> Cc: Richard Lynch; internals@lists.php.net
> Subject: Re: [PHP-DEV] Scalar type hinting
>
> Err sorry yes John is correct. I wasn't paying close enough attention.
>
> Here's *my* vision of how that progression would look:
>
> $a = "1"; // Current kosher unchanged.
> weak int $a = "1"; // Converts to 1. No error thrown.
> strong int $a = "1"; // Converts to 1. May or may not throw an error (I'm still
> on
> the fence).
>
> $a = "blah"; // Current kosher unchanged.
> weak int $a = "blah"; // Throws E_x error level.
> strong int $a = "blah"; // Throws E_y error level.
>
>
> Where E_y > E_x.
>
> --Kris
>
>
> On Tue, Feb 28, 2012 at 1:52 PM, John Crenshaw
> <johncrenshaw@priacta.com>wrote:
>
> > No, In the example given there's an error on int $a = "1". There
> > should be no error because this juggles fine.
> >
> > John Crenshaw
> > Priacta, inc.
> >
> > -----Original Message-----
> > From: Kris Craig [mailto:kris.craig@gmail.com]
> > Sent: Tuesday, February 28, 2012 4:47 PM
> > To: Richard Lynch
> > Cc: internals@lists.php.net
> > Subject: Re: [PHP-DEV] Scalar type hinting
> >
> > @Richard That's fairly close to what I'm thinking, yes. But there
> > seems to be a diverse range of ideas bouncing around right now, so at
> > present it's all in flux.
> >
> > --Kris
> >
> >
> > On Tue, Feb 28, 2012 at 1:44 PM, Richard Lynch <ceo@l-i-e.com> wrote:
> >
> > > On Mon, February 27, 2012 4:34 pm, Kris Craig wrote:
> > > > I think this is the main reason for differentiating between "strong"
> > > > (or
> > > > whatever word is appropriate) and "weak." The developer may very
> > > > well want their script to blow-up in such a case.
> > >
> > > I believe I actually "get it" now...
> > >
> > > You want 3 layers:
> > >
> > > $a = "1"; //current kosher unchanged weak int $a = "1"; // some
> > > E_x
> > > error level strong int $a = "1"; // some E_y error level where E_y >
> > > E_x
> > >
> > > Is that a correct summation?
> > >
> > > --
> > > brain cancer update:
> > >
> > > http://richardlynch.blogspot.com/search/label/brain%20tumor
> > > Donate:
> > >
> > >
> > > https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id
> > > =F
> > > S9NLTNEEKWBE
> > >
> > >
> > >
> > > --
> > > PHP Internals - PHP Runtime Development Mailing List To unsubscribe,
> > > visit: http://www.php.net/unsub.php
> > >
> > >
> >