6 ms·
You’re right. Going back to my physics example, all the variables in a physics problem are actually of the same type, float. So you’d need more specific types,
by jawzz 4y ago
You’re right. Going back to my physics example, all the variables in a physics problem are actually of the same type, float. So you’d need more specific types, but that would be infeasible-the whole point of types in a general purpose language is that they’re general enough for any use case.
If you were just coding physics problems you could have types restricted to the physics domain, that is, physical units. Which it looks like MATLAB does now support: https://www.mathworks.com/help/symbolic/units-of-measurement.html https://www.mathworks.com/help/symbolic/units-of-measurement...
- randomswede 4y agoWerrrrlllllll... It all depends on what yo umean by "type". In physics problems, I find taht quantities may be measured in "floats", but have the types "mass", "amperage", "distance per second per second" and the like. In Go, I would probably model this as: type mass float64 type speed float64 type acceleration float64 That way, they'd all have float64 as the "storage type", but it would be harder to accidentally pass an acceleration when I wanted a mass.
- robertlagrant 4y ago> Going back to my physics example, all the variables in a physics problem are actually of the same type, float This is why some people recommend a practice I've forgotten the name of, where they defined a new type that maps to language type. So type Mass could just be a float, but you know better how to treat it.