[frustration, sorry] Import conflict madness.
Sean Kelly
sean at f4.ca
Sun Jun 18 12:15:38 PDT 2006
Bruno Medeiros wrote:
> Sean Kelly wrote:
>> Dawid Ciężarkiewicz wrote:
>>> You write your great soft in D. You're coding with smile because
>>> everything
>>> in seems to be so good. You added few new files, new classes. Porting
>>> your
>>> project from C++ to D seems to be so good idea. You type "make".
>>>
>>> And then out of nowhere: BANG!!!
>>>
>>> battle.d(31): import battle.map conflicts with cell.cell.map at
>>> cell/cell.d(29)
>>
>> For what it's worth, the symbol resolution rules styled after the C++
>> class-scope rules. On the surface, this does seem to provide solid
>> support for the approach: it's a sticky issue and an established
>> language has solved the problem this way, so why not do that?
>> However, I think the reasons that this rule was chosen for C++ may be
>> related to language syntax that D simply doesn't have, thus reducing
>> the strength of the correlation.
>
> I can't figure out what kind of parallel or comparison could be made of
> symbol resolution with a language that has no structured module system.
> What would be the analogous case in C++ for the situation mentioned
> above? What are the C++ class-scope rules?
C++ class member symbol lookup is roughly similar to module-level lookup
in D at a conceptual level, so Walter modeled the D lookup rules on this
aspect of C++. If you pretend a C++ class is a D module and use
multiple inheritance instead of import you'll see identical behavior for
symbol lookup.
Sean
More information about the Digitalmars-d
mailing list