About FunctionDeclaration and ClassFunctionDeclaration

Andreas Pakulat apaku at gmx.de
Fri Mar 9 11:01:23 UTC 2012


On 09.03.12 10:31:23, Milian Wolff wrote:
> On Friday 09 March 2012 00:42:18 Sven Brauch wrote:
> > [1] PS: While we're at that topic, it would be great to have a few
> > more of those functions anyways, to avoid dynamic_cast type checking.
> > For example, isClassDeclaration() would be useful for me. Is there any
> > general objection in adding such things?
> 
> If it's worth it... Personally I rarely have a case where I just need to know 
> what kind a declaration is, most often I'll also have to call one of the 
> methods of the more concrete type. Hence something like:
> 
> if(c = dynamic_cast<...>(dec)) {
>  c->foo();
> }
> 
> Adding an additional virtual function call here just to save one dynamic cast 
> in some conditions... I doubt this is much faster. And of course not more 
> readable! I'd like to see some benchmark that shows how the dynamic cast 
> compares to the virtual function call :)

Not having much of a clue of how duchain is designed (and probably
unrelated to the problem at hand), I wonder why
AbstractFunctionDeclaration does not inherit from Declaration. The extra
"MergeAbstractFunctionDeclaration" template tripped me over last night
when I looked at the inheritance chain.

>From a design point of view I don't think it makes much sense, but I
guess I'm simply missing something vital to understand the reason.

Andreas

PS: And of course that wouldn't solve the problem that Sven has I think.

PPS: AbstractFunctionDeclaration already has API for the
defaultparameter-stuff as far as I can see. And I'd say all the stuff
shared between ClassFunction and FunctionDeclaration would make sense to
move up there.





More information about the KDevelop-devel mailing list