On Mon, Jan 16, 2012 at 5:29 PM, Norman Gray <norman.x.g...@gmail.com> wrote: >> Anything called by a Java library in a tight loop via an interface, >> though, you might prefer reify for. Reify has some other features, >> too, and probably some other limitations. Though there's a sizable >> overlap region where either can be used with acceptable results. > > It's not clear from the docs what 'reify' returns, but it seems to accept > only protocols, interfaces or java.lang.Object. It does appear therefore > that the only way of extending (in JVM terms) a class is through > bells-and-whistles-and-gongs gen-class.
That'd be one of the other limitations of reify. In your particular HashMap-extending case it wouldn't work, though you could implement Map and delegate to a closed-over HashMap. Like proxy, though, reify returns an instance rather than creating a class for later instance-creation (or for static method calls); deftype, defrecord, and gen-class do that and defrecord makes Map-like classes (but immutable ones) (you can still add other behavior, including overriding methods from Object and such). Think of proxy and reify as somewhat like Java anonymous inner classes, and deftype, defrecord, and gen-class as somewhat like non-anonymous Java classes, with defrecord additionally inheriting many of the behaviors of Clojure's map type. -- 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