D - Another compiler bug? Static struct functions...
- ssuukk (108/108) Dec 19 2003 OK, I wrote about it in different thread, but maybe it will be better to...
-
Carlos Santander B.
(44/44)
Dec 19 2003
"ssuukk"
wrote in message - ssuukk (1/43) Dec 19 2003 But make IS inside frVector struct! :-O
-
Carlos Santander B.
(9/9)
Dec 19 2003
"ssuukk"
wrote in message - ssuukk (3/12) Dec 19 2003 It also compiled for me - for some time. All of the sudden I got this
- Patrick Down (7/19) Dec 19 2003 I have seen this bug before too. Unfortunatly it's been a couple of
- ssuukk (2/18) Dec 19 2003 Certainly, that's what I tought. But "compile order bug" was too crazy
- Patrick Down (3/21) Dec 19 2003 I've seen some crazy bugs while working with D. :-) If I have some time
OK, I wrote about it in different thread, but maybe it will be better to start a new one. For me it seems (due to error message I get) that this is a compiler problem (not to mention the code compiled for some time...) This is the offending code. It gives following error, at this line in the "cross" procedure: return frVector.make(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x); Error: "undefined identifier module frVector.make" (which looks like compiler thinks "make" is a module in subdirectory "frVector", right?) import c.stdio; import std.math; alias double frReal; struct frVector { // aby odwoływać się do nich jako x y z i tablicy union { struct{ frReal x; frReal y; frReal z;}; frReal w[3]; } // niby-konstruktor static frVector make(frReal xx, frReal yy, frReal zz){ frVector result; result.x=xx; result.y=yy; result.z=zz; return result; } // użytkowe void set(frReal xx, frReal yy, frReal zz) { x=xx; y=yy; z=zz; } void set(frVector vv) { x=vv.x; y=vv.y; z=vv.z; } frReal opIndex(int i) { return w[i]; } frReal opIndex(int i, frReal val) { w[i]=val; return val; } void print() { printf("(%f,%f,%f)\n",x,y,z); } // ze skalarem frVector opMul(frReal sc){ return frVector.make(x*sc, y*sc, z*sc); } frVector opDiv(frReal sc){ return frVector.make(x/sc, y/sc, z/sc); } void opDivAssign(frReal sc){ x=x/sc; y=y/sc; z=z/sc; } // unarne frVector opNeg() { frVector vv; return frVector.make(-x,-y,-z); } // z wektorem frVector opAdd(frVector vv){ return frVector.make(vv.x+x,vv.y+y,vv.z+z); } frVector opSub(frVector vv){ return frVector.make(vv.x-x,vv.y-y,vv.z-z); } frVector opMul(frVector vv){ return frVector.make(vv.x*x,vv.y*y,vv.z*z); } frVector opDiv(frVector vv){ return frVector.make(vv.x/x,vv.y/y,vv.z/z); } frReal dot(frVector v) { return x*v.x + y*v.y + z*v.z; } frVector cross(frVector v) { return frVector.make(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x); } // inne frReal magnitudeSquared(){ return x*x + y*y + z*z; } frReal magnitude(){ return sqrt(x*x + y*y + z*z); } void normalize(){ (*this)/=magnitude; } }
Dec 19 2003
"ssuukk" <ssuukk .go2.pl> wrote in message news:brudqd$djh$1 digitaldaemon.com... | OK, I wrote about it in different thread, but maybe it will be better to | start a new one. For me it seems (due to error message I get) that this | is a compiler problem (not to mention the code compiled for some time...) | | This is the offending code. It gives following error, at this line in | the "cross" procedure: | | return frVector.make(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x); | | Error: | | "undefined identifier module frVector.make" | | (which looks like compiler thinks "make" is a module in subdirectory | "frVector", right?) | | | | | import c.stdio; | import std.math; | | alias double frReal; | | struct frVector | { | // aby odwoływać się do nich jako x y z i tablicy | union { | struct{ frReal x; frReal y; frReal z;}; frReal w[3]; | } | | // niby-konstruktor | static frVector make(frReal xx, frReal yy, frReal zz){ | frVector result; | result.x=xx; result.y=yy; result.z=zz; | return result; | } | ... You need to put "make" inside frVector. Or you should make the call just as "make" and not "frVector.make" ----------------------- Carlos Santander Bernal
Dec 19 2003
| OK, I wrote about it in different thread, but maybe it will be better to | start a new one. For me it seems (due to error message I get) that this | is a compiler problem (not to mention the code compiled for some time...) | | This is the offending code. It gives following error, at this line in | the "cross" procedure: | | return frVector.make(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x); | | Error: | | "undefined identifier module frVector.make" | | (which looks like compiler thinks "make" is a module in subdirectory | "frVector", right?) | | | | | import c.stdio; | import std.math; | | alias double frReal; | | struct frVector | { | // aby odwoływać się do nich jako x y z i tablicy | union { | struct{ frReal x; frReal y; frReal z;}; frReal w[3]; | } | | // niby-konstruktor | static frVector make(frReal xx, frReal yy, frReal zz){ | frVector result; | result.x=xx; result.y=yy; result.z=zz; | return result; | } | ... You need to put "make" inside frVector. Or you should make the call just as "make" and not "frVector.make"But make IS inside frVector struct! :-O
Dec 19 2003
"ssuukk" <ssuukk .go2.pl> wrote in message news:bruqgc$vp8$1 digitaldaemon.com... | But make IS inside frVector struct! :-O | My mistake: you're right. And that's the same reason why your code compiles for me. Even a call to frVector.make. ----------------------- Carlos Santander Bernal
Dec 19 2003
Carlos Santander B. wrote:"ssuukk" <ssuukk .go2.pl> wrote in message news:bruqgc$vp8$1 digitaldaemon.com... | But make IS inside frVector struct! :-O | My mistake: you're right. And that's the same reason why your code compiles for me. Even a call to frVector.make.It also compiled for me - for some time. All of the sudden I got this strange error message...
Dec 19 2003
ssuukk <ssuukk .go2.pl> wrote in news:bruvbc$1745$1 digitaldaemon.com:Carlos Santander B. wrote:I have seen this bug before too. Unfortunatly it's been a couple of months since I last played with the Vector lib so I don't remember how I got around it. I do know it started happening when I used the Vector class in a module other than the one it was defined in. I think this may be one of those odd bugs related to the module compile order."ssuukk" <ssuukk .go2.pl> wrote in message news:bruqgc$vp8$1 digitaldaemon.com... | But make IS inside frVector struct! :-O | My mistake: you're right. And that's the same reason why your code compiles for me. Even a call to frVector.make.It also compiled for me - for some time. All of the sudden I got this strange error message...
Dec 19 2003
Certainly, that's what I tought. But "compile order bug" was too crazy for me. I wonder if it will be easy for Walter to replicate this, though :-)I have seen this bug before too. Unfortunatly it's been a couple of months since I last played with the Vector lib so I don't remember how I got around it. I do know it started happening when I used the Vector class in a module other than the one it was defined in. I think this may be one of those odd bugs related to the module compile order.My mistake: you're right. And that's the same reason why your code compiles for me. Even a call to frVector.make.It also compiled for me - for some time. All of the sudden I got this strange error message...
Dec 19 2003
In article <brv3to$1do9$1 digitaldaemon.com>, ssuukk says...I've seen some crazy bugs while working with D. :-) If I have some time this weekend I will try to factor it down into an easy example for Walter.Certainly, that's what I tought. But "compile order bug" was too crazy for me. I wonder if it will be easy for Walter to replicate this, though :-)I have seen this bug before too. Unfortunatly it's been a couple of months since I last played with the Vector lib so I don't remember how I got around it. I do know it started happening when I used the Vector class in a module other than the one it was defined in. I think this may be one of those odd bugs related to the module compile order.My mistake: you're right. And that's the same reason why your code compiles for me. Even a call to frVector.make.It also compiled for me - for some time. All of the sudden I got this strange error message...
Dec 19 2003