On Thu, Oct 29, 2009 at 4:49 AM, Konrad Hinsen
<konrad.hin...@fastmail.net>wrote:

> On 28 Oct 2009, at 22:21, Rock wrote:
> > I honestly prefer your first case scenario. Seems much more efficient,
> > less resource-consuming, and just straightforward. But I really would
> > like to know what your preference is. If you had to choose, which way
> > would you go?
>
> If I were to design an array interface for Clojure, it would consist
> of multimethods implemented for both an efficient array data structure
> for internal use and for nested vectors. The implementation for the
> latter would convert the nested vectors to the efficient structure and
> do all the necessary checks. It would be there for convenience and
> clarity in user code. Ideally I would then implement the same
> interface for Colt arrays and netCDF arrays as well, both for having
> an effcient structure for large data sets and for interoperability.
> And once we are at it, why not have another implementation for sparse
> arrays, using a suitable data structure?


One issue with using multimethods is the resolution overhead. I don't think
the JIT can optimize this to the extent it can optimize a normal polymorphic
Java call.

So you might want to use a Java interface for this instead, and Clojure's
Java interop with macros to wrap a nice Clojury API around it.

A second problem is boxing of primitives, and a third is noncontiguous
storage. The Java for the nonsparse stuff should probably use and expose
Java arrays of primitives. If you can live without runtime polymorphism,
having only compile-time polymorphism, the polymorphism can move back to the
Clojure side but live in a macro; then a sugar-coated API call directly
translates at macroexpand time into manipulation of Java arrays in either
Java calls or a Clojure function that uses loop/recur with primitives and is
loaded with type hints for the array type used (likely double[]).

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

Reply via email to