On 24 November 2010 02:11, JMatt <jm...@jmatt.org> wrote: > The easiest way to prevent divergence is to write and use native > clojure libraries.
I totally agree. However because of clojure's excellent interop capabilities it is extremely common (in fact encouraged) for developers to directly use Java code. For example the json library I am porting (https://github.com/danlarkin/clojure-json) directly uses java.IO.StringReader etc. I currently plan to do what you have suggested - implement a single API using both Java and CLR components by means of defprotocol and extend-type. It should work for this simple case. But actually I think that the better solution would be for the json library to have no VM-specific code and instead rely on lower-level clojure libraries to provide the reading/writing/buffer capabilities. It is those libraries which should switch implementation based on VM. Another interesting problem is type hints. CLR equivalent to Integer is Int32, so for my first stab I have broken java compatibility by directly replacing #^Integer with #^Int32. Ultimately I will have to create a new type (IntegerType) and have the implementation switch based on the VM. > I know I'd prefer to use clojure > if I had to write .NET code some time in the future. Yeah, it makes a huge difference! For anyone that's interested, the current port is at https://github.com/davidjagoe/clojure-json but please note that I have temporarily broken java compatibility and unicode is not supported at the moment because the .net readers don't have an equivalent to java's read() which does the right thing wrt chars... .net treats everything as a byte. Boo. Cheers, David -- 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