[Haskell-cafe] Data.Binary Endianness
ketil at ii.uib.no
Tue Sep 11 07:22:48 EDT 2007
On Tue, 2007-09-11 at 12:01 +0100, Jules Bean wrote:
> > How can the format be portable if the representation isn't unambigously
> > defined? And if it is unabmigously defined, what's wrong with using it
> > for externally defined data formats?
> It's portable because it works on other machines also running that exact
> version of Data.Binary, regardless of their CPU architecture (in
> particular, word size or endianness). That is the precise sense of
> 'portable' used here.
Okay. Data.Binary is not for persistence, then (since the format may
change between versions of the library, and presumably between different
compilers/RTS), but merely for transient serializing, as over a network
This isn't so obvious from the documentation (I myself have blatantly
used it for persistence and for reading in externally specified data),
and the functions involving FilePaths also tend confusing the issue
here. Perhaps it could be made clearer?
Another way to avoid abuse of Data.Binary would be to add a unique magic
number to each stream, and throw an exception when a mismatching magic
number is encountered.
More information about the Haskell-Cafe