aboutsummaryrefslogtreecommitdiff
path: root/core/id.nom
diff options
context:
space:
mode:
Diffstat (limited to 'core/id.nom')
-rw-r--r--core/id.nom33
1 files changed, 17 insertions, 16 deletions
diff --git a/core/id.nom b/core/id.nom
index 8875696..9cf5820 100644
--- a/core/id.nom
+++ b/core/id.nom
@@ -1,7 +1,7 @@
-#!/usr/bin/env nomsu -V4.8.10
+#!/usr/bin/env nomsu -V4.10.12.7
#
A simple UUID function based on RFC 4122: http://www.ietf.org/rfc/rfc4122.txt
-
+
use "core/metaprogramming.nom"
use "core/operators.nom"
use "core/math.nom"
@@ -13,21 +13,22 @@ use "core/control_flow.nom"
%NaN_surrogate = {}
%nil_surrogate = {}
%obj_by_id = {}
-set %obj_by_id's metatable to {__mode:"v"}
+set %obj_by_id's metatable to {__mode: "v"}
%id_by_obj = {}
-set %id_by_obj 's metatable to {..}
- __mode:"k", __index: (..)
- [%self, %key] ->:
- if (%key == (nil)):
- return %self.%nil_surrogate
- if (%key != %key):
- return %self.%NaN_surrogate
- --- (retry) ---
- %id = (uuid)
- if (%obj_by_id.%id != (nil)): go to (retry)
- %self.%key = %id
- %obj_by_id.%id = %key
- return %id
+set %id_by_obj's metatable to {..}
+ __mode: "k", __index: [%self, %key] ->:
+ if (%key == (nil)):
+ return %self.%nil_surrogate
+
+ if (%key != %key):
+ return %self.%NaN_surrogate
+
+ --- (retry) ---
+ %id = (uuid)
+ if (%obj_by_id.%id != (nil)): go to (retry)
+ %self.%key = %id
+ %obj_by_id.%id = %key
+ return %id
externally (uuid) means:
# Set all the other bits to randomly (or pseudo-randomly) chosen values.