Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73501 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52613 invoked from network); 1 Apr 2014 13:24:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Apr 2014 13:24:41 -0000 Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:44632] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/30-50797-81EBA335 for ; Tue, 01 Apr 2014 08:24:41 -0500 Received: (qmail 26803 invoked from network); 1 Apr 2014 15:24:36 +0200 Received: from heim-033-53.raab-heim.uni-linz.ac.at (HELO RoLaptop) (193.171.33.53) by ns73.kreativmedia.ch with (AES128-SHA encrypted) SMTP; 1 Apr 2014 15:24:35 +0200 To: Date: Tue, 1 Apr 2014 15:24:33 +0200 Message-ID: <004a01cf4dad$b8bfc410$2a3f4c30$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: Ac9NrYZeDSj0ThZFQ9aan7PDtxlbAw== Content-Language: de-ch Subject: Weak logic operators From: php@tutteli.ch ("Robert Stoll") Heya, I wrote my question already on the general list but got no answer. Maybe someone on this list can help me out. I was wondering for what reason PHP has weak logic operators. So far I have only used the weak logic operator 'or' in the following situation: foo() or die("nooo"); And it is quite a long time ago I have used it the last time. You could also write the following instead: if(!foo()){ die("noooo"); } I am aware of that one can use 'or' and 'and' as substitute for || and && if using brackets in addition: $a = ( foo() and bar() ); But I do not really see the benefit of writing it this ways. I think the weak logic operators just add more complexity to the language and hence decrease maintenance. Moreover they are a source of confusion (should I use 'or' or || etc.). The situation for the operator 'xor' is even worse than for 'or' and 'and' in my opinion, since it has no short-circuit and one could use ^ instead of xor: $a = ( foo() xor bar() ); Could be written as follows: $b = foo() ^ bar(); So I am curious, are there other use cases out there that justify the existence of those operators? Cheers, Robert