• Ingen resultater fundet

some arguments against or in favor.

This description outlines the background topics assumed to be well-known, hence it describes information deliberately missing from this dissertation. From a positive point of view, the contributions of this work would be of interest for specialists who are working with the design, implementation, or specication of statically typed object-oriented languages, specically:::

inheritance mechanisms, virtual classes, genericity.

general block-structure (inner classes), advanced name-binding (scoping).

method combination, class combination, systematic propagation of such.

classes and methods as more-than-usual rst class entities.

dynamic classes and dynamic object specialization (extension).

type analysis for such systems.

the trade-o between name equivalence and structural equivalence.

Moreover, crossing the border of just language design into a broader topic area, the results presented here are also closely related to the following:

aspect-oriented programming, subject-orientation.

activities, object collaborations.

1.2 Organization

The chapters of this thesis are quite dierent; some are concerned with the conceptual framework aroundgbeta andBetaat this level there is little dif-ference between the twoand others present and motivate technical details of certain language constructs or briey survey the approaches to specic topics in other programming languages; yet others focus on software engineering as-pects or on the implementation of gbeta. Finally, some chapters present partial formalizations of the semantics and static analysis.

Chapter 2 establishes the basic concepts such as objects and patterns, with an emphasis on the underlying conceptual framework which puts these concepts into perspective. It then goes into a brief presentation of the concrete language constructs which support these basic concepts, deferring a large amount of detail to later chapters.

In Chap. 3, patterns are treated in great detail. Since the concepts are so tightly integrated, this chapter also introduces mixins which are the building blocks that patterns are made of, and it introduces objects, since they are to such a large extent determined by their associated patterns. Moreover, the mechanism which is used throughout to create new patterns from existing ones,

the C3 linearization algorithm, is introduced, formalized, and some soundness properties about it are proved. Inheritance of attributes and specialization of behavior is covered, and the rule for name lookup within an object is presented.

Finally, the notion of qualications, which is similar to declared types of refer-ences in other languages, is presented.

Some pattern attributes are bound to pattern values by means of a uni-cation process which actually drives the entire propagation machinery, namely virtual pattern attributes, and they are covered in Chap. 4.

The next chapter, Chap. 5, discusses the notion of block structure and the associated notion of context dependency, and motivates why that might actually be considered the essence of object-orientation even though block structure has had an unstable and often rather low popularity in the object-oriented commu-nity and elsewhere.

The interplay between block structure and virtual pattern attributes is the essential basis on which the capability for propagating specialization relies. How this works is covered in Chap. 6.

Chapter 7 goes on to another unusual feature in a statically type checked language, namely the capability of gbetato support the creation of new classes and methods at run-time. The rst part of this chapter argues that it is indeed justied to call these features `dynamic' even though they are kept under strict control by the static analysis.

Finally, Chap. 8 presents a number of miscellaneous functionality related enhancements ingbeta, some of which are not backward compatible withBeta; and Chap. 9 presents a few mechanisms which were added to gbeta in order to solve some problems with the expressiveness and/or safety properties of the

Betastatic analysis. Programs using the former enhancements can generally be rewritten to an equivalent form that do not use these enhancements, by means of local changes to the source code. In contrast, the latter improvements, the ones related to the static analysis, allow the expression of type safe designs which could not expressed safely in any similar design without these improvements.

This concludes the direct treatment of the language gbeta. After that, in Chap. 10, the modularization system ingbetais presented. This is the fragment language, and the only dierence between the fragment language ingbetaand inBetais that thegbetaimplementation is more generalbecause it skips over some hard problems in the area of separate compilation. Nevertheless, the more general implementation of the fragment language may work as an illustration of how important it is to try to implement it more completely than is the case withBeta today.

The two next chapters present two more formally strict descriptions of two small languages which exhibit the core properties of gbeta, but avoid a large amount of complications from all the non-core constructs which exist in order to makegbetaa practical language. It was for a long time an important goal to formalizegbetaas a whole, but it seems that concrete language design bears a rich motivation in itself whereas a rigid formalization may appear to be a more mundane task of cleaning up the results achieved elsewhere.

The short Chap. 14 concludes, and thereby marks the end of the main part

1.2. ORGANIZATION 5 of this thesis. The appendices which follow after Chap. 14 give additional details about certain topics which have been covered more briey throughout the earlier chapters. Appendix A gives the complete, context-free grammar forgbeta. The proofs for some properties of the linearization algorithm appear in App. B. The next appendix, App. C, contains the original presentation of the Expression Problem, as it was given by Philip Wadler on the Java genericity mailing list in the autumn of 1998; this is used in Chap. 9.4. Appendix D presents each of the instructions in the special virtual machine for execution of gbetaprograms, making it easier to nd an estimated upper bound of the detailed time and space complexity of the execution of gbetaprograms.

Since the chapters of this thesis are so dierent in content, it might be ben-ecial to separate the dierent kinds of topics and create, say, several selective tables of content which simply omit references to all the parts of the thesis which are concerned with all other perspectives than the one in focus for that partic-ular table of content. This would make it possible to read some parts of the thesis in order to learn about the concrete language syntax and semantics, skip-ping all the more philosophical considerations about the conceptual framework etc. However, this would not be an easy task, exactly because it is one of the main points of the thesis that all these perspectives must be brought together in order to do serious language design, so to the extent that this has actually been achieved it will be almost impossible to read about one aspect in isolation because there will be cross-references to all the other aspects which would then be hard to understand.

The Language

gbeta

7

Basic Concepts

Coming from the Scandinavian tradition of object-orientation, and in particular having its roots inBeta, gbetahas a terminology which is in some ways non-standard. It might seem that the unusual terminology is an unjustied added diculty, making it harder for the general public to understand and judge the value of the contributions of this community. However, the unusual words often denote unusual concepts (e.g. pattern), and in these cases a non-standard word is obviously called for. Moreover, some words which are used everywhere (e.g.

object) have a dierent meaning. Hence, these basic concepts need to be intro-duced carefully; the next section introduces objects and patterns at an abstract level, and the following sections of this chapter introduce concrete language constructs for patterns, objects, and other basic aspects of gbeta.

2.1 Objects and Patterns

The following discussion introduces the conceptual foundation for gbeta, com-plementing the conceptual framework forBeta, of which a detailed presentation can be found in [74, ch. 18]. This treatment should be self-contained, though, such that [74] need only be consulted for additional depth. The discussion ap-plies to Beta as well asgbeta. The concrete language constructs arising from the considerations in this section are described in Sect. 2.2 and on.

2.1.1 Modeling

Program executions are considered to be similar to simulations, having a mod-eling relation to a topic: the structure and dynamics of the program execution (the model system) should reect the structure and dynamics of a selected part of the real world, as viewed from a given perspective (the referent system).

The choice of a perspective is essentialfor instance, a bus may be consid-ered a complex system of interconnected and interacting physical components in a CAD/CAM system used by a bus manufacturer, or the same bus may be

9

represented by a few data items like name and price in an accounting system.

Dierent perspectives on the same thing may give rise to entirely dierent computerized representations.

Many other approaches to object-orientation also emphasize the modeling relation between the real world and object-oriented programs, e.g. [24], even though conceptual modeling may not be given the rst priority, and the choice of perspectives is treated only implicitly.

It might seem that this framework only applies to simple-minded mirroring of physical phenomena like train schedules or payrolls, leaving many well-known computer programs unexplained, e.g., word processors. To counter this objec-tion we must expand on the importance of a peculiar circularity, namely that models are themselves phenomena. For example, the contents of a le used in

an accounting system may be considered a model of the real-world state at some point, but at the same time it may be managed (e.g., copied) as a phenomenon in its own right by an operating system utility (such as `cp' or a `File Man-ager'). Similarly, a word processor supports the presentation and manipulation of a computerized phenomenona piece of written, natural languagewhich, considered as a model, might be concerned with the description of objects and patterns in a computer language calledgbeta:::

The perspectives on computerized material as model or as phenomenon will always be intertwined because the main benet of a computerized modeling system compared to, e.g., a book is the dynamic manipulability of the model.

To manipulate a model, it must be treated as a phenomenon.

2.1.2 Modeling Phenomena with Objects

A program execution cannot reect the development in a part of the real world in an amorphous, holistic way. A divide and conquer strategy must be applied, by dividing the referent system into phenomena, each less complex than the referent system as a whole. The programming language must then provide a representation of real-world phenomena; objects play this rôle.

This rôle is dual, since phenomena may be things as well as behavior. Con-sequently, the object concept corresponds to both objects and method invo-cations in more traditional languages. Note that a conventional method is not the same as an invocation of that method; in most languages there is no explicit access to invocations.

2.1.3 Modeling Dynamicsa Non-solution

Supporting phenomena is not sucientthe world is not static. A development in the real world may bring phenomena into view or otherwise change their status from irrelevant or inexistent to present and relevant, e.g., when a house is built or a tornado emerges. Because of the vast complexity of the real world, it is not feasible to rebuild it in all details inside the computer. Hence, the emergence of phenomena in the execution of a computerized model (a program) can not be expected to be an automatic consequence of the immanent properties of the

2.1. OBJECTS AND PATTERNS 11 model. In other words, we cannot model the society and nature in such faithful detail that the house will be built inside the computer and then destroyed by the tornado inside the computer, for reasons which in details parallel a similar development in the real world, down to the stroke of the wings of a buttery on Sri Lanka which originally made the dierence between tornado and no tornado. The conclusion is:

We do not want to copy the world, it is too complex.

2.1.4 Complexity Management

Natural language provides a wonderful wealth of accumulated knowledge about modeling and complexity management.

To take a simple case rst, consider xed references to phenomena, like names of persons or places, or signals. A signal unconditionally signals the state of the sender, like saying Ouch! when it hurts, hence referring to a xed phenomenon within the sender. A particular sound might be used by some birds to signal fear, and those birds would not need any language capability beyond signals to make use of them. Fixed references may eciently direct the attention to known phenomena and hence work in a complex world, but they rely entirely on previous knowledge and do not provide intra-lingual complexity management.

Luckily, language is not only xed references to known phenomena. For example, we can talk about the house and the tornado from the previous sec-tion without having experienced them ourselves, and without reconstructing the events in every detail. We are using a model of the event which includes a purposeful level of complexity, and this is only possible because we give up built-in causality (i.e., the inevitable link from a cause to its eect). The words that describe the emergence of the tornado have no built-in mechanism which forces the production of words that describe the eects of the tornado sweeping over the landscape, even if that were the actual development. Someone telling a story about the tornado could just as well tell about the miraculous change which suddenly made the tornado weaken and dissolve, turning into a peaceful breeze and leaving the house untouched. The loss of causality is at the same time a liberation from necessity, giving the freedom to describe non-existing phenomena as well as existing ones, thus enabling dreams, lies, hypotheses, theories, etc.

To explain how natural language obtains this liberation from real-world causality, but still retains the ability to go beyond simple references to ex-isting knowledge, we must deal with the concept of concepts. There are several dierent philosophical views of concepts, including the Aristotelian and the prototypical view [74, ch. 18]. All of them recognize the ability of concepts to denote a collection of phenomena, called the extension of the concept, by means of some kind of decision procedure, called the intension of the concept. E.g., for a hard, Aristotelian concept like `prime number' we might use a quite rig-orous procedure to determine whether a given phenomenon already considered a number could also be considered a prime number, and for a soft,

prototyp-ical concept like `nice weather' we might have a long discussion about it. For concrete system development, Aristotelian concepts are much more manageable (implementable) than prototypical ones, but in the discussion here, the choice of concept of concepts is unimportant.

The ability of a concept to denote a set of phenomena determined by a de-cision procedure contrasts with the more primitive language entities like proper names or signals. They can be learned directly by repeated experiences of the connections, whereas concepts are unavoidably dependent on descriptions or other specications of the intension. This introduces a circularity in that

`concept' can only be dened using concepts; luckily this is no problem when explaining it post-hoc.

The extension of a concept is not arbitrary, the members of the set of phe-nomena in the extension are in certain ways similar. These similarities make it possible to use existing experience to estimate the properties of a situation described in terms of concepts. Hence, a concept based description will provide a useful model, avoiding both the restriction to simple, xed references to phe-nomena, and the complexity of (in any sense) copying the mechanisms of the referent system. We may now expand on the conclusion made in the previous section:

We cannot copy the world, but we can describe it.

Natural language avoids the complexity explosion by not supporting real-world causality.

Natural language then gains the ability to go beyond xed references to known phenomena by means of concepts.

2.1.5 Understanding

This section presents a simplistic view of the human mind. It is of course not supposed to overthrow all the eorts made by psychologists, philosophers, and others over the centuries; it is only supposed to help leveraging the richness of the human mind as a source of inspiration when doing programming language design. Moreover, it focuses on the activity of consuming and understanding lan-guage, only mentioning sensory experiences and production of language briey at the end.

Think of the human consciousness as a universe, capable of supporting dy-namic processes by means of entities. We will make no attempt to explain the physiology which supports such entities on the basis of networks of neurons, nor to detail the nature of those entities; but note that they imply that under-standing at a very fundamental level consists of dividing the world into parts,

phenomena, and then reconstructing an image of the world in terms of images of those parts. This is an analytical approach to understanding, based on breaking

down and reconstructing. It is very suitable for our purposes, oriented towards language, whereas a holistic approach would be more oriented towards word-free

exploration of ne details of total, undivided mental states. Since programs are

2.1. OBJECTS AND PATTERNS 13 just (extremely regular) language, the analytical approach has the right bias for us.The mental entities can be described from a functional point of view. Their basic responsibility is to be images of real world phenomena, thus enabling the human carrier to make reasonable predictions and thence useful decisions when interacting with that real world. The human understanding of the surrounding world is thus an active reconstruction of the world in terms of such mental images. The reconstruction may shift rapidly, as if several potential versions of mental universes are available and more or less activated, corresponding to changes of attention and of mode of thinking.

The mental reconstruction need not be perfect. For example, ghosts are1 simply mental images which do not correspond to real world phenomena; con-versely, walking right into a glass door is usually the consequence of having failed to build a mental image of that glass door at the right time. More importantly, dierent perspectiveschosen according to dierent basic understandings of the world and dierent desires and goals in dierent situationsradically inuence the contents and structure of the mental shadow world.

Furthermore, human beings are capable of detaching the mental image of the world from the actual surroundings, for instance when being intensely en-gaged in reading a book. With this we arrive at the core topic of this section:

listening, reading, or otherwise consuming language. Language consumption corresponds to using the language as abstract (world-detached) directions as to

listening, reading, or otherwise consuming language. Language consumption corresponds to using the language as abstract (world-detached) directions as to