On Apr 29, 5:58 pm, Stu Hood <stuh...@gmail.com> wrote:
> Instead of attaching the metadata directly to the object, what if the
> metadata was stored outside the object, in a global map of {object metadata,
> ...}? In order to handle garbage collection, something similar to Java's
> WeakHashMap could be used, with the object itself as the key.

Interesting idea.

There might be performance penalities, depending on how often metadata
is used.  Metadata guarantees atomic updates (alter-meta!) so the
WeakHashMap might need to be wrapped in a synchronized map, at a
further penalty.

I've never needed metadata on non-Clojure types.  Do you have a use in
mind?

This could be a library, too, sort of like:

(defn my-meta [object]
  (if (instance? clojure.lang.IMeta object)
      (meta object)
      (*global-metadata* object)))

-SS
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to