`[nil methodname]` returns nil. Python et al have the decency to crash to the ground, look embarassed, and stop running.
`[nil methodname]` returns nil. Python et al have the decency to crash to the ground, look embarassed, and stop running.
In any of those, dereferencing a null pointer is undefined. The compiler can literally emit code that plays Nethack in this situation [0]. ObjC's "nothing will happen" behavior is a significant improvement in safety against similarly-situated languages.
I'm pretty sure I'm on record in HN for ranting about the fact that C & C++'s undefined & funny behavior literally created multimillion dollar industries in building analysis tools to cove their gaping problems. Which is why I am tend to boost Rust when possible (designed for correctness and determinism! woo!).
Dropping errors is not IMO better or worse. Both are silent failure modes.
NSArray *a = [self somethingThatProducesAnArray];
if (a.count > 0) {
// do something
}
else {
// do something else
}
than NSArray *a = [self somethingThatProducesAnArray];
if (a && a.count > 0) {
// do something
}
else {
// do something else
}Again, message, not method.