Re: GtkD HelloWorld app crashes with exception

2013-05-17 Thread Alexandr Druzhinin
18.05.2013 9:52, Enjoys Math пишет: I'm on Windows 7 64-bit and using DMD2, compiling a regular 32-bit windows app using Visual D "New Project > Windows App" and replacing winmain.d with the code below: > ... I'm using GtkD-2.2.0 from here: https://code.google.com/p/gtkd-packages/downloads/li

GtkD HelloWorld app crashes with exception

2013-05-17 Thread Enjoys Math
I'm on Windows 7 64-bit and using DMD2, compiling a regular 32-bit windows app using Visual D "New Project > Windows App" and replacing winmain.d with the code below: module winmain; private import gtk.MainWindow; private import gtk.Label; private import gtk.Main; class HelloWorld : MainWind

Re: Find variable at run time

2013-05-17 Thread Josh
On Friday, 17 May 2013 at 22:15:09 UTC, bearophile wrote: Josh: Is something like this possible in D? void main() { int x, y, z; write("Increment which variable: "); string input = readln()[0..$ - 1]; findVar(input)++; writeln(x, y, z); } The Go language and its standard libra

Re: Compiler bug ?

2013-05-17 Thread Jesse Phillips
On Friday, 17 May 2013 at 14:35:35 UTC, Maxim Fomin wrote: If it alwalys a bad idea, compiler should not accept such code. I'm pretty sure the answer is: Compilers can have different extensions, it would be bad for a compiler to reject code which is valid by another compiler. That said, I d

Re: how to have alias this with an unaccessible member?

2013-05-17 Thread Timothee Cour
so in what you suggest, the exact same problem remains with 'get' being exposed instead of 'x', so the situation didn't improve... looks like it's impossible to achieve this? On Fri, May 17, 2013 at 4:24 PM, Simen Kjaeraas wrote: > On Sat, 18 May 2013 01:13:00 +0200, Timothee Cour < > thelastma

Re: how to have alias this with an unaccessible member?

