Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68263 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51765 invoked from network); 20 Jul 2013 08:00:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jul 2013 08:00:18 -0000 Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.180 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 209.85.214.180 mail-ob0-f180.google.com Received: from [209.85.214.180] ([209.85.214.180:40959] helo=mail-ob0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/91-13120-E834AE15 for ; Sat, 20 Jul 2013 04:00:16 -0400 Received: by mail-ob0-f180.google.com with SMTP id eh20so6232583obb.39 for ; Sat, 20 Jul 2013 00:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=4v7HZY0G8Bpotd4ziGEWynBJ2IDRJZem93fgS3Zvroo=; b=us9G4Ku2C5kyhTlA/2c450GNlyYCOxOOy8+Sd3YDcXWpzllooYdoKioK4d1nCzg1PP Gd6QPOkFcwhIoLVVwtH/KGVWSPe5ClDXx2DwJT7LF74j2vHH9I5x2UjMVxuzTJRrjtrP 3Wvy5wH+LFKAef6utR7W7WeipjgYVQMs9jhY8y20r+k/11ZK8PR6Dl7H+7ug90mlliwC uq+Hiz78R7jTUZcLH/fKN++uJ/zHhYhRF13qiHCYikYoW8IDjxlGJqx/pCwPRr0/d35/ qAShrPsqRp3tz8OaTMDn0eZVrHHatN2tnQGrMOcr8AszuyU4qCEBZEMgy8Qma3HKvFBm 0lFQ== MIME-Version: 1.0 X-Received: by 10.182.171.7 with SMTP id aq7mr14651570obc.103.1374307199573; Sat, 20 Jul 2013 00:59:59 -0700 (PDT) Received: by 10.182.79.167 with HTTP; Sat, 20 Jul 2013 00:59:59 -0700 (PDT) In-Reply-To: <51EA3E36.1090402@sugarcrm.com> References: <51EA3E36.1090402@sugarcrm.com> Date: Sat, 20 Jul 2013 03:59:59 -0400 Message-ID: To: Stas Malyshev Cc: Yasuo Ohgaki , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=e89a8ff1ccae7164d404e1ecd4e1 Subject: Re: [PHP-DEV] Operator precedence is undefined? From: theanomaly.is@gmail.com (Sherif Ramadan) --e89a8ff1ccae7164d404e1ecd4e1 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Jul 20, 2013 at 3:37 AM, Stas Malyshev wrote: > Hi! > > > I cannot believe this is true now, but I ask list before I fix doc. > > I don't think there's something that needs to be fixed. "Undefined" > means "it depends on implementation and we do not want to commit to a > specific behavior here because implementations may change". This is a > fair warning against using implementation details that are not promised > to stay fixed and later crying why next PHP version broke your code. > Because you used undefined behavior. If the behavior is specified as > undefined, that means "don't do this" - so you know it may be broken, > and write better code instead that is not broken. > > Stas, I agree that we should not rush to commit changes in the midst of on-going discussion. However, I have to just add to this notion of undefined behavior that by your definition ALL of PHP is undefined behavior. Everything we do is an implementation detail. What specification do we have that clearly defines PHP's behavior? Can you honestly tell me that we haven't changed behavior in the past despite no clear warning of "undefined behavior" in the manual? References being one example. I'm just suggesting that we carefully consider our arguments and not only acknowledge them when they work out to our benefit and then discard them the moment they don't support our cause. Clearly there is an argument here that this is acceptable behavior and clearly there is an argument that it is undefined. The real question is whether or not its worth specifying as "undefined behavior" in the manual. A single line comment in an example like that which states "may print 4 or 5" is not good documentation. My suggestion is either clarify in an actual note or section of that documentation why it is considered undefined behavior or to remove the comment. There is unquestionable signs of confusion coming from our users as the bug report indicates. We should not ignore the fact that this comment has confused somebody and should instead strive to improve it. My suggestion would be to ad some clarifying language here: "Using multiple increment/decrement operators in the same expression has no guaranteed order of resolution and is subject to change. Relying on code such as $a = 1; ++$a + $a++ === 4; is considered undefined behavior." --e89a8ff1ccae7164d404e1ecd4e1--