ForwardDeclaration usage
Niko Sams
niko.sams at gmail.com
Wed Feb 11 16:02:14 UTC 2009
On Wed, Feb 11, 2009 at 4:05 PM, Milian Wolff <mail at milianw.de> wrote:
> 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
I talked with david about exactly this issue and one way to solve this issue
is using ForwardDeclaration. However I decided to run the DeclarationBuilder two
times - just because it was much simpler to implement.
If you resolve those ForwardDeclarations into real Declarations and remove the
invalid ones after building I don't see any problem.
Niko
More information about the KDevelop-devel
mailing list