Edit: Changed the request to Local properties, as this is the solution for the other proposal and has much more value then the request below.
Rem Objects Elements has Non Nullable references, which are implemented like they are implemented in c# 8.0 (as I understand it).
With this implementation, the compiler checks agains possible null assignments - and all those possible null assignments are not allowed, making it very hard to use them.
I’d like to advocate for a solution that solves this problem; instead of using Non Nullable references i’d like to use Non Nullable Objects. A Non Nullable Object is an object with a default value.
After each assignment the compiler adds a check to see if the non nullable Object became null and if so, the default value is assigned to it, making sure that the object will never be null.
The difference: With a Non Nullable Reference the compiler is trying to prevent that a null reference is ever assigned. With a Non Nullable Object, a null reference is simply replaced by a default value.
To elaborate the following code:
//normal reference var s: String; //value of s is null //Non Nullable Reference var x: Non Nullable String := ""; //Non Nullable Object // the default can be anything that returns an instance of this object type, // in this case a constant, but it can also be New String or the result of a function. var y: String; default ""; //value of y is now "" x := s; //will not compile because you assign a nullable object to a non nullable object y := s; //will compile, y will be "" after this call
It is much simpler to use a non nullable Object than a non nullable Reference, as a Non nullable object can always be assigned to and it will never, ever be null. (Unless you define the default as a function that returns null, but that would be silly).