Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23104 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79046 invoked by uid 1010); 3 May 2006 06:17:47 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 79025 invoked from network); 3 May 2006 06:17:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 May 2006 06:17:46 -0000 X-PHP-List-Original-Sender: steph@zend.com X-Host-Fingerprint: 192.38.9.232 gw2.emini.dk Linux 2.4/2.6 Received: from ([192.38.9.232:12216] helo=gw2.emini.dk) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 00/FE-31513-80B48544 for ; Wed, 03 May 2006 02:17:44 -0400 Received: from foxbox (IGLD-84-229-199-69.inter.net.il [84.229.199.69]) by gw2.emini.dk (Postfix) with ESMTP id AB42EAFA4C; Wed, 3 May 2006 08:17:30 +0200 (CEST) Message-ID: <048001c66e79$0e1170c0$6602a8c0@foxbox> Reply-To: "Steph Fox" To: "D. Dante Lorenso" Cc: References: <44584619.60400@lorenso.com> <44584835.1030807@vocalspace.com> Date: Wed, 3 May 2006 08:16:01 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Subject: Re: [PHP-DEV] Seeking 'coalesce' php internal function From: steph@zend.com ("Steph Fox") D. Please read the mailing list archives. And don't mention it again ;) - Steph ----- Original Message ----- From: "D. Dante Lorenso" To: Cc: Sent: Wednesday, May 03, 2006 8:05 AM Subject: Re: [PHP-DEV] Seeking 'coalesce' php internal function > D. Dante Lorenso wrote: >> I don't think something like this can NOT be written in userspace >> because the 'isset' and 'empty' checks need to be run before arguments >> can be passed to a user function or warnings will start flying. A >> function like this simplifies code which used to look like this: >> >> if (!empty($_POST["postkey"])) { >> $value = $_POST["postkey"]; >> } >> elseif (!empty($_GET["getkey"])) { >> $value = $_POST["getkey"]; >> } >> elseif (!empty($default_value)) { >> $value = $default_value; >> } >> else { >> $value = "hard coded value"; >> } >> >> Into this: >> >> $value = coalesce($_POST["postkey"], $_GET["getkey"], >> $default_value, "hard coded value"); > > I mean "I DON'T think like this CAN be written in userspace". And, yes, > there is a bug in that code up above (around $_GET testing), but the > 'coalesce' function removes the test/set with identical values so > removes those kinds of careless bugs. > > Dante > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > > __________ NOD32 1.1380 (20060125) Information __________ > > This message was checked by NOD32 antivirus system. > http://www.eset.com > >