home
/
code
/
tiger.ml.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Hide counter inside closure
[tiger.ml.git]
/
compiler
/
src
/
lib
/
tiger
/
tiger_symbol.ml
diff --git
a/compiler/src/lib/tiger/tiger_symbol.ml
b/compiler/src/lib/tiger/tiger_symbol.ml
index
747cb03
..
a850406
100644
(file)
--- a/
compiler/src/lib/tiger/tiger_symbol.ml
+++ b/
compiler/src/lib/tiger/tiger_symbol.ml
@@
-5,14
+5,16
@@
type t =
; symbol : int
}
; symbol : int
}
-let counter = ref 0
+let next =
+ let counter = ref 0 in
+ fun () ->
+ incr counter;
+ !counter
let symbols = H.create 16
let unique_of_string name =
let symbols = H.create 16
let unique_of_string name =
- incr counter;
- let symbol = !counter in
- {name; symbol}
+ {name; symbol = next ()}
let of_string name =
match H.find_opt symbols name with
let of_string name =
match H.find_opt symbols name with
This page took
0.027712 seconds
and
4
git commands to generate.