3 ms·
Conventional type systems don't really help you when your code is pretty much just taking in vectors/matrices of floats and returning vectors/matrices of floats
by smabie 6y ago
Conventional type systems don't really help you when your code is pretty much just taking in vectors/matrices of floats and returning vectors/matrices of floats.
- antris 6y agoYou are correct, however that's a niche use case that would warrant using a non-conventional type system. Conventional type systems are mostly for just dumping a bunch of strings and integers to and from a database and formatting them neatly.
- MaxBarraclough 6y agoYou still have the option of introducing new types, even there. In Ada, the programmer is discouraged from using the Ada equivalent of int directly, and is encouraged to instead introduce a subtype that reflects the specific use of int (including automatic range checking). This isn't as natural in C++ but is still possible. Boost offers a BOOST_STRONG_TYPEDEF [0] to deliberately introduce an incompatible type. (I do recall having trouble getting it to behave, but it's been a while.) Whether this makes sense in most mathematical code, I'm not sure, but it seems like it's an option. [0] https://www.boost.org/doc/libs/1_73_0/boost/serialization/strong_typedef.hpp https://www.boost.org/doc/libs/1_73_0/boost/serialization/st...
- jeffreygoesto 6y agoIf you are working with physicial quantities in C++ there are also [0] https://github.com/nholthaus/units https://github.com/nholthaus/units [1] https://github.com/mpusz/units https://github.com/mpusz/units