summaryrefslogtreecommitdiff
path: root/tex/context/base/util-sto.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/util-sto.lua')
-rw-r--r--tex/context/base/util-sto.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/tex/context/base/util-sto.lua b/tex/context/base/util-sto.lua
index 49abd8c82..34787be9b 100644
--- a/tex/context/base/util-sto.lua
+++ b/tex/context/base/util-sto.lua
@@ -88,3 +88,13 @@ end
--~ local t = bla.test
--~ table.print(t)
--~ print(t.a)
+
+function storage.setinitializer(data,initialize)
+ local m = getmetatable(data) or { }
+ m.__index = function(data,k)
+ m.__index = nil -- so that we can access the entries during initializing
+ initialize()
+ return data[k]
+ end
+ setmetatable(data, m)
+end