4 ms·
I wrote a tree editor for programs for my Master's thesis, in 1980. You can get it at https://www.cs.toronto.edu/~radford/MSc-thesis.abstract.html https://www.
by radford-neal 5y ago
I wrote a tree editor for programs for my Master's thesis, in 1980. You can get it at https://www.cs.toronto.edu/~radford/MSc-thesis.abstract.html https://www.cs.toronto.edu/~radford/MSc-thesis.abstract.html
The editor operates on the AST down to the lowest level, with careful design of keyboard input and cursor feedback to make that not too painful for things like infix operators. The language is described by a grammar, and there is an AST macro language.
My conclusion afterwards was that the shift at that time away from keyboard input towards editing with a mouse was negative for editing in terms of the AST (rather than text), since with AST editing there's a less direct connection between seeing and pointing and what you're editing. I got interested in other things.
But perhaps that was a premature conclusion.
- amichail 5y agoWhat do you think of TeXmacs, which uses a WYSIWYG tree editor for writing scientific/math documents? (TeXmacs is not based on TeX nor emacs but is inspired by both.)
- konkin 5y agoMath notation is hopelessly stuck in the 19th century and needs an update to the 20th. Polish notation with operators of known arity is an excellent way to ease natural scientists/mathematicians into a modern tree based grammar for mathematics without a soup of parenthesis, e.g. / 1 / 2 3 vs / / 1 2 3 A full s-expression based grammar for mathematics is unfortunately not something that you can write on paper and requires white space delineation to be readable. On a screen with something like emacs paredit both of those are a breeze however. The fact that higher order functions don't need a special notation is really freeing.
- Jtsummers 5y agoWhat value would Polish notation add over (largely) infix for the typical mathematician? Why do mathematicians need to be told what notation to use by non-mathematicians when their notations (note the plural) are in wide, and apparently successful, use today? How would Polish notation help, for instance, with things like describing set membership or logical relations? How is this more readable (using ASCII): -> a b Than the current approach: a -> b Which provides a convention sense of the relationship that the former does not? The second one can be "read" in order: a implies b. The first cannot.
- konkin 5y ago>Why do mathematicians need to be told what notation to use by non-mathematicians when their notations (note the plural) are in wide, and apparently successful, use today? The same reason why geometers needed to be told to start using Arabic numerals by algebraists: mathematics is asking new questions and the old tools aren't good enough. That we even need to make a notational distinction between operators like addition and operators like high order partial derivatives should show that clearly enough. >How would Polish notation help, for instance, with things like describing set membership or logical relations? How is this more readable (using ASCII): Start working on longer expressions and the lack of parenthesis becomes a godsend. -> -> a b c and -> a -> b c can be parsed in only one way, by comparison with infix notation you need miscellaneous parenthesis to show the way you want a -> b -> c to be parsed: (a -> b) -> c and a -> (b -> c). Or you need to memorize an arbitrary number of rules which increase exponentially with each new operator you add. > Which provides a convention sense of the relationship that the former does not? The second one can be "read" in order: a implies b. The first cannot. In English and only for binary operators, and even then you can just as easily understand "add 5 and 6" as you can "5 plus 6". How would you use infix notation to express a ternary or higher operator? The notation for the definite integral needs a super and sub script as well as a dummy variable for an operator that is fundamentally a ternary one. By comparison in prefix notation it becomes definite_integral upper_limit lower_limit function.
- Jtsummers 5y ago> The same reason why geometers needed to be told to start using Arabic numerals by algebraists. Mathematics is changing and the old tools aren't good enough to answer current questions. At least those were other mathematicians who could understand the domain and the importance of notations for the work. Hah, no, "-> -> a b c" is not easy to parse, except for a computer. going are people not to read easily. It's a silly argument that prefix is fundamentally easier for humans when it disrupts the flow even in your example. Even using the words, "implies implies a b c", does not parse well as a reader, even if it can only be parsed one way. If you go to a higher arity operation, switch to function (which is prefix, like polish) notation if it makes sense. But even then, we have things like the integral which uses physical placement to take (typically) up to 3 arguments: b ∫ f(x) dx a With other similar operations. And if order of operations is not clear from an expression, then yes, use parentheses. That's what they have been used for for quite a while.
- gushogg-blake 5y agoNice! One thing I thought ASTs weren't that good at was the initial writing of code - did you find that?
- radford-neal 5y agoA big part of the design work was trying to get it to be good at that, while still being entirely tree based. But you'll have to judge yourself how successful I was. Well, your judging that would be easier if you could use it, rather than just read about it... I still have the source code, but since it was designed to work with a vector graphics display attached to a PDP-11, getting it to work in a modern environment would take some work. We had only one vector graphics display, so there was no chance then to have a significant user community, which was another problem.