Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23144 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24917 invoked by uid 1010); 4 May 2006 01:57:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 24902 invoked from network); 4 May 2006 01:57:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2006 01:57:53 -0000 X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 204.11.219.139 lerdorf.com Linux 2.5 (sometimes 2.4) (4) Received: from ([204.11.219.139:51868] helo=lerdorf.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 74/9F-63443-D9F59544 for ; Wed, 03 May 2006 21:57:49 -0400 Received: from [192.168.200.106] (c-24-6-5-134.hsd1.ca.comcast.net [24.6.5.134]) (authenticated bits=0) by lerdorf.com (8.13.6/8.13.6/Debian-1) with ESMTP id k441vfTu016422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 3 May 2006 18:57:42 -0700 Message-ID: <44595F95.6090607@lerdorf.com> Date: Wed, 03 May 2006 18:57:41 -0700 User-Agent: Thunderbird 3.0a1 (Macintosh/20060414) MIME-Version: 1.0 To: "D. Dante Lorenso" CC: Jochem Maas , Rick Widmer , PHPdev References: <44584619.60400@lorenso.com> <200605030815.34801.johannes@php.net> <44585828.1030603@vocalspace.com> <44585E89.6000400@vocalspace.com> <44586BDF.6040600@developersdesk.com> <4459410D.9090802@vocalspace.com> <445942E9.201@developersdesk.com> <44594553.6020009@iamjochem.com> <44594A27.4040201@vocalspace.com> <4459558D.7050703@lerdorf.com> <445959DD.9030607@vocalspace.com> In-Reply-To: <445959DD.9030607@vocalspace.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Seeking 'coalesce' php internal function From: rasmus@lerdorf.com (Rasmus Lerdorf) D. Dante Lorenso wrote: > In my PHP zen world, empty() and filled() are friends. Ok, I've been > selling 'filled()' for a while now. Can we reverse the sell and try > this .. why SHOULDN'T filled() be added to the language? Because it doesn't do enough. Unlike empty(), when there actually is something there, you have to check the type before using it anyway. eg. $a = filled($_GET['a'],$_GET['b']); You still have to do: if(!is_array($a)) echo $a; Because people could put ?a[]=1 in the GET args there and you have to check for that before using it. That second type check defeats the purpose of filled() as far as I am concerned. We need a quick way to do a check and default assignment without throwing a notice which is what ?: provides, then we need a decent way to check input arguments which is what pecl/filter is being brought into the core for (among other things). See: http://www.php.net/~derick/meeting-notes.html#ifsetor-as-replacement-for-foo-isset-foo-foo-something-else By the way, the lack of array checks is rampant out there. Pick just about any PHP site and find a page where it has arguments and add [] to one of them and watch it blow up. In some cases where the developers were smart enough to send errors to their error log, you can't see that you made it blow up, but in surprisingly many you can: http://en.wikipedia.org/w/index.php?title[]=Special:Userlogin&returnto[]=Main_Page -Rasmus