Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82925 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30234 invoked from network); 17 Feb 2015 06:04:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2015 06:04:15 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.223.172 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.223.172 mail-ie0-f172.google.com Received: from [209.85.223.172] ([209.85.223.172:40142] helo=mail-ie0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/E0-24654-ED9D2E45 for ; Tue, 17 Feb 2015 01:04:14 -0500 Received: by iebtr6 with SMTP id tr6so28157369ieb.7 for ; Mon, 16 Feb 2015 22:04:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=wUMr68nT9/dWEgRW/dKlWRs61cbc4/PlTe19rLRbzfQ=; b=QZiM8LVAYOggKihDceHN4hFete8B8/TrwAh+J9RFIOyZUzKttrB/xiAPG1KlKTuVIm hhuPcXWLiLHJYXz4OGaGFLy5agpiQWdkzg7VDis/iP0N7L8eQdEvW3bFD1Z3OJ22zTHu wElvj52S9oAsjr6dyzFcFSy28fY/28dY/2YLGuBxQO8TUEhSePGuqEIH8cgM/DyzlLXD 4PdVvrs8iMVMm8MUcCLpx+uV90eZg+J98WX+rnDOjRjSq/gm3onhKPfLXSksld5k36KL SpWrZP6emURjqsLaIzVcKftzj4i5uhA/o+6O7weQlomiVGVrfqMPCm2ksKC6yngnNtg8 uTjA== X-Gm-Message-State: ALoCoQlMKBFMzSY8uRbZWTuNQNbLsIkq8jq1ab+KY6HE2+RDgA1bSYsUPFnAvjvbePbZjyDlbsM3jevwRI0kcXduN0Z2sZImSpArM/+dXzTFUwjsLD2+kvdETCTsKRKvJvhRB4mY7KocCYcijf+D8fMYD1n9tdo7LQ== X-Received: by 10.43.103.8 with SMTP id dg8mr32837488icc.18.1424153051210; Mon, 16 Feb 2015 22:04:11 -0800 (PST) References: <011801d04a07$83ab1c00$8b015400$@php.net> <016f01d04a3a$e9183220$bb489660$@php.net> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-index: AQGD0sLDaA+/0NIeBlQhQC5OtPA/xwHih9+6AanvcsEBj7eMC51kYKqA Date: Tue, 17 Feb 2015 08:04:10 +0200 Message-ID: To: Sara Golemon , francois@php.net Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: RE: [PHP-DEV] Reviving scalar type hints From: zeev@zend.com (Zeev Suraski) > -----Original Message----- > From: php@golemon.com [mailto:php@golemon.com] On Behalf Of Sara > Golemon > Sent: Tuesday, February 17, 2015 1:58 AM > To: francois@php.net > Cc: Philip Sturgeon; Arvids Godjuks; Jefferson Gonzalez; Rowan Collins; > PHP > internals > Subject: Re: [PHP-DEV] Reviving scalar type hints > > On Mon, Feb 16, 2015 at 2:50 PM, Fran=C3=A7ois Laupretre > wrote: > > Once again, anyone can take over version 0.3, if it is so great. Why > > don't > you do it ? > > I will play the game, stop working on my proposal, and vote 'yes' again= . > > But don't ask me to do it in your place. > > > If nobody else does it, I will. > > I think Andrea's 0.3 proposal was extremely well balanced, served > everyone's > needs whether they would admit it or not, and who's only failing > (subjectively > termed) was the use of declare(). I think > declare() is fine and not nearly as ugly as some have slandered it to be, > but > I'm willing to read the winds and modify it for v0.4. > > Straw poll: > 1) int or string->float conversions, when the string looks *exactly* like a number. Given almost all of our inputs (from databases, forms, files, etc.) come in string form, that's by far the conversion that's going to give us the most trouble - and is most probably the use case that by far is going to result the largest amount of explicit casts to work around that problem. What if strict mode didn't just blindly check zval.type, but actually allowed for this one type of conversion to go through without a problem? No bool to int. No Apple to int. No "123 testing" to float. Just "32" to 32 and "37.7" to 37.7. Can the strict supporting camp consider that option? Judging by the examples brought up by proponents of v0.3, this type of conversion isn't their issue. It's the 'obviously wrong' conversions that bug them. As a secondary concern I'd put int to float conversions where no (meaningful) data is being lost, e.g. 37 -> 37.0, even though a tiny bit of accuracy is lost. Rejecting this particular conversion places us at being stricter than mostly all other languages. That said, it's a much less common conversion so I don't feel nearly as strongly about it as the string one. Last, regarding internal functions, I do agree with Rasmus and Drew. Again= , judging by the examples brought up as a part of the discussion, it seems a= s if we gave ZPP developers a standard easy way of being a lot more picky about the types of values of particular arguments, and allowing them to do this selectively for those places that are very sensitive (e.g. curl_setopt()) would be a more suitable solution than just turning strict validation for all internal functions, which were built with very very different assumptions in mind. The biggest difference between internal functions and userland functions in the context of this RFC is that with userland functions, we're starting with a clean slate. There are no type hint definitions anywhere, developers can selectively add them as they see fit. With internal functions, we have type requirements EVERYWHERE already= , but with semantics that didn't take strict typing into account at all and evolved for almost 20 years. Strict typing the way it is now would radically change these semantics overnight, and will make the adoption of strict a much bigger headache than it can be, as I believe Rasmus demonstrated. I think addressing these issues could get us a LOT closer to consensus and make a lot of those who voted 'no' on v0.3 vote yes on v0.4. Thanks for your consideration. Zeev