I'm looking for the D equivalent of:
//C++
void foo() {
static string bar = painfulToInitialize(); //Always returns the
same value
/* A bunch of code */
}
I don't need the thread-safety that C++ provides in that case,
though it wouldn't hurt. I'm essentially trying to memoize the
result of painfulToInitialize() between calls to foo. I could use
std.functional.memoize, but that seems like a syntactic burden.
Unfortunately, I cannot compute the value at compile time.
What's the idiomatic way of doing something like this?