Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44856 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47154 invoked from network); 9 Jul 2009 08:40:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jul 2009 08:40:23 -0000 Authentication-Results: pb1.pair.com header.from=paul.biggar@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=paul.biggar@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.206 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: paul.biggar@gmail.com X-Host-Fingerprint: 209.85.218.206 mail-bw0-f206.google.com Received: from [209.85.218.206] ([209.85.218.206:49304] helo=mail-bw0-f206.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CD/3A-27938-6FCA55A4 for ; Thu, 09 Jul 2009 04:40:23 -0400 Received: by bwz2 with SMTP id 2so5547398bwz.23 for ; Thu, 09 Jul 2009 01:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=tyT+T0nohWQvl42zIMELSKFjruZ+0VdHkBMF7yt4TVI=; b=BapUm6IRO3DZNBQxwLHIwPvtKwI8zA7yuDviYJB81mwZFX7F3QzxqhEgmgh5IbACc8 RHzbBnHN8hVaikAIIKLWuMXmx5ddKevhv1e/xbog2QGq/M0KGWWyfb+D2aasLbqrEaTp L3jyAavmhls1nwx+CFYb3Lf0O9IS1loOAGqvE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=r76HDby4NQRmUqevqCOo3uhHUUwQc78Aj2a/QwB3H7GEEU3rSARlZCB3WSrOTgxWA+ SCA7zA+LUjquhPaWnxbYxcumnrkMp3R4cUr+LGw6Hk4+HX97NVB9Gxb15Ed6z7Ocj4vZ 56v93lh+euntAR5ESZhQZkh70xtFxfHRiV+bo= MIME-Version: 1.0 Received: by 10.103.192.2 with SMTP id u2mr278007mup.31.1247128819080; Thu, 09 Jul 2009 01:40:19 -0700 (PDT) In-Reply-To: <7.0.1.0.2.20090708224156.0ac5a438@zend.com> References: <7.0.1.0.2.20090708224156.0ac5a438@zend.com> Date: Thu, 9 Jul 2009 09:39:59 +0100 Message-ID: To: Zeev Suraski Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Type hinting - Request for Discussion From: paul.biggar@gmail.com (Paul Biggar) 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 wrote: > The options as I see them: > > 1. =C2=A0Do nothing. =C2=A0I think the vote established that this is not = what people > want. Agreed. > 2. =C2=A0Move forward with the semantics of the current patch. =C2=A0This= approach has > substantial drawbacks in my opinion, and is a strong misfit with the rest= of > PHP (again, in my opinion). =C2=A0See previous posts from Stas, Rasmus, m= yself > and maybe others illustrating this point. =C2=A0Lukas'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. =C2=A0Implement 'weak' typing. =C2=A0What does that mean? =C2=A0Conver= sion 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). =C2=A0For exampl= e, if > you denote that an argument is supposed to be an integer, then a string t= hat > looks like an integer (e.g. "17") would be silently converted to an integ= er, > however, a string that does not look like an integer (e.g. "foo") will er= ror > out. =C2=A0We need to come up with a complete pass/fail table, but that w= ould be > the theme. =C2=A0Unlike 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. =C2=A0Agree 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. =C2=A0Make sure people understand *why* we're implementing it - perfor= mance 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. =C2=A0Since the inconsistencies int= roduced > by option #2 are very substantial (between internal and userland function= s, > 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. = =C2=A0In > 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. =C2=A0If people here find it useful I'l= l 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 --=20 Paul Biggar paul.biggar@gmail.com