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 2,969 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;

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..


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.

  3. That will be nice ! I submitted a report back in 2003 that is related to marking default for non array properties:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: