Kodak Color Control Patches Kodak Gray
Total Page:16
File Type:pdf, Size:1020Kb
Kodak Color Control Patches 0 - - _,...,...,. Blue Green Yellow Red White 3/Color . Black Kodak Gray Scale A 1 2 a 4 s -- - --- - -- - -- - -- -- - A Study of Compile-time Metaobject Protocol :J/1\'-(Jt.-S~..)(:$/;:t::;i':_;·I'i f-.· 7 •[:]f-. :::JJl. (:~9 ~~Jf'?E By Shigeru Chiba chiba~is.s.u-tokyo.ac.jp November 1996 A Dissertation Submitted to Department of Information Science Graduate School of Science The Un iversity of Tokyo In Partial Fulfillment of the Requirements For the Degree of Doctor of Science. Copyright @1996 by Shigeru Chiba. All Rights Reserved. - - - ---- - ~-- -- -~ - - - ii A Metaobject Protocol for Enabling Better C++ Libraries Shigeru Chiba Department of Information Science The University of Tokyo chiba~is.s.u-tokyo.ac.jp Copyrighl @ 1996 by Shi geru Chiba. All Ri ghts Reserved. iii iv Abstract C++ cannot be used to implement control/data abstractions as a library if their implementations require specialized code for each user code. This problem limits programmers to write libraries in two ways: it makes some kinds of useful abstractions that inherently require such facilities impossi ble to implement, and it makes other abstractions difficult to implement efficiently. T he OpenC++ MOP addresses this problem by providing li braries the ability to pre-process a program in a context-sensitive and non-local way. That is, libraries can instantiate specialized code depending on how the library is used and, if needed, substitute it for the original user code. The basic protocol structure of the Open C++ MOP is based on that of the CLOS MOP, but the Open C++ MOP runs metaobjects only at compile time. This means that the OpenC++ MOP does not imply runtim e penalties caused by dispatching to metaobjects. Copyright @ 1996 by Sh igeru C hi ba. All Ri ghts Reserved. v vi Biographical Sketch Acknowledgments Shigeru Chiba was born in Tokyo, Japan, in 1968. After liv ing in Osaka This thesis was supervised by Gregor Ki czales. I would like to express my for a few years, he spent most of his childhood in Yokohama, a suburb of deep gratit ud e to him. I also profoundly thank Takashi !l !asuda, my supervi Tokyo. As many other children living in a suburb of Tokyo do, he went to a sor at The University of Tokyo. He continuously supported and encouraged high school in Tokyo, and first met meta computation there when his good me during this work. John Lamping gave me a plenty of constructive com friend at the high school let him borrow a book, Godel, Escher·, Bach: an ments and criticism, whi ch g reatly helped me write this thesis. Finally, I Eternal Golden Braid, by Douglas R. Hofstadter. Looking back now, it was greatly thank my thesis co mmittee, Akinori Yonezawa, 1\ ei Hira ki , Yoshio natural that he was captured by the idea of meta computation, which was Oyanagi, Masami ll agiya, Hiroshi Imai, and aoki Kobayashi. plainly explained in the book. I am grateful for financial support received from J a pan Society for the But the life at university was attractive enough to have him forget meta Promotion of Science (Nihon Gakujyutsu Sinkoukai), from The Information computation. It had actually gone from his mind until it emerged again in technology Promotion Agency, Japan (!PA), from Xerox Corporation, from front of hun at the department of information science. He was supposed to Japan Foundation for the Education and Training of Information Process walk away from it, but what he really did was to dance along a circle and ing (Jyouhousyori Kyouiku Kensyu Jyosei Zaidan), and from International come back to the same place. It might be his karma a lt hough he hopes he Information Science Foundation, Japan (Jyouhou I<agaku Kokusai Koryu drew not a circle but a heli x. Zaidan). Also, Department of Information Science at The University of The second encounter eventuall y took him to California, where a guru Tokyo let me extend my stay at PARC with exceptional courtesy. is li ving. He has not yet known what is the next. This thesis project was conducted at Xerox Palo Alto Research Center (PARC) in Palo Alto, California, U.S.A. viii CONTENTS 6.7 The Standard Template Library. 87 6.8 The OOPACK Benchmark Test 91 6.9 Summary 96 7 Conclusion 99 Contents A Back quote 109 A.1 Quote 109 A.2 Backquote . 109 B Reference Manual 111 Introduction 1 B.1 Introduction . 111 B.2 Tutorial .. 2 Limitations of C++ 112 7 B.2.1 Verbose Objects 113 2.1 Inherita nce 7 B.2.2 Syntax Extension for Verbose Objects 117 2.2 Template 13 B.2.3 Matrix Library 118 2.3 Summary 17 B.2.4 Syntax Extension for the Matrix Library . 121 B.2.5 Before-Method 3 Techniques for Processing a Program 124 19 B.2.6 Wrapper Function 3.1 Lisp Macros . ... 126 19 B.3 Base-Level Language (OpenC++) 3.2 3-Lisp ..... 132 21 B.3.1 Base-level Connection to the MOP 3.3 The CLOS MOP 132 26 B.3.2 Syntax Extensions . 3.4 Summary 132 35 B.3.3 Loosened Grammar 134 4 The OpenC++ MOP B.4 Metaobject Protocol (MOP) . 13.) 37 8.4.1 Representation of Program Text 4.1 Overview ... 13.) 37 8.4.2 4.2 Context-sensitive and No n-local Representation of Types 142 40 4.3 8.4 .3 Representation of Environment 144 Syntax Extension 44 4.4 What is New? . 8.4.4 Class Metaobjects 14.) 46 4.5 Summary B.4.5 Error Message 1.).) 49 B.4.6 C++ Preprocessing 1.)6 5 Meta Helix B.5 Command Reference 1.)7 51 5.1 Implementation Level Conflation 51 c Programs 5.2 Inadeq uate Solutions . 159 56 C.l The Distributed Object Library . 5.3 The Meta Helix Architecture 1.)9 58 C.2 The Wrapper Function Metaclass Library 5.4 Implementing the Meta Helix 163 60 C.3 Vector Library 5.5 Summary 166 63 C.4 The Standard Template Library . 168 6 Libraries in OpenC++ C.5 OOPACK benchmark 174 65 6.1 Named Object Libra ry 65 6.2 Distributed Object Library 67 6.3 Wrapper Library 74 6A Implementation of qi\ lake() 79 6.5 Metaclass 81 6.6 Vector Library . 83 vii - -- ~--·····------~ List of Figures 1.1 The common part and the specialized part of a library 2 3.1 The CLOS MOP is metacircular . 28 3.2 An improved implementation of 3-Lisp 30 3.3 An metacircular implementation 32 5.1 Two handles with the same abstraction 58 5.2 The im plementation relation between interfaces 60 5.3 The Meta Helix supports n implementation levels. 60 6.1 The in stance-of relationship among metaclasses 81 B.1 The OpenC++ Compiler 112 B.2 Instance-of Relationship . 155 ix - -~ ~ --- - - List of Tables Chapter 1 3.1 Lisp Macros, 3-Lisp, and the CLOS MOP . 35 Introduction 6.1 Execution performance of the vector library (J.Lsec.) 86 6.2 Execution performance of STL (msec.) ...... 91 6.3 Execution time of the OOPACK benchmark (sec.) 96 In computing science, elegance is not a luxury 13.1 stati c mem ber functions on Ptree bul a maller of life and dea lh . 136 - E. W. Dijkstra B.2 enum constants returned by Ptree : :Whati s() 138 Execution speed is th e only metric in computer science. - Kei Hirak i One of today's significant concerns in software industry would be to decrease time and costs of software development. Anybody wou ld agree that good libraries promote code reuse and thereby contribute to rapid and low-cost software development. This thesis deals with a language mechanism for programmers to write good libraries. What are good libraries? Good libraries provide useful control/data al> stractions, which are commonly used for a number of a pplications, hi gh-level to improve readabili ty of programs, and simple and intuitive to avoid lead ing the li brary users to mis use the li bra ries and cause serious errors. Also, efficiency is another criterion of good libraries . Since writing a good library is a very difficult task, the programmer is required to have not only good progra mming skill but also deep knowledge about the application domain in that the libra ry helps progra mm ers. For example, library developers need to know typical functions and data structures used in that domain. Development of good libraries also needs assistance of la nguage design ers, who should provide language mechan isms for writing good libraries. T his is a more realistic option for the designers th a n including all desirable control/data abstractions in the language specifi cations, sin ce the designers cannot ex pect every desirable abstraction in advance a nd because the la n guage would be too complex if built-in language mechanisms cover all the desirable abstrac tions, such as I/ 0, persistency, distribution, concurrency, and so on. Programming languages shou ld have a minimum set of built-in mechanisms a nd most of abstractions should be suppli ed by librari es. xi 2 CHAPTER 1. INTRODUCTION 3 Motivating problem Solution by this thesis Language mechanisms that have been developed so far for writing libraries To solve the problem mentioned above, this thesis proposes a new language are not powerful enough to support every desirable control/data abstrac mechanism for enabling libra ries to supply specialized code and include more tions. For example, the C++ language [58] is one of languages that have useful control/data abstractions.