From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,FAKE_REPLY_C, MAILING_LIST_MULTI,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,15edb893ef79e231 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-22 14:36:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!t-online.de!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: Mike Brenner Newsgroups: comp.lang.ada Subject: Re: Copying semantics molehill (was Re: True faiths) Date: Tue, 22 Jan 2002 17:35:49 -0500 Organization: none Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1011738962 75307 137.194.161.2 (22 Jan 2002 22:36:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 22 Jan 2002 22:36:02 +0000 (UTC) Return-Path: X-Mailer: Mozilla 4.78 [en]C-20010724M (Windows NT 5.0; U) X-Accept-Language: en Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:19202 Date: 2002-01-22T17:35:49-05:00 > Can anyone show an example of a situation where copying semantics really matter? In the semantics of the realtime world the most important attribute is speed, since nothing means anything if it does not arrive in time in that realtime world. Therefore, one example would be that unintentionally cloning something (duplicating all of its parts) might take up too many resources (time, memory, network bandwidth, etc.), and might therefore become meaningless, even though speed is not part of the equation in non-realtime semantics. In many situations, such as unchecked_conversions, there is a critical percentage difference between whether the compiler generates code to copy or whether it "does the copy at compile time". > Imagine you have an object with some simple attributes, and some connections to other complex objects, and you want to save this object to a file. A shallow copy would only take those attributes that were simple, for example, numbers and strings. Perhaps it we could also define a shallow copy to also copy the top level of references to those complex objects? > A deep copy would also copy out all of the connected complex objects, and all of their connected objects, and all of their connected objects, etc. For a great many objects that you will actually build, a deep copy will eventually copy the entire image, or get stuck in a copy cycle, where some referent of the original object refers back to the original object. There are tools, such as in VisualWorks, that scan the copy graph before copying to work around this cyclic copying. They work, but they are often unavoidably slow. In addition to tools, there are algorithms that detect cycles in graphs. If such a cycle were not detectable at all, then could we not report a bug against that storage management system. I agree that it can take a long time. > The exact meaning of "copy" turns out to be a *really* hard problem: there is no single answer that works in all cases. I agree one has to think out which kind of copy one wishes to do, and I agree that there is no single answer that works in all cases. But how hard is it really? The two most common types of copies needed are true clones of everything and top-level shallow copies of just the pointers. These are provided in many languages including, for example, Java and Python. When an intermediate level of copying is required, then it might probably need to be programmed manually. Although not always used, Ada provides the ability to provide complex data structures without passing access types. In addition, a relational model can be used, implemented in the Ada language, for example, where all data structures would be two-dimensional tables. There are actually many ways to manage the data to avoid difficulty in defining to what level one needs to copy. Mike