On Tuesday, 4 February 2014 at 22:30:39 UTC, Walter Bright wrote:
you can write them twice or use a template (except in a virtual context), and in both cases you keep the efficiency of not checking for null when the argument is not nullable.

That's just what I wish to avoid. Consider adding more pointer types - the combinatorics quickly explode. Heck, just have two pointer parameters, and you already have 4 cases.

I wonder how Rust deals with this.


I think it is pretty much same thing as with using specialised types (i.e. SQLEscapedString) - your API explodes exponentially if you try to write code with methods/functions that support all of them but in practice you shouldn't. Same is here. Some functions should always deal with with nullable types and most - only with non-nullable. Tricky part is writing your code in such way that separation is clear but good language guidlines and examples can solve it.

Also non-nullable types should be implicitly cast to nullable parameters so you don't always need to support all cases distinctively.

Reply via email to