cursed polymorphic unboxed array code #549
Replies: 4 comments 4 replies
-
Perhaps I'm not understanding this correctly, but the following generates the same disassembly on my machine:
|
Beta Was this translation helpful? Give feedback.
-
h/t @aijony I didn't know one could do
with the type variable |
Beta Was this translation helpful? Give feedback.
-
Associated types (or type families, or whatever) could greatly improve the ergonomics of this; one could write the type of That said, I'd still sorta prefer just having the compiler know about arrays, and the handful of other cl types that can be specialized. |
Beta Was this translation helpful? Give feedback.
-
See #1007 for a proposed, more ergonomic design based on the above. |
Beta Was this translation helpful? Give feedback.
-
I was just playing around with implementing efficient arithmetic with polymorphic unboxed arrays. The code below is clumsy (you have to write stuff like
(Array ArrayDoubleFloat Double-Float)
and(ArrayDoubleFloat Double-Float)
when you want to actually use a specific unboxed array type...), but it works! >_>Note that
sum-array
,map!
, anddouble!
is polymorphic.You can monomorphize just fine to get native double-float instructions inside of the loops:
Peeking into the disassembly of the monomorphized
sum-array-df
loop innards:Edit 1: Did match destructuring in the method implementations so Coalton would generate correct type annotations for the inner accessors.
Edit 2: Simplify by getting rid of intermediate unboxed array type.
Beta Was this translation helpful? Give feedback.
All reactions