Re: static class instances not allowed?

2013-06-11 Thread bearophile
C# compilers present bugs with a standard number, like: myprog.cs(7,60): error CS1525: ... This is useful because you can then write an explanation page for each of those bugs, like CS1525: http://msdn.microsoft.com/en-gb/library/3hdyz4dw%28v=vs.80%29.aspx In such pages you can explain w

Re: static class instances not allowed?

2013-06-11 Thread Eric
On Tuesday, 11 June 2013 at 16:09:39 UTC, Steven Schveighoffer wrote: On Tue, 11 Jun 2013 10:04:21 -0400, Eric wrote: The following code does not compile: class Foo { int x; } class Bar { static Foo f = new Foo(); } // compiler error static Foo g = new Foo(); // compiler error These can

Re: static class instances not allowed?

2013-06-11 Thread Steven Schveighoffer
On Tue, 11 Jun 2013 10:04:21 -0400, Eric wrote: The following code does not compile: class Foo { int x; } class Bar { static Foo f = new Foo(); } // compiler error static Foo g = new Foo(); // compiler error These can be solved with a static ctor. Essentially, any static initializers mu

Re: static class instances not allowed?

2013-06-11 Thread Eric
Why aren't static class instances allowed? Is there a work-around, or alternative approach to this? C# compilers present bugs with a standard number, like: myprog.cs(7,60): error CS1525: ... This is useful because you can then write an explanation page for each of those bugs, like CS1

Re: static class instances not allowed?

2013-06-11 Thread bearophile
Eric: The following code does not compile: class Foo { int x; } class Bar { static Foo f = new Foo(); } // compiler error static Foo g = new Foo(); // compiler error void main() {} (dmd7) desk3:~/tp/d_test2/dlib>dmd T.d T.d(4): Error: variable T.Bar.f is mutable. Only const or immutable clas

static class instances not allowed?

2013-06-11 Thread Eric
The following code does not compile: class Foo { int x; } class Bar { static Foo f = new Foo(); } // compiler error static Foo g = new Foo(); // compiler error void main() {} (dmd7) desk3:~/tp/d_test2/dlib>dmd T.d T.d(4): Error: variable T.Bar.f is mutable. Only const or immutable class threa