The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

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

Posted by jpluimers on 2015/09/25

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…

5 Responses to “A while ago Allen Bauer commented on the working theory of Nullable in Delphi”

  1. C Johnson said

    We seem to hear very little from Allen the last few years. Considering his role at the company, I would definitely like to hear more from him.

  2. abouchez said

    Yes, nullable types, at language level, like in C# with int? or string?, may be even better.
    But we have a nullable value type since the beginning of Delphi history, thanks to the variant type, which may hold a null value.
    I’ve just written a blog article about how nullable values are handled in our Open Source ORM, without using any generics, but variant types.
    So it is compatible with Delphi 6 and up, on whatever version, and also with FPC.
    See http://blog.synopse.info/post/2015/09/25/ORM-TNullable%2A-fields-for-NULL-storage

  3. That will be nice ! I submitted a report back in 2003 that is related to marking default for non array properties: http://qc.embarcadero.com/wc/qcmain.aspx?d=4718

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.