aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2017-10-19 16:34:38 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2017-10-19 16:34:38 -0700
commit443f8c73bb67e2fb085c5595add10b98f4696805 (patch)
treea3b37c12b62a18fd3dd77f2fda11939cc22e5fb5
parente43f60a12477d65b88c828bcdaf99f362d4f80d0 (diff)
Added default dict.
-rw-r--r--lib/collections.nom6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/collections.nom b/lib/collections.nom
index 5958bb9..9432baa 100644
--- a/lib/collections.nom
+++ b/lib/collections.nom
@@ -162,6 +162,12 @@ rule [%items sorted by %key] =:
# Metatable stuff
compile [counter] to: "setmetatable({}, {__index=function() return 0; end})"
+compile [default dict] to: ".."
+ |setmetatable({}, {__index=function(self, key)
+ | t = {};
+ | self[key] = t;
+ | return t;
+ |end})"
rule [chain %dict to %fallback] =:
when (type of %fallback) == ?:
* "table":