[MLton-user] Re: Apparent bug in PackWord32Big.subVec

Matthew Fluet fluet at tti-c.org
Thu Jun 21 20:46:50 PDT 2007


> I wanted to also check to see if anyone has thought further about adding:
>> PackWord16Big
> 
> As had been discussed here in 2004:
>> http://osdir.com/ml/lang.ml.mlton.user/2004-11/msg00011.html

The trunk revision of the mlton sources provides:
   PackWord{8,16,32,64}{Big,Little}
See
http://mlton.org/cgi-bin/viewsvn.cgi/mlton/trunk/basis-library/integer/pack-word.sml?rev=5657&view=auto

> Also, I have a general question about the SML Basis wrt
> Pack<N>Big.subVec.  It seems baffling to me that the index provided to
> subVec is interpreted as a multiple of element size, rather than
> allowing you to index at arbitrary byte locations.  I want to use it
> to project numbers of different size from a heterogeneous object in
> memory (read in the BinIO).  Is there any other good way to do this in
> MLton (aside from dropping down into C and using the FFI)?

You can see from the implementation above that the underlying primitives 
used to implement the PackWord structures are byte indexed.

It wouldn't be difficult to expose some MLton.* structures that gave 
byte indexing versions of the PackWord operations.  But, I don't believe 
that you can accomplish byte indexing (efficiently) with just the 
operations of the Basis Library.





More information about the MLton-user mailing list