Walter:
> struct LogicalConst(T)
> {
> @property T v() {
> if (!set) {
> _v = some_expensive_computation();
> set = true;
> }
> return _v;
> }
>
> private:
> bool set = false;
> T _v;
> }If this idiom becomes common (thanks to its presence in D docs, etc) it is possible to add logic to the DMD front-end to recognize it (even when inlining of v() doesn't happen), and use this knowledge to perform some const-like optimizations. Is this possible and useful? Bye, bearophile
