[fpc-devel] Abstract functons with parameters on classes

Vinzent Höfler JeLlyFish.software at gmx.net
Thu Jul 27 21:29:19 CEST 2006

ik wrote:

> Assume I have the same API calls for different things in classes, and
> the only difference me as someone who uses this API is to use the
> right class, but all of the other code is not changed, except specific
> calls ...

You would not only need to know the "right" class, but also the right 
parameter set belonging to the call.

This sort of screws the whole object-orientation.

> Now I know that Parent do not know anything about a child, but can I
> make it "virtual" in the way the parameters is created in the child
> way, and do it as part of the abstract ?

You can do that by using a more generic parameter (array of const, or 
even a class type), but what's the point? A caller still needs to know 
the correct parameter set and the callee needs to evaluate if it has 
given the correct one for its particular instance.

That's like implementation "generics" as case-statement:

case Argument of
1: Do_1;
2: Do_2;

You can do that, but I would strongly recommend, you don't. It's stupid, 
believe me. Everytime you add something, you have to reimplement all the 
checks. I've seen such code. It just doesn't work out.


More information about the fpc-devel mailing list