Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75458 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77003 invoked from network); 14 Jul 2014 13:36:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 13:36:50 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.199 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.199 imap11-2.ox.privateemail.com Received: from [192.64.116.199] ([192.64.116.199:38828] helo=imap11-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F7/A6-43645-1FCD3C35 for ; Mon, 14 Jul 2014 09:36:50 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id EEA048800DB; Mon, 14 Jul 2014 09:36:46 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap11.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap11.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LM5CiyUP4HkK; Mon, 14 Jul 2014 09:36:46 -0400 (EDT) Received: from [192.168.0.15] (unknown [90.210.122.167]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 03C5B8800E6; Mon, 14 Jul 2014 09:36:45 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: Date: Mon, 14 Jul 2014 14:36:42 +0100 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <05CE2216-C5D9-4937-9F2E-AA1407284D9F@ajf.me> References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <16D48604-0C0A-4613-91A4-21392E3A2636@ajf.me> To: Chris Wright X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: ajf@ajf.me (Andrea Faulds) On 14 Jul 2014, at 14:33, Chris Wright wrote: > 2) A common-ish use case here would be: >=20 > function foo(bool $bool) {} > foo($flags & A_FLAG); >=20 > The intent of the expression $flags & A_FLAG is obvious to the reader > as fetching a boolean, but the result will often be an integer that is > neither 1 nor 0. This cannot be handled by foo((bool)$flags & A_FLAG); > because of precedence, foo((bool)($flags & A_FLAG)); is messy. Andrea > suggested foo($flags & A_FLAG !=3D 0); which is better but still a > little messy. >=20 > Personally I would rather just accept data loss and stay consistent > with the rest of the language (i.e. condition evaluation), but I do > understand the PoV of those resistant to it. Yeah, that=92s the problem for me. I want things like ($flags & A_FLAG) = to work, but I don=92t want =93foo=94 to work. I suggested on IRC that empty strings, TRUE, FALSE, NULL, and values = that validate for the int type hint could be accepted. Is that a good = idea? Though it feels a bit loose, I think it covers all the important = common use cases. -- Andrea Faulds http://ajf.me/