Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85498 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50939 invoked from network); 27 Mar 2015 08:58:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Mar 2015 08:58:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.172 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.172 mail-wi0-f172.google.com Received: from [209.85.212.172] ([209.85.212.172:37759] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/D1-38005-CAB15155 for ; Fri, 27 Mar 2015 03:58:21 -0500 Received: by wiaa2 with SMTP id a2so21916613wia.0 for ; Fri, 27 Mar 2015 01:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type:subject:from:date:to :message-id; bh=hNMfs0pPEr0/4gP2i/gpNtKB20I3o1nvKRMApndgqPE=; b=hDK0toxW2IOfIm+ptLatThAIro8+uNwRIhq9bwvPkkjsvXQa3NdtjjLDCy9wWKUwIE 1eFW2XggRHBATR26p2940zEjJ5YuWnqDBnpTTDmcs9WXkByE+Qn/7iyb3BtM8QXOtUMe jSLNKhqpvC1ntF+0i/EwfOd9AevP3Jgs4JH7Q1LmmKXzmQGLWqPT1d1jIhwISyypldOG rF4AHrG0v7BK6HJv811Q4HTA4/fgTX0SiCNO9xS5Sxs+ddSMaTh30nZ0upfrWorv0w50 V8v8U2VDqwoRrluLqdg6g0youuUs6mocw8DGAGq/cS/HXjKqQClUPPEAbSXumJyrWeiw SoEg== X-Received: by 10.180.219.102 with SMTP id pn6mr53562175wic.50.1427446697651; Fri, 27 Mar 2015 01:58:17 -0700 (PDT) Received: from [192.168.0.2] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id ub1sm1829079wjc.43.2015.03.27.01.58.16 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Mar 2015 01:58:16 -0700 (PDT) User-Agent: K-9 Mail for Android In-Reply-To: <20150326224056.GB28328@phcomp.co.uk> References: <20150326224056.GB28328@phcomp.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Date: Fri, 27 Mar 2015 08:57:12 +0000 To: Alain Williams ,internals@lists.php.net Message-ID: <822A4769-D028-425A-A1A9-0626414B9B29@gmail.com> Subject: Re: [PHP-DEV] [RFC] Fix the Tenary Operator -- Please!? Please? From: rowan.collins@gmail.com (Rowan Collins) On 26 March 2015 22:40:56 GMT, Alain Williams wrote: >On Thu, Mar 26, 2015 at 10:31:00PM +0000, Rowan Collins wrote: > >> What I've always been annoyed by is the *precedence* of the operator >- having to add brackets to mix it with string concatenation, etc - >which it turns out to is the same in all sorts of languages. > >It is the ''all sorts of languages'' that is key here. The point is >that PHP >associativity for ?: is different from other languages and it is that >that >confuses and leads to bugs. What is right/wrong is not as important as >all >others doing it the other way. This reply is competely out of context to the message you quote. Yes, I know that the *associativity* of the operator is wrong. My contention is that in practice, few people ever try to associate multiple instances of the operator, so few bugs result from it not working. I contrasted this with *precedence*, particularly the precedence of an expression mixing the ternary operator with string concatenation, which is a much more common thing to do. But here, PHP is doing the "right" thing, if measured by other languages doing the same. Personally, I'd be in favour of making the operator non-associative, thus breaking obviously if people try it. Changing it now would result in people using it in PHP 7, then running the code under PHP 5 and having obscure bugs to fix. Regards, -- Rowan Collins [IMSoP]