3 ms·
It's wildly useful to have interface contracts that can be verified by the compiler. In my experience this benefit of using pointers (vs references) only when t
by nemetroid 5y ago
It's wildly useful to have interface contracts that can be verified by the compiler. In my experience this benefit of using pointers (vs references) only when the argument is optional way outweighs the drawback of not seeing an '&' at the call site.
- quotemstr 5y ago> In my experience this benefit of using pointers (vs references) only when the argument is optional way outweighs the drawback of not seeing an '&' at the call site. Maybe so. Reasonable people differ on this subject. My point is different: it's just not true that if a parameter is a pointer, then as a general requirement you have to check at runtime whether that pointer is non-NULL. It drives me nuts when I see these checks sprinkled throughout a codebase.
- nemetroid 5y ago> My point is different: it's just not true that if a parameter is a pointer, then as a general requirement you have to check at runtime whether that pointer is non-NULL. It drives me nuts when I see these checks sprinkled throughout a codebase. My point is that if you only ever use pointer arguments to indicate that the argument is optional, then the checks are required.
- stevenhuang 5y agoBut it is a reasonable rule, hence it being a general requirement in a lot of places. More nuanced, it's more important to have these null checks on a library's public interfaces than a library's private interfaces. Private interfaces can do with asserts for null check.
- quotemstr 5y ago> it's more important to have these null checks on a library's public interfaces No it isn't.
- stevenhuang 5y agoLibrary authors and users would disagree with you.