Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70766 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23261 invoked from network); 19 Dec 2013 22:16:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Dec 2013 22:16:15 -0000 Authentication-Results: pb1.pair.com header.from=admacedo@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=admacedo@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.181 as permitted sender) X-PHP-List-Original-Sender: admacedo@gmail.com X-Host-Fingerprint: 209.85.213.181 mail-ig0-f181.google.com Received: from [209.85.213.181] ([209.85.213.181:42614] helo=mail-ig0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DB/7D-42949-D2073B25 for ; Thu, 19 Dec 2013 17:16:14 -0500 Received: by mail-ig0-f181.google.com with SMTP id k19so5317707igc.2 for ; Thu, 19 Dec 2013 14:16:11 -0800 (PST) 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=IiG494Hc6tnCsY7hfPuiHJ7cpC2Ihl0mX79khqMvGk8=; b=QVQO56i9wEKPW3yOLG4EITc3RKWuT+fRcjY/jCanTOyhcj6Ym/UcKff6xcNwTlSaoJ m0T9yRS4cdioHk7JXr68gh7UklAGZ8aSD3kfLLSah8su14h7wQsGhPdO/mUe1mvctpB2 CkfLRVXuqx4oVoFYbe0dMzdtSuMkYABrIoKLrb3/54eGJuM/oYHvG2uQnbY31nHcsqqj 4P5gfUJcO1Ml1Ikq68wCp109JG4MkQIeEoQPnqNhR8p4sPAC9WJkDB+bqnfJckQXQM93 bRYIUgWJ11ZoYf7gvXHCsc2eY6IiKip0hWmCz4v2H0qmnTw/Fmyyd16krpIWDwkuNaf5 xs+Q== MIME-Version: 1.0 X-Received: by 10.42.32.133 with SMTP id e5mr3010099icd.39.1387491371009; Thu, 19 Dec 2013 14:16:11 -0800 (PST) Received: by 10.64.240.77 with HTTP; Thu, 19 Dec 2013 14:16:10 -0800 (PST) Received: by 10.64.240.77 with HTTP; Thu, 19 Dec 2013 14:16:10 -0800 (PST) In-Reply-To: <52B36BFC.4080708@lerdorf.com> References: <52B36BFC.4080708@lerdorf.com> Date: Thu, 19 Dec 2013 22:16:10 +0000 Message-ID: To: Rasmus Lerdorf Cc: PHP Internals , Daniel Lowrey , Kris Craig Content-Type: multipart/alternative; boundary=bcaec518664e4c4ffb04edea8273 Subject: Re: [PHP-DEV] Re: power operator (again) From: admacedo@gmail.com (Daniel Macedo) --bcaec518664e4c4ffb04edea8273 Content-Type: text/plain; charset=ISO-8859-1 On 19 Dec 2013 21:58, "Rasmus Lerdorf" wrote: > > On 12/19/2013 04:50 PM, Kris Craig wrote: > > I believe that, especially for a KISS language like PHP, our top priority > > with math operators should be to match arithmetic laws as closely and as > > intuitively as possible. The average PHP developer is going to do -3 ** 2 > > and expect a result of 9, not -9, and rightly so I think. > > No, the average PHP developer is going to do $var ** 2 and it will > behave exactly as they expect with negative values. Yes, in the very I didn't quite understand if you're making the case for assuming a type casting of $var and keep with the expected math or if operator precedence would mean the result could be negative in some cases. Example: $str = '-3'; $res = 0 - $str ** 2; PEMDAS would mean this results in $res having a value of 9 whatever the case ($str positive or negative)! Would this be different in regards to operator precedence? > rare case that someone for some reason hardcodes a negative literal > there, they are going to have to learn about operator precedence because > we really can't have 0 - 3**2 be different from - 3**2. > > -Rasmus > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --bcaec518664e4c4ffb04edea8273--