We’re deep into researching and scheduling of development time for the next major release of the Delphi product family. One of the issues we have to weigh carefully is what language features introduced in Delphi for .NET are worthwhile to implement in Delphi for Win32. Investing an enormous effort into implementing a feature in Win32 that isn’t really useful to Win32 developers would be a waste of Borland effort.
One such candidate for Win32 is attribute syntax. Attributes allow you to decorate types, methods, properties, parameters, variables, and fields with declarative info of your own design that can be retrieved at runtime. Essentially, attributes provide a mechanism for user-defined RTTI payloads.
Attributes can be used almost anywhere in .NET because everything has runtime metadata. In Win32, attributes would have to be restricted to symbols that are capable of carrying RTTI. In Win32, attributes could only appear on classes declared under $M+ (such as descendents of TPersistent / TComponent), and published methods and properties and their parameters.
On the surface, implementing attribute syntax in Win32 sounds like a no-brainer. And for the compiler, it pretty much is – the hard part of parsing the attribute declaration and attaching it to a symbol is already done. However, for attributes to be useful, they need to be discoverable at runtime. That means adding a fair amount of non-trivial code to the RTL to extract info from RTTI, select attributes that match a qualification or target set, construct instances of the attributes, and return them to the caller. So, no-brainer it ain’t.
Attributes are useful in .NET largely because there is an existing ecosystem that defines and consumes attributes. If we add attribute syntax to the Win32 side, we won’t see the same level of immediate benefit because there is no attribute ecosystem in Win32, and we aren’t proposing to define one.
The bottom line is that attributes for Delphi Win32 will require quite a bit of work but the customer benefit is not a clear home-run.
So, here’s the question to you: What would you use attributes for in Win32 applications? What other Win32 Delphi features would you be willing to sacrifice in order to get Win32 attributes?
Click on the comments link below to add a comment. (Layout and appearance will change daily while I tweak the style bits)