Re: Defining classes with cyclic dependencies

2024-03-17 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 17 March 2024 at 20:38:16 UTC, Per Nordlöw wrote: I was surprised that the compiler cannot compile ```d class A { B b; } class B { C c; } class C { D d; } class D { A a; } ``` . Shouldn't it? Ahh, nevermind. I defined these inside a unittest scope so that's why it failed. Defining

Defining classes with cyclic dependencies

2024-03-17 Thread Per Nordlöw via Digitalmars-d-learn
I was surprised that the compiler cannot compile ```d class A { B b; } class B { C c; } class C { D d; } class D { A a; } ``` . Shouldn't it?

Re: What sorts of things cause cyclic dependencies?

2010-10-14 Thread spir
as well? There > > is no way to determine which constructor to run first, so the runtime > > throws a "cyclic dependency" exception. > > > I should mention that this can happen with larger cycles as well, i.e. "a > imports b, b imports c, c imports ..., ..

Re: What sorts of things cause cyclic dependencies?

2010-10-14 Thread Steven Schveighoffer
t; throws a "cyclic dependency" exception. I should mention that this can happen with larger cycles as well, i.e. "a imports b, b imports c, c imports ..., ... imports a". This can make some cyclic dependencies very hard to track down. There was a discussion about this on

Re: What sorts of things cause cyclic dependencies?

2010-10-14 Thread bearophile
Jonathan M Davis: > Well, just knowing that it involves module constructors is definitely useful, > though the error message really needs to be improved. Thanks. You may file a bug report, with an example, asking for a better error message (with a better wording), or a much better error message

Re: What sorts of things cause cyclic dependencies?

2010-10-13 Thread Jonathan M Davis
ay to determine which constructor to run first, so the runtime > > throws a "cyclic dependency" exception. > > I should mention that this can happen with larger cycles as well, i.e. "a > imports b, b imports c, c imports ..., ... imports a". This can make > some cyc

Re: What sorts of things cause cyclic dependencies?

2010-10-13 Thread Lars T. Kyllingstad
before a's, > since a depends on b. But what happens if b imports a as well? There > is no way to determine which constructor to run first, so the runtime > throws a "cyclic dependency" exception. I should mention that this can happen with larger cycles as well, i.e. "a

Re: What sorts of things cause cyclic dependencies?

2010-10-13 Thread Lars T. Kyllingstad
On Wed, 13 Oct 2010 21:25:15 -0700, Jonathan M Davis wrote: > Okay. in the code that I'm working on at the moment, I get an exception > saying that a cyclic dependency was detected but no information > whatsoever as to where it is or what it means. I haven't been able to > find much information on

What sorts of things cause cyclic dependencies?

2010-10-13 Thread Jonathan M Davis
Okay. in the code that I'm working on at the moment, I get an exception saying that a cyclic dependency was detected but no information whatsoever as to where it is or what it means. I haven't been able to find much information on them other than some discussions of making it so that the compile

Re: Cyclic Dependencies

2009-02-16 Thread Ellery Newcomer
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

Re: Cyclic Dependencies

2008-12-09 Thread Steven Schveighoffer
"Jarrett Billingsley" wrote > It can obviously be argued that since the operands of ?: are constant, > the compiler _could_ figure out that they should be of type wchar[], > but that would make the semantic analysis more complicated, and since > appending 'w' to the strings is far easier, it probab

Re: Cyclic Dependencies

2008-12-09 Thread Ary Borenszweig
Jarrett Billingsley wrote: On Tue, Dec 9, 2008 at 12:00 PM, Ellery Newcomer <[EMAIL PROTECTED]> wrote: Derek Parnell wrote: > It is not a bug. A string literal such as "true" is a char[] type (UTF8), and the compiler will not implicitly convert UTF8 to UTF16 (wchar[]). Which would then beg th

Re: Cyclic Dependencies

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 12:00 PM, Ellery Newcomer <[EMAIL PROTECTED]> wrote: > Derek Parnell wrote: > > It is not a bug. A string literal such as "true" is a char[] type (UTF8), >> >> and the compiler will not implicitly convert UTF8 to UTF16 (wchar[]). > > Which would then beg the obvious > > wcha

Re: Cyclic Dependencies

2008-12-09 Thread Ellery Newcomer
Lars Ivar Igesund wrote: Tango 0.99.7 doesn't support DMD 1.037 - either use DMD 1.033 or check out Tango trunk. Say what you will, I got it to work :) I also experienced the crash on 1.030, 1.033, and 1.035 variously on linux and windows, so 1.037 was just to see if it had been fixed by

Re: Cyclic Dependencies

2008-12-09 Thread Ellery Newcomer
Derek Parnell wrote: > It is not a bug. A string literal such as "true" is a char[] type (UTF8), and the compiler will not implicitly convert UTF8 to UTF16 (wchar[]). Which would then beg the obvious wchar[] w = "true";

Re: Cyclic Dependencies

2008-12-09 Thread Ellery Newcomer
torhu wrote: You can't use module constructors (static this) in modules that import each other. So THAT'S why I couldn't replicate it :)

Re: Cyclic Dependencies

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 9:52 AM, Steven Schveighoffer <[EMAIL PROTECTED]> wrote: > I'm not sure about this problem. I've not encountered it, but it sounds > weird that it would cause a runtime error... It is weird. [a.d] module a; import b; static this(){} void main(){} [b.d] mod

Re: Cyclic Dependencies

2008-12-09 Thread Steven Schveighoffer
"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 dependenc

Re: Cyclic Dependencies

2008-12-09 Thread Denis Koroskin
On Tue, 09 Dec 2008 10:26:29 +0300, Ellery Newcomer <[EMAIL PROTECTED]> wrote: 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. (not being a C++

Re: Cyclic Dependencies

2008-12-09 Thread Lars Ivar Igesund
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 le

Re: Cyclic Dependencies

2008-12-09 Thread torhu
Ellery Newcomer wrote: 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 de

Re: Cyclic Dependencies

2008-12-09 Thread Derek Parnell
On Tue, 09 Dec 2008 01:26:29 -0600, Ellery Newcomer wrote: > > wchar[] w = (true)? "true":"false"; > > --> Error: cannot implicitly convert expression ("true") of type char[] > to wchar[] > > or should it be reported as a bug? It is not a bug. A string literal such as "true" is a char[] type

Re: Cyclic Dependencies

2008-12-08 Thread Zarathustra
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 le

Cyclic Dependencies

2008-12-08 Thread Ellery Newcomer
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 ab