digitalmars.D - Well that was stupid of me (feature request)
- BCS (32/32) Sep 10 2007 I just came across a stupid little mistake I made that probably added a ...
- Bruno Medeiros (5/25) Sep 11 2007 That code does compile: it has syntax errors.
- BCS (5/27) Sep 11 2007 I never clamed it did compile. In fact the code shown doesn't actually g...
- Bruno Medeiros (9/41) Sep 11 2007 I know it actually has not to do with your point, but you asked for
-
BCS
(5/44)
Sep 11 2007
well that assumes they "cheat" and try to compile it. "Real men... - Bruno Medeiros (5/54) Sep 11 2007 I noticed your syntax error without compiling. My point maintains. :)
-
BCS
(2/10)
Sep 11 2007
8-O ...
I just came across a stupid little mistake I made that probably added a few dozen K to may app. template Foo(T) { int Bar() { struct Baz {int i; char j} Stack!(Baz) newton; } } struct Stack(T) { unittest { writef("%s\n", T.stringof); } } Look at that for a few seconds. Do you see it? Well I didn't at first. In fact it wasn't until I added the status report line to my unittest that I notice the problem. What I saw was about 10 time too many copies of the unittest running. And all on the same type. After staring at it for a while (and eating dinner, and doing some homework) I figured it out. The Baz type is not one type, but one type for /every/ version of the Foo template. Therefor you get a different (identical) version of the Stack template for every copy of the Foo template. The solution is easy in this case. Move Baz out of Foo. However What would be nice is a way to say; "This thing that is inside of a template is the same thing for all versions of the template". Note: if you want a type to be reused for only some of the template args, you could make it a template marked for reuses but specialize it on the args you want to keep.
Sep 10 2007
BCS wrote:I just came across a stupid little mistake I made that probably added a few dozen K to may app. template Foo(T) { int Bar() { struct Baz {int i; char j} Stack!(Baz) newton; } } struct Stack(T) { unittest { writef("%s\n", T.stringof); } }That code does compile: it has syntax errors. -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Sep 11 2007
Reply to Bruno,BCS wrote:I never clamed it did compile. In fact the code shown doesn't actually give you anything at all because none of the template are instanced. However that has nothing to do with my point. My point is about a subtle bug in a piece of my code that looks a lot like this.I just came across a stupid little mistake I made that probably added a few dozen K to may app. template Foo(T) { int Bar() { struct Baz {int i; char j} Stack!(Baz) newton; } } struct Stack(T) { unittest { writef("%s\n", T.stringof); } }That code does compile: it has syntax errors.
Sep 11 2007
BCS wrote:Reply to Bruno,I know it actually has not to do with your point, but you asked for people to look at your code, and see if they could see the mistake. But with a syntax error it would be hard to find the intended mistake without actually reading the part where you say what it is. That's all I'm saying :) -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#DBCS wrote:I never clamed it did compile. In fact the code shown doesn't actually give you anything at all because none of the template are instanced. However that has nothing to do with my point. My point is about a subtle bug in a piece of my code that looks a lot like this.I just came across a stupid little mistake I made that probably added a few dozen K to may app. template Foo(T) { int Bar() { struct Baz {int i; char j} Stack!(Baz) newton; } } struct Stack(T) { unittest { writef("%s\n", T.stringof); } }That code does compile: it has syntax errors.
Sep 11 2007
Reply to Bruno,BCS wrote:<joking> well that assumes they "cheat" and try to compile it. "Real men" don't need a compiler to take on this kind of challenge! </joking> Then again "real men" can do a better job parsing code in there head than "girly men" can do /with/ a compiler. <G>Reply to Bruno,I know it actually has not to do with your point, but you asked for people to look at your code, and see if they could see the mistake. But with a syntax error it would be hard to find the intended mistake without actually reading the part where you say what it is. That's all I'm saying :)BCS wrote:I never clamed it did compile. In fact the code shown doesn't actually give you anything at all because none of the template are instanced. However that has nothing to do with my point. My point is about a subtle bug in a piece of my code that looks a lot like this.I just came across a stupid little mistake I made that probably added a few dozen K to may app. template Foo(T) { int Bar() { struct Baz {int i; char j} Stack!(Baz) newton; } } struct Stack(T) { unittest { writef("%s\n", T.stringof); } }That code does compile: it has syntax errors.
Sep 11 2007
BCS wrote:Reply to Bruno,I noticed your syntax error without compiling. My point maintains. :) -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#DBCS wrote:<joking> well that assumes they "cheat" and try to compile it. "Real men" don't need a compiler to take on this kind of challenge! </joking> Then again "real men" can do a better job parsing code in there head than "girly men" can do /with/ a compiler. <G>Reply to Bruno,I know it actually has not to do with your point, but you asked for people to look at your code, and see if they could see the mistake. But with a syntax error it would be hard to find the intended mistake without actually reading the part where you say what it is. That's all I'm saying :)BCS wrote:I never clamed it did compile. In fact the code shown doesn't actually give you anything at all because none of the template are instanced. However that has nothing to do with my point. My point is about a subtle bug in a piece of my code that looks a lot like this.I just came across a stupid little mistake I made that probably added a few dozen K to may app. template Foo(T) { int Bar() { struct Baz {int i; char j} Stack!(Baz) newton; } } struct Stack(T) { unittest { writef("%s\n", T.stringof); } }That code does compile: it has syntax errors.
Sep 11 2007
Reply to Bruno,BCS wrote:8-O ... <g>Then again "real men" can do a better job parsing code in there head than "girly men" can do /with/ a compiler. <G>I noticed your syntax error without compiling. My point maintains. :)
Sep 11 2007