Quantcast
Channel: Delphi – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 1460

A while ago Allen Bauer commented on the working theory of Nullable in Delphi

$
0
0

I missed this last May, but revisiting some old G+ posts I saw Allen Bauer commenting:

Current working theory of Nullable<T>.

Nullable<T> = record
...
property Value: T read FValue; default;
...
end;

Using the default directive to “hoist” the operators of “T”. Currently the default directive only works for array properties by “hoisting” the ‘[]’ operator. Marking a non-array property with default will make the containing type behave as that type.

This, coupled with some intrinsic compiler knowledge of the Nullable<T> type will make Nullable<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.

So hopefully, one day there will me more than Nullable<T> in Spring.pas which has been around for quite a while now..

–jeroen

Source: Delphi’s New Feature Desired: Nullable Types and Null Propagation Nullable…


Filed under: Delphi, Development, Software Development

Viewing all articles
Browse latest Browse all 1460

Trending Articles