Hi,
I'm still getting used to the primitive support in Clojure, and I want
to confirm my understanding.
As far as I know, primitive support is only supported in local let
bindings, right?
So in designing a vector math library,
To translate from Java, one would write a class with primitive fields.
class Vector{
float x,y,z;
}
What would be the best choice in Clojure?
{:x 0 :y 0 :z 0}
I think a map would have too much overhead to retrieve and set keys.
Is that correct? Although this is the most straight-forward
conversion.
A 3-element vector
[0 0 0]
Still has the boxing/unboxing overhead. (Unless Clojure supports
primitives in collections, which I'm not sure about)
A Java array
(make-array Float/TYPE 0)
Is this the most efficient representation?
I don't really like this representation, cause I lose the named
fields, as well as the ability to put other types of data into the
same vector struct.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---