Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11033 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68734 invoked by uid 1010); 9 Jul 2004 17:19:27 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 67383 invoked from network); 9 Jul 2004 17:18:59 -0000 Received: from unknown (HELO mail.a-s-i.com) (208.42.143.194) by pb1.pair.com with SMTP; 9 Jul 2004 17:18:59 -0000 Received: from romulus.a-s-i.com (localhost [127.0.0.1]) by mail.a-s-i.com (8.12.11/8.12.11) with ESMTP id i69HIwsN023904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 9 Jul 2004 12:18:58 -0500 Received: (from glamm@localhost) by romulus.a-s-i.com (8.12.11/8.12.11/Submit) id i69HIwa1023903 for internals@lists.php.net; Fri, 9 Jul 2004 12:18:58 -0500 X-Authentication-Warning: romulus.a-s-i.com: glamm set sender to glamm@a-s-i.com using -f Date: Fri, 9 Jul 2004 12:18:58 -0500 To: internals@lists.php.net Message-ID: <20040709171858.GA23613@romulus.a-s-i.com> Mail-Followup-To: Bob Glamm , internals@lists.php.net References: <5.1.0.14.0.20040707203931.02fa6200@mail.ionzoft.com> <40ED64A0.7050305@cschneid.com> <20040708151952.92187.qmail@pb1.pair.com> <20040708215205.23281.qmail@pb1.pair.com> <20040708222005.4329.qmail@pb1.pair.com> <20040708233326.73283.qmail@pb1.pair.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040708233326.73283.qmail@pb1.pair.com> User-Agent: Mutt/1.4.1i Subject: Re: [PHP-DEV] what happened to that new isset() like language From: glamm@a-s-i.com (Bob Glamm) > To be honest I am kinda hot and cold about how close it is to the > ternary operator. On the one hand the two could be easily confused, but > on the other hand they are in fact very similar in function in which > case we could "market" (meaning document) them as being related. > > Ternary operator: > > $a = $b ? $b : $c; > > Compound Ternary operator: > > $a = $b ?: $c; Not that my opinion makes much difference, but from an end-user/developer point of view, overloading ?: is not a good idea: a) Every other language that uses ?: (and there are a fair number of them) gives it the same behavior: if/then/else. Adding additional functionality to ?: would be entirely unexpected. b) Upon seeing this initially, my first guess at functionality: $a = $b ?: $c; My guess is that it would imply that $a is set to NULL or becomes undefined in the case that $b evaluates to true, and set to $c if $b evaluates to false. Note that this is completely different from what actually happens. In this instance, if I've not encountered the operator before, I'm more likely to assume that my guess at its functionality is correct. However, if it's $a = function_name($b, $c); I'll immediately go to www.php.net/manual to look up 'function_name'. As far as introducing operators to PHP that have no equivalents in other common languages: IMHO you'd need a very strong case to introduce them for precisely the two reasons outlined above, most likely some new programming paradigm that occurs often enough and is similar enough in functionality to one of the current set of operators to justify using an operator as a shortcut for it. -Bob