Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46146 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11166 invoked from network); 21 Nov 2009 17:28:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Nov 2009 17:28:45 -0000 X-Host-Fingerprint: 86.210.33.42 ANantes-552-1-34-42.w86-210.abo.wanadoo.fr Date: Sat, 21 Nov 2009 12:28:43 -0500 Received: from [86.210.33.42] ([86.210.33.42:8028] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F9/B5-13841-B43280B4 for ; Sat, 21 Nov 2009 12:28:43 -0500 Message-ID: To: internals@lists.php.net References: <17.CC.25743.CB6770B4@pb1.pair.com> <84B23126-8011-48DA-B65A-750AA9C5B57E@pooteeweet.org> User-Agent: Pan/0.133 (House of Butterflies) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Posted-By: 86.210.33.42 Subject: Re: [PHP-DEV] suggestion about ternary operator From: seza@paradoxal.org (Alban) Le Sat, 21 Nov 2009 09:48:10 +0100, Lukas Kahwe Smith a écrit : > On 21.11.2009, at 06:12, Alban wrote: > >> This is not a big problem but if a solution exists, this would be so >> cool ! Especialy when we have to check existance of twenty or more key >> in array. Code would be be lighter and clear. Since i use PHP, I always >> have in my 'common function file' a function like that : >> >> function getIssetVar($var, $default) { return ((isset($var)) ? $var : >> $default); } >> >> So is it possible to make a little improvement on this operator or >> introduce a new operator or a core function which do that ? What's your >> feeling about it ? > > > this feature request has already been discussed and declined: > http://wiki.php.net/rfc/ifsetor > > please review this rfc before continuing this thread. > > regards, > Lukas Kahwe Smith > mls@pooteeweet.org Thanks for the link to the RFC :) Excuse me, but I'll be little hard in this post. This for insult the community but I want the community really think about the decision it made and the reason why. I also read why it have been refused here : http://www.php.net/~derick/meeting-notes.html#ifsetor-as-replacement-for- foo-isset-foo-foo-something-else Is it serious ? « The name for this new operator is heavily disputed and we could not agree on a decent name for it. » Tomorrow I will not send food to the association for children who are hungry because I can not choose between offering Thai or basmati rice. Stop sarcasm, seriously, this is not an honorable response from people making decisions. Take your responsibility and make a vote or impose a name, just do it. « Instead of implementing ifsetor() we remove the requirement for the "middle" parameter to the ?: operator. » That's not people wants and that's not do their need. So that not a correct answer of the php developper demand. « In combination with the new input_filter extension you then reach the original goal of setting a default value to a non-set input variable with: $blahblah = input_filter_get(GET, 'foo', FL_INT) ?: 42; » I don't see how do that with the actual filter extension. Even if it is possible, this is not a pretty short and easier solution than : $var = (isset($var)) ? $var : 'default'; Why not add a simple new operator who do the job, this is not needing a name : // set a default value if $var is not set $var ?= 'default'; // equalivalent to : $var = (isset($var)) ? $var : 'default'; -- Alban Leroux seza@paradoxal.org