Michael Weber wrote:
> Maybe it's worth to know how many objects a list has (without explicit
> zeroElem), so I'd suggest to extend the class to:
> 
>    marshalList       ::        [a] -> IO Addr

We agree here.

>    marshalListN      :: Int -> [a] -> IO Addr

I don't see a reason for the duplication of length information, e.g.
what should `marshalListN 1000 [1,2,3]' mean? And
`marshalListN 2 [1,2,3]' is equivalent to `marshalList (take 2 [1,2,3])'.

>    unmarshalList     ::        Addr -> IO [a]

How many elements are there starting at the given Addr? Hmmm....

>    unmarshalListN    :: Int -> Addr -> IO [a]

This is my definition of unmarshalListN.

> where `marshalList' stores the list length at the beginning of the
> buffer, like:
> [ marshalList code deleted ]

This seems to be a rather special case, e.g. why should the length
be marshaled as an Int? Some ancient Pascals on PCs used a byte length
prefix for strings. And what about alignment? There could/must be some
padding if the alignment constraints for the list element type are
stronger than the ones for Int. Therefore this function does not belong
to a general purpose library IMHO.

I'll post a new proposal for a "better" Addr module later...

Cheers,
   Sven

P.S.: I've received a few personal mails regarding the spelling of
marshaling, but there is no real agreement on this. It seems that both
spellings are possible and both "feel right", depending on the speaker
and the dictionary.  :-)
-- 
Sven Panne                                        Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik                     FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen              Oettingenstr. 67
mailto:[EMAIL PROTECTED]            D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne

Reply via email to