Is there a benefit in using old style `object` instead of `class` in Delphi?

前端 未结 4 1537
刺人心
刺人心 2020-12-31 15:31

In Delphi sane people use a class to define objects.
In Turbo Pascal for Windows we used object and today you can still use

4条回答
  •  庸人自扰
    2020-12-31 16:10

    When given a choice between "fast and possibly broken" and "fast and correct," always choose the latter.

    Old-style objects offer no speed incentive over plain old records, so wherever you might be tempted to use old-style objects, you can use records instead without the risk of having uninitialized compiler-managed types or broken virtual methods. If your version of Delphi doesn't support records with methods, then just use standalone procedures instead.

提交回复
热议问题