by todd8 · 4y ago · 0 comments
I had the pleasure of meeting Nicklaus Wirth around 1977 at Texas Instruments. I worked in a department that had developed a PASCAL compiler for TI processors; Wirth had been invited to give us a demonstration of his Pascal/Modula based system. I don't remember the details of the impressive presentation, but I do remember him telling the joke about his name: in Europe they call him by name (sounds like "Virt") while Americans call him by value saying "Worth" for his last name.
I enjoyed his books a great deal and read every published paper of his that I could get my hands on. I learned a great deal from his clear writing during formative years in my programming career.
--- below this line, I stray off topic ---
[1] For example, the Algol 68 Report used a two-level grammar (Van Wijngaarden grammar) to describe the syntax of Algol 68. Such a two level grammar had one set of rules that would expand into an arbitrarily large different set of productions describing the syntax of an Algol 68 program. Vw grammars are capable of defining recursively enumerable languages. In the Algol 68 report it was hoped that more language features could be precisely described by such a formal grammar rather than by prose that stated requirements like "variable must be declared before use".
While admirable, such a goal isn't practical because the set of recursively enumerable languages is essentially equivalent to the set of Turing machine programs or Chomsky's type 0 grammars. We don't want compilers to be burdened with solving the impossible to solve halting problem.
The two-level grammar of Algol 68 gave the semantics of Algol 68 in a denotational language, the second level. As such, it is not more complicated as other languages with defined semantics, such as in the ML family. To my knowledge, people used that second level to implement a real virtual (ho hum) machine, resulting in a working interpreter. However, the ML aficionados can be surprised with the information that their language was not first one with fully defined semantics. Algol 68 was ahead of its time.
As for Pascal, history as I know says that Wirth invented Pascal as a training language for a course in which a one pass compiler was to be built. Only later, when the Algol 68 project became complicated, Wirth started to market it as a superior design - something which it never has been.
And yes, I enjoyed Turbo Pascal.
In any case, there’s something to be said for defining a language in a series of layers: tokens, then trees, then perhaps elaboration / desugaring, then one or more layers of semantics (typing, binding, execution). In an actual frontend, you probably even want a looser tree syntax followed by a layer of “semantic” checks that could technically be folded into the syntax, in order to be able to tell the user things like “you can’t use an array type like that” rather than “unexpected bracket”. Compare Lisp s-expressions, the Dylan idea of skeleton syntax trees, and the class of visibly pushdown languages as used in one recent structural editor[1]. Contrast the refusal of the Glasgow Haskell Compiler to desugar before typechecking[2].
Page 6 of the report presents the ideas of the Vw-grammar. Protonotions, Notions, Metanotions, Hypernotions, Paranotions, Symbols, Productions and Production Trees are introduced to explain the grammar! I encourage readers to take a peek at almost any paragraph of the 70 page Algol 68 report and compare it to the The Programming Language Pascal Revised Report by Wirth [2],[3]. It's easy to see why Pascal became quite popular and Algol 68 never did.
Despite the fact that Algol 68 was too difficult to compile efficiently at the time, it introduced a number of features we take for granted today. See Richard Hamlet's Ignorance of Algol 68 Considered Harmful, [4].
On a personal note, I was a young Computer Scientist at the time these reports were published, and I miss how easy it was back then to keep up with the research that was going on at the time. Today it's impossible to be a generalist. So many independent and important branches have sprouted off the trunk of CS that everyone is a novice in major parts of the field.
[1] ACM SIGPLAN Notices, Volume 12, Issue 5, May 1977 pp 1–70, https://doi.org/10.1145/954652.1781176
[2] http://standardpascaline.org/The_Programming_Language_Pascal...
[3] https://www.amazon.com/Pascal-User-Manual-Report-Standard/dp...
[4] ACM SIGPLAN Notices, Volume 12, Issue 4, April 1977 pp 51-56, https://doi.org/10.1145/954654.954659
[1] https://jmvdveer.home.xs4all.nl/en.download.learning-algol-6...
Second... OK, I got through the first part (the language description), and it basically confirms my earlier brief glances at various Algol 68 documents: it’s a fundamentally pretty nice and consistent language with some warts, some hilariously archaic points, and godawful one-of-a-kind terminology, and its age excuses basically all of those. (No surprise I liked it though, I like both Standard ML and METAFONT, and those are both transparently Algolish in different ways.) Not looking forward to the ALLCAPS operators, but then I wrote some all-caps Forth some time ago and it was okay.
Third, though—that description (unlike the report) doesn’t seem to be using W-grammars at all? It uses what is pretty pedestrian ABNF in funny notation. It’s very helpful in getting me to understand how Algol 68 works, but doesn’t really relate to my original question of how those two-level W-things work. Except by maybe reverse engineering them by comparing the report with the guide, but that sounds like a last-resort option.