Allen Bauer (ex Delphi R&D team) wrote the brilliant piece about a year and a half ago. We can still dream, right?
Allen Bauer, May 25, 2015
Current working theory ofNullable<T>.
Nullable<T> = record
…
property Value: T read FValue; default;
…
end;Using the
defaultdirective to “hoist” the operators of “T“. Currently thedefaultdirective only works forarrayproperties by “hoisting” the ‘[]‘ operator. Marking a non-array property withdefaultwill make the containing type behave as that type.This, coupled with some intrinsic compiler knowledge of the
Nullable<T>type will makeNullable<T>work without any addition of keywords or other standard functions or procedures.Using the “
default” directive on a non-array property will work for any type, except for having the null-propagation semantics.When considering language features, I try and not only make it work for the intended purpose, but also broaden reach of any supporting feature. In the above scenario, even user-defined operators on “
T” will be properly hoisted and used.
This was part of a very interesting G+discussion at Delphi’s New Feature Desired: Nullable Types and Null Propagation….
It covered topics like these:
- Rooted type systems
- IfThenElse implementations (and what’s needed in the language to have them)
- Null propagation
- The inline keyword
- Lazy parameters
- Nullable types in the Spring4D framework (see Spring.pas)
–jeroen





