On Tuesday, 4 February 2014 at 22:30:39 UTC, Walter Bright wrote:
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.

Rust does not have null pointers.

In cases where you want to mark an object of some type as having "no value", or being "null", you use a stdlib type Option<T>, which is basically a tagged union plus some static compiler guarantees:

enum Option<T> {
    Some(T),
    None
}

An Option<T> either contains a T (tagged 'Some' then) or nothing (tagged 'None').

If you have a function that takes an Option<T> you can also pass it a (pure, non-nullable) T by specifying Some(myT) as the parameter.

Reply via email to