Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11040 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59996 invoked by uid 1010); 9 Jul 2004 19:24:00 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 59922 invoked from network); 9 Jul 2004 19:24:00 -0000 Received: from unknown (HELO smtp802.mail.sc5.yahoo.com) (66.163.168.181) by pb1.pair.com with SMTP; 9 Jul 2004 19:24:00 -0000 Received: from unknown (HELO notebook.local) (toddruth@sbcglobal.net@69.111.214.103 with login) by smtp802.mail.sc5.yahoo.com with SMTP; 9 Jul 2004 19:23:59 -0000 Reply-To: truth@proposaltech.com To: Cris H Cc: internals@lists.php.net In-Reply-To: <20040709190753.87430.qmail@web25102.mail.ukl.yahoo.com> References: <20040709190753.87430.qmail@web25102.mail.ukl.yahoo.com> Content-Type: text/plain Message-ID: <1089401037.2319.30.camel@notebook.local> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 09 Jul 2004 12:23:58 -0700 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] what happened to that new isset() like language From: truth@proposaltech.com (Todd Ruth) That would satisfy some of the requested feature, but try calling ifsetor($my_array['bad key'], functionWithSideEffects()). Marcus has repeatedly mentioned that the requested feature is hard (bordering on impossible) to implement, but in the requested feature (if I understand it (and it is what I would ask for too :) )), there would be no error for using a key that isn't in the array, there would be no side effect of creating a key in the array, and if the $my_array['bad key'] actually did happen to be non-NULL, the function with the side effects wouldn't get called. That would be really handy, especially if it could take a variable number of arguments. Using a standard name like coalesce would be nice. BTW, I have no weight around here; just thought I could help clarify, having following this thread with interest... - Todd On Fri, 2004-07-09 at 12:07, Cris H wrote: > Isn't this problem solvable with just a "User Space" function? > > > error_reporting(E_ALL); > > function ifsetor(&$variable, $alternate = NULL){ > if(isset($variable)){ > $tmp = $variable; > echo('

$variable exists.

'); > } > else{ > $tmp = $alternate; > echo('

no $variable here.

'); > } > return $tmp; > } > > // no errors thrown ... > > $nonexistent = ifsetor($nonexistent); > ifsetor($randomNonexistent); > > if($nonexistent !== NULL) > echo('

$nonexistent is NOT NULL

'); > else > echo('

$nonexistent is NULL

'); > > ?> > > Because, as Derick Rethans mentioned, arguments passed by > reference will not trigger the Undefined (variable | index) > Notice at the point of the function call, and also PHP's C++ > style default arguments providing the alternate value, surely > the above code would suffice? > > Apologies if I've completely misunderstood (with certainty a > non-zero probability)... > > Regards, > > Cris > > > > > > ___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com