What is the essential difference between calling a record's constructor, and calling a 'standard' procedure of that record?
In other words, in what circumstances would you want to declare a constructor for an advanced record, rather than just declaring a plain procedure? And are such routines in records correctly termed 'methods', or is that term restricted to the routines of classes and interfaces?
A constructor is essentially a
class function. Though if
jamie is right with his comment that in Delphi constructors can also be used for extended
New then this would be a further difference to ordinary class methods and would additionally explain why the Delphi developers decided to use the
constructor keyword.
And yes, the term
method is also used here, essentially for any routine that has a hidden
Self parameter (e.g. a static class function (compared to a class function) wouldn't be a method
).
This works in Delphi without an issue but it does insist on using an Constructor, not just any method..
It makes sense that it only works with constructors (the same is true for the TP style objects), because then the compiler can be sure about the function signature.