
Am Sonntag, 17. Mai 2009 15:08:29 schrieb Don Stewart:
Sven.Panne:
[...] I think most problems can be fixed in a rather pragmatic way by adding a few functions to the binary package: [...] Patches are welcome.
Attached. A few remarks: * This is only a quick and mildly tested implementation of the IEEE functions, especially NaNs, infinities and denormalized numbers are untested. These problems could totally be avoided if we can coerce representations directly, changing only their interpretation. * The *host functions assume an IEEE platform, but this can easily be changed (see comments). * Perhaps one can use unsafeCoerce for word32ToFloat and friends, but I haven't checked this. * I've seen a few "{- INLINE -}" comments. Is this really wanted or only a typo? * A comment about using peek/poke for the *le/*be functions is wrong, because this would introduce alignment constraints on some platforms. I think the main point is to provide a nice and efficient API, hiding all the dirty stuff in the implementation.
One final remarks: I think the low level functions of the binary package should really keep the notions of "endianess" and "alignment constraints" separate, something which isn't done currently: The *host functions have alignment restrictions, the *be/*le functions don't. There is no good reason for this non-orthogonality.
That seems reasonable.
There are various ways to achieve this, but the most obvious way leads to a
combinatorial explosion of functions: