
The Design and Implementation of a Multiparadigm Programming Language By Chi-keung Luk A dissertation submitted in partial fulfillment of the requirement Tor the degree of Master of Philosophy in The Department of Computer Science The Chinese Hi^S^^^^ong Kong Hong 丨] July,1993 ‘ / » • \\ ; /, r-'*'^ "J '5 » Jaf • » i ‘ - . • - 職,� v^* ‘ . ‘‘ • • - •鞭 ff/7 - - V , ‘ ^ ‘ •••• . ... •‘一 - •. ‘ • . ’ • � r ^ ^ • ....... • •- ^^ ^ � . • • . ...• • - .... ‘ .; I . , “ ‘ . • - � ’ • ‘ .fchi ...... .... .... -.. f ,• : - • . ...- '^::.- h - . • ‘ • I-… ,.,:.::...I … ....… ‘ • • • • • • ‘ •• • •- To my family - ‘•I'v • . • .:;;. � ... .\ ‘ V? # . 1. • — , . h ‘‘ ;•l ' '^‘:- ..., .’...’. :k.‘. .•.”、.、."、:^ •"、.々 J,' ‘ ... : .4..-..、.... 广 .... ••« ; 1 �/ . - • /,. i ; ”• • ‘ ‘• 1. - • ... ‘ I 、 • ...- ‘ .. ‘ • •..,. .... • - . ‘ . ; i ••;•.•". , &岁:..‘..... I. .-.,., . ‘ . r . ‘ • - �••,.... - -. , ‘ . ...-.. 广略 \ ^ f \ i\ ::::;::「:、., ... »... .’ . .it'. -:• • r .!4. � .r. * . …,’" V.. | “•.:!•. ‘ .‘ * ;I •. -; ••‘ - • i - / . - ...... -.F. tf = .... • ••..,- ” . ‘ .• ,- . - 'i • ‘: . • … - ( . •‘ , ......_ � ‘ ” �, ^” “ tj 二 • . .„ ...‘.. .. .,. .1 ‘ . f 」 ;* 节;n,; ^ . • , \ , KJ : - ;C 、 ‘,‘ “ ^ ‘ n^Mu,、 , .. .. :, ’—玄 、_ . - - �_ % 1 < rp..IT: ....- ‘ . • •:.」 .,’?。:4 vwi •Sv*' • '。.•,.、•<• . •>. V ’. .1. ‘ ,-.. v^. • . y r . : . ‘ , .. • C „ .. •• •• ' - • I' :.••、.••••;.:又,.:.'、!;. 、厂:、• .”:;......:..). •• . • .... .’ • ^ - - . 少. ,• --. I - ” •v�‘ ’,、»> . ‘ ‘ • , - ‘ �'/V , I. � “ • • �- A , ; t . .�. , - ,. • :•、::: : .. "..、.:•::..’- ,,,ai^m. A'- ‘-r i ‘ i - ‘ . … • • : • 饭綠被办‘ .,. ..t"1 l.lfc.... M\… <;。 ,t...•�(’ -L ,、>…... ,>一 /.,.》� .•.�”,1 ;:::::. :fe^ 、.…‘.、」,,:, 。.,..> 種.; … .,. •.‘,:..:,:、,.1 .. 二„.…..‘〜;’二’…’ :: Contents Preface xi 1 Introduction 1 1.1 Programming Languages 2 1.2 Programming Paradigms 2 1.2.1 What is a programming paradigm 2 1.2.2 Which came first? Languages or paradigms? 2 1.2.3 Overview of some paradigms 4 1.2.4 A spectrum of paradigms 6 1.2.5 Mulitparadigm systems — not a dream but a need.. 7 1.3 The Objectives of this research 8 2 Studies of the object-oriented, the logic and the functional paradigms 10 2.1 The Object-Oriented Paradigm 10 2.1.1 Basic components 10 2.1.2 Motivations 11 2.1.3 Some related issues 12 2.1.4 Computational models for object-oriented programming 16 2.2 The Functional Paradigm 18 2.2.1 Basic concepts 18 2.2.2 Lambda calculus 20 2.2.3 The characteristics of functional programs 21 2.2.4 Practicality of functional programming 25 2.3 The Logic Paradigm 28 2.3.1 Relations 28 2.3.2 Logic programs 29 2.3.3 The opportunity for parallelism 30 2.4 Summary 31 3 A survey of some existing multiparadigm languages 32 3.1 Logic + Object-Oriented 33 一 3.1.1 LogiC++ 33 3.1.2 Intermission 34 3.1.3 Object-Oriented Programming in Prolog (OOPP) 36 3.1.4 Communication Prolog Unit (CPU) 37 3.1.5 DLP 37 iii • 3.1.6 Representing Objects in a Logic Programming Language with Scoping Constructs (OLPSC) 39 3.1.7 KSL/Logic 40 3.1.8 Orient84/K 41 3.1.9 Vulcan 42 3.1.10 The Bridge approach 43 3.1.11 Discussion ^ 3.2 Functional + Object-Oriented 46 3.2.1 PROOF 46 3.2.2 A Functional Language with Classes (PLC) 47 3.2.3 Common Lisp Object System (CLOS) 49 3.2.4 FOOPS 50 3.2.5 Discussion 51 3.3 Logic + Functional 52 3.3.1 HOPE 52 3.3.2 FUNLOG 54 3.3.3 F* 55 3.3.4 LEAF …… 56 3.3.5 Applog 57 3.3.6 Discussion 58 . 3.4 Logic + Functional + Object-Oriented 61 3.4.1 Paradise 61 3.4.2 LIFE 62 3.4.3 UNIFORM 63 3.4.4 G 64 3.4.5 FOOPlog 66 3.4.6 Logic and Objects (L&O) 66 3.4.7 Discussion 67 4 The design of a multiparadigm language 1 70 4.1 An Object-Oriented Framework 71 4.1.1 A hierarchy of classes 71 4.1.2 Program structure 71 4.1.3 Parametric classes 72 4.1.4 Inheritance... :……… 73 4.1.5 The meanings of classes and methods 75 4.1.6 Objects and messages 75 4.2 The logic Subclasses 76 4.2.1 Syntax 76 4.2.2 Distributed inference 76 4.2.3 Adding functions and expressions to logic programs 77 4.2.4 State modelling 79 4.3 Thcfunctional Subclasses 80 4.3.1 The syntax of functions 80 4.3.2 Abstract data types 81 4.3.3 Augmented list comprehensions 82 4.4 Ihe Semantic Foundation of /Programs 84 4.4.1 Tj*: Transform functions into Horn clauses 84 4.4.2 7*2*: Transform object-oriented features into pure logic 85 iv 4.5 Exploiting Parallelism in /Programs 89 4.5.1 Inter-object parallelism 89 4.5.2 Intra-object parallelism 92 4.6 Discussion 96 5 An implementation of a prototype of 1 99 5.1 System Overview 99 5.2 /-to-Prolog Translation 101 5.2.1 Pass 1 - lexical and syntax analysis 101 5.2.2 Pass 2 - Class Table Construction and Semantic Checking 101 5.2.3 Pass 3 - Determination of Multiple Inheritance Precedence 105 5.2.4 Pass 4 - Translation of the directive part 110 5.2.5 Pass 5 - Creation of Prolog source code for an I object 110 5.2.6 Using expressions in logic methods 112 5.3 /-to-LML Translation 114 5.4 The Run-time Handler 117 5.4.1 Object Management 118 5.4.2 Process Management and Message Passing 121 6 Some applications written in 1 125 6.1 Modeling of a State Space Search 125 6.2 A Solution to the N-queen Problem 129 6.3 Object-Oriented Modeling of a Database 131 6.4 A Simple Expert System 133 6.5 Summary 138 7 Conclusion and future work 139 7.1 Conclusion 139 7.2 Future Work 141 A Language manual 146 A.l Introduction 146 A.2 Syntax 146 A.2.1 The lexical specification 146 A.2.2 The syntax specification 149 A3 Classes 152 A.4 Object Creation and Method Invocation 153 A.5 The logic Subclasses 155 A.6 The functional Subclasses 156 A.7 Types 158 A.8 Mutable States 158 B User's guide 160 B.l System Calls 160 B.2 Configuration Parameters 162 B.3 Errors 163 B .4 Implementation Limits 164 B.5 How to install the system 164 V B.6 How to use the system 164 B.7 How to recompile the system 166 B.8 Directory arrangement 167 C List of publications 168 Bibliography 169 vi List of Programs 4.1 The definition of class person 73 4.2 The definition of class student 77 4.3 The definition of class gcd 78 4.4 The definition of the functional subclass boolean_ops 81 4.5 Implementation of list, stack and queue ADTs using functional subclasses 82 4.6 A simple program in I for illustrating T* 88 4.7 A parallel quicksort program in/ 90 4.8 Implementation of generic list, stack and queue using logic subclasses 96 4.9 A program to demonstrate the use of backtracking in object-oriented programming 97 5.1 A program used to illustrate the construction of the class table 104 5.2 Programs used to demonstrate the pass 4&5 of the Mo-Prolog translation 111 5.3 A program to demonstrate the /-to-LML translation 116 6.1 Definition of the class search 126 6.2 Definition of the class maze 126 6.3 Definition of the class four 一 queen 127 6.4 Definition of the class breath一first 128 6.5 Definition of the class queen 130 6.6 Definitions of three classes: staff, teaching and support 132 6.7 Some functions on the database in program 6.6 133 6.8 Definition of the class inference 134 6.9 Definition of the class fact s—base 134 6.10 Definition of the class doctor 135 6.11 Definition of the class disease 135 6.12 Definitions of some subclasses of disease 136 6.13 Definition of the class hospital 137 vu•着 List of Figures 1.1 Dates and ancestry of several important programming languages 3 1.2 Organization of programming paradigms 6 1.3 The operational-definitional spectrum 7 2.1 The configuration of an object 11 2.2 Relationships between types and classes 13 2.3 The family of object-based languages 15 2.4 Modeling an object as an automation 16 2.5 An example of a relation R between X and Y 28 3.1 The LOOF-space 33 3.2 Some logic + object-oriented approaches in the LOOF-space 45 3.3 Positions of some functional + object-oriented approaches in the LOOF-space 52 3.4 An example of narrowing 59 3.5 The classification of some logic + functional approaches 60 4.1 Class hierarchy in /.... 71 4.2 The structure of an / program 72 4.3 The structure of a class definition 72 4.4 A multiple inheritance hierarchy 74 4.5 The translation scheme 7* for giving semantics to / programs"" 84 4.6 Two message passing modes 89 4.7 An execution sequence of the parallel quicksort 91 4.8 Two deadlock situations 92 4.9 The configuration of an object with intra-object parallelism 93 4.10 The state diagram of an activity within an object 95 5.1 A configuration of the system 100 5.2 The Mo-Prolog translation scheme 102 5.3 The structure of a class table entry 103 .5.4 Example of a class table 104 5.5 A multiple inheritance hierarchy 106 5.6 A journey starting atE 109 5.7 The scheme to construct a LML module from a functional subclass definition 115 5.8 The components of the run-time handler 118 5.9 A client/server model for process communication 122 5.10 The sequence of creating an object followed by an invocation of a method of this object 123 6.1 Object-oriented modeling of a database 131 7.1 Cooperation between the three paradigms in 1 141 7.2 Hie original and a proposed translation schemes 143 B.l The directory tree of the system 167 viii List of Tables 1 • 1 Generations of programming languages 2 2.1 A summary of characteristics of the logic, the functional and the object-oriented paradigms 31 3.1 The support of subclasses and subtypes in the four functional + object-oriented approaches 51 7.1 A summary on the paradigms involved and the level of parallelism of some multiparadigm languages 140 B.l Error-handling 163 B.2 Implementation limits of the prototype 164 B.3 Directories of the system 167 ix List of Algorithms 5.1 Algorithm for filling two bit matrices A and J 107 5.2 An algorithm to traverse the inheritance hierarchy in the intended order 108 5.3 Algorithm to convert a logic program embedded with expressions to a corresponding expression-free logic program 113 5.4 Procedure to transform a functional subclasses definition into LML modules 114 / V Preface This thesis is about the research of multiparadigm programming languages.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages188 Page
-
File Size-