The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,417 other followers

Delphi static class methods are assignment compatible with plain old function pointers

Posted by jpluimers on 2013/04/24

So I won’t forget, as the  [WayBackstatic in different languages varies in meaning:

[WayBack] Static on class methods makes them assignment compatible with plain old function pointers.

Thanks Moritz Beutel for initially posting this.

–jeroen

via:

related:

  • [Archive.isFacebook – Delphi developer: static class methods
  • [WayBack] Delphi 2007: Methods; Class Methods:

    Like class methods, class static methods can be accessed without an object reference. Unlike ordinary class methods, class static methods have no Self parameter at all. They also cannot access any instance members. (They still have access to class fields, class properties, and class methods.) Also unlike class methods, class static methods cannot be declared virtual.

    Methods are made class static by appending the word static to their declaration.

5 Responses to “Delphi static class methods are assignment compatible with plain old function pointers”

  1. Good to know, thanks.

  2. uligerhardt said

    At last. :-) See [How compatible are static class methods and regular routine pointers?](http://stackoverflow.com/questions/6940171/how-compatible-are-static-class-methods-and-regular-routine-pointers)

  3. A. Bouchez said

    Of course!

    I always saw static class methods as the new “global functions”.
    And class variables as the new “global variables”.
    To be used with care – unless your code may become not re-entrant any more – it may be the open door to make your code not thread-safe.
    For instance, it may lead into impossibility to launch several class instances in parallel, or make your code much more difficult to test / mock / stub…

    IMHO static class methods should be used with care, just as global functions are in pascal.

    • jpluimers said

      Yeah, the “of course” is totally right. I had that very “duh” moment september last year with I found Moritz’ answer (:

      And indeed: all static class stuff are replacements for global stuff with the benefit of an extra name in the scope so they won’t pollute the global scope.
      Regular “global” criteria apply: use with care (:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: