Peter N Lewis wrote:
I have added a new option `--objects-are-references' (off by default, on for Mac Pascal) which choses reference model for objects. To get Mac semantics one has to use `--objects-are-references' and `--methods-always-virtual'.
Looks good. Can we add control over the warning:
warning: object type has virtual method, but no constructor
off by default in Mac Pascal, possibly off for objects-are-references?
What is the reasoning for the warning, why are objects supposed to have a constructor?
BP requires it. In fact, a constructor doesn't only have to exist, but must be called at runtime before virtual method calls will work. GPC doesn't require this, even in the BP model, so the warning is more for compatibility.
Are constructors ever called implicitly? As far as I could see, the only time a constructor was called was if it was passed to New when the object is created...? Should this be a BP compatibility warning only?
I think it should be coupled to the object model.
In OOE, the problem does not exist:
: 6.1.3.5 Constructors. : : There is a predefined constructor called Create in the Root class. Since : every abstract class and every concrete class is a descendant of Root, every : such class has at least one constructor.
Maybe the same is true for Delphi. If not, can a class not have a constructor there?
Frank