Implementing generalized operator overloading

This paper presents a practical method of adding problem‐specific notation to an established computer language. Our idea is to use unrestricted operator overloading as a tool to map the problem domain notation directly into an existing programming language. Our method introduces new operator symbols...

Ausführliche Beschreibung

Gespeichert in:
Bibliographische Detailangaben
Veröffentlicht in:Software, practice & experience practice & experience, 1998-05, Vol.28 (6), p.593-610
Hauptverfasser: Miles, William S., Johnson, Leroy F.
Format: Artikel
Sprache:eng
Schlagworte:
Online-Zugang:Volltext
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
Beschreibung
Zusammenfassung:This paper presents a practical method of adding problem‐specific notation to an established computer language. Our idea is to use unrestricted operator overloading as a tool to map the problem domain notation directly into an existing programming language. Our method introduces new operator symbols and function names into a host language by overloading existing usage. We extend the host programming language syntax to an augmented language which is mapped to the host language by a programmable preprocessor. The preprocessor uses a programmer‐modifiable symbolic language grammar to translate an augmented program into a standard program. This process gives a natural extension to any computer language without modifying the host language. Direct use of problem notation can improve program legibility and code comprehension within the problem domain. The preprocessor provides a useful research tool for exploring language issues without the need to write a compiler for a new language. It can also be used to provide a domain specific language for a programming group at lower cost than new language development. This paper presents several working examples which illustrate our work. We redefine many of the standard C operators to alleviate some of the more common programming errors, thus creating a ‘cleaner’ C. As a more esoteric example, we encode a subset of APL vector operators as an algebraic extension to the C language. A curious application of our method shows its success in an arbitrary problem domain by compiling and executing poetry. Our final example introduces standard symbolic logic notation into C for tautology verification. © 1998 John Wiley & Sons, Ltd.
ISSN:0038-0644
1097-024X
DOI:10.1002/(SICI)1097-024X(199805)28:6<593::AID-SPE161>3.0.CO;2-S