🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Jose E. Hernandez Sat, 10 Oct 1992 21:41
Why not a copy protocol
#312
Author: Jose E. Hernandez
Date: Sat, 10 Oct 1992 21:41
12 lines
1007 bytes
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...

thank you!

jose'

PS  I am looking for reasons why CLOS doesn't include a copy protocol,
not necessarily for examples on how to implement one.
Re: Why not a copy protocol
#313
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads