News for hackers. Stuff that matters.
Re:Nil in Go is typed in theory and sort of untyped in practice by Spivak on Wednesday March 31, 2021 @03:02PM (#26651527)
Eh, languages end up with this all the time with type conversions.

In JS:

    false == undefined => false
    false == null => false
    undefined == null => true
Re:Nil in Go is typed in theory and sort of untyped in practice by masklinn on Wednesday March 31, 2021 @03:49PM (#26652187)
First, your comment makes no sense:

    a = 1
    b = 2
    c = 1
    a == b => false
    b == c => false
    a == c => true
Is that surprising? Equality is transitive, inequality is not.

Second, if you have to reach for old javascript "features" (or got forbid PHP) to defend a language you're in a bad, bad place.

Third, the broken equality is not something that's usually praised about javascript. In fact the first rule of javascript equality is that there is only one situation in which `==` is the correct operator: checking that something is null (because that avoids having to differentiate between null and undefined, papering over one javascript wart using another). In every other situation you want "strict" (===) equality.

Re:Nil in Go is typed in theory and sort of untyped in practice by virtue3 on Wednesday March 31, 2021 @05:31PM (#26653425)
I managed to get my team to use `lodash.isNil` because we had gotten bitten by this crap too many times. And `lodash.isEmpty` for strings/arrays/etc.
Re:Nil in Go is typed in theory and sort of untyped in practice by mirekrusin on Wednesday March 31, 2021 @03:54PM (#26652255)
What is absurd about this statement from logical point of view?

  A != B
  A != C
  B == C
...looks like valid logical statement, ie. A = 1, B = 2, C = 2:

  1 != 2
  1 != 2
  2 == 2
Re:Nil in Go is typed in theory and sort of untyped in practice by presto8 on Thursday April 01, 2021 @01:40PM (#26663716)
What about A=1, B=2, C=3?

   A != B    1 != 2
   A != C    1 != 3
   B == C    2 == 3
Re:Nil in Go is typed in theory and sort of untyped in practice by mirekrusin on Tuesday April 06, 2021 @05:18PM (#26717513)
If you write `y = x + 1` and say what about `y = 42` and `x = 0`, `42 = 0 + 1` doesn't mean math/equation is absurd, does it?
Re:Nil in Go is typed in theory and sort of untyped in practice by dragonwriter on Wednesday March 31, 2021 @03:57PM (#26652292)
That's not an example of nontransitivity. You’ve only shown that some nontruthy values are unequal by == and some are equal by ==. Nontransitivity would be a == b, b == c, c != a. But you have the much more expected b != a, b != c, c == a.

JS loose equality is intransitive, though; the standard example being:

  '0' == 0; // true
  0 == ''; // true
  '0' == ''; // false