Path: news.daimi.aau.dk!not-for-mail From: John Cowan Newsgroups: comp.lang.beta Subject: Loki Paper 1: Overview Date: Thu, 19 Mar 1998 10:03:57 +0100 (MET) Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 62 Approved: mailtonews@daimi.aau.dk Distribution: world Message-ID: <199803190903.KAA17185@noatun.mjolner.dk> Reply-To: "John Cowan NNTP-Posting-Host: daimi.daimi.aau.dk Xref: news.daimi.aau.dk comp.lang.beta:11464 The Loki Papers is a series of documents which I will be posting off and on to comp.lang.beta in the hope of stirring some interest. The purpose of the Loki Project, which these papers document, is to provide a compiler and support classes for translating Beta into the Java language. Although Beta and Java are very different languages in syntax as well as semantics, Java is flexible enough that compiling Beta into it does not seem an utterly impossible proposition. The Loki Papers, when complete, will serve as a specification of such a compiler. Obviously, there's more than one way to do it: these papers reflect only my personal views. When I say "Loki does this" or "Loki will have that", that is only for conciseness. I do not have the resources to actually write and deliver Loki to the astonished world. I wish I did. However, I am hoping that someone with the necessary time will be able to make a stab at a real implementation. Such an effort should be "open source", available under either the GNU Public License or one of the other standard licenses. (See http://www.opensource.org for details.) Obviously, a closed-source implementation is also possible, and I cannot prevent it. I will assume a fair knowledge of Java 1.1, but I will explain any particularly arcane features as I need them. However, the pattern attributes of Beta are implemented using Java inner classes, so an understanding of this relatively new feature is essential. After posting, these papers will appear on my Web site at http://www.ccil.org/~cowan/loki for future reference. "Loki" of course is yet another name from Norse mythology; the trickster god who sometimes works with, sometimes against, the other gods. The purpose of Loki is to provide a correct, rather than an ultra-efficient, implementation of the Beta language. As I hope to demonstrate, some of the shortcuts taken by the current Mjolner compiler (no object equality, no true concurrency) are not necessary in a Java implementation. In addition, it is fairly simple to view Java language constructs as special cases of Beta ones, and allow Beta programs to make use of Java classes, fields, and methods directly. In general, the Java object model is accepted, not flouted, but some Java infrastructure is created in each pattern by the compiler. Beta patterns are implemented as Java classes, subpatterns are subclasses, and pattern attributes are inner classes. Both static and dynamic object attributes are Java instance variables. The do-part of each Beta pattern is implemented as a hidden Java method, and hidden methods are also created for implementing Beta's "inner" imperative and to optimize certain uses of inserted objects. The Beta fragment architecture is mostly abstracted away by the compiler. It is not yet clear to me whether it should attempt to do more than syntax and static semantics checking when compiling less than a complete program. Generation of Java code may need to wait until all the Beta code is available. The fragment visibility model, at any rate, is incompatible with Java's visibility model: all Beta classes and members would be declared "public" in the Java code. -- John Cowan cowan@ccil.org e'osai ko sarji la lojban.