digitalmars.D - compile-time initialization of objects need?
- Weed (18/18) Dec 26 2008 In fact, the D is not contain a mechanism for compile-time
- Christopher Wright (21/28) Dec 27 2008 You want syntactic sugar for two things:
- Weed (4/37) Dec 28 2008 It not syntactic sugar. I suggest not to waste time at all performance
- Christopher Wright (2/5) Dec 28 2008 Sorry, syntactic sugar and some minor optimizations.
- Weed (6/12) Dec 28 2008 These of optimization are very important when the program contains many
- Christopher Wright (5/15) Dec 28 2008 If the object is mutable, you still need to get it into writable memory....
In fact, the D is not contain a mechanism for compile-time initialization of objects. Maybe add? For example, that would be very usable for any objects which have mathematical primitives. Example: struct S { float[10] array; this( float f ) { array[0] = f; } } void main() { S a = S(8); // ok static S b = S(8); // error }
Dec 26 2008
Weed wrote:In fact, the D is not contain a mechanism for compile-time initialization of objects. Maybe add? void main() { S a = S(8); // ok static S b = S(8); // error }You want syntactic sugar for two things: // example 1 void foo () { static S s; static bool s_initialized = false; if (!s_initialized) { s_initialized = true; s = S(8); } } // example 2 // module/class level S s; static this () { s = S(8); } Neither of these need to happen at compile time.
Dec 27 2008
Christopher Wright пишет:Weed wrote:It not syntactic sugar. I suggest not to waste time at all performance on run-time initialization of objects and check of side conditions on a course of performance of the program.In fact, the D is not contain a mechanism for compile-time initialization of objects. Maybe add? void main() { S a = S(8); // ok static S b = S(8); // error }You want syntactic sugar for two things: // example 1 void foo () { static S s; static bool s_initialized = false; if (!s_initialized) { s_initialized = true; s = S(8); } } // example 2 // module/class level S s; static this () { s = S(8); } Neither of these need to happen at compile time.
Dec 28 2008
Weed wrote:It not syntactic sugar. I suggest not to waste time at all performance on run-time initialization of objects and check of side conditions on a course of performance of the program.Sorry, syntactic sugar and some minor optimizations.
Dec 28 2008
Christopher Wright пишет:Weed wrote:These of optimization are very important when the program contains many objects for mathematics. In adjacent thread wish to take out complex numbers in library, for example. Those who used static initialization of complex types can want to use it and with new library.It not syntactic sugar. I suggest not to waste time at all performance on run-time initialization of objects and check of side conditions on a course of performance of the program.Sorry, syntactic sugar and some minor optimizations.
Dec 28 2008
Weed wrote:Christopher Wright пишет:If the object is mutable, you still need to get it into writable memory. If the computation is cheap enough that it's reasonable to do at compile time, copying will be a major cost. Therefore this optimization is not very important.Weed wrote:These of optimization are very important when the program contains many objects for mathematics.It not syntactic sugar. I suggest not to waste time at all performance on run-time initialization of objects and check of side conditions on a course of performance of the program.Sorry, syntactic sugar and some minor optimizations.
Dec 28 2008