digitalmars.D.learn - Immutable & circular imports
- =?iso-8859-2?B?VG9tZWsgU293afFza2k=?= (29/29) Dec 16 2009 Amusing things happen when immutable arguments and circular imports are ...
- grauzone (4/41) Dec 16 2009 There are a _lot_ of circular dependency bugs, and there are a lot of
- =?iso-8859-2?B?VG9tZWsgU293afFza2k=?= (11/14) Dec 17 2009 =
Amusing things happen when immutable arguments and circular imports are put together: ---------------------------------------------- module hello; import test; struct Strukt { Staly* s; } ---------------------------------------------- module test; import hello; immutable struct Staly { int a; } void f_strukt(Strukt* stk) { f_staly(stk.s); // ups! } void f_staly(Staly* s) { } ---------------------------------------------- Error: function test.f_staly (immutable(Staly)* s) is not callable using argument types (Staly*) Error: cannot implicitly convert expression ((*stk).s) of type Staly* to immutable(Staly)* Am I writing code too weird or is this a compiler bug? The only thing about circular imports on D page is: "Cycles (circular dependencies) in the import declarations are allowed as long as not both of the modules contain static constructors or static destructors." So what I tried to pull off seems fair game. Tomek
Dec 16 2009
Tomek Sowiński wrote:Amusing things happen when immutable arguments and circular imports are put together: ---------------------------------------------- module hello; import test; struct Strukt { Staly* s; } ---------------------------------------------- module test; import hello; immutable struct Staly { int a; } void f_strukt(Strukt* stk) { f_staly(stk.s); // ups! } void f_staly(Staly* s) { } ---------------------------------------------- Error: function test.f_staly (immutable(Staly)* s) is not callable using argument types (Staly*) Error: cannot implicitly convert expression ((*stk).s) of type Staly* to immutable(Staly)* Am I writing code too weird or is this a compiler bug? The only thing about circular imports on D page is: "Cycles (circular dependencies) in the import declarations are allowed as long as not both of the modules contain static constructors or static destructors." So what I tried to pull off seems fair game.There are a _lot_ of circular dependency bugs, and there are a lot of immutable related bugs. Combine both together and you get... probably even more bugs.Tomek
Dec 16 2009
Dnia 17-12-2009 o 01:14:53 grauzone <none example.net> napisa=B3(a):There are a _lot_ of circular dependency bugs, and there are a lot of ==immutable related bugs. Combine both together and you get... probably ==even more bugs.So I'm noticing... BTW, what is your approach to avoid such woes when = writing in D2? Best I could think of so far is putting /*immutable*/, = /*pure*/, etc. and relying on "mind compiling" and discipline... which i= s = little fun. Anyway, thanks for reply. I filed a bug. http://d.puremagic.com/issues/show_bug.cgi?id=3D3629 Tomek
Dec 17 2009