How to set non-static variable in static method within class

2009-11-19 Thread Sam Hu
Greetings! How to set value to non-static variable in a static method within a class? Given below code: import std.stdio; class InputDialog { string name; static string s_name; static this() { s_name=;

Re: How to set non-static variable in static method within class

2009-11-19 Thread Ary Borenszweig
Sam Hu wrote: Greetings! How to set value to non-static variable in a static method within a class? Given below code: import std.stdio; class InputDialog { string name; static string s_name; static this() { s_name=;

Re: How to set non-static variable in static method within class

2009-11-19 Thread Sam Hu
Ary Borenszweig Wrote: You can't access non-static data from a static method. Non-static data is related to an instance of a class, and a static method is not bound to any instance. Why do you want to do that? Say I want to implement an utility dialog, InputDialog in DFL which is a

Question about mutable arrays

2009-11-19 Thread A Bothe
Hey guys, I've found a problem that occurred since DMD 2.034: When I've created a dynamic array like string[] a; and I want to assign something via the index of this array a[0]=Test; DMD says the array isn't mutable...even if these are normal types like int or char. Does anybody knows how to

Re: Question about mutable arrays

2009-11-19 Thread Ellery Newcomer
A Bothe wrote: Hey guys, I've found a problem that occurred since DMD 2.034: When I've created a dynamic array like string[] a; and I want to assign something via the index of this array a[0]=Test; DMD says the array isn't mutable...even if these are normal types like int or char.

Re: How to set non-static variable in static method within class

2009-11-19 Thread Trass3r
You can't access non-static data from a static method. Non-static data is related to an instance of a class, and a static method is not bound to any instance. Exactly. The only way would be to have some array of instances somewhere to access.

Bypassing the const promise

2009-11-19 Thread Tomek SowiƱski
const on a function forbids changing members: class Wrong { int a; void foo() const { a = 4; } } The above rightly doesn't compile. But with a little twist... class A { int a; void foo(ref int i) const { i = 4; } void foo() const { foo(a);

Re: Bypassing the const promise

2009-11-19 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tomek SowiƱski wrote: const on a function forbids changing members: class Wrong { int a; void foo() const { a = 4; } } The above rightly doesn't compile. But with a little twist... class A { int a; void

Re: Question about mutable arrays

2009-11-19 Thread Phil Deets
On Thu, 19 Nov 2009 09:16:16 -0500, A Bothe i...@alexanderbothe.com wrote: Hey guys, I've found a problem that occurred since DMD 2.034: When I've created a dynamic array like string[] a; and I want to assign something via the index of this array a[0]=Test; DMD says the array isn't

Re: Question about mutable arrays

2009-11-19 Thread Ali Cehreli
A Bothe Wrote: I've found a problem that occurred since DMD 2.034: I am testing it with 2.036. When I've created a dynamic array like string[] a; I like to see it a slice. Even if we go with dynamic array, I see it as an empty dynamic array. and I want to assign something via the index