<p>Am 12.04.2016 12:01 schrieb "Maciej Izak" <<a href="mailto:hnb.code@gmail.com">hnb.code@gmail.com</a>>:<br>
><br>
> another way is to introduce attributes for selected language elements in Delphi compatible way. For example in Delphi we have:<br>
><br>
> TCustomAttribute = class(TObject)<br>
> end;<br>
> WeakAttribute = class(TCustomAttribute);<br>
> UnsafeAttribute = class(TCustomAttribute);<br>
> RefAttribute = class(TCustomAttribute);<br>
> VolatileAttribute = class(TCustomAttribute); </p>
<p>What I don't like about such a usage of attributes (aside from the syntax, but that's an orthogonal problem) is that the compiler needs to be made aware of each and every special attribute... (yes, it also needs to support each keyword, but in the case of keywords it doesn't have to be somehow defined in some units as well)<br>
[Note: this is less a "I don't want it", but a "I don't like it"]</p>
<p>><br>
> Note: these attributes are on my TODO list.</p>
<p>Please don't do anything attribute related until I've merged Joost's class attributes branch which lays the foundations for the attributes. I've planned this for after the reintegration of my dynamic packages branch which is currently WIP (the merge, not the branch ;) )</p>
<p>> To protect our management operators we should declare in System.pp:<br>
><br>
> FixedAttribute = class(TCustomAttribute); // or SystemInitializedAttribute<br>
><br>
> Now the gSomething from example is declared as:<br>
><br>
> var<br>
> [Fixed] gSomething: TSomeType; // fixed can be used only for global variables and for class var/{$J+} const (aka static var)</p>
<p>That together with your suggestion to force this attribute for records with management operators might indeed be useful, but there are some problems... (see below)</p>
<p>> ... that means "don't' [Initialize|Finalize|FillChar|Whatever] this variable from module but from System.pp (in special table in initialization section)". Any module may contain special hidden section (if [Fixed] attribute is detected); that will register all global variables declared with [Fixed] and any variable with [Fixed] will be excluded from standard initialization/finalization process. That special all "Fixed Sections" from all modules should be called before any other initialize/finalize to register all variables (and before system initialize section ofc, where all registered fixed variables shall be initialized, and after all ofc finalized).</p>
<p>The system unit's initialization *must* be run first, otherwise you won't have a heap or synchronisation primitives or whatever you might need. That then also extends to units like heaptrc, cmem, cthreads, etc.</p>
<p>Maybe it would be better to initialize such records always *after* *all* initialization sections have been run... :/ (and deinitialized first)</p>
<p>Regards,<br>
Sven</p>