Why are strings linked lists?

sebc at macs.hw.ac.uk sebc at macs.hw.ac.uk
Fri Nov 28 15:14:27 EST 2003


On Fri, Nov 28, 2003 at 12:37:30PM +0100, Wolfgang Jeltsch wrote:
> >
> > So, what is happening that there is 1 cell in the heap
> > containing the representation of 'a', and then a linked list
> > of length 5000000, where each element points to that cell.
> 
> Yes, you're right. But if you choose the array alternative, you cannot use 
> sharing and would, therefore, still need 20 MB.

You can use sharing if you don't use unboxed arrays.  Not that it
matters if a character takes as much space as a pointer, but for
64-bits floating point numbers on a platform with 32-bits pointers, it
would decrease memory consumption by almost half.
Anyway, I'm just nitpicking. :-)

-- 
Sebastien-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://haskell.org/pipermail/haskell/attachments/20031128/1cd85dff/attachment.bin


More information about the Haskell mailing list