Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59866 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45629 invoked from network); 13 Apr 2012 09:37:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2012 09:37:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=paul.konyves@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=paul.konyves@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: paul.konyves@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gy0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:65481] helo=mail-gy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/D1-35770-3D3F78F4 for ; Fri, 13 Apr 2012 05:37:24 -0400 Received: by ghbg2 with SMTP id g2so1703188ghb.29 for ; Fri, 13 Apr 2012 02:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Pytbe5b/r0FK61CTOwiQeyI39bwRXeC/aDEp3aa/0RM=; b=CMyi+z4sgp0lC8RNOfum4aRCDBrsvPOPw4zARwK3kQDQof8wuHXIaIxdjI/yzn3eVX BUoLF/vXNfUVk9g3Z4cQMI9xBtFg4Hv2sJFTEoUKjNpC3DGoChesZ7X0MjSsgrprnQsH +UCIiGYo3tTG6TBP+ixWnrbVNE+0/VADTCOXksDArAL05YoHKzXzpcU3ItaONPtWsV3C WxKh5RXYy6bTJM+kHUhi6yRfVKU8+kxlGETTRvBveLkT1uX2vnAKhe9zb/NDD3FdBMyb MuNjZ58Kl60V9ozQnCCZQsKfj3euzD476rVaAAOdT3gYmTBsWjsOJ69EtLirHszN09Qy Iqpw== Received: by 10.236.184.202 with SMTP id s50mr929412yhm.84.1334309841095; Fri, 13 Apr 2012 02:37:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.147.182.20 with HTTP; Fri, 13 Apr 2012 02:37:00 -0700 (PDT) In-Reply-To: References: <1334271932.4609.161.camel@guybrush> Date: Fri, 13 Apr 2012 11:37:00 +0200 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf303f6522194c8804bd8c38a5 Subject: Re: [PHP-DEV] Allow non-variable arguments to empty() From: paul.konyves@gmail.com (Pal Konyves) --20cf303f6522194c8804bd8c38a5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > Hi! > > "The original reason for this restriction probably is that - in a way - > it "doesn't make sense" to pass anything but a variable to empty()" > > I don't see the point of empty( function() ). > > You tipically use empty on values that holds information you want to use > later in the program flow (a string, an integer). That means you'd better > extract it to a variable because you want to avoid calling twice a functi= on > that provides this value. > > In my opinion, in other cases a 'isThatStuffTrueOrFalse()' function shoul= d > be created to provide the same information as empty( returnThatStuff() ). > They both are yes-no questions, but the preceding one is a better > indication what the program does. > > Pal > > > 2012/4/13 Johannes Schl=C3=BCter > >> On Wed, 2012-04-11 at 00:53 +0200, Nikita Popov wrote: >> > >> > Currently the empty() language construct only works on variables. You >> > can write if (empty($array)) but not empty if (empty(getSomeArray()). >> >> I've mentioned this thought off-list already but let's discuss it >> officially: >> >> A fear I have is that this makes empty more looking like a function, >> while not being one. Right now one notices quite quickly that it is >> something else. Things like $check =3D $condition ? "empty" : "isset"; >> $check($bar); trigger an even more confusing error (Call to undefined >> function) >> >> I'm not sure whether that's a strong argument, but I guess it's good >> enough to be noted :-) >> >> johannes >> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > --20cf303f6522194c8804bd8c38a5--