How can I compile this?
rm
roel.mathys at gmail.com
Sat Oct 14 11:33:15 PDT 2006
Dawid Ciężarkiewicz wrote:
> Tom S wrote:
>
>> Dawid Ciężarkiewicz wrote:
>>> $ make
>>> bud rdwars \
>>> -w -op -debug -gc \
>>> -od.obj \
>>> -Xstd \
>>> -L-ldl
>>> map.d(43): enum Direction is forward referenced
>>> make: *** [rdwars] Error 1
>>>
>>>
>>> PLEASE. I just can't go through ...
>>>
>>> Only dmd/phobos + bud should be needed.
>>
>> I fixed it by putting Direction in its own module, 'direction' and
>> importing where necessary. This essentially moves the Direction enum out
>> of an import cycle, which seems to be the root of the problem.
>> Actually, cyclic imports can cause many sorts of problems and it's
>> generally wise to avoid them altogether
>>
>> Powodzenia! ;)
>
> Well this sucks. How can you people write real programs? If'd be forced to
> put every enum in it's own file I'll end up with mess and no hair on my
> head.
>
> I'll do as you told me. But I will not start any new project in D. I'll wait
> until D is ready. What is the point of having fancy features where simple
> things are messed up. :/
>
> Dzięki. :) Dalej powinno być z górki ... - oby.
cyclic dependencies should work agreed, but I couldn't easily follow the
dependencies you created in your program.
even more, all your import are plain imports :-)
you'd better use "private import ..."
that prevents symbols imported in a module for it's internal
implementation to leak through to other modules.
an example:
module A import module B
module B import module C
=> all public definitions in module C are now available in module A
=> the definitions in C are available in B and in A
or:
module A private import module B
module B private import module C
=> only symbols defined in B are available in A
=> C symbols are not available in A
=> you wish C in A, do a new private import I'd say
roel
More information about the Digitalmars-d-learn
mailing list