Hi Zeev,

I've been keeping a very close eye, and have taken part in a good few
discussions, including putting my own idea on the table.

On Thu, Jul 9, 2009 at 8:47 AM, Zeev Suraski<z...@zend.com> wrote:
> The options as I see them:
>
> 1.  Do nothing.  I think the vote established that this is not what people
> want.

Agreed.


> 2.  Move forward with the semantics of the current patch.  This approach has
> substantial drawbacks in my opinion, and is a strong misfit with the rest of
> PHP (again, in my opinion).  See previous posts from Stas, Rasmus, myself
> and maybe others illustrating this point.  Lukas's 'Strict and Weak Typing
> RFC' (http://wiki.php.net/rfc/typecheckingstrictandweak) has some good
> insight as to why strict typing is problematic in PHP.

I believe nearly all opinions voiced have wanted the current patch.
Many more were in favour of strict typing only, but for the few
dissenters, like myself, Ilia included casting semantics using (int)
syntax.

There are I think maybe 5 or 6 people who have expressed opinions
against this. All others have been pro (I'm not counting the vote
here, I'm looking at discussions).


> 3.  Implement 'weak' typing.  What does that mean?  Conversion rules will be
> very similar to those for internal functions, but slightly stricter (like I
> said, if we were to rewrite the conversion rules for internal functions
> today - we'd probably make them slightly stricter, too).  For example, if
> you denote that an argument is supposed to be an integer, then a string that
> looks like an integer (e.g. "17") would be silently converted to an integer,
> however, a string that does not look like an integer (e.g. "foo") will error
> out.  We need to come up with a complete pass/fail table, but that would be
> the theme.  Unlike option #2, this fits the rest of PHP quite well (except
> for minor inconsistencies with internal functions - but these are dwarfed in
> comparison to the inconsistencies of option #2).

This seems like a good idea, but others disagree. I wrote a set of
rules for this, which are very much how you describe them: slightly
stricter than casting, but weaker than strict typing. In the
discussion, there was very little support, and so I withdrew it.


> Two other issues that we need to revisit:
> 1.  Agree on when it will be implemented - I think it's pretty clear it
> should not go to 5.3.

The last discussion certainly made this clear. It should be cleared up
whether people want this is 5.4 (if it happens). I think its
established that people want this in 6.


> 2.  Make sure people understand *why* we're implementing it - performance is
> certainly *not* the reason.

I believe there was only two misguided souls who believed this would
lead to better performance. Everyone else wanted it on its merits.


> Before moving ahead with votes or committing the code, I suggest we focus on
> the pros & cons of options #2 and #3.  Since the inconsistencies introduced
> by option #2 are very substantial (between internal and userland functions,
> and also how values behave in PHP in general), I suggest we focus on use
> cases where option #2 would be truly needed and superior to option #3.  In
> other words - what is the added value and is it worth the price?

It doesnt sound like you are aware of the casting semantics that Ilia
added. They are largely consistent with the internal function
semantics.

function x (int x) { /* fail on non-int */ }
function x ((int) x) { /* cast parameter to an int */ } // just like
internals functions

Indeed this adds the ability to make your function work like an
internals function (useful perhaps for library interfaces).


> I think we can take Lukas's RFC and either change it or write something
> based on it for weak typing only.  If people here find it useful I'll go
> ahead and do that.

I believe people don't want this. I wrote a set of rules, Lukas wrote
the RFC, and neither got anything like the support that strict typing
got.

One large problem is that it introduced a new 3rd set of rules, and
this set is not intuitive but rather slightly subjective (reasonable
people might disagree on whether a bool should be weakly converted to
an int, for example). The strict type checks are at least simple, and
the current weak ones are what people are used to.


Obviously I'm not against discussion, but we just had this discussion.


Thanks,
Paul



-- 
Paul Biggar
paul.big...@gmail.com

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to