Why is AbstractFunctionDeclaration not a Declaration? Why is ClassFunctionDeclaration not a FunctionDeclaration?

Andreas Pakulat apaku at gmx.de
Mon Mar 1 15:53:53 UTC 2010


On 01.03.10 16:22:49, Milian Wolff wrote:
> David Nolden, 01.03.2010:
> > Am Montag 01 März 2010 16:01:56 schrieb Milian Wolff:
> > > Hey all, esp. David!
> > > 
> > > Is there any reason why an AbstractFunctionDeclaration does not inherit
> > > 
> > >  from Declaration? And why is a ClassFunctionDeclaration only an
> > > 
> > > AbstractFunctionDeclaration, but not a normal FunctionDeclaration?
> > > 
> > > I find that rather unintuitive and makes my code harder since I cannot
> > > use simple polymorphie to handle methods and functions (in my case no
> > > 
> > >  difference) in one go...
> > > 
> > > Anything against me changing that?
> > 
> > This cannot be changed, due to multiple inheritance.
> > 
> > A ClassFunctionDeclaration inherits ClassMemberDeclaration as well as
> > AbstractFunctionDeclaration, and a FunctionDeclaration inherits Declaration
> > and AbstractFunctionDeclaration.
> > 
> > "Declaration" must be only once in the whole inheritance chain, and for
> > that reason AbstractFunctionDeclaration is a pure abstract class that is
> > just "added" to FunctionDeclaration and ClassFunctionDeclaration. The only
> > other option would be making ClassMemberDeclaration such an abstract
> > class, but that would be a rather useless change.
> 
> So there is no useful connection whatsoever between a FunctionDeclaration and 
> ClassFunctionDeclaration - except for AbstractFunctionDeclaration (typesafe 
> but useless data) or Declaration (not typesafe yet the info I need).
> 
> Or should I only pass pointers to AbstractFunctionDeclarations around and cast 
> them to... well what - Declarations?
> 
> This is rather ugly to work with I must say. Of course I see the problem, yet 
> I do hope that there is some way to make it work nicer!

Hmm, how about rewriting the code in $your-favourite-dynamic-language? I
know this won't be a problem in python or JS and I'm sure it wouldn't be a
problem in either ruby, php or perl  too :)

Andreas

PS: Yes I know this is not a useful post, but I couldn't resist

-- 
You will visit the Dung Pits of Glive soon.




More information about the KDevelop-devel mailing list