[Python-ideas] Why operators are useful
steve at pearwood.info
Mon Mar 18 19:58:03 EDT 2019
On Mon, Mar 18, 2019 at 05:51:08AM -0700, Rémi Lapeyre wrote:
> Maths’ typing is explicit so you don’t need to spend brain cycles to
> determine them.
Surely that depends on how formal you are being?
Maths can vary hugely in formality, even at a professional level. It is
a terrible overgeneralisation to state that maths is always explicitly
typed, unless your definition of mathematics is defined so narrowly as
to exclude the majority of maths done in the world.
In my own personal experience, there is a lot of mathematics done using
implicit typing. I've never seen anyone explicitly declare that the i, j
or k loop variables in a sum or product is an element of ℤ, they just
Likewise it is very common to assume that n is an integer, x and y are
Reals, and z is a Complex. Perhaps not in formal papers, but in less
formal contexts, it is very common to assume specific convections used
in the field rather than spell them out fully. For example:
You might not give Wikipedia much credence, but I trust you won't
object to John Baez and Terry Tao as examples of actual practicing
Similarly, I've never seen anyone explicit declare the type of a
variable used for a change in variable. Even if we've explicitly stated
that x is a Real, we might write something like:
let u = x^2 + 3x
in order to apply the chain rule, without explicitly stating
that u is also a Real. Why would you need to?
Its not like mathematics has a compiler which can flag type errors. We
declare types only when needed. The rest of the time, we can use
convention, domain-knowledge or inference to determine types.
More information about the Python-ideas