namespace Invercargill { public delegate T CachedGet(); private static Dictionary cache; public T once(owned CachedGet constructor) { if(cache == null) { cache = new Dictionary(); } int location = (int)constructor; NativeElement element; if(!cache.try_get(location, out element)) { element = new NativeElement(constructor()); cache.set(location, element); } return element.assert_as(); } }