[MLton] Apparent fix to PackReal

Eric McCorkle ericmcc at cs.brown.edu
Tue Feb 20 12:15:40 PST 2007


PackReal.toBytes was returning a reference to a single globally  
defined array.  I changed pack-real.sml from:


local
    val a = ArrayUninit bytesPerElem
in
    fun toBytes (r: real): Word8Vector.vector =
       (updA (a, 0, r)
        ; Word8Vector.fromPoly (Vector.fromArray a))
end

to:


fun toBytes (r: real): Word8Vector.vector =
    let
       val a = Array.arrayUninit bytesPerElem
    in
      updA (a, 0, r)
      ; Word8Vector.fromPoly (Vector.fromArray a)
    end


and it seems to work fine.  Someone please confirm that this is the  
Right Thing™.

-- 
Eric McCorkle
Brown University
CS Graduate Student



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mlton.org/pipermail/mlton/attachments/20070220/c4085386/attachment.html


More information about the MLton mailing list