Open ichiban opened 11 months ago
Atom may or may not be re-implemented as unique.Handle[string]
.
New unique package The new unique package provides facilities for canonicalizing values (like “interning” or “hash-consing”).
Any value of comparable type may be canonicalized with the new Make[T] function, which produces a reference to a canonical copy of the value in the form of a Handle[T]. Two Handle[T] are equal if and only if the values used to produce the handles are equal, allowing programs to deduplicate values and reduce their memory footprint. Comparing two Handle[T] values is efficient, reducing down to a simple pointer comparison.
Since we took advantage of Go's memory management, we have a lot of pointers and interfaces which are pointers disguised.
This also lets us provide an approachable set of APIs, I hope, but comes with a cost of GC because the GC has to trace all the live terms.
We might be able to provide a workable set of APIs while implementing a WAM-like region-based memory management.
Related issues:
Some articles that might be related: