ForwardDeclaration usage

Milian Wolff mail at milianw.de
Wed Feb 11 15:05:19 UTC 2009


On Mittwoch 11 Februar 2009, Andreas Pakulat wrote:
> On 11.02.09 14:15:24, Milian Wolff wrote:
> > I introduced a PreDeclarationBuilder for PHP but this introduced a bunch
> > of bugs I only now realize. Before I try to fix them, I wanted to ask if
> > I could not make it obsolete by using ForwardDeclarations.
>
> Note: I'm no DUChain expert, however
>
> > Take this code:
> >
> > ~~~~
> > <?php
> > $foo = new Bar;
> > class Bar {}
> > ~~~~
> >
> > I.e.: In PHP it is possible to use classes before they are actually
> > declared.
>
> Actually Bar is used before its defined.

I always confuse those :)

> Anyway, yes I think you could and should use ForwardDeclaration for that,
> because thats really what you're telling the PHP interpreter: Create a new
> object from the class Bar, which I will define later on.

I'll try it out then, as soon as I got the time. But if this is a no-go 
(zwabel?) I'd love to hear that beforehand :D

> The only catch might be if one cannot have the same range covering a 
ForwardDeclaration and a Use, because the new Bar is also still a Use of the 
class Bar...

Since the UseBuilder is run _after_ the DeclarationBuilder I don't think this 
will be a problem.

Thanks for the reply
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20090211/7a7299bf/attachment.sig>


More information about the KDevelop-devel mailing list