[fpc-pascal] Abstract classes ignored

C Western l at c-m-w.me.uk
Sun Apr 18 12:31:17 CEST 2021


On 18/04/2021 03:34, Ryan Joseph via fpc-pascal wrote:
>
>> On Apr 17, 2021, at 3:09 PM, Sven Barth <pascaldragon at googlemail.com> wrote:
>>
>> The compiler will generate a warning in case you instantiate a class that is abstract or has abstract methods. You can escalate these warnings to errors if you need:
> It's probably not practical to put that warning into all potential files but a warning is still probably good enough as a reminder. It's curious though why it's not an error by default, because if the class is abstract and you instantiate it and try to use it things are going to fail anyways so why does the compiler allow it in the first place?
>
> Regards,
> 	Ryan Joseph
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

My own code will have cases where I have only implemented some of the 
abstract methods for some classes, in principle because the code is 
incomplete, but there are also case where it never makes sense to 
implement them and calling them indicates a logical error elsewhere in 
the code.

Colin



More information about the fpc-pascal mailing list