2013-05-17 Thread Simen Kjaeraas
On Sat, 18 May 2013 01:13:00 +0200, Timothee Cour wrote: How to have alias this with an unaccessible member (x below). Making the member private won't work as it'll disable all operations on said member. struct A(T){ T x; //private T x would prevent alias this from doing anything us

how to have alias this with an unaccessible member?

2013-05-17 Thread Timothee Cour
How to have alias this with an unaccessible member (x below). Making the member private won't work as it'll disable all operations on said member. struct A(T){ T x; //private T x would prevent alias this from doing anything useful alias x this; } void main(){ auto a=A!int; a++;//sho

Re: Find variable at run time

2013-05-17 Thread bearophile
Josh: Is something like this possible in D? void main() { int x, y, z; write("Increment which variable: "); string input = readln()[0..$ - 1]; findVar(input)++; writeln(x, y, z); } The Go language and its standard library make the usage of such runtime reflection much sim

Re: Find variable at run time

2013-05-17 Thread Adam D. Ruppe
Not with local variables, but you can with a struct. === import std.stdio; void main() { struct Vars { int x; int y; int z; ref int get(string name) { // allMembers gets the names of each member as a

Re: Compiler bug ?

2013-05-17 Thread 1100110
On 05/17/2013 12:27 PM, Jonathan M Davis wrote: > On Friday, May 17, 2013 19:19:46 bearophile wrote: >> I think to answer this issue we need someone that knows more >> about the DMD compiler (as Kenji Hara). I think that if we want >> to forbid those variables in user code, then probably there is a

Re: Compiler bug ?

2013-05-17 Thread Maxim Fomin
On Friday, 17 May 2013 at 17:08:31 UTC, Jonathan M Davis wrote: On Friday, May 17, 2013 11:59:38 1100110 wrote: On 05/17/2013 09:35 AM, Maxim Fomin wrote: > If it alwalys a bad idea, compiler should not accept such > code. It is not the D way to forbid you from shooting yourself in the foot.

Re: Compiler bug ?

2013-05-17 Thread Jonathan M Davis
On Friday, May 17, 2013 19:19:46 bearophile wrote: > I think to answer this issue we need someone that knows more > about the DMD compiler (as Kenji Hara). I think that if we want > to forbid those variables in user code, then probably there is a > way do to it. Oh, I'm sure that it would be possi

Re: Compiler bug ?

2013-05-17 Thread bearophile
Jonathan M Davis: However, if it _never_ makes sense to declare a variable beginning with two underscores, I don't know why the compiler wouldn't forbid it other than the fact that it probably inserts such variables prior to when it would do the semantic analysis to check whether variables st

Re: Compiler bug ?

2013-05-17 Thread Jonathan M Davis
On Friday, May 17, 2013 11:59:38 1100110 wrote: > On 05/17/2013 09:35 AM, Maxim Fomin wrote: > > If it alwalys a bad idea, compiler should not accept such code. > > It is not the D way to forbid you from shooting yourself in the foot. > > goto, catch(Throwable th), there are plenty more examples.

Re: Compiler bug ?

2013-05-17 Thread Jonathan M Davis
On Friday, May 17, 2013 16:40:23 Temtaime wrote: > Yes, i want to see 'undeclared variable' error, but the compiler > omits function declaration instead. > > And why i shouldn't use __? I think it's ordinary identifier. Identifiers begining with two underscores are reserved by the compiler, which

Re: Compiler bug ?

2013-05-17 Thread 1100110
On 05/17/2013 09:35 AM, Maxim Fomin wrote: > On Friday, 17 May 2013 at 14:12:10 UTC, Namespace wrote: >> I don't see where k comes from? > > I think the point is that it comes from nowhere. Compiler incorectly > omits two errors from output: "Error undefined indentifier" and > "template instance e

Re: Compiler bug ?

2013-05-17 Thread Ali Çehreli
On 05/17/2013 07:40 AM, Temtaime wrote: Yes, i want to see 'undeclared variable' error, but the compiler omits function declaration instead. And why i shouldn't use __? I think it's ordinary identifier. "Iden­ti­fiers start­ing with __ (two un­der­scores) are re­served." http://dlang.org/le

Re: Compiler bug ?

2013-05-17 Thread Namespace
On Friday, 17 May 2013 at 14:35:35 UTC, Maxim Fomin wrote: On Friday, 17 May 2013 at 14:12:10 UTC, Namespace wrote: I don't see where k comes from? I think the point is that it comes from nowhere. Compiler incorectly omits two errors from output: "Error undefined indentifier" and "template i

Re: delegates and temporary struct

2013-05-17 Thread Steven Schveighoffer
On Thu, 16 May 2013 18:53:55 -0400, Jack Applegame wrote: Look at this code: import std.stdio; class Foo { int value = 123456; } struct Bar { this(Foo f) { foo = f; } @property auto lambda() { return (){ writefln("value = %s", foo.value); }; } Foo foo; } auto getLambda(Foo f) { re

Re: Compiler bug ?

2013-05-17 Thread bearophile
Maxim Fomin: If it alwalys a bad idea, compiler should not accept such code. Ideally you are right. But I think sometimes you want to use those reserved names... So I don't know. Bye, bearophile

Re: Compiler bug ?

2013-05-17 Thread bearophile
Temtaime: This code doesn't compiles with an error: Error: 'b' is not of arithmetic type, it is a B If i remove k++, then it's OK. It seems that compiler omitting the function if there an error in it. It's a bad error message, but it's correct, because k doesn't exists. This error message i

Re: Compiler bug ?

2013-05-17 Thread Temtaime
Yes, i want to see 'undeclared variable' error, but the compiler omits function declaration instead. And why i shouldn't use __? I think it's ordinary identifier.

Re: Compiler bug ?

2013-05-17 Thread Maxim Fomin
On Friday, 17 May 2013 at 14:12:10 UTC, Namespace wrote: I don't see where k comes from? I think the point is that it comes from nowhere. Compiler incorectly omits two errors from output: "Error undefined indentifier" and "template instance error instantiation". This should go to bugzilla.

Re: Compiler bug ?

2013-05-17 Thread Namespace
I don't see where k comes from? And it's always a bad idea to prefix a variable with '__', because this is reserved to the compiler.

Compiler bug ?

2013-05-17 Thread Temtaime
struct A { int opBinary(string op)(A) { k++; return 0; } } struct B { A __a; alias __a this; } void main() { B b; auto c = b * b; } This code doesn't compiles with an error: Error: 'b' is not of arithmetic type, it is a B If i remove k++, then it's OK. It seems

Re: Using MySql with D on Mac OS 10.8

2013-05-17 Thread Jacob Carlborg
On 2013-05-17 14:00, Gary Willoughby wrote: Are there any decent wrappers available for D to allow me to read data from a file and place it into a MySql database. I'm using Mac OS 10.8. Is there an official library? Has anyone used MySql with D on Mac OS? Check this out: http://forum.dlang.org

Using MySql with D on Mac OS 10.8

2013-05-17 Thread Gary Willoughby
Are there any decent wrappers available for D to allow me to read data from a file and place it into a MySql database. I'm using Mac OS 10.8. Is there an official library? Has anyone used MySql with D on Mac OS? Thanks.

Re: Recursive mixin templates

2013-05-17 Thread Sebastian Graf
On Thursday, 16 May 2013 at 15:34:54 UTC, Simen Kjaeraas wrote: This is one of those weird things. I believe it is intentional, but I feel it should be a bug. Basically, overload sets cannot cross mixin borders. So if two mixins create a function with the same name, they don't overload prope