Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82604 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95633 invoked from network); 13 Feb 2015 11:38:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Feb 2015 11:38:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=reeze.xia@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=reeze.xia@gmail.com; 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: reeze.xia@gmail.com X-Host-Fingerprint: 209.85.212.179 mail-wi0-f179.google.com Received: from [209.85.212.179] ([209.85.212.179:60453] helo=mail-wi0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 84/86-62214-A32EDD45 for ; Fri, 13 Feb 2015 06:38:35 -0500 Received: by mail-wi0-f179.google.com with SMTP id hi2so11359783wib.0 for ; Fri, 13 Feb 2015 03:38:32 -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=Xng3dRqQKAPx+SsYYtHnNmEhi0LAO2omSvaDCpWuZx8=; b=Wb2AAKdoDLDTmduROOdhUAJXOZczRcv2UW2PrV65kFqSPqxGATRG9Nzu6JchpJNHwH JEPv91UsoJhY3a8OtTHNT9Ysh2ZGrZTvkntIm8jek/8OdFfaqNn3Y/SsvfxA8AOfd8WX P4MMdH8wE2nxiy++6ncjMVSZTUGZPpxzFCeYpoXtoaOHcCV4OfqOO65UzgQM70p9/0+c R2Wzicy1BNfYCd3v/p/6S5uSfIwrP3YG8bEPvmF7IwP16Bxl/X92qs8sf4PXp+QmJSaf ha7Cu+sCf1VguWWjWy10jy1Bo25yKCGBcuLKVeB1WLMsHkA2J+UalfhBdyxcY8L6ajsu FhTg== X-Received: by 10.180.91.5 with SMTP id ca5mr15561301wib.13.1423827512077; Fri, 13 Feb 2015 03:38:32 -0800 (PST) MIME-Version: 1.0 Sender: reeze.xia@gmail.com Received: by 10.194.193.5 with HTTP; Fri, 13 Feb 2015 03:38:11 -0800 (PST) In-Reply-To: <1E15BAAB-C8FC-49A9-B73F-E0E7DEFA208D@ajf.me> References: <54DDA797.4030501@php.net> <1E15BAAB-C8FC-49A9-B73F-E0E7DEFA208D@ajf.me> Date: Fri, 13 Feb 2015 19:38:11 +0800 X-Google-Sender-Auth: 4rUgcveg7ztKs5GGul-_nfqdA6k Message-ID: To: Andrea Faulds Cc: Michael Wallner , Thomas Punt , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f46d043c7e12142f12050ef6ad65 Subject: Re: [PHP-DEV] [DISCUSSION] Make empty() a Variadic From: reeze@php.net (reeze) --f46d043c7e12142f12050ef6ad65 Content-Type: text/plain; charset=ISO-8859-1 Hi, On 13 February 2015 at 19:31, Andrea Faulds wrote: > > > On 13 Feb 2015, at 11:16, Andrea Faulds wrote: > > > > Hey, > > > >> On 13 Feb 2015, at 07:28, Michael Wallner wrote: > >> > >> On 12/02/15 19:55, Thomas Punt wrote: > >> > >>> I'd like to propose to make empty() a variadic, where if any > >>> arguments passed in are considered empty, then false is returned > >> > >> Should that read "if any arguments passed in are considered *NOT* empty, > >> then false is returned"? > > > > No, I think it's correct, if confusingly phrased. I believe Thomas is > proposing variadic empty() where TRUE is returned if any of its arguments > are empty, otherwise FALSE. So, empty($a, $b, $c) would be equivalent to > empty($a) || empty($b) || empty($c), much like isset($a, $b, $c) is > equivalent to (and implemented as) isset($a) && isset($b) && isset($c). > > Wait, I think I made a mistake. > > * Thomas proposed "if any arguments passed in are considered empty, then > false is returned", i.e. !(empty($a) || empty($b) || empty($c)) if his > words are taken literally. This doesn't make much sense, I think it was a > mistake. > * You suggested he may have meant "if any arguments passed in are > considered *NOT* empty, then false is returned", i.e. (empty($a) && > empty($b) && empty($c)) > * I assume Thomas actually meant "where if any arguments passed in are > considered empty, then *true* is returned", i.e. (empty($a) || empty($b) || > empty($c)) > > Sorry for the confusion. > > I think the || behaviour is the most useful, as it's the analogue of > isset's. So !empty($a, $b, $c) would work similarly to isset($a, $b, $c), > and similarly, !isset($a, $b, $c) would work similarly to empty($a, $b, $c). > For example: echo $a, $b, $c, & empty($a, $b, $c), they are treated equal, if the empty() means if any one of them is empty then result is TRUE, the advantage of it disappeared: if (empty($a, $b, $c)) { // you might want to check it again. if (empty($a)) { //blah blah. } else if (empty($b)) { } } > > But that's just my opinion. :) > -- > Andrea Faulds > http://ajf.me/ > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Reeze Xia http://reeze.cn --f46d043c7e12142f12050ef6ad65--