<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">2017-02-07 12:10 GMT+01:00 Mattias Gaertner <span dir="ltr"><<a href="mailto:nc-gaertnma@netcologne.de" target="_blank">nc-gaertnma@netcologne.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div id="gmail-:3w5" class="gmail-a3s gmail-aXjCH gmail-m15a1844c1a0a165d">The getter/setter of a class-property must be "static" (Delphi<br>
compatible).<br>
If I understand "static" correctly, then "static" simply omits passing<br>
the class as parameter. So a static class procedure is just a dumber<br>
version of a normal class procedure.<br>
<br>
What is the advantage of using "static" for class property accessors?<br>
Aka: Why did Delphi choose static here?</div></blockquote></div><br>Generally "static" means no hidden parameter "self". "static" for methods is used for methods designed for callbacks from external API. </div><div class="gmail_extra"><br></div><div class="gmail_extra">We have 3 possibilities:</div><div class="gmail_extra"><br></div><div class="gmail_extra">===code begin===</div><div class="gmail_extra">type</div><div class="gmail_extra">  TFooClass = class of TFoo; </div><div class="gmail_extra">  TFoo = class</div><div class="gmail_extra">    function A: Int32; // self as instance</div><div class="gmail_extra">    class function B: Int32; // self as meta class of TFoo</div><div class="gmail_extra">    class function C: Int32; static; // no self</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">    property D: Int32 read A; </div><div><div class="gmail_extra"><div><div class="gmail_extra">    property E: Int32 read B; </div></div><div><div><div class="gmail_extra">    class property F: Int32 read C;</div></div></div><div class="gmail_extra">===code end===</div><div class="gmail_extra"><br></div><div>"class property" has two advantages. First: you can use "static" methods for properties and second: will work for improper implemented code ;) (which is maybe disadvantage?):</div><div><br></div><div>TFoo($1).F;</div><div>TFooClass($1).F;<br></div></div></div></div><div class="gmail_extra"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Best regards,<br>Maciej Izak</div></div></div>
</div></div>