No-overloading Principle
نویسنده
چکیده
A C++ programmer said to Rabbi Shammai: " I promise to try object technology if you can explain the secret of objects while standing on one foot. " Rabbi Shammai whacked him on the head with a 10-by-2 ruler. He went to Rabbi Hillel who, standing on one foot, answered: " No overloading. That is the secret of objects. All the rest is commentary. " Some commentary now. The beauty of object technology (OT) is that for all the variations, refinements, codicils, and con-sequences—including fifteen years of the Journal of Object-Oriented Programming articles—everything in the end rests on a single idea: class. A class is an association between some names and some operations, called " features " in Eiffel (and known as " members " in several other languages). In a class P O I N T d e-scribing points in a plane, the names may include x, y, ro, theta, move, and rotate; the features may include operations to return a point's cartesian and polar coordinates, move it by a certain displacement, and rotate it around the origin by a certain angle. The association between names and features is one-to-one: x denotes the operation that returns the horizontal coordinate; ro the one that returns the distance to the center; rotate the rotation operation. Enforcing a one-to-one correspondence keeps everything simple and manageable. It makes the class readable and avoids confusion: if you see a feature name f and do not know what it means, you only have to search until the first feature declaration with that name, and stop there; you know that you have found what you are looking for, and do not need to worry about some competing definition. Easy, simple, and comforting. The rule is simple: Human languages do not quite follow that rule. This can be a source of riddles, as in " time flies like an arrow. " Amusement apart, it is also a source of confusion, not appropriate for a programming or specification language that is designed for precise statement of intent. Within a single syntactic scope such as a class, just choose different names. Why indeed give the same name to two different things? Names are not an endangered species, and there is no tax on keystrokes. Even in Eiffel, where we like giving features clear, meaningful, pro-nounceable names—I have never been able to understand why others use b t n C …
منابع مشابه
Averaging Met hods for Transient Regimes in Overloading Retrial Queueing Systems
A new approach is suggested to study transient and stable regimes in overloading retrial queueing systems. This approach is based on limit theorems of averaging principle and diffusion approximation types for so-called switching processes. Two models of retrial queueing systems of the types h?/G/i/w.r (multidimensional Poisson input flow, one server with general service times, retrial system) a...
متن کاملGeneric Programming on the Structure of Homogeneously Nested Arrays
In this paper we propose a new means to model and operate on nested arrays that allows for a high level of abstraction without introducing a performance penalty. We achieve this by using a nesting structure on array types which allows us to shift the nesting information of arrays from the runtime representation level to the type system level. This information can then be exploited for generic f...
متن کاملType Inference for Overloading without Restrictions, Declarations or Annotations
This article presents a type system based on the DamasMilner system [DM82], that supports overloading. Types of overloaded symbols are constrained polymorphic types. The work is related to Haskell type classes [Wad89,NP93,HHJW96], System O [OWW95] and other type systems with similar forms of constrained types [Kae88,Smi91,Jon94,DCO96]. Restrictions imposed in these systems with respect to overl...
متن کاملAdding overloading to Java type inference
Zusammenfassung In this paper we extend our Java with type inference by adding methods. Functions had been realized as lambda expressions defined in fields until now, which led to the restrictions that no overloading is available. Therefore the main challenge of adding methods is to deal with overloading. We present the change of the data-structures and the algorithm.
متن کاملGeneralizing Overloading for C++2000
This paper outlines the proposal for generalizing the overloading rules for Standard C++ that is expected to become part of the next revision of the standard. The focus is on general ideas rather than technical details (which can be found in AT&T Labs Technical Report no. 42, April 1,1998).
متن کاملLower Bounds on Type Checking Overloading
Smith has proposed an elegant extension of the ML type system for polymor-phic functional languages with overloading. Type inference in his system requires solving a satissability problem that is undecidable if no restrictions are imposed on overloading. This short note explores the eeect of recursion and the structure of type assumptions in overloadings on the problem's complexity.
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2001