Calling D code from C

2011-09-19 Thread Jonathan M Davis
Someone who has actually done a C or C++ application or two which used D code should answer this question. I know that there are at least a few folks around here who have done that, but I've never done it myself. http://stackoverflow.com/questions/7480046/implementing-a-c-api-in-d

Re: Is there a profiler for D2?

2011-09-19 Thread Jonathan M Davis
On Tuesday, September 20, 2011 08:35:52 Mirko Pilger wrote: > > Is there any usable profiler for D2? > > dmd -profile I don't believe that it doesn't currently work with 64-bit binaries though, so if you want to run the profiler, you're going to need to do it with a 32-bit binary (which as all

Re: Is there a profiler for D2?

2011-09-19 Thread Mirko Pilger
Is there any usable profiler for D2? dmd -profile

Is there a profiler for D2?

2011-09-19 Thread Cheng Wei
Is there any usable profiler for D2?

Re: D, DLLs, UnrealScript and UDK (Sort of a complex question)

2011-09-19 Thread lsc9x
Excellent! Thanks so much for your feedback!. I am excited to get into C++ and D now.

Re: A little puzzle

2011-09-19 Thread Timon Gehr
On 09/20/2011 12:50 AM, Adam Burton wrote: Simen Kjaeraas wrote: On Mon, 19 Sep 2011 23:20:47 +0200, bearophile wrote: A tiny puzzle I've shown on IRC. This is supposed to create an inverted array of cards, but what does it print instead? import std.stdio, std.algorithm, std.range; void main

Re: A little puzzle

2011-09-19 Thread Adam Burton
Simen Kjaeraas wrote: > On Mon, 19 Sep 2011 23:20:47 +0200, bearophile > wrote: > >> A tiny puzzle I've shown on IRC. This is supposed to create an inverted >> array of cards, but what does it print instead? >> >> import std.stdio, std.algorithm, std.range; >> void main() { >> int[52] cards;

Re: A little puzzle

2011-09-19 Thread Timon Gehr
On 09/19/2011 11:20 PM, bearophile wrote: A tiny puzzle I've shown on IRC. This is supposed to create an inverted array of cards, but what does it print instead? import std.stdio, std.algorithm, std.range; void main() { int[52] cards; copy(iota(cards.length - 1, -1, -1), cards[]);

Re: A little puzzle

2011-09-19 Thread Simen Kjaeraas
On Mon, 19 Sep 2011 23:20:47 +0200, bearophile wrote: A tiny puzzle I've shown on IRC. This is supposed to create an inverted array of cards, but what does it print instead? import std.stdio, std.algorithm, std.range; void main() { int[52] cards; copy(iota(cards.length - 1, -1, -1)

A little puzzle

2011-09-19 Thread bearophile
A tiny puzzle I've shown on IRC. This is supposed to create an inverted array of cards, but what does it print instead? import std.stdio, std.algorithm, std.range; void main() { int[52] cards; copy(iota(cards.length - 1, -1, -1), cards[]); writeln(cards); } Bye, bearophile

Re: attribute decl in version decl

