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

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:

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

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 following

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): } Hundreds of OpenGL decls 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, 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() { auto

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

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: 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 or

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: 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){

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 ellery-newco...@utulsa.edu: Just came across some old D code that does this: version(linux){ extern(C): } Hundreds of OpenGL decls in dmd 2.055, the extern(C) is not being applied to the

Re: attribute decl in version decl

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

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: import

Re: attribute decl in version decl

2011-09-19 Thread Daniel Murphy
Ellery Newcomer ellery-newco...@utulsa.edu 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

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: 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 world will

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): } Hundreds of OpenGL decls 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.

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

Re: attribute decl in version decl

2011-09-19 Thread Trass3r
Change it to the following, and you're golden. extern(System): Hundreds of OpenGL decls 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 Timon Gehr
On 09/19/2011 03:37 PM, Trass3r wrote: Change it to the following, and you're golden. extern(System): Hundreds of OpenGL decls 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

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: attribute decl in version decl

2011-09-19 Thread Ellery Newcomer
On 09/18/2011 11:04 PM, Daniel Murphy wrote: Ellery Newcomer ellery-newco...@utulsa.edu 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

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. }); code golf or

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: A little puzzle

2011-09-19 Thread Simen Kjaeraas
On Mon, 19 Sep 2011 23:20:47 +0200, bearophile bearophileh...@lycos.com 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 Adam Burton
Simen Kjaeraas wrote: On Mon, 19 Sep 2011 23:20:47 +0200, bearophile bearophileh...@lycos.com 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 Timon Gehr
On 09/20/2011 12:50 AM, Adam Burton wrote: Simen Kjaeraas wrote: On Mon, 19 Sep 2011 23:20:47 +0200, bearophilebearophileh...@lycos.com 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,

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.