Project

General

Profile

Bug #13152

Updated by nobu (Nobuyoshi Nakada) about 7 years ago

I noticed this difference between ruby and crystal when converting a gem. 

 ```ruby 
 puts     -2**4 -> -16 (ruby) || 16 (crystal) 
 puts (-2)**4 ->    16 (both) 
 ``` 

 ruby parses `-2**4` -2**4 as `-(2**4)`, -(2**4), while crystal does `(-2)**4`, (-2)**4, which is more intuitive. 
 This creates need to be careful converting negative number usage from ruby <-> crystal. 
 (I haven't investigated differences with other languages.) 
 Using parentheses to explicitly create intended outcomes can overcome this. 

 However, on the heels of the discussion/decision to not change the default rounding behavior of numerics 
 in 2.4.0 would it also be worth it to change this parsing behavior to make this more natural 
 and intuitive, as in crystal?

Back