Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:9275 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61005 invoked by uid 1010); 16 Apr 2004 20:02:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 60789 invoked from network); 16 Apr 2004 20:02:34 -0000 Received: from unknown (HELO theta.altoona-pa.com) (209.161.72.28) by pb1.pair.com with SMTP; 16 Apr 2004 20:02:34 -0000 Received: from ionzoft-jeg.ionzoft.com (dpvc-207-68-114-163.alt.east.verizon.net [207.68.114.163]) by theta.altoona-pa.com (Postfix) with ESMTP id DE99813E46 for ; Fri, 16 Apr 2004 16:02:34 -0400 (EDT) Message-ID: <5.1.0.14.0.20040416160223.00ba1c90@mail.ionzoft.com> X-Sender: izftjason@mail.ionzoft.com X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Fri, 16 Apr 2004 16:02:42 -0400 To: internals@lists.php.net Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [RFC] ifsetor operator From: jason@ionzoft.com (Jason Garber) I completely agree with the EXACT way Marcus has proposed this operator. The key is that the first argument must be a Variable, because it is tested to see if it ISSET(), not if it's null. That is why you can't have any expression for the first argument - it would be like calling isset('foo'), which does not make any sense. I think that this internal function addresses the need exactly, and that the correct solution has been arrived at. Thanks Marcus! Sincerely, Jason Garber At 4/16/2004 09:38 PM +0200, Marcus Boerger wrote: >[RFC] ifsetor operator > >Hello List, > > i also agrre that an internal function is much better. And here is >it as such an internal function (that does not result in an expensive >function call). > >Synopsis: "ifsetor" "(" value "," default ")" > > Returns the value if it exists or a given default value. > >Syntax: "ifsetor" "(" variable [ "," expression ] ")" > >Semantic: > - The value in question must be a variable. > - The default value can be any expression. > - The default value can be omitted in which case NULL will be used. > >http://marcus-boerger.de/php/ext/ze2/ze2-ifsetor-20040416-2.diff.txt > >best regards >marcus > > >Friday, April 16, 2004, 2:12:04 AM, you wrote: > > > Hello Jason, > > > here is your operator patch: > > http://marcus-boerger.de/php/ext/ze2/ze2-ifsetor-20040416.diff.txt > > > currently it uses the following syntax: > > > $var $: $defaul > > > which would equal > > > isset($var) ? $var : $default > > > Notice that at the moment the operator is '$:' and not '?:'. This is > > because i haven't looked on how to solve the conflicts i get when i > > use '?:'. If there is more interest in that operator i could invest > > more work in trying to fix that problem. > > > best regards > > marcus > > > According to your options and the possibility to implement this as a > > function. That would only work as a parser internal function like empty > > or set. Doing so would be very easy i guess. Though it would require a > > new keyword say 'ifsetor' (which reflects its purpose more as 'setor'). > > > best regards > > marcus