Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10991 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23409 invoked by uid 1010); 8 Jul 2004 21:52:05 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 23282 invoked by uid 1007); 8 Jul 2004 21:52:05 -0000 Message-ID: <20040708215205.23281.qmail@pb1.pair.com> To: internals@lists.php.net Date: Thu, 08 Jul 2004 17:51:41 -0400 User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 References: <5.1.0.14.0.20040707203931.02fa6200@mail.ionzoft.com> <40ED64A0.7050305@cschneid.com> <20040708151952.92187.qmail@pb1.pair.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 130.58.81.153 Subject: Re: [PHP-DEV] what happened to that new isset() like language From: contact_marcos@yahoo.es (Marc Richards) Rasmus Lerdorf wrote: > On Thu, 8 Jul 2004, Marc Richards wrote: > >>Christian Schneider wrote: >> >> >>>Before it gets forgotten: I still think that >>>$x = ifsetor(mixed var, mixed var [, ...]); >>>with expressions in all parts is the way to go. >>> >>>Example usage: >>>$a = ifsetor($_REQUEST['x'], $db->get('x'), 'default_x'); >>> >> >>The other syntax could work for that as well... >> >>$a = $_REQUEST['x'] ?: $db->get('x') ?: 'default_x'; >> >> >>and with a little white-space it is even more readable: >> >>$a = $_REQUEST['x'] ?: $db->get('x') ?: 'default_x'; > > > That syntax is way too confusing. > > Spotting the difference between: > > $a = $b ?: $c ?: $d; > > $a = $b ? $c : $d; > > is non-trivial and the two would do completely different things. That is true for other things as well: $a = $b += $c += $d; $a = $b + $c = $d; That doesn't make them inheritly evil. Adding white-space and brackets can make it even more readable. $a = ($b ?: ($c ?: $d)); $a = ($b ? $c : $d); > This needs to be a function that people can easily look up in the > documentation. Does it? There are other similar constructs that don't e.g. +=, $a ? $b : $c, .=; I think that part of the reason that these things are so terse is because if would defeat the whole point to use a function name; The aim is to be concise. If what marcus says about only being able to take two areguments is true, then it makes an even stronger case, lest we end up with: $a = ifsetor($b, ifsetor($c, $d)); Marc