On Sep 28, 12:19 pm, Tim Bradshaw <t...@tfeb.org> wrote: > > There are several existing systems which do this. The HP48 (and > descendants I expect) support "units" which are essentially dimensions. > I don't remember if it signals errors for incoherent dimensions. > Mathematica also has some units support, and it definitely does not > indicate an error: "1 Inch + 1 Second" is fine. There are probably > lots of other systems which do similar things. > The problem is that if you allow expressions rather than terms then the experssions can get arbitrarily complex. sqrt(1 inch + 1 Second), for instance.
On the other hand sqrt(4 inches^2) is quite well defined. The question is whether to allow sqrt(1 inch). It means using rationals rather than integers for unit superscripts. (You can argue that you can get things like km^9s^-9g^3 even in a simple units system. The difference is that these won't occur very often in real programs, just when people are messing sbout with the system, and we don't need to make messing about efficient or easy to use). -- http://mail.python.org/mailman/listinfo/python-list