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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f4fd2,23202754c9ce78dd X-Google-Attributes: gidf4fd2,public X-Google-Thread: fac41,15edb893ef79e231 X-Google-Attributes: gidfac41,public X-Google-Thread: 114809,15edb893ef79e231 X-Google-Attributes: gid114809,public X-Google-Thread: 103376,15edb893ef79e231 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-22 06:49:49 PST Newsgroups: comp.lang.lisp,comp.lang.ada,comp.lang.eiffel,comp.lang.smalltalk Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!torn!utnut!news.ecf!doylep From: doylep@eecg.toronto.edu (Patrick Doyle) Subject: Copying semantics molehill (was Re: True faiths) Sender: news@ecf.utoronto.ca (news) Organization: Computer Group, Elec. Eng., University of Toronto Message-ID: References: <9jtu3u8cq92b05j47uat3412tok6hq X-Nntp-Posting-Host: wildcat.eecg Date: Tue, 22 Jan 2002 14:25:09 GMT Xref: archiver1.google.com comp.lang.lisp:24966 comp.lang.ada:19179 comp.lang.eiffel:5492 comp.lang.smalltalk:18430 Date: 2002-01-22T14:25:09+00:00 List-Id: Kaz Kylheku wrote: >In article <3C4A58B8.10304@mail.com>, Hyman Rosen wrote: >>Richard Riehle wrote: >> >>> procedure Copy_Deep (Source : in T; Target : in out T); >>> procedure Copy_Shallow (Source : in T; Target : in out T); >> >>I dislike the notion of providing these methods as external interfaces >>to a type. It seems wrong to me for a client to have to know what kind >>of copy to use - that's the type's business to know. > >This turns out to be circular reasoning, because what a type ``knows'' >is partally defined by the operations you can perform on it. > >Suppose that you have N methods for copying an object. I do not take it >as a theorem that you can always make an (N + 1)-th method which unifies >the other N, magically choosing the appropriate one. How can this magic >meta-method possibly know what semantics the caller wants? I must be crazy. I have never written a system where the semantics of the "copy" operation mattered. Mainly, this is for two reasons: 1. A lot of my data is immutable, so the copying semantics are moot. 2. Instead of copying an existing object, my usual idiom is to create a new one from scratch. I suppose there are some cases where these two things don't apply, or would be inappropriate, and one would have to think very carefully about the semantics of copying, but I can't think of such a case off the top of my head. I suppose that only says something about my inexperience as a programmer. Can anyone show an example of a situation where copying semantics really matter? -- -- Patrick Doyle doylep@eecg.toronto.edu