[fpc-pascal] how to simulate abstract properties
M.Santhoff at web.de
Mon Aug 17 19:02:08 CEST 2009
Am Montag, den 17.08.2009, 09:12 +0200 schrieb Graeme Geldenhuys:
> Marc Santhoff wrote:
> > the compiler runs and throws no error. Fine, but this way every class
> Because you did not instantiate any instances of that class. Here is the
> output after compiling my sample program with FPC 2.2.5
I did while testing.
> $ fpc test1.pas
> Free Pascal Compiler version 2.2.5 [2009/05/28] for i386
> Copyright (c) 1993-2008 by Florian Klaempfl
> Target OS: Linux for i386
> Compiling test1.pas
> test1.pas(31,24) Warning: Constructing a class "TDerived2" with abstract
> Linking test1
> 35 lines compiled, 0.1 sec
> 1 warning(s) issued
> It clearly shows the error, which is correct. Just declaring a class
> with abstract methods doesn't mean the compiler must throw an error.
> TDerived2 might have another class deriving from it, which adds the getA
No, it shows a warning message, no error.
The point is, the compiler finishes making a runnable program. I
personally don't want that to happen because it will make avoidable
trouble at runtime. If this compiled binary get's delivered somehow
(e.g. by error or ignorance) it will be a nice source of support calls
or even more dangerous consequences.
Making the compiler stop on error will prevent such trouble.
> As far as I can see, the compiler is doing everything correctly.
Don't get me wrong, I'm not saying the compiler does sth. wrong, I only
want to work it differently in classifying some warnings as an error.
The patch Jonas showed does exactly that, so I'm happy.
Marc Santhoff <M.Santhoff at web.de>
More information about the fpc-pascal