Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Object copying
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== In Eiffel === Runtime objects in [[Eiffel (programming language)|Eiffel]] are accessible either indirectly through [[reference (computer science)|references]] or as ''expanded'' objects which fields are embedded within the objects that use them. That is, fields of an object are stored either [[Internal storage|externally or internally]]. The Eiffel class <code lang="eiffel">ANY</code> contains features for shallow and deep copying and cloning of objects. All Eiffel classes inherit from <code lang="eiffel">ANY</code>, so these features are available within all classes, and are applicable both to reference and expanded objects. The <code lang="eiffel">copy</code> feature effects a shallow, field-by-field copy from one object to another. In this case no new object is created. If <code lang="eiffel">y</code> were copied to <code lang="eiffel">x</code>, then the same objects referenced by <code lang="eiffel">y</code> before the application of <code lang="eiffel">copy</code>, will also be referenced by <code lang="eiffel">x</code> after the <code lang="eiffel">copy</code> feature completes. To effect the creation of a new object which is a shallow duplicate of <code lang="eiffel">y</code>, the feature <code lang="eiffel">twin</code> is used. In this case, one new object is created with its fields identical to those of the source. The feature <code lang="eiffel">twin</code> relies on the feature <code lang="eiffel">copy</code>, which can be redefined in descendants of <code lang="eiffel">ANY</code>, if needed. The result of <code lang="eiffel">twin</code> is of the anchored type <code lang="eiffel">like Current</code>. Deep copying and creating deep twins can be done using the features <code lang="eiffel">deep_copy</code> and <code lang="eiffel">deep_twin</code>, again inherited from class <code lang="eiffel">ANY</code>. These features have the potential to create many new objects, because they duplicate all the objects in an entire object structure. Because new duplicate objects are created instead of simply copying references to existing objects, deep operations will become a source of performance issues more readily than shallow operations.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)