code review

Thomas 'PointedEars' Lahn PointedEars at web.de
Sun Jul 1 03:04:22 EDT 2012


Evan Driscoll wrote:

> On 6/30/2012 23:45, Evan Driscoll wrote:
>> You may also
>> want to put Java in there as well, as < is effectively not commutative
>> in that language. (I didn't try C#.)
> 
> I guess you could actually put Lua and Ruby into the roughly same
> category as Java too.
> 
> But things get a little nastier in ==, as 'false == false == false'
> evaluates as '(false == false) == false' to 'false' in Java and Lua.
> (Ruby produces a syntax error for this, roughly the Haskell approach.)
> 
> But we have Javascript:

s/Javascript/ECMAScript (implementations)/g

>   1 < 1 < 2
>   => true
>   false == false == false
>   => false

Correct, because

  0. 1 < 1 < 2
  1. (1 < 1) < 2
  2. false < 2
  3. 0 < 2
  4. true

and

  0. false == false == false
  1. (false == false) == false
  2. true == false
  3. false

See also the ECMAScript Language Specification, 5.1 Edition, section 11.9:

<http://ecma-international.org/ecma-262/5.1/#sec-11.9>

-- 
PointedEars

Please do not Cc: me. / Bitte keine Kopien per E-Mail.



More information about the Python-list mailing list