Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68251 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29360 invoked from network); 20 Jul 2013 04:44:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jul 2013 04:44:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.220.51 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.220.51 mail-pa0-f51.google.com Received: from [209.85.220.51] ([209.85.220.51:59890] helo=mail-pa0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 33/5D-13120-0C51AE15 for ; Sat, 20 Jul 2013 00:44:49 -0400 Received: by mail-pa0-f51.google.com with SMTP id lf11so5164170pab.10 for ; Fri, 19 Jul 2013 21:44:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:x-originating-ip:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=1iOdFLcwVuq3m2Y24HRGRPUz0zXHkZlei5L84a3l0Mc=; b=Zy6t+5T7aZJYPP04rcZ/4+MaLExhW9LBp2UPu9ulIjsWMFDEnlhawrc8F4FC/GQ3tL m727hjHKibvDzfoFPCuCOYyzlrRCuEWezqjPtvcI+fGseU+HXID1oS6YpPw1Ff1GXz1s Oiu54XVXOkRTdsHklQ2mGoxwt7v4PnCc1OVRY3vGwhuYDeDTRft8Z9b0vfKLn7Psr51W GRZ+f4EQPqOytJhSeMP1fs3ZxWKJbm/MC+R28zX5HxNXZuMuUl162yo4E9dchCCqd5Ga rJbv5RbT+3hijyqAvJf+iygaheQZCrDcI0LFHsk4xt4ZeRAtR+8TXIxkSO8cUQs6Z/eY Xszw== MIME-Version: 1.0 X-Received: by 10.68.173.97 with SMTP id bj1mr20544555pbc.176.1374295486379; Fri, 19 Jul 2013 21:44:46 -0700 (PDT) Sender: php@golemon.com Received: by 10.70.128.71 with HTTP; Fri, 19 Jul 2013 21:44:46 -0700 (PDT) X-Originating-IP: [98.210.180.187] In-Reply-To: References: Date: Fri, 19 Jul 2013 21:44:46 -0700 X-Google-Sender-Auth: cSsPKRAEWxN_SlLvFWBswNdmK-s Message-ID: To: Yasuo Ohgaki Cc: Sherif Ramadan , PHP internals Content-Type: multipart/alternative; boundary=047d7b339f17484ef504e1ea1a71 X-Gm-Message-State: ALoCoQlmz30wc2KEUS9E//iVkXvGUZgGB9DZW9AhG174wL7ibBYZuppjQqRUVFwM2KPmWTnYS0W6 Subject: Re: [PHP-DEV] Operator precedence is undefined? From: pollita@php.net (Sara Golemon) --047d7b339f17484ef504e1ea1a71 Content-Type: text/plain; charset=ISO-8859-1 What's undefined isn't the relationship between preinc/postinc and add. What's undefined is the use of multiple preinc/postinc operators within a single expression (preincrements in particular). Our parser grammer, as it currently stands, does have a predictable order, but that is a side-effect of implementation. The language's definition of order of resolution of multiple preinc/postinc elements within a single ticked statement is that they are undefined. And *that* is what made your *particular* change to the documentation incorrect. If you'd like to define behavior for: echo ++$a + 1; then that's a different matter. Defining the behavior of ++$a + $a++, however is inviting misunderstanding*. What was inappropriate, was asking for comment, receiving comment which cited an issue, then committing without discussing that issue first. -Sara * Even if, technically, either order of evaluation will result in the same answer for this contrived expression. ++$a * $a++ is a more obviously ambiguous answer for a language which explicitly does not define an order of resolution. On Fri, Jul 19, 2013 at 9:28 PM, Yasuo Ohgaki wrote: > Hi Sara, > > 2013/7/20 Sara Golemon > >> On Fri, Jul 19, 2013 at 7:16 PM, Yasuo Ohgaki wrote: >> >>> >>> >>> If there aren't comments, I'll rewrite the example. >>> >>> >>> There were comments. I explicitly told you that that the behavior is >> defined as undefined. You CHOSE to ignore that comment. You CHOSE to >> break the documentation. >> > > If there is defined precedence, arithmetic operation should follow it. > If there is exception, it should be documented. > > I don't understand why/how the arithmetic operation can be > ambiguous with defined precedence. (++ and -- are higher than +) > > $a = 1; > echo ++$a + $a++; > > should always print 4 with current PHP precedence definition. > If it does not, it's a bug in language. > > // mixing ++ and + produces undefined behavior > $a = 1; > echo ++$a + $a++; // may print 4 or 5 > > I don't see any reason it became undefined. > If this kind of simple precedence is broken, how programmers write > code and/or trust the language? > > http://3v4l.org/mR4da/vld#tabs > > This site seems support PHP 4.3.0 to PHP 5.5.0 and opcode looks > fine. Am I missing something? > > If you would like to suggest use of (), it should be done differently. > IMHO. > The comment only ruins PHP's reputation as language. > > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > --047d7b339f17484ef504e1ea1a71--