I only know enough about floating point arithmetic to stay away from it. That said, I was under the impression that different compilers (and/or different compiler flags) can treat bitwise-identical floating points differently, and I worry in general that—if we allow f{16,32,64}s to cross the FFI boundary, that the C compiler on one side will treat them differently to how the Rust compiler does. I'm not sure how much this matters for the applications where we're using floating points, which seem mostly localised to the system using them (i.e. we're not sending floats over the network and expecting others to interpret them exactly as we do, right?).
I can't explain Stringlist; it's always confused me. The way I'd do it is to have direct conversion between a smartlist_t and a Vec<T>, where T is probably an opaque pointer to whatever type in C, orT is only allowed to be a String which we've copied from a non-NULL char* (e.g. impl From<Stringlist> for Vec<String>, or something, and then keep Stringlist private since internally it's a bunch of C types that we don't want propagating into our more Rusty code)… but also I have not thought this through as much as I should yet.
I'm okay with merging this, but also I think we should probably be figuring out a better way to deal with smartlist_t←→Vec<T> conversions.
I talked briefly with komlo about the Stringlist thing and it seems like she wanted to do the simpler thing of a smartlist of strings because doing the generic thing correctly might take significantly more work and not necessarily be right on the first try.
I would be in favor of a ticket for a longer term plan to try to get the generic Rust representation of a smartlist right. I don't have enough background to open a ticket myself on the issue. (Also sorry if I misremember the details of what komlo told me.)
We can write unit tests for issues like this, but I don't think they will affect us.
and I worry in general that—if we allow f{16,32,64}s to cross the FFI boundary, that the C compiler on one side will treat them differently to how the Rust compiler does. I'm not sure how much this matters for the applications where we're using floating points, which seem mostly localised to the system using them
"Raw transmutation from u64.
This is currently identical to transmute::<u64, f64>(v) on all platforms. It turns out this is incredibly portable, for two reasons:
Floats and Ints have the same endianess on all supported platforms.
IEEE-754 very precisely specifies the bit layout of floats.
The caveat doesn't apply, because we aren't transmitting binary floats over the network. We don't even want to transmit decimal floats over the network. Nor would we ever transmit NaNs over the network.
(i.e. we're not sending floats over the network and expecting others to interpret them exactly as we do, right?).
Trac: Owner: teor toN/A Status: merge_ready to assigned
Replying to isis:
The caveat doesn't apply, because we aren't transmitting binary floats over the network. We don't even want to transmit decimal floats over the network. Nor would we ever transmit NaNs over the network.
(i.e. we're not sending floats over the network and expecting others to interpret them exactly as we do, right?).