🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #313

Re: Why not a copy protocol

#313
From: Barry Margolin
Date: Mon, 12 Oct 1992 01:24
33 lines
2161 bytes
In article <138668@lll-winken.LLNL.GOV> jeh@llnl.gov (Jose E. Hernandez) writes:
>Does anyone know why CLOS does not provide a copy protocol.  Although it
>is true that in some cases the semantics (as well as the implementation)
>of what do we mean by making a copy of an instance can be non-trivial, I
>would argue that the same is true with changing the class of an
>instance.  Nevertheless, CLOS provides a protocol for this, why not for copy...

CLOS has no copy (nor an equivalence) protocol because the appropriate type
of copying and equality is often context-sensitive.  A simple COPY-OBJECT
or EQUAL-OBJECT generic function would force a particular case of this to
be distinguished as the "default", which would be error-prone (a caller
might have a different expectation from the implementor of a particular
method).

Many of us believe that even the functions EQUAL and EQUALP were a mistake;
EQUAL was simple enough in the early days when Lisp only had one structured
type (conses), but now its behavior on arrays, structures, and CLOS
instances is confusing.

An example of a function that provides general capabilities without falling
into this trap is SORT.  Rather than requiring all types to implement a
generic LESS-THAN operator, the caller provides the comparison function
that's appropriate to his context.

I once tried to design completely general copying and equality generic
functions.  They had a number of options that allowed the caller to specify
what type of recursion should be performed.  It ended up being more complex
than I was comfortable with.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Technical Details
Message-ID: <1bak5aINNha@early-bird.think.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!sdd.hp.com!think.com!barmar
References: <138668@lll-winken.LLNL.GOV>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!sdd.hp.com!think.com!barmar
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.lang.clos
Subject: Re: Why not a copy protocol
Date: 12 Oct 1992 01:24:58 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
Lines: 33
Message-ID: <1bak5aINNha@early-bird.think.com>
References: <138668@lll-winken.LLNL.GOV>
NNTP-Posting-Host: gandalf.think.com
Keywords: clos copy copy-protocol