On Tue, 26 Jun 2007, Graeme Geldenhuys wrote:
> Hi,
>
> [I'm posting this here, seeing that I got no response from the FPC
> Users mailing list. I guess nobody there uses Interfaces.]
>
> I'm pretty new to using interfaces... I want to use interfaces so that
> I can spot problems at compile time and not runtime. For example: If
> I used a base class with abstract methods and then created descendant
> classes. Now if I forgot to implement one of the abstract methods which gets
> called somewhere... I'll only find the problem at runtime (with an
> abstract error) and not
> compile time.
The compiler warns you if you create an instance of a class with uninmplemented
abstract methods. It even tells you which ones:
See:
home: >fpc -vwh testab.pp
Hint: Start of reading config file /home/michael/.ppc386.cfg
Hint: End of reading config file /home/michael/.ppc386.cfg
testab.pp(9,21) Warning: Constructing a class "TStrings" with abstract methods
classesh.inc(489,14) Hint: Found abstract method: TStrings.Get(< TStrings>,
LongInt):AnsiString
classesh.inc(491,14) Hint: Found abstract method: TStrings.GetCount(<
TStrings>):LongInt
classesh.inc(514,15) Hint: Found abstract method: TStrings.Clear(< TStrings>)
classesh.inc(515,15) Hint: Found abstract method: TStrings.Delete(< TStrings>,
LongInt)
classesh.inc(523,15) Hint: Found abstract method: TStrings.Insert(< TStrings>,
LongInt,const AnsiString)
home: >cat testab.pp
program testab;
uses classes;
var
S : TStrings;
begin
S:=TStrings.Create;
end.
So I see no need for interfaces ?
If you are using class references to instantiate your classes, then you can
remedy this by
creating a small test unit which explicitly creates an instance of every class
in your units.
Michael.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives