Copying and Comparing : Problems
نویسندگان
چکیده
In object oriented programming, it is sometimes necessary to copy objects and to compare them for equality or inequality. We discuss some of the issues involved in copying and comparing objects and we address the problem of generating appropriate copying and comparing operations automatically, a service that is not provided by most object oriented languages and environments. Automatic generation appears to be not only desirable, because hand-coding these methods is mechanical and yet error-prone, but also feasible, because the form of the code is simple and largely predictable. Some languages and some object models presented in the literature do support generic copying and comparing, typically deening separate \shal-low" and \deep" versions of both operations. A close examination of these deenitions reveals inadequacies. If the objects involved are simple, copying and comparing them is straightforward. However, there are at least three areas in which insuucient attention has been given to copying and comparing complex objects: (1) values are not distinguished from objects ; (2) aggregation is not distinguished from association; and (3) the correct handling of linked structures other than trees is neglected. Solving the third problem requires a mechanism built into the language, such as exists in Eiiel. Building such a mechanism without modifying the language requires a language with suucient reeexive facilities, such as Smalltalk. Even then, the task is diicult and the result is likely to be insecure. We show that fully automatic generation of copying and comparing operations is not feasible because compilers and other software tools have access only to the structure of the objects and not to their semantics. Nevertheless, it is possible to provide default methods that do most of the work correctly and can be ne-tuned with a small additional amount of hand-coding. We include an example that illustrates the application of our proposals to C++. It is based on additional declarations handled by a preprocessor.
منابع مشابه
Copying and Comparing: Problems and Solutions
In object oriented programming, it is sometimes necessary to copy objects and to compare them for equality or inequality. We discuss some of the issues involved in copying and comparing objects and we address the problem of generating appropriate copying and comparing operations automatically, a service that is not provided by most object oriented languages and environments. Automatic generatio...
متن کاملComparing Trailing and Copying for Constraint Programming
A central service of a constraint programming system is search. In almost all constraint programming systems search is based on trailing, which is well understood and known to be efficient. This paper compares trailing to copying. Copying offers more expressiveness as required by parallel and concurrent systems. However, little is known how trailing compares to copying as it comes to implementa...
متن کاملCode-Copying in the Balochi Language of Sistan
This empirical study deals with language contact phenomena in Sistan. Code-copying is viewed as a strategy of linguistic behavior when a dominated language acquires new elements in lexicon, phonology, morphology, syntax, pragmatic organization, etc., which can be interpreted as copies of a dominating language. In this framework Persian is regarded as the model code which provides elements for b...
متن کاملTHE IMPACT OF TEACHING SUMMARIZING ON EFL LEARNERS’ MICROGENETIC DEVELOPMENT OF SUMMARY WRITING
Summary writing is associated with lots of cognitive and metacognitive complexities that necessitates instruction (Hirvela & Du, 2013). Contrary to majority of studies carried out on summarization instruction, the present study addressed the underlying processes or microgenetic developments of the Iranian EFL learners’ summary writing. To this end, 41 male and female undergraduate students rece...
متن کاملMONITORING OF LEAD POISONING IN SIMPLE WORKERS OF A COPYING CENTER BY FLAME ATOMIC ABSORPTION SPECTROSCOPY
Inorganic lead compounds are used most widely in paint and pigment industries. Because of exposure to lead dust in workers in a copying center, we compared blood lead levels in these workers to normal individuals and investigated the relationship between job tenures of the workers and their blood lead levels. This survey was performed on 20 simple workers in a copying center of Tehran Univ...
متن کامل