2011-09-19 Thread Ellery Newcomer
On 09/19/2011 08:59 AM, Timon Gehr wrote: > > You could use the C preprocessor ;). Or this, that does the same thing: > > version(V1) private enum _v1=true; > else private enum _v1=false; > mixin((_v1?"extern(System):":"extern(C):")~q{ > // all declarations that should be affected. > }); o

Re: attribute decl in version decl

2011-09-19 Thread Ellery Newcomer
On 09/18/2011 11:04 PM, Daniel Murphy wrote: > "Ellery Newcomer" wrote in message > news:j557r6$vgt$1...@digitalmars.com... >> Just came across some old D code that does this: >> >> version(linux){ >> extern(C): >> } >> > > Are the prototypes extern(Windows) when not on linux, by any chance? Th

Re: Functions, intrinsics, flexibility

2011-09-19 Thread Alex Rønne Petersen
On 18-09-2011 21:47, Timon Gehr wrote: On 09/18/2011 08:57 PM, bearophile wrote: I don't know what is the right design in this case. Intrinsics are useful because they sometimes give more performance, but normal functions are sometimes more handy because they allow more flexibility, like taking

Re: Functions, intrinsics, flexibility

2011-09-19 Thread Ary Manzana
On 9/19/11 3:32 PM, Alex Rønne Petersen wrote: On 18-09-2011 21:47, Timon Gehr wrote: On 09/18/2011 08:57 PM, bearophile wrote: I don't know what is the right design in this case. Intrinsics are useful because they sometimes give more performance, but normal functions are sometimes more handy b

Re: attribute decl in version decl

2011-09-19 Thread Timon Gehr
On 09/19/2011 03:37 PM, Trass3r wrote: Change it to the following, and you're golden. extern(System): That only fixes this particular issue. I once had the following case that can't be done: version(V1) { extern(System): } else { extern(C): } You could use the C preprocessor ;). Or this,

Re: attribute decl in version decl

2011-09-19 Thread Trass3r
Change it to the following, and you're golden. extern(System): That only fixes this particular issue. I once had the following case that can't be done: version(V1) { extern(System): } else { extern(C): }

Re: attribute decl in version decl

2011-09-19 Thread Mike Parker
On 9/19/2011 1:55 AM, Ellery Newcomer wrote: Just came across some old D code that does this: version(linux){ extern(C): } in dmd 2.055, the extern(C) is not being applied to the OpenGL decls. should it? Change it to the following, and you're golden. extern(System):

Re: D, DLLs, UnrealScript and UDK (Sort of a complex question)

2011-09-19 Thread Trass3r
So, my question is THIS: Can I write a "windows" DLL file in D that would have functions that can be accessible from a compiled C++ program? (Actually, in this case, it's UnrealScript that is compiled into a C++ exe.) It's perfectly possible to create DLLs with D, also see http://www.d-prog

Re: D, DLLs, UnrealScript and UDK (Sort of a complex question)

2011-09-19 Thread bearophile
lsc9x: > So, I was poking around looking at C++ books and I wondered "Gee, I know there > were languages A, C, C, C++ and C#, I wonder if there is a "D" language. > > Surprise! There is! > > Not only that, but D sounds like a better language for me to learn than C++ The best language of the wo

D, DLLs, UnrealScript and UDK (Sort of a complex question)

2011-09-19 Thread lsc9x
Dear Friends, I have a pretty technical question about D that I might be making more or less complex based on my lack of knowledge about C++. Any help would be appreciated! I'm a novice programmer who is more into the design end of game design, but I want to learn programming. I know some very

Re: attribute decl in version decl

2011-09-19 Thread Daniel Murphy
"Ellery Newcomer" wrote in message news:j557r6$vgt$1...@digitalmars.com... > Just came across some old D code that does this: > > version(linux){ > extern(C): > } > Are the prototypes extern(Windows) when not on linux, by any chance? That is the only combination I've ever had to use, and is su

Re: newbie question

2011-09-19 Thread bearophile
Timon Gehr: > As to > source-level compatibility, the only "guarantee" that Ds design gives is > that C code will either compile as D code with identical semantics or > not compile at all. In practice there are few differences, try to compile this in C and D, swapping the import/include: imp

Re: attribute decl in version decl

2011-09-19 Thread Ellery Newcomer
On 09/18/2011 04:09 PM, Trass3r wrote: > Am 18.09.2011, 18:55 Uhr, schrieb Ellery Newcomer > : > >> Just came across some old D code that does this: >> >> version(linux){ >> extern(C): >> } >> >> >> >> >> >> in dmd 2.055, the extern(C) is not being applied to the OpenGL decls. >> should it? >

Re: attribute decl in version decl

2011-09-19 Thread Trass3r
Am 18.09.2011, 18:55 Uhr, schrieb Ellery Newcomer : Just came across some old D code that does this: version(linux){ extern(C): } in dmd 2.055, the extern(C) is not being applied to the OpenGL decls. should it? Walter once said it was deliberate. That extern(C) is only valid in

Re: attribute decl in version decl

2011-09-19 Thread Timon Gehr
On 09/18/2011 10:46 PM, Ellery Newcomer wrote: On 09/18/2011 01:02 PM, Timon Gehr wrote: If you are asking, if the D compiler is wrong here: No, it is by design, you can check with the D grammar. Nah, just confirming that failure to apply the externs is a bug. version(linux){ extern(C):

Re: attribute decl in version decl

2011-09-19 Thread Ellery Newcomer
On 09/18/2011 01:02 PM, Timon Gehr wrote: > > If you are asking, if the D compiler is wrong here: No, it is by design, > you can check with the D grammar. Nah, just confirming that failure to apply the externs is a bug.

Re: newbie question

2011-09-19 Thread Timon Gehr
On 09/18/2011 10:08 PM, %u wrote: does D compatibility with C restrict D from evolving ? Binary compatibility as in extern(C) certainly does not. As to source-level compatibility, the only "guarantee" that Ds design gives is that C code will either compile as D code with identical semantics o

newbie question

2011-09-19 Thread %u
does D compatibility with C restrict D from evolving ? and if D drop this will that prevent complexity?

Re: Functions, intrinsics, flexibility

2011-09-19 Thread Timon Gehr
On 09/18/2011 08:57 PM, bearophile wrote: I don't know what is the right design in this case. Intrinsics are useful because they sometimes give more performance, but normal functions are sometimes more handy because they allow more flexibility, like taking their address ("first class functions

Functions, intrinsics, flexibility

2011-09-19 Thread bearophile
I don't know what is the right design in this case. Intrinsics are useful because they sometimes give more performance, but normal functions are sometimes more handy because they allow more flexibility, like taking their address ("first class functions"): import std.math; void main() { aut

Re: attribute decl in version decl

2011-09-19 Thread Timon Gehr
On 09/18/2011 06:55 PM, Ellery Newcomer wrote: Just came across some old D code that does this: version(linux){ extern(C): } in dmd 2.055, the extern(C) is not being applied to the OpenGL decls. should it? Yes they should be applied, unless they declare D functions, which is seld

attribute decl in version decl

2011-09-19 Thread Ellery Newcomer
Just came across some old D code that does this: version(linux){ extern(C): } in dmd 2.055, the extern(C) is not being applied to the OpenGL decls. should it?

Re: Unable to get Phobos working on Ubuntu x64 (Oneiric)

2011-09-19 Thread Jonathan M Davis
On Friday, September 16, 2011 23:15:16 Kiith-Sa wrote: > Jonathan M Davis wrote: > > On Friday, September 16, 2011 12:47 Kiith-Sa wrote: > >> I've just installed a new system - Ubuntu 11.10 beta x64 and can't get > >> dmd/phobos 2.055 to work. > >> > >> When I try to compile file hello.d with the

Re: with() statement doesn't want to work with property functions

2011-09-19 Thread Timon Gehr
On 09/18/2011 05:14 PM, Andrej Mitrovic wrote: struct Bar { int x; } struct Foo { Bar _bar; Bar bar() { return _bar; } } void main() { Foo foo; with (foo.bar) { } } Error: foo.bar() is not an lvalue I've made a getter because I want to control h

Re: Converting Duration to TickDuration

2011-09-19 Thread Jonathan M Davis
On Tuesday, September 13, 2011 04:32:28 Vladimir Panteleev wrote: > The simplest way I found is: > TickDuration.from!"hnsecs"(duration.total!"hnsecs") > > Is there a simpler way? There's now a pull request which adds opCast to Duration which casts to TickDuration: https://github.com/D-Programmin

with() statement doesn't want to work with property functions

2011-09-19 Thread Andrej Mitrovic
struct Bar { int x; } struct Foo { Bar _bar; Bar bar() { return _bar; } } void main() { Foo foo; with (foo.bar) { } } Error: foo.bar() is not an lvalue I've made a getter because I want to control how _bar is manipulated. I've lost the ability to use the w