Reply to post: Re: Null pointers

Mads Torgersen and Dustin Campbell on the future of C#

ThomH

Re: Null pointers

I think they're politely not referencing competitors, to avoid lurid misrepresentations, but what they're describing sounds exactly like optionals in Ceylon or Swift, as also available in Java 8 and via Boost in C++ but in both cases being opt-in. If so then the semantics are fairly easy: any reference/pointer that may be null explicitly says so, and there's some sort of single-statement construct for dereferencing arbitrarily many in sequence or else getting some other result if any is null (depending on language possibly also optionally allowing an exception if any is null).

E.g. in no language in particular, result = dictionary[helper.getAdaptor().getProperty()].or(defaultValue)

...without having to test whether dictionary exists, then whether helper exists, then whether getAdaptor returns non-null, then whether getProperty returns non-null.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon