Re: Can't get D calling C to build.

2010-08-20 Thread Bob Cowdery
Thanks for the replies. I've bounced off D a few times because it didn't seem ready to risk a whole development. I should have mentioned I'm trying this on Windows 7. I did suspect object formats were incompatible but as you say would have expected a decent error message. I also tried from the

Re: Can't get D calling C to build.

2010-08-20 Thread Bob Cowdery
On 20/08/2010 06:51, Kagamin wrote: Bob Cowdery Wrote: Now I've tried this with just D code and it writes the output and runs so I know something works. Does anyone know where to look, is it Code::Blocks, compiler, stupidity (probably). On windows dmd uses ancient OMF object format, but gcc

Dynamic method example in TDPL

2010-08-20 Thread Joel Christensen
I've typed this example program in, but it doesn't compile. I looked up the The D programming language errata but it wasn't listed. I'm using DMD v2.048. /** Date: Aug 20, 2010 This was copied from TDPL book pages 386 - 387 */ module dynamicmethods; import std.stdio; import

Re: unittest questions

2010-08-20 Thread Johannes Pfau
On 20.08.2010 01:17, Jonathan M Davis wrote: If you declare a nested function as static, it shouldn't be a delegate. Also, I don't believe that you need the semicolon after the function declaration. - Jonathan m Davis Thanks for all the answers. I guess I'll just declare the functions as

Re: Getting .init of a Typetuple

2010-08-20 Thread Johannes Pfau
On 19.08.2010 22:07, Philippe Sigaud wrote: And, looking in my codebase, here is what I'm using ;) template Init(T...) { T Init; } It's so simple... I think I found this before the bug report and then forgot about it and copied an old version. I'll update the bug report

Re: Dynamic method example in TDPL

2010-08-20 Thread Stanislav Blinov
20.08.2010 13:00, Joel Christensen wrote: There seem to be quite a few errors in this one: /** Date: Aug 20, 2010 This was copied from TDPL book pages 386 - 387 */ module dynamicmethods; import std.stdio; import std.variant; alias Variant delegate(Dynamic self, Variant[] args...)

Re: String literals have only one instance?

2010-08-20 Thread Rory Mcguire
Rory Mcguire wrote: Are all string literals that have the same value initialized to the same address? void main() { string same() { return This; } assert(This is same()); assert(This is This); } Can this be relied upon? Interesting thanks guys. Was just curious about the speed

Re: Dynamic method example in TDPL

2010-08-20 Thread Andrej Mitrovic
You mean Andrei? P.S. anyone can edit the errata page. It has a history backup, so if someone accidentally screws up something you can roll back to a previous version. If you find something that needs to be added, go ahead and do it. Btw., I haven't reached that page yet. :p Stanislav Blinov

Re: Dynamic method example in TDPL

2010-08-20 Thread Stanislav Blinov
20.08.2010 15:49, Andrej Mitrovic wrote: You mean Andrei? Nope :p P.S. anyone can edit the errata page. It has a history backup, so if someone accidentally screws up something you can roll back to a previous version. If you find something that needs to be added, go ahead and do it. Yeah, I

Re: having trouble linking a library into a DLL

2010-08-20 Thread Stanislav Blinov
20.08.2010 1:04, Cody Rose wrote: try using -L/IMPLIB:canto.lib I'm trying to create a Windows DLL as described in the tutorial at http://www.digitalmars.com/d/2.0/dll.html. I got the basic example working fine, but if I try to get more complicated, it doesn't work. Specifically, I'm trying

Re: Can't get D calling C to build.

2010-08-20 Thread Bob Cowdery
A bit more playing and I see that it's assumed that C code is compiled with dmc and then the D code can be compiled with dmd which will also link in the obj left by dmc. It wasn't clear at all that to make things work easily one needs to use both the C and D Digital Mars compilers. Code::Blocks

Re: Can't get D calling C to build.

2010-08-20 Thread div0
On 20/08/2010 09:17, Bob Cowdery wrote: I'm still concerned it's a bit too soon as a lot of things seem to be either Windows or Linux (cmake says its only tested for *nix) but not both and there is very little guidance on building. I really want to get this working on Windows first. As D makes

Problem with using as shorthand for if

2010-08-20 Thread Ersin Er
Hi, The following code compiles and outputs 1 = 1 as expected: 1 == 1 writeln(1 = 1); However, the following code fails to compile (although it should not): 1 == 2 writeln(1 = 2); The error is as follows: Error: integral constant must be scalar type, not void What I expect that the second

Re: Problem with using as shorthand for if

2010-08-20 Thread Jonathan M Davis
On Friday, August 20, 2010 13:06:11 div0 wrote: On 20/08/2010 20:59, Ersin Er wrote: Hi, The following code compiles and outputs 1 = 1 as expected: 1 == 1 writeln(1 = 1); However, the following code fails to compile (although it should not): 1 == 2 writeln(1 = 2); The

Re: Problem with using as shorthand for if

2010-08-20 Thread Iain Buclaw
== Quote from Ersin Er (ersin...@gmail.com)'s article Hi, The following code compiles and outputs 1 = 1 as expected: 1 == 1 writeln(1 = 1); However, the following code fails to compile (although it should not): 1 == 2 writeln(1 = 2); The error is as follows: Error: integral constant must

Re: Problem with using as shorthand for if

2010-08-20 Thread div0
On 20/08/2010 21:16, Jonathan M Davis wrote: It's legal according to TDPL. It seems to be intended to be used as a shorthand for if. So, stuff like condition writeln(my output); are supposed to be perfectly legal as bizarre as that may seem. I don't believe that it would be legal to do

Re: Problem with using as shorthand for if

2010-08-20 Thread Jonathan M Davis
On Friday, August 20, 2010 14:00:22 div0 wrote: Then Andrei has taken leave of his senses and this is one situation where DMD is corrent and TDPL is wrong. Half arsed, moronic shortcuts like that belong in scripting languages and shell environements, not serious programming languages. Well,

Re: Problem with using as shorthand for if

2010-08-20 Thread Ersin Er
On Sat, Aug 21, 2010 at 00:00, div0 d...@sourceforge.net wrote: On 20/08/2010 21:16, Jonathan M Davis wrote: It's legal according to TDPL. It seems to be intended to be used as a shorthand for if. So, stuff like condition writeln(my output); are supposed to be perfectly legal as

Re: Problem with using as shorthand for if

2010-08-20 Thread Ersin Er
On Fri, Aug 20, 2010 at 23:06, div0 d...@sourceforge.net wrote: On 20/08/2010 20:59, Ersin Er wrote: Hi, The following code compiles and outputs 1 = 1 as expected: 1 == 1 writeln(1 = 1); However, the following code fails to compile (although it should not): 1 == 2 writeln(1 = 2);

Re: Problem with using as shorthand for if

2010-08-20 Thread bearophile
Jonathan M Davis: Well, Andrei is definitely a fan of using D for small scripts, so arguments that something shouldn't be done because it's intended for scripting aren't going to fly with him. Personally, I find it a bit weird, but I don't really care. I probably won't code that way,

Re: Problem with using as shorthand for if

2010-08-20 Thread Jonathan M Davis
On Friday, August 20, 2010 15:32:16 bearophile wrote: Jonathan M Davis: Well, Andrei is definitely a fan of using D for small scripts, so arguments that something shouldn't be done because it's intended for scripting aren't going to fly with him. Personally, I find it a bit weird, but I

Re: __gshared on structs

2010-08-20 Thread bearophile
Bernard Helyer: Because DMD ignores invalid attributes, and almost never flags them as an error (or even a warning!). Vote this: http://d.puremagic.com/issues/show_bug.cgi?id=3934 Bye, bearophile