Syntax Extension as a Tool for Application Programming
Richard J. Fateman · 2003
Notation is a powerful tool for leveraging our thinking. As an example, most people believe we can conceive of and express algorithms more effectively when we use a suitable computer programming language. It is clear that we lose some capabilities when inappropriately constrained by a language. It possible to accomodate different “paradigms ” of thinking by choosing alternative notations or programming languages: this is often the essence of specially designed computer application languages or so-called “methodologies”. The largely unexploited issue we address here is the notion of having one programming language but with a run-time mutable syntax. It seems especially plausible to provide such a feature when the language must address an application whose own notational syntax can mutate, even over a short textual span. This is likely in mathematics and in other fields using formulas in which “customized ” new scientific notations are sometimes invented. Preface and Personal Disclaimer I am not keen on extra notational constructs for usual programming. I usually write programs in Lisp, a language notorious for its near-absence of specially distinguished characters and its total lack of precedence rules. All non-atomic Lisp expressions have explicit boundaries marked by parentheses. An expression that appears in a more conventional “infix ” syntax as a+b*c+d is written as (+ a ( * b c) d), and sin 2 x+cos 2 x is (+ ( ^ (sin x) 2)( ^ (cos x) 2)). To persons raised on infix programming languages such as C, Fortran, Java, this latter form may seem ugly and unfamiliar, but then the conventional expression sin 2 x + cos 2 x is quite unacceptable as input to C, Fortran, Java or Lisp. Observe that this “natural ” formula consists of a 2-dimensional variable-font utterance. What is familiar to a mathematician (or even a high school student) is ugly to a computer. It is a conceit of computer scientists that mathematics shares a significant common notation at its core with higher-level