If you use a java.util.WeakHashMap (and resist the temptation to mutate it
instead of making modified copies) and the name objects are interned (so
any two that are equal are identical -- so, as usual, you want to use
:clojure :keywords), then name->node mappings get auto-GC'd if the name
stops being in use anywhere else. (Just don't include a copy of the name
*inside* the node with that name. It shouldn't be needed because you should
never have a node in hand without having first had the name, in this
architecture. If for any reason it *is* needed store it as a string instead
of a keyword so it won't be the same interned object, but can be converted
into such with (keyword foo).)


On Mon, Sep 9, 2013 at 8:05 PM, Mark Engelberg <mark.engelb...@gmail.com>wrote:

> There's one other big downside to the mapping-from-names-to-nodes
> technique that I forgot to mention.  If you plan to delete connections
> between nodes, and the structure is intricate enough that you don't know
> whether you can safely delete the node itself, then you can potentially end
> up with orphan name->node pairs in your mapping that are unnecessary.
> Cleaning these up would basically mean you'd have to write your own garbage
> collection routines.
>
> If you work with real pointers, you get garbage collection for free.
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to