[fpc-pascal] class contracts [[was: Re: Optional param modifier]]

Martin Frb lazarus at mfriebe.de
Mon Apr 15 12:52:42 CEST 2019


On 15/04/2019 09:41, Sven Barth via fpc-pascal wrote:
> Am 14.04.2019 um 23:48 schrieb Martin Frb:
>> As for "documentation". I disagree with the way it is done in oxygen. 
>> But I am not sure I have any good alternative.
>> For me a class contract (require/ensure) is part of the interface.

Putting them in the implementation as oxygen does may also cause a 
technical issue.
As pointed out, for a class the contract also affects inherited methods.


Unit A
interface
   TFoo= class
     procedure DoFoo(a:TSome); virtual;
  end;
implementation
uses B;
   procedure DoFoo(a:TSome);
   requires
     whatever



Unit B;
interface
uses A; // AFAIK can only read the interface, the implementation has a 
circular "uses B"
   TFooSpecial= class(TFoo)
     procedure DoFoo(a:TSome); override; // needs to know implementation 
details from unit A
  end;





More information about the fpc-pascal mailing list