3 ms·
Well, Python is duck typed, but None doesn't pretend to be a duck, a cow, a pig, etc. That sounds extremely dangerous.
by icebraining 13y ago
Well, Python is duck typed, but None doesn't pretend to be a duck, a cow, a pig, etc. That sounds extremely dangerous.
- dilap 13y agonil just always comes back with 0 or nil or whatever -- it's like a really dumb version of None in the Maybe monad, and trying to get you some of the convenience (except way, way worse from a safety perspective). For extra fun, NSNull (the "designated" object (as opposed to an actual zero value of nil) to represent nil) doesn't happily respond to any message sent to it -- i.e., if you replace nil with NSNull somewhere in the code, it will most likely blow up.
- drewcrawford 13y agoIn C/C++, dereferencing the null pointer is undefined. That is a hell of a lot more dangerous than doing nothing. ObjC's "defined to do nothing" behavior is a significant step up from the other languages in the "fast, compiled, bare metal" cluster (C,C++).
- Iftheshoefits 13y agoIt's rather subjective to say that's a "significant step up". "Dereferencing a null" indicates a potentially serious underlying issue that the "do nothing" hand-holding you describe masks.