2 ms·
> I don't think you can have all of traditional mathematical notation (which is often highly overloaded) in a programming language while only using syntax for d
by kmill 9y ago
> I don't think you can have all of traditional mathematical notation (which is often highly overloaded) in a programming language while only using syntax for disambiguation.
I think it is reasonable to be able to handle certain subsets of mathematical notation, but yeah, in total it seems to be context dependent. (I've tried designing languages to deal with this before, and my previous comments were about actual issues I had encountered making it all consistent.)
> For example, sin cos x would parse as sin(cos(x)), (sin(cos))(x), (sin * cos)(x), ... and most of these would be discarded by the type checker
Unfortunately, all of those make some sense! The first is what anyone who took precalculus would read, but the second could be substituting cos into the power series of sin, and the third could be the pointwise product (sin * cos)(x) := sin(x) * cos(x), which is particularly important for the ring of functions on the real line.
> Overall, I'm not convinced that such a highly ambiguous system would be beneficial in a general purpose programming language, but when you just want to type in a specific mathematical formula, disambiguate it once, and then work with the unambiguous representation (maybe using a pretty-printer), I think it would be useful.
One thing I've been enjoying about Mathematica is the ability to have the source code be written in 2D graphical notation.
I'm not convinced that it would be useful to have a special way to input and disambiguate mathematical formulae for a general purpose programming language because 1) actual formulae are infrequent and 2) it tends not to be too challenging to translate a formula into the syntax of the programming language. I think the main use case for trying to interpret traditional math notation is for exploratory calculating/graphing/programming where you would only ever use the equation at most a few times.