darcs patch: Implementation of aton and ntoa outside the IO
tomasz.zielonka at gmail.com
Mon Sep 25 04:35:14 EDT 2006
On Mon, Sep 25, 2006 at 05:09:13PM +0900, Robert Marlow wrote:
> I think HostAddresses are probably good how they are now. It seems a bit
> too much work to convert a HostAddresses endianness everytime it's used.
Do you mean too much work for the programmer or for the computer?
If the latter, then I propose to make HostAddresses an abstract
newtype, which doesn't allow to observe the endianness of the platform.
Internally it could still keep the address in network order, so no
conversions would be neccessary. However, the easiest way to implement
eg. comparisons for such a datatype would be to flip endianness before
comparing. So you will have to pay the cost of conversion for some
operations. I would prefer if this cost was associated with network
operations (connect, sentto, recvfrom, ...), because they already have
a relatively big cost and you don't call them so often.
> If the problem is how it appears (which along with PortAddress can be
> confusing) perhaps it just needs a different show implementation.
The problem is everything that gives different results on platforms with
different byte-orders. Show is one example, but there are also arithmetic
operations, Ord, etc.
More information about the Libraries