Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60451 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45539 invoked from network); 4 May 2012 21:18:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2012 21:18:08 -0000 Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:34070] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DD/74-18322-F8744AF4 for ; Fri, 04 May 2012 17:18:08 -0400 Received: by werb13 with SMTP id b13so2353149wer.29 for ; Fri, 04 May 2012 14:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=DxQGCjwhslhFUCVUG7Z2W7ioJIbEwLO0/xoOL6KDegM=; b=knofmTJDW4SXZd5Ae6qbj3c/Oe4QUVgSZ+lAXqCGAOgUnN51yetX5lJF3fPaB3Sr7Y ynNbaADFNj019LPTOBdbE0CkSg6ja8pxmHPZnBdpsTZac+Bx9iI6VV6i8wmsPc0tMNV3 3nKK3SVTryH5Fb0qjxIuKk+QMA5N1csE4bMO8xYcYZ8aSr+uJEaZDv25rG//s/9tEJmi gK4sf2elcEv9l4bfsM2AIkSRt4jk4I4KkE14xS8snOuw4A6u6eSEirrzqj9gHyPHlwtv MaX0V4zauFpqQZ7RRGrPPoaalDwdI4Wob1asXnI8/kULzf1PlbIzg7PD7lt8IMoYp1Tv zvUA== MIME-Version: 1.0 Received: by 10.180.77.233 with SMTP id v9mr16094836wiw.22.1336166283777; Fri, 04 May 2012 14:18:03 -0700 (PDT) Received: by 10.223.96.129 with HTTP; Fri, 4 May 2012 14:18:03 -0700 (PDT) In-Reply-To: References: <396c1a02d4e7195f2b89e26ace2276a6.squirrel@www.l-i-e.com> Date: Fri, 4 May 2012 14:18:03 -0700 Message-ID: To: Ferenc Kovacs Cc: Richard Lynch , PHP internals Content-Type: multipart/alternative; boundary=f46d043d6461b495c304bf3c74b7 Subject: Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset() From: kris.craig@gmail.com (Kris Craig) --f46d043d6461b495c304bf3c74b7 Content-Type: text/plain; charset=ISO-8859-1 On Fri, May 4, 2012 at 1:27 PM, Ferenc Kovacs wrote: > >> I've been following the debate and I'm still a bit unclear as to what the >> benefit would be to allowing non-variables in isset(). I mean, as was >> stated earlier, expressions are neither "set" nor "unset". Furthermore, >> if >> you were to assign a variable to any valid expression (empty or >> otherwise), >> it would be considered "set". Therefore, through simple deductive logic, >> would an expression passed to isset() not, by definition, *always* return >> >> TRUE if the expression itself is syntactically valid? >> > > yeah, this wouldn't be much to think about if isset in php wouldn't handle > null values as not set. > Hmm I'd never really thought about that before. But now that you mention it, that does sound like a problem. Honestly, I can see no value in maintaining a different "standard" for what constitutes a set or not-set variable depending on the function. While I understand Pierre's point that people have used $var = NULL; in the past to unset variables, I don't think we should actually be supporting that. After all, $var = (anything, including nothing) is, by definition, "setting" the variable to something (or nothing). I would analogize this to a printed dictionary. Let's say you look up the word, "glarbofatass". It's not there. So you take out another dictionary and look it up again. There's an entry for it, but the entry says, "This word has no meaning." In the first dictionary, "glarbofatass" is not set. In the second dictionary, "glarbofatass" is set to the state of having no meaning. Nevertheless, it *is* set. I've never thought of setting something to NULL as being *literally *the same thing as unsetting it (though the purpose and end result are mostly the same). If we didn't have an unset() function, I might feel differently about this. But we do, so really I don't see why "= NULL" needs to be an alias for unset(). To be honest, I doubt this would pose any real BC breakage, either, unless someone can point me to an instance where somebody uses "= NULL" to unset a variable and then checks it with isset() later, expecting FALSE. Personally, I would consider "= NULL" == unset() but only as it pertains to isset() to be a bug that should be fixed, not a "feature" that should be preserved. And if we make that change (perhaps target it for PHP 6 since it would nonetheless pose a fundamental logic change, albeit an extremely minor and low-impact one), then this RFC suddenly makes a lot more sense while allowing the scope to be limited to empty() without creating any annoying contradictions. --Kris --f46d043d6461b495c304bf3c74b7--