|
|
|
|
|
by kccqzy
890 days ago
|
|
It's really, really difficult to come up with a type system for mathematics. Let's just talk about Plus, the symbol for using the plus sign. What's its type? You might say it takes a few numbers and returns a new number. But what kind of number does it return? It is capable of returning machine precision numbers or their custom high precision numbers. It can return integers, rational numbers, real numbers or complex numbers, as the case may be. It is capable of working on lists of numbers and matrices of numbers, and it returns lists of numbers or matrices of numbers. But wait Mathematica doesn't require a list's elements' types to be homogeneous, so it can return different types of numbers for each element of the returned list. It is capable of working on completely undefined symbols, much like in real mathematics you expect a teenager to be able to reason about the expression `x+x+x` and simplify it to `3x` without knowing what `x` might be. It could very well leave everything the same, for example when you add two undefined symbols `x+y` and get back `x+y`. So I personally think it is perhaps not productive to think about type systems and type signatures when working with Mathematica. But you can definitively think in terms of transformation rules. And Mathematica either documents these rules or makes these rules intuitive. |
|