comp.lang.ada
 help / color / mirror / Atom feed
From: kaz@accton.shaw.ca (Kaz Kylheku)
Subject: Re: Copying semantics molehill (was Re: True faiths)
Date: Tue, 22 Jan 2002 18:00:08 GMT
Date: 2002-01-22T18:00:08+00:00	[thread overview]
Message-ID: <IMh38.15646$XG4.659269@news2.calgary.shaw.ca> (raw)
In-Reply-To: GqCG1x.nFH@ecf.utoronto.ca

In article <GqCG1x.nFH@ecf.utoronto.ca>, Patrick Doyle wrote:
>Kaz Kylheku <kaz@ashi.footprints.net> 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.

Anecdotal evidence. I have written systems where it mattered.

Here is a recent example: a protocol stack where I have three ways
to copy a network buffer buffer object. I can copy a pointer, and
increment a reference count. I can copy the header structure which
maintains various pointers into the buffer, and bump up a lower reference
count on the buffer. Or I can do a deep copy which copies the buffer
as well.

This data is not immutable, so the copying semantics are not moot.

>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?

How about a Lisp example?

	(eq 'a 'a)  ==> T

	(eq 'a (copy-symbol 'a)) ==> NIL

A copy of a symbol is usually useless, because a symbol is meaningful
precisely because it is EQ to itself. So you usually need shallow,
reference copies of a symbol.

If a symbol is embedded in an object, and you want to copy that object,
you probably want to copy those embeddded symbols by reference.  And then
you are no longer making an entirely new object from scratch; the common
symbols are shared substructure.



  parent reply	other threads:[~2002-01-22 18:00 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <B85AB00A.3603%verec@mac.com>
     [not found] ` <%njZ7.279$iR.150960@news3.calgary.shaw.ca>
     [not found]   ` <B85BD264.370E%verec@mac.com>
     [not found]     ` <n7ybsg9lq8y.fsf@panix1.panix.com>
     [not found]       ` <3c36fbc5_10@news.newsgroups.com>
     [not found]         ` <gat-0501022256350001@192.168.1.50>
     [not found]           ` <4idg3u40ermnp682n6igc5gudp7hajkea9@4ax.com>
     [not found]             ` <gat-1001021155210001@eglaptop.jpl.nasa.gov>
     [not found]               ` <bruce-6C0AC5.10391411012002@news.paradise.net.nz>
     [not found]                 ` <gat-1001021515510001@192.168.1.50>
     [not found]                   ` <76be8851.0201101909.9db0718@posting.google.com>
     [not found]                     ` <gat-1101020950400001@eglaptop.jpl.nasa.gov>
2002-01-11 23:46                       ` True faiths ( was Re: The true faith ) israel r t
2002-01-12  0:38                         ` Steven T Abell
2002-01-13 12:20                           ` Kevin McFarlane
2002-01-13 18:52                             ` Erik Naggum
2002-01-14  8:12                               ` Espen Vestre
2002-01-14 10:40                                 ` israel r t
2002-01-16  6:42                                   ` Patrick Doyle
2002-01-16  8:00                                     ` israel r t
2002-01-16  8:55                                       ` Espen Vestre
2002-01-20  0:55                                         ` Mad Hamish
2002-01-20  1:18                                           ` Bruce Hoult
2002-02-13 16:31                                             ` Tom Hawker
2002-02-13 17:51                                               ` Larry Kilgallen
2002-02-13 23:28                                               ` Peter Gummer
2002-02-14  3:10                                                 ` Greg C
2002-02-14  1:56                                               ` Hartmann Schaffer
2002-02-14  9:59                                               ` Barry Watson
2002-01-16  8:00                                     ` " Do computers because it pays well" ( was Re: True faiths ) israel r t
2002-01-14 11:00                               ` True faiths ( was Re: The true faith ) Immanuel Litzroth
2002-01-18 15:19                                 ` Bob Bane
2002-01-18 17:44                                   ` René
2002-01-18 18:04                                   ` Hyman Rosen
2002-01-18 23:22                                     ` Richard Riehle
2002-01-18 23:53                                       ` Matthew Heaney
2002-01-20  5:39                                       ` Hyman Rosen
2002-01-20  5:59                                         ` Kaz Kylheku
2002-01-20 15:15                                           ` Software Scavenger
2002-01-21  1:42                                         ` Richard Riehle
2002-01-21  9:52                                           ` Hyman Rosen
2002-01-21 16:38                                             ` Richard Riehle
2002-01-21 20:30                                             ` Kaz Kylheku
2002-01-22  5:35                                             ` Raffael Cavallaro
2002-01-18 18:44                                   ` Simon Willcocks
2002-01-22 17:01                                     ` Hyman Rosen
2002-01-22 21:59                                       ` Bruce Hoult
2002-01-22 22:08                                         ` Hyman Rosen
2002-01-22 23:22                                           ` Kenny Tilton
2002-01-23 21:12                                             ` Hyman Rosen
2002-01-23 22:24                                               ` Tim Bradshaw
2002-01-24  0:15                                               ` Kenny Tilton
2002-01-24  8:14                                                 ` Hyman Rosen
2002-01-24 16:50                                                   ` Canconical C++ assignment (was Re: True faiths ...) Ray Blaak
2002-01-23  2:26                                           ` True faiths ( was Re: The true faith ) Bruce Hoult
2002-01-23 17:49                                             ` Richard Riehle
2002-01-22 22:09                                         ` Jim Rogers
2002-01-22 22:54                                           ` Kaz Kylheku
2002-01-22 23:47                                             ` Jim Rogers
2002-01-23  0:08                                               ` Ada SDL Eric Merritt
2002-01-23  1:39                                                 ` Rajat Datta
2002-01-23 10:52                                                 ` Preben Randhol
2002-01-23 13:59                                                   ` Eric Merritt
2002-01-23 16:48                                                     ` Preben Randhol
2002-01-23 16:01                                           ` True faiths ( was Re: The true faith ) Greg C
2002-01-26  0:40                                           ` AG
2002-02-11  7:18                                             ` David Combs
2002-02-11 17:50                                               ` Ray Blaak
2002-02-11 20:13                                               ` Kaz Kylheku
2002-02-13 21:17                                               ` Tom Hawker
2002-01-23 17:45                                         ` Georg Bauhaus
2002-01-18 19:36                                   ` Bruce Hoult
2002-01-18 19:57                                     ` Kaz Kylheku
2002-01-18 19:58                                     ` Marc Spitzer
2002-01-18 20:11                                       ` Ed Falis
2002-01-18 22:14                                         ` Kenny Tilton
2002-01-19  2:46                                           ` Thomas F. Burdick
2002-01-19  7:32                                     ` av1474
2002-02-13 23:12                                 ` Tom Hawker
2002-01-14 11:42                               ` Kevin McFarlane
2002-01-12  2:31                         ` Victor B. Putz
2002-01-12  3:56                         ` Kenny Tilton
2002-01-12  5:49                           ` israel r t
2002-01-12  6:04                             ` Thaddeus L Olczyk
2002-01-12  8:42                               ` Friedrich Dominicus
2002-01-12 15:44                             ` Andreas Bogk
2002-01-14 13:52                             ` Georg Bauhaus
2002-01-12 19:39                           ` Doug Hockin
2002-01-12 19:49                             ` Thaddeus L Olczyk
2002-01-12 20:14                             ` Kenny Tilton
2002-01-12 22:45                               ` Fernando Rodr�guez
2002-01-13  1:03                               ` Thomas F. Burdick
2002-01-13  5:24                                 ` Kenny Tilton
2002-01-12 15:58                         ` Preben Randhol
2002-01-12 16:18                           ` Nils Goesche
2002-01-12 17:03                             ` Thomas F. Burdick
2002-01-12 17:56                               ` Christopher Browne
2002-01-13  0:52                                 ` Thomas F. Burdick
2002-01-13 18:17                                   ` Nils Goesche
2002-01-13 19:04                                     ` Thomas F. Burdick
2002-01-13 19:26                                       ` James A. Robertson
2002-01-13 20:40                                         ` Nils Goesche
2002-01-13 20:43                                     ` Andreas Bogk
2002-01-13 19:05                             ` Preben Randhol
2002-01-13 19:20                               ` Preben Randhol
2002-01-16 12:00                           ` Christian Lynbech
     [not found]                       ` <9jtu3u8cq92b05j47uat3412tok6hq <3C409A34.7DE61ACB@nyc.rr.com>
2002-01-13 15:23                         ` Patrick Doyle
2002-01-13 16:29                           ` Dr. Edmund Weitz
     [not found]                       ` <9jtu3u8cq92b05j47uat3412tok6hq <i1t28.632$XG4.38637@news2.calgary.shaw.ca>
2002-01-22 14:25                         ` Copying semantics molehill (was Re: True faiths) Patrick Doyle
2002-01-22 15:47                           ` Steven T Abell
2002-01-26 17:32                             ` Patrick Doyle
2002-01-22 18:00                           ` Kaz Kylheku [this message]
2002-01-26 17:37                             ` Patrick Doyle
2002-01-28  3:08                           ` Robert Dewar
2002-01-28 18:47                             ` Patrick Doyle
2002-01-23  1:43                       ` True faiths ( was Re: The true faith ) Larry Kilgallen
     [not found]                       ` <9jtu3u8cq92b05j47uOrganization: LJK Software <FfppBdBcNxcL@eisner.encompasserve.org>
2002-01-23  2:04                         ` Jim Rogers
2002-01-23 17:02                           ` Darren New
2002-01-22 22:35 Copying semantics molehill (was Re: True faiths) Mike Brenner
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox