Darwin(ID:8449/dar010)Law-based OO prologOO Programming system based on the idea of law-enforcement References: Introduction At its inception, object-oriented programming methodology was based on two principles: 1. The principle of encapsulation, which gives rise to the view of a system as a collection of objects which interact by exchanging messages. 2. The principle of hierarchical inheritance, which provides a simple and elegant organizational discipline for objects’ and their behavior. The principle of encapsulation, which is strongly related to the notion of data-abstraction, has been widely accepted. The principle of hierarchical inheritance, on the other hand, has been the subject of great deal of controversy, in spite of its considerable intuitive appeal. Indeed, many variations of the original clean concept of hierarchical inheritance have been proposed and implemented in a multitude of object-oriented languages. These include various versions of multiple inheritance, a form of incomplete inheritance, which excludes certain methods from being inherited, a concept of multi-dimensional inheritance, etc. Moreover, some argue that the principle of inheritance should be replaced by some other organizing discipline, such as prototyping and delegation. It is hard to escape the conclusion that inheritance, hierarchical or otherwise, is simply too narrow a concept to serve as a unifying principle for objectoriented programming. Indeed, experience suggests that no single scheme would do. Yet, the exchange of messages between objects clearly must be subjected to Borne regulatory regime, since a completely undisciplined interaction between objects would make the system unmanageable. If one accepts the proposition that there is no universal disciplines which can satisfy all needs, it follows that one needs a mechanism for formulation and imposition of arbitrary disciplines. This paper describes such a mechanism based on the recently developed notion of law-governed system 151, currently being ‘supported by an experimental programming environment called Darwin. Extract: The Concept of Law-Governed Object-Oriented System The Concept of Law-Governed Object-Oriented System The concept of law-governed system has been developed as a methodology for dealing with large scale evolving systems 151. The essence of this methodology can be described, intuitively, as follows. When using a traditional programming language, one specifies a system by writing a program; the structure of this program, and its behavior, are naturally subject to the .discipline built into the programming language in question. On the other hand, when using a language which supports law-governed systems, the programmer himself defines the discipline under which his system is to operate. This is done by means of a formal device called the law of the syetem. The general concept of law-governed system deals both with the operation and the evolution of systems, and is not restricted just to object-oriented programming. Here we introduce a simplified version of this concept, which does not support the evolution of systems, and which is specialized to object-oriented programming. In this section, we introduce an abstract model of such a system, leaving many of the details to be specified later. A law-governed object-oriented system is a pair When a message ? send(s,m,t) is presented to a Prolog interpreter for evaluation with respect to the ‘set of rules comprising the law of the system. This evaluation may result in one of the following three outcomes: 1. The message is delivered to its target. This is done by means of the primitive deliver (m,t), which delivers message text m to object t.2 2. Message m is modified into a different message ml, and/or rerouted to another object tl. In other words, the result of send(s,m, t) may be deliver (ml, tl). Note that in this case the receiver tl is different from the target t of the message. 3. Finally, the message may be blocked, and not delivered at all. (The effect that such a failure of the message may have on its sender is left unspecified here:) Several comments about our concept of law-governed object-oriented system should be made at this point. First, the enforcement mechanism described above, which calls for each message to be intercepted at run time, and evaluated with respect to the law, is inefficient to the point of being impractical. However, this "enforcement-by-interception" paradigm is merely a conceptual device; in practice, the law should be validated statically, say at compile time, whenever possible. Second, while in this paper, the law of a system is treated as being fixed, under our general model the law can change, and this change itself is subject to the law. Such control over the evolution of the law requires, among other things, to treat the rules comprising the law as objects of the system. Detailed discussion of this issue is beyond the scope of this paper. Finally, a point of clarification. Note that our law enforcement mechanism is capable of intercepting and effecting every message. And since we are using the very powerful Prolog language to specify the law, it is possible to shift much of the algorithmic burden from the program to the law. Indeed, one may be able to use the law to, effectively, replace the entire program. This however, is not our intention. Indeed, such use of the law would defeat our purpose. The whole idea of law-governed system is based on our conviction that the comprehensibility and manageability of a large scale program can be greatly improved by having it governed by a relatively small and simple law. The idea, therefore, is to use the law to govern a program, not to replace it. For that reason, in fact, it is not really necessary to have the whole power of Prolog to specify the law; we just chose not to worry about a minimal language necessary for our needs in this paper. in SIGPLAN Notices 22(12) December 1987 (OOPSLA '87) view details in R.F. Crew, "ASTLOG: A Language for Examining Abstract Syntax Trees" pp229-242 view details in [ACM] ACM Computing Surveys (CSUR) 30(2) June 1998 view details |