On Jan 31, 2020, at 15:05, [email protected] wrote: > > The types in most programming languages are only technical types. If a > variable has a type, you may know that it is of type integer or double, but > you don't know if it's a length or an area. > The types required are semantic types. > > stypes: > length > area > time > speed > scalar > > allowed expressions: > length = length > length + length : length > time = time > time + time : time > scalar * length : length > scalar * time : time > sqrt(area) : length > speed = speed > length / time : speed
Some of these already exist in the stdlib. For example, datetime.timedelta can be multiplied by a scalar, added to a timedelta, or added to a time, but can’t be multiplied by a timedelta or a time, or added to a scalar. The others could be defined—and in fact there are multiple libraries on PyPI with different designs that do exactly that in different ways. If you wanted to add one of those PyPI libraries to the stdlib, or maybe just add the “framework” part of it that people can use to create new quantity types themselves, that might be a reasonable proposal, but you’d need to look them all over and make the case for why one design is the right one to standardize on and why it needs to be standardized in the first place, not just suggest that we should have something underspecified.
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/LQTWYT5MXRA424UH4O7Z456O7DLDFCGK/ Code of Conduct: http://python.org/psf/codeofconduct/
