Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82270 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26883 invoked from network); 9 Feb 2015 11:21:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Feb 2015 11:21:25 -0000 Authentication-Results: pb1.pair.com header.from=andigutmans@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=andigutmans@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.179 as permitted sender) X-PHP-List-Original-Sender: andigutmans@gmail.com X-Host-Fingerprint: 209.85.212.179 mail-wi0-f179.google.com Received: from [209.85.212.179] ([209.85.212.179:55129] helo=mail-wi0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/6F-50460-43898D45 for ; Mon, 09 Feb 2015 06:21:24 -0500 Received: by mail-wi0-f179.google.com with SMTP id l15so16380424wiw.0 for ; Mon, 09 Feb 2015 03:21:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=/C/J1aMirodMQ9Xwm5/MhEypiImmnVbg8WKoMpB8GYc=; b=sMdXG4ua4UWpo5Pk9Zawqa6JHO27tslVR1XIKOZYUC+ZohYFAJVIrd/eosf8jVs7kv ryXnTL8PJBgIhKFyOWaX7Yb80Xwzy4p2N6IBuUpEikLAnOTIOK1L1Ec72AMHAKZLdgsr SwgSXEWJf0gKa3m495TtlGjpqCxTzAoHEtN6AA58J5CELjuBeI7jzOJFWAjuj9HDqeBH jhBobSjLLXtSbj3cfRsEvUTr7T56gIBy16e87mAi0eZJbHxbUgI4Yxi42elp8mWirb8O WBKzdp9545UFnccPm/OPJmtcmNy6f6WMWY1LLnVuORTxdfeaTRuCV0tdzBxuAyMSjsgJ QEyg== X-Received: by 10.180.73.239 with SMTP id o15mr33874528wiv.14.1423480881323; Mon, 09 Feb 2015 03:21:21 -0800 (PST) Received: from [10.54.141.51] ([88.128.80.42]) by mx.google.com with ESMTPSA id r3sm13977678wic.10.2015.02.09.03.21.20 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Feb 2015 03:21:20 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: <54D6DD7E.5060602@lerdorf.com> Date: Mon, 9 Feb 2015 03:21:20 -0800 Cc: Andrea Faulds , PHP Internals X-Mao-Original-Outgoing-Id: 445173680.26578-e020bd000fe45919403111b95d3e8fc4 Content-Transfer-Encoding: quoted-printable Message-ID: <0A7EF057-B482-4AA7-A151-6CFF61ACE087@gmail.com> References: <8703B53E-2C4A-4AC6-95C4-D4F19C6D5221@ajf.me> <9E1C2427-0295-4F3E-BD29-04DA84321067@ajf.me> <54D6CC39.50708@lerdorf.com> <93AAEA55-1C03-46AD-88D0-6A2F5531FCA6@ajf.me> <54D6DD7E.5060602@lerdorf.com> To: Rasmus Lerdorf X-Mailer: Apple Mail (2.2070.6) Subject: Re: [PHP-DEV] [VOTE] Scalar Type Hints From: andigutmans@gmail.com (Andi Gutmans) > On Feb 7, 2015, at 7:52 PM, Rasmus Lerdorf wrote: >=20 > On 02/07/2015 09:51 PM, Andrea Faulds wrote: >>> tan(1); >>> echo strstr("test", "est", 1); >>=20 >> Banning int->float and float->int is both a pain point and sometimes = a life-saver. It=E2=80=99s annoying that tan(1) doesn=E2=80=99t work. On = the other hand, you discover if your ints floats would be silently = truncated (as I did with PictoSwap). >>=20 >> I wouldn=E2=80=99t say that int->string not working is a problem, = though. Seeing something like strstr(=E2=80=9Ctest=E2=80=9D, =E2=80=9Cest=E2= =80=9D, 1); is rather confusing. Looking at it, I=E2=80=99d think the = third parameter is some sort of number for you to want to pass an = integer to it. If I want a string, I=E2=80=99ll use one. >=20 > This isn't int->string. This is int->boolean. The 3rd arg to strstr() = is > a boolean and passing 1 instead of true makes it blow up. It is very > very common for people to pass 0 or 1 in place of true/false to all > sorts of things in PHP. Thanks for those relevant examples. I think it=E2=80=99s also worth emphasizing that in C people frequently = work around this by forcing casts. The value of strict typing diminishes = quickly and the code ends up being less readable. I think in PHP this is going to be even more so due to the reasons = Rasmus states. We have *a lot* of places like this which will lead to = unnatural acts and code which is no more strict than it was before (just = not as pretty). Andi=