Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70094 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65608 invoked from network); 10 Nov 2013 21:24:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Nov 2013 21:24:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.50 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.50 mail-la0-f50.google.com Received: from [209.85.215.50] ([209.85.215.50:33904] helo=mail-la0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/61-58055-D69FF725 for ; Sun, 10 Nov 2013 16:23:58 -0500 Received: by mail-la0-f50.google.com with SMTP id eo20so3334842lab.23 for ; Sun, 10 Nov 2013 13:23:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=pVJaoGwdEpiXk0OFFuT/SopK4qHB4qAN6BEuMeh1sbg=; b=xQGU0Pi7UT7SG3Tnp+8qPCroOYKX6uwTxiu1kRu0NV/rhQM8qj10ctUFR6aAqdygYj Zdbfaa3W5EMn+RKeMn63ZJBJ8XIulW1L0JBhXWqRMd4qHyKRl+EuT2wIO17+srG16cTn 9CBNdz+eflaRZvknA9RM+6ntiFQSR0win92aB0A3lDda9JmXQKbLu7DPwd81yS5eePRq X+egt8782QsX2unDFI7lYfTcSotQ1GOlfBb0oLx2BZpDmi/dmwoRuyhOoKNW/LDC0TlM q2KVfTJ04LiUQX5SGcexulcOg/493JzXKK8TIz351wz+H/loxLkKh/pMN6t0D0FUdenS W9uA== X-Received: by 10.112.190.65 with SMTP id go1mr19460611lbc.16.1384118634664; Sun, 10 Nov 2013 13:23:54 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.154.201 with HTTP; Sun, 10 Nov 2013 13:23:14 -0800 (PST) In-Reply-To: <1337538879.20131110161144@cypressintegrated.com> References: <38311741.20131110152833@cypressintegrated.com> <1337538879.20131110161144@cypressintegrated.com> Date: Mon, 11 Nov 2013 06:23:14 +0900 X-Google-Sender-Auth: dKRl4EDxNXKZXxk8KbFTpeG15vY Message-ID: To: Sanford Whiteman Cc: Yasuo Ohgaki Content-Type: multipart/alternative; boundary=001a11c34b7c8bd88604ead93baa Subject: Re: [PHP-DEV] Re: [RFC] Comparison and conversion inconsistency - need more info From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c34b7c8bd88604ead93baa Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Nov 11, 2013 at 6:11 AM, Sanford Whiteman < swhitemanlistens-software@cypressintegrated.com> wrote: > OK, first throw out EVERYTHING you have assumed to date. > > Now, realize that PHP has a documented rule of comparing booleans to > integers (this rule is found in the "NULL or boolean - to - anything" > part of the page on comparison). > > The rule is: compare as booleans, where FALSE < TRUE. > > So take > > FALSE < -100 > > How do we compare them as booleans? > > =E2=80=A2 FALSE is already a bool: use FALSE > > =E2=80=A2 cast -100 to bool: use TRUE > > So the effective strict comparison is > > FALSE < TRUE > > By the definition of boolean comparison in PHP, this expression must > be TRUE. > > How about > > TRUE < -100 > > Compare as booleans? > > =E2=80=A2 TRUE is a boolean: use TRUE > > =E2=80=A2 cast -100 to bool: use TRUE > > So we've got > > TRUE < TRUE > > By the definition of non-object comparison in most any language > (including PHP), this expression is FALSE. > Root cause of my misunderstanding is wrong assumption that BOOL/NULL are evaluated as INT, but it's BOOL. Thank you for your time. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c34b7c8bd88604ead93baa--