On 8/25/16, Ken Kundert <python-id...@shalmirane.com> wrote: [...]
> Just allowing the units to be present, even it not > > retained, is a big advantage because it can bring a great deal of clarity to > the > meaning of the number. For example, even if the language does not flag an > error > when a user writes: > > vdiff = 1mV - 30uA It reminds me: "Metric mishap caused loss of NASA's Mars Climate orbiter. It could be nice to have language support helping to avoid something similar. [...] > 2. Or accept X in lieu of E. After all, the e is silent anyway. Thus, on > input > we accept ... > > 1Y -> 1e+24 > 1Z -> 1e+21 > -> 1X -> 1e+18 <- only difference > 1P -> 1e+15 Are SI prefixes frozen? Could not be safer to use E_ instead of X in case of possible new future prefixes? ------ What you are proposing reminds me " [Python-ideas] Trial balloon: adding variable type declarations in support of PEP 484". Instead of adding constant type declaration. Sorry this is just really quick idea around thinking that it could be good to have parser possibility to check metric mishaps. distance1 = 1:km # or? -> distance1:length = 1:km distance2 = 1000:cm # or? -> distance2:length = 1000:cm length = distance1 + distance2 # our parser could yell :) (or compiler could translate it with warning) _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/