News for hackers. Stuff that matters.
Re:Statically-typed error handling in Python using Mypy by weberc2 on Sunday December 08, 2019 @10:41PM (#21740231)
C, C++, Rust, Go, etc have no special distinction between reference types and primitive types but rather everything is a value and some values are pointers/references. In a language with operator overloading, I don’t see why you’d ever want to check string identity by default. Interestingly, Go doesn’t have operator overloading but it treats strings as a special case including doing a string comparison for ==. Not saying this is better or worse, although no one makes mistakes with string comparison as far as I’m aware, for whatever that is worth.
Re:Statically-typed error handling in Python using Mypy by CamouflagedKiwi on Monday December 09, 2019 @02:32AM (#21740983)
That special case isn't specifically for strings - you can also compare arrays, channels and structs that way (as long as the array/struct doesn't contain anything non-comparable). Unfortunately it's a rarer footgun though since it can panic when comparing interfaces :(