What can be done to reduce executable size?
Adam D. Ruppe
destructionator at gmail.com
Fri Dec 16 09:05:39 PST 2011
On Friday, 16 December 2011 at 16:35:27 UTC, Jonathan M Davis
wrote:
> That would break purity, so no that doesn't work. The
> singletons are pure.
I'm tempted to say just cast it away, since you aren't actually
breaking purity in any meaningful way; the return value is always
the same and it should have no other side effects (except on the
internal variable).
Lying around pure was a bit of a pain... but this seems to have
done the trick:
alias pure string function () hax;
private string impureConstructor() {
static string cache;
if(cache is null)
cache = "lol pure defeated";
return cache;
}
private pure hax getPureConstructor() { return cast(hax)
&impureConstructor; }
public @system @property pure string test() {
return getPureConstructor()();
}
// test now works
More information about the Digitalmars-d
mailing list