compile-time initialization of objects need?
Christopher Wright
dhasenan at gmail.com
Sat Dec 27 20:16:21 PST 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.
More information about the Digitalmars-d
mailing list