Hello
Hello,
Do you know why the "defaut" keyword of a class property is sometime defined also as an attribute ?
Vcl.Buttons.TBaseNavigator.Flat
[Default(False)]
property Flat: Boolean read FFlat write SetFlat default False;
hum...perhaps for string or single types...but I don't see any uses case...but now System.Classes use the huge System.Rtti unit :/
Do you know why the "defaut" keyword of a class property is sometime defined also as an attribute ?
Vcl.Buttons.TBaseNavigator.Flat
[Default(False)]
property Flat: Boolean read FFlat write SetFlat default False;
hum...perhaps for string or single types...but I don't see any uses case...but now System.Classes use the huge System.Rtti unit :/
It seems like work has been started to replace(?) the default keywords with attributes?
ReplyDeleteIn theory, and this is very theoretical, an attribute could produce an object instance, and not just simple types values like the default keyword.
Then again - It uses DefaultAttribute from System.Classes, which holds a ... variant.
/facepalm (I am not a fan of variants).
/sub
ReplyDeletePaul TOTH then you need to browse the VCL sources for where the `DefaultAttribute` and `TDefaultAttributeBase` actually being queried and processed.
ReplyDeleteJeroen Wiert Pluimers I greped "[Default", it is used in Data.* DataSnap.* Vcl.DB* but each time for boolean on integer value that is already defined with a default keyword.
ReplyDeleteIt's seems that like TComponent.BeginInvoke() it has been added and never used anywhere.
I'd like that one new release will shrink the exe size instead of adding garbage each time.
I've just discovered that FMX.Text uses TRegEx to find CR/LF in the text...System.RegularExpressionsAPI is only 128Kb after all
RegularExpression is a powerfull tool, but not necessary to split some text (also used in TPlatformCocoa.DialogOpenFiles to split the filter string)
default keyword only works for very few types:
ReplyDelete[Default('Hello world')] // <- works
property Foobar: string read fFoobar write fFoobar default 'Hello world'; // <- does not work because E2146
Probably their internal coding guidelines say always add both if possible. Anyway even if they don't use it themselves this might be handy for third party component developers.
Paul TOTH I agree. That's the drawback of losing so many senior team members in R&D.
ReplyDeleteStefan Glienke I prefer an extra "Hello world" in some DFM than extra Kb in all projects. And it is possible to use "stored" to check for non trivial default values.
ReplyDeletePaul TOTH BeginInvoke is part of the APL. It is not unusual that a library provides functionality that is not used by itself. That doesn't mean that it is not used by other developers in their applications.
ReplyDeletedocwiki.embarcadero.com - Using the Asynchronous Programming Library - RAD Studio
Uwe Raabe If that works as well as the PPL does I would not touch it with a 10 foot pole ;)
ReplyDeleteUwe Raabe Okay, but why is it tied to TComponent ?
ReplyDeletePaul TOTH Why not? Would you prefer it in TObject?
ReplyDeleteActually BeginInvoke is a bit more than the sparse documentation tells. For example for TWinControls components it makes sure the passed callback is executed in the thread the control was created in (mostly the ui mainthread).
ReplyDeleteIn C# (where this obviously was cop.. inspired by) the BeginInvoke is on the Control class.
However in Delphi TComponent is the base class that both UI frameworks share so it makes sense to put it there.