Cyclic Dependencies

Steven Schveighoffer schveiguy at yahoo.com
Tue Dec 9 06:52:05 PST 2008


"Ellery Newcomer" wrote
> Hello all,
>
> I began learning D a few months ago, and now I have a question about 
> cyclic dependencies (and some random whining).
>
> I come from a java background and have had no serious exposure to C++. In 
> java, cyclic dependencies are legit to the best of my knowledge. I don't 
> know about C++, thus I don't know about D.
>
> When I first started learning D I decided that a good way to learn it 
> would be by porting a popular java api (mind, I didn't say intelligent), 
> which came complete with a few cyclic dependencies. At the moment, I'm 
> using GDC, and it refuses to swallow cyclic dependencies. The compiler 
> doesn't complain, but it throws a runtime exception. I can break the 
> dependency loops and GDC will work just fine, but what I'm wondering is 
> whether it is standard that the dependency hierarchy be acyclic, or is 
> this some quirk of GDC, or is it more likely that there is something weird 
> going on in my java-to-D translation.

I'm not sure about this problem.  I've not encountered it, but it sounds 
weird that it would cause a runtime error...

>
> Also, I would be trying to compile with DMD, but I have evidently managed 
> to crash the compiler, and I don't know if it's DMD's fault or mine. It 
> reports an Internal Error in e2ir.c at line 3904.

This is a bug in the compiler.  Try to figure out what causes the bug 
(smallest example possible), and post it to digitalmars' bugzilla.  These 
are very weird, sometimes hard to narrow down issues, but it helps the 
compiler writers to have a small test case to reproduce it.

> (not being a C++ guru, the line "assert(n2->Enumbytes);" doesn't mean much 
> to me)

It's saying n2->Enumbytes should not be null, if it is, then throw throw an 
error.

> That was with DMD 1.037, Tango 0.997, and using dsss to build.

Hm... as far as I know, DMD 1.037 doesn't work with Tango 0.99.7.  Did you 
recompile Tango?  Or are you using precompiled libraries?  If you are, you 
should match the compiler to what the libraries were built with.  If you 
need to use 1.037, download the latest svn Tango trunk and compile it, or 
wait for the next release.  There are many corrected issues due to compiler 
changes in the Tango source tree.

>
> On an unrelated note, is this code supposed to be incorrect?
>
> wchar[] w = (true)? "true":"false";
>
> --> Error: cannot implicitly convert expression ("true") of type char[] to 
> wchar[]

A string literal such as "true" is typed as char[].  You cannot assign a 
char[] to a wchar[] without a cast.  Like Zarathustra said, a wchar[] string 
literal is written as "true"w.

-Steve 




More information about the Digitalmars-d-learn mailing list