I keep running into places where I need to support static initializers.
Do you guys like the Java syntax of "class { static {..} }"?
You can have multiple static {} blocks which are merged in definition order.
andyMon 12 Dec 2005
You mean just static code blocks? Not inner classes or anything? Java's is ok - haven't seen how anyone else does it though.
brianMon 12 Dec 2005
C# does with a static constructor:
class Foo
{
static Foo()
{
}
}
Java seems simpler.
johnMon 12 Dec 2005
I actually like C# better because it forces you to do that stuff in one place. I don't like that Java allows you to litter your class with static blocks.
brianMon 12 Dec 2005
Well actually you do scatter them because your static field intializers are really part of your static initializer and get inserted in the same order.
I don't have a strong preference for forcing only one, but in this case the Java syntax and semantics seems perfectly fine, so I don't see a good reason to change it.
brianThu 15 Dec 2005
I added static initializer blocks (just like Java) and support for static field initialization.
brian Mon 12 Dec 2005
I keep running into places where I need to support static initializers.
Do you guys like the Java syntax of "class { static {..} }"?
You can have multiple static {} blocks which are merged in definition order.
andy Mon 12 Dec 2005
You mean just static code blocks? Not inner classes or anything? Java's is ok - haven't seen how anyone else does it though.
brian Mon 12 Dec 2005
C# does with a static constructor:
Java seems simpler.
john Mon 12 Dec 2005
I actually like C# better because it forces you to do that stuff in one place. I don't like that Java allows you to litter your class with static blocks.
brian Mon 12 Dec 2005
Well actually you do scatter them because your static field intializers are really part of your static initializer and get inserted in the same order.
I don't have a strong preference for forcing only one, but in this case the Java syntax and semantics seems perfectly fine, so I don't see a good reason to change it.
brian Thu 15 Dec 2005
I added static initializer blocks (just like Java) and support for static field initialization.