[fpc-pascal] Bug in enumerators 2.6.4

Torsten Bonde Christiansen tc at epidata.info
Mon Mar 24 09:32:52 CET 2014


On 2014-03-22 22:34, hinstance at yandex.ru wrote:
> What you do this for? Using override directive makes no sense in this case, so I suggest you just don't use it. If you don't use it, the descendant enumerator will still work like intended
I Think override makes perfect sense in this case.

I get to only implement the GetCurrent procedure once, the example is 
simplified but in my real-world application it does some additional 
structure checking, and in all derived classes i get to call the 
ancestor method but return an object of the type i need.

If I could not override the code for GetCurrent the following

forBar inBarList do
     Bar.Val2:=1;

would not be able to know the Bar is a TBar, but would rather see Bar as 
a pointer (since in this case it inherits from TList). And all 
subsequent code would have to do some sort of typecasting.

I hope that makes a little bit of sense...

Regards,
Torsten.



More information about the fpc-pascal mailing list