[MLton-user] Raw conversion of 32 bits into Real32.t
Matthew Fluet
fluet at tti-c.org
Tue Jan 23 05:31:45 PST 2007
>> MLton will flatten away some tuples so that they are never allocated
>> on the heap. I could imagine doing something similar with
>> arrays/vectors of statically known size; it would effectively turn the
>> array/vector into a tuple, which would be flattened.
>>
>> Unfortunately, in this particular example, where we are using the
>> array to coerce between Word32.word and Real32.real, it wouldn't
>> really work, since we're necessarily accessing multiple Word8.word
>> elements at a time.
>
> This approach sounds to me far preferable. I am confused by why
> accessing word8 elements would preclude the optimization you described?
Because the Pack{Real32,Word32}Little functions are accessing multiple,
contiguous elements of the array. So, one would need to ensure that the
elements are laid out in a contiguous manner and that the operations
that accessed the elements could be typed correctly. The type systems
we have don't really allow that to be expressed; the Pack* functions are
primitives that get to be assigned the appropriate type.
More information about the MLton-user
mailing list