On Fri, 2007-06-22 at 10:52 +0400, Bulat Ziganshin wrote:

> >> i tried it once and found that ByteArray# size is returned rounded to 4 -
> >> there is no way in GHC runtime to alloc, say, exactly 37 bytes. and
> >> don't forget to add 2 unused bytes at average
> 
> > Right, GHC heap object are always aligned to the natural alignment of
> > the architecture, be that 4 or 8 bytes.

> that i'm trying to say is that one need to store exact string size
> because value returned by getSizeOfByteArray is aligned to 4


Ah yes, you're quite right. To allow GHC's ByteArray# to be used to
implement a compact string type it'd have to be changed to store the
length in bytes rather than words.

Duncan

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to