On Wed, Apr 06, 2022 at 03:50:35PM -0000, Brian McCall wrote:

> Stephen J Turnbull and Paul Moore have asked why the "need" for 
> something other than a library (or perhaps a better library). There 
> are a number of examples that show simple unit calculations and it's 
> easy to argue based on those that nothing further is needed. I think 
> more complicated counter-examples could help push back against this, 

Thanks for the extensive example, but it is still a *simple* unit 
calculation. It is basically just a longer version of `n = b*c/d`, only 
with ten variables instead of three.

All of the library's formats seem reasonable to me in the example you 
give. Syntax is important, but in this case all you are doing is binding 
a literal quantity with its unit to a name, and for that purpose, the 
syntax is 
not that important. What does it *really* matter which of these you 
write?

    h = 6.62607015e-34[m**2*kg/s]
    h = unit('m**2*kg/s')(6.62607015e-34)
    h = 6.62607015e-34 * units.m**2*units.kg/units.s
    h = 6.62607015e-34 * m**2*kg/s
    h = Quantity('6.62607015e-34 m2kg/s')
    h = unit(6.62607015e-34, "m2kg/s")

Yes, you have to learn a slightly different notation for each, but every 
branch of science and engineering has their own notation and conventions 
which needs to be learned.

For constants, that's just arguing over the colour of the bikeshed.

The aim of your post here was to try to justify why units have to be 
built into the language, rather than supported via a library. You have 
done a reasonable job of showing that calculations with units are 
useful, but nobody denied that. Regardless of the individual strengths 
and weaknesses of the existing libraries, you have shown nothing to 
justify why unit support must be built into the language itself.


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/I6OSC3KJDQ5VC6W62GI2QF3TWVIRY27W/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to