Re: Java Metadata Wrapper

2013-09-02 Thread Cedric Greevey
On Sun, Sep 1, 2013 at 9:58 AM, Colin Jones wrote: > I thought of protocols initially here too, but protocols just define > functions, so where would the data live that you want as metadata? > > A closure over the data? This implies extending the protocol on a > per-instance basis, which afaik do

Re: Java Metadata Wrapper

2013-09-01 Thread Mikera
I was actually thinking of the case where the metadata was computed in some way from the Java object (i.e. when it is more like read-only property). In most of the cases where I have wanted metadata on arbitrary Java objects, this would have been sufficient. You probably want to go the wrapper

Re: Java Metadata Wrapper

2013-09-01 Thread Mark
I think the general solution would be a weak identity map. On Sunday, September 1, 2013 6:58:25 AM UTC-7, Colin Jones wrote: > > I thought of protocols initially here too, but protocols just define > functions, so where would the data live that you want as metadata? > > A closure over the data

Re: Java Metadata Wrapper

2013-09-01 Thread Colin Jones
I thought of protocols initially here too, but protocols just define functions, so where would the data live that you want as metadata? A closure over the data? This implies extending the protocol on a per-instance basis, which afaik doesn't exist (cljs design work aside http://dev.clojure.org

Re: Java Metadata Wrapper

2013-08-30 Thread Mikera
Yeah, that's another good example where a protocol might be helpful. Arguably, you could make a case for nearly all of Clojure's abstractions being backed by a protocol. It has certainly proved to be a very useful technique in core.matrix I don't think there's even much performance downside of

Re: Java Metadata Wrapper

2013-08-30 Thread Colin Fleming
I've also been interested in this for Named (a protocol for things I can call "name" on), although my use-case is mostly interop with Java frameworks. On 31 August 2013 15:13, Mikera wrote: > It would be better, I think, if metadata was attachable via a protocol > rather than than a wrapper: th

Re: Java Metadata Wrapper

2013-08-30 Thread Mikera
It would be better, I think, if metadata was attachable via a protocol rather than than a wrapper: then you could just extend the protocol to any arbitrary Java class. Wrappers are a pain to make work because of wrapping / unwrapping and protocols also have the advantage of being very efficient.

Re: Java Metadata Wrapper

2013-08-30 Thread Alex Miller
In some cases you could proxy and add IMeta that way. On Friday, August 30, 2013 2:16:26 PM UTC-5, JvJ wrote: > > I've noticed that, when doing a lot of Java interop, it's impossible to > attach metadata to most Java objects, since they don't implement the IMeta > interface. A workaround for t

Re: Java Metadata Wrapper

2013-08-30 Thread John D. Hume
On Fri, Aug 30, 2013 at 2:16 PM, JvJ wrote: > Would it be possible (or even useful) to create some kind of generic IMeta > structure that can wrap other Java objects and have them act like normal, > except for the added metadata (or even other Clojure-esque features)? > Are you interested in :ta

Java Metadata Wrapper

2013-08-30 Thread JvJ
I've noticed that, when doing a lot of Java interop, it's impossible to attach metadata to most Java objects, since they don't implement the IMeta interface. A workaround for this would be to do something like put every Java object in a single-element list and attach metadata to the list, but