1
votes

Recently, I came across the following property declaration in the component TDBNavigator:

property Enabled;
[Default(False)]     <--------------------
property Flat: Boolean read FFlat write SetFlat default False;

What does the directive [Default(False)] mean? What is its main purpose?

1

1 Answers

5
votes

The [Default(True|False)] Attribute does the same thing as the default True|False clause on the property itself. DFM streaming supports both forms, and with each new IDE release, more and more properties are being moved to this Attribute model. Why Embarcadero feels this is needed, I have no idea. However, Attributes were added in XE3 and are accessible via Extended RTTI (the System.Rtti unit), and thus can be applied to things that old-style RTTI (the System.TypInfo unit) simply doesn't work for. So, this may have been added to aid with other kinds of streaming frameworks, and they decided to apply it to DFMs, too. Who knows.