Agreed, I wouldn't break binary compatibility in a minor release, if
this change is to be made it should be done in the next major release
branch IMO

On Mon, Jun 8, 2015 at 3:02 PM, Winnebeck, Jason
<jason.winneb...@windstream.com> wrote:
> If this isn't a clear cut fix then you might want consider leaving it as it 
> is for backwards compatibility. Groovy already has enough issues with 
> breaking changes. At first it looks reasonable that unary - should have 
> precedence over everything but (), but taking the power of a negative number 
> is not normally a sensible thing to do since it only works when the right 
> hand side is an integer and half the time the result is positive. So, in my 
> mind there are arguments for both sides, and then when applied to something 
> as critical as source compatibility, it really lends to keeping existing 
> behavior, in my opinion.
>
> Jason
>
> -----Original Message-----
> From: Paul King [mailto:pa...@asert.com.au]
> Sent: Sunday, June 07, 2015 10:26 AM
> To: users@groovy.incubator.apache.org
> Subject: Re: precedence rules for power operator vs -, +, ++, --
>
>
> OK, looks like there is precedence in both directions:
>
> http://en.wikipedia.org/wiki/Order_of_operations#Exceptions
>
>
> On 7/06/2015 11:48 PM, Jochen Theodorou wrote:
>> "-8 - 1"
>>
>> is in all languages I tests -9. That means Pyhton, Lua, Java, Ruby, QBasic, 
>> Javascript, Go. And that in general independent of spacing.
>>
>> bye blackdrag
>>
>> Am 07.06.2015 13:50, schrieb Paul King:
>>>
>>> What do lua/python/ruby return for "-8 - 1"?
>>>
>>> On 7/06/2015 8:40 PM, Jochen Theodorou wrote:
>>>> Am 06.06.2015 13:08, schrieb Paul King:
>>>> [...]
>>>>> def x = 5
>>>>> assert -x ** 2 == -25  // treated as -(x ** 2) assert --x ** 2 ==
>>>>> 24  // treated as --(x ** 2)
>>>>>
>>>>> This behavior is different to the other operators and different to
>>>>> what the comments in the grammar describe as the intended behavior
>>>>> but the order of two rules was presumably accidentally reversed in the 
>>>>> grammar.
>>>>>
>>>>> After the change, the following executes:
>>>>>
>>>>> def x = 5
>>>>> assert -x ** 2 == 25   // treated as (-x) ** 2
>>>>> assert --x ** 2 == 16  // treated as (--x) ** 2
>>>>
>>>> I just checked Ruby and Python and there -2**4 will return -16, same
>>>> for -2^4 in Lua. So now I am wondering if that is the right thing
>>>> for unary minus
>>>>
>>>> bye blackdrag
>>>>
>>>
>>>
>>> ---
>>> This email has been checked for viruses by Avast antivirus software.
>>> https://www.avast.com/antivirus
>>>
>>
>>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
>
> ----------------------------------------------------------------------
> This email message and any attachments are for the sole use of the intended 
> recipient(s). Any unauthorized review, use, disclosure or distribution is 
> prohibited. If you are not the intended recipient, please contact the sender 
> by reply email and destroy all copies of the original message and any 
> attachments.



-- 
Graeme Rocher

Reply via email to