Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

It's hard to think of you as the end result of millions of years of evolution.


devel / comp.lang.lisp / Re: Why doesn't Common Lisp have COPY-INSTANCE ?

SubjectAuthor
* Why doesn't Common Lisp have COPY-INSTANCE ?Spiros Bousbouras
+* Re: Why doesn't Common Lisp have COPY-INSTANCE ?Lieven Marchand
|+- Re: Why doesn't Common Lisp have COPY-INSTANCE ?Jeff Barnett
|+* Re: Why doesn't Common Lisp have COPY-INSTANCE ?Spiros Bousbouras
||`- Re: Why doesn't Common Lisp have COPY-INSTANCE ?Kaz Kylheku
|`- Re: Why doesn't Common Lisp have COPY-INSTANCE ?Kaz Kylheku
`* Re: Why doesn't Common Lisp have COPY-INSTANCE ?Stefan Monnier
 `- Re: Why doesn't Common Lisp have COPY-INSTANCE ?Spiros Bousbouras

1
Why doesn't Common Lisp have COPY-INSTANCE ?

<DXtbolEBBTECtCaXE@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17526&group=comp.lang.lisp#17526

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!paganini.bofh.team!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Why doesn't Common Lisp have COPY-INSTANCE ?
Date: Wed, 8 Nov 2023 12:13:16 -0000 (UTC)
Organization: To protect and to server
Message-ID: <DXtbolEBBTECtCaXE@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 8 Nov 2023 12:13:16 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="1726148"; posting-host="9H7U5kayiTdk7VIdYU44Rw.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
Cancel-Lock: sha256:jPFy7RT+LAFlcI6RJz7n57i/uiY0tZmTbIo601B0k0c=
X-Organisation: Weyland-Yutani
X-Notice: Filtered by postfilter v. 0.9.3
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Wed, 8 Nov 2023 12:13 UTC

I mean something analogous to COPY-STRUCTURE but for copying class instances.
I am thinking of something like

(defgeneric copy-instance (object) ... )

which returns a fresh object of the same class. Bound slots in the
object argument will have the same value in the fresh object ; unbound
slots in the object argument will be unbound in the fresh object.

CL doesn't offer convenient facilities to write it yourself either [although
a built-in construct could probably be made faster by using knowledge of
internals]. For example if it it had something like

(defgeneric slots-list (class) ...)

which returns a list of the names of the slots for the class , it would help.
Or you could have analogous constructs which return additional information
for the class like the names of initargs , names of accessors [if any] ,
etc. But , since it doesn't have any of that , all you can do is write a
wrapper for DEFCLASS which stores the information you want [like list of
slots] for further use with other macros.

--
vlaho.ninja/menu

Re: Why doesn't Common Lisp have COPY-INSTANCE ?

<874jhwgex7.fsf@wyrd.be>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17527&group=comp.lang.lisp#17527

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 08 Nov 2023 20:35:16 +0000
From: mal@wyrd.be (Lieven Marchand)
Newsgroups: comp.lang.lisp
Subject: Re: Why doesn't Common Lisp have COPY-INSTANCE ?
References: <DXtbolEBBTECtCaXE@bongo-ra.co>
Date: Wed, 08 Nov 2023 21:37:08 +0100
Message-ID: <874jhwgex7.fsf@wyrd.be>
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:9HmQtISt6Cl719GwJomb8LalAIg=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Lines: 31
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-vEJZ8vx/BD56Ow+qC1rPvmmuTfnQK7wzTajUnnBeS2lQ0nkj9IPY/9I54Uh/RHe9/gKO/+5p+JqyJl/!DnK7ahEIdhkRS4mJanQPz12EycMbRN+X/UGjIXVi9Q==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Lieven Marchand - Wed, 8 Nov 2023 20:37 UTC

Spiros Bousbouras <spibou@gmail.com> writes:

> I mean something analogous to COPY-STRUCTURE but for copying class instances.
> I am thinking of something like
>
> (defgeneric copy-instance (object) ... )
>
> which returns a fresh object of the same class. Bound slots in the
> object argument will have the same value in the fresh object ; unbound
> slots in the object argument will be unbound in the fresh object.
>
> CL doesn't offer convenient facilities to write it yourself either [although
> a built-in construct could probably be made faster by using knowledge of
> internals]. For example if it it had something like
>
> (defgeneric slots-list (class) ...)
>
> which returns a list of the names of the slots for the class , it would help.
> Or you could have analogous constructs which return additional information
> for the class like the names of initargs , names of accessors [if any] ,
> etc. But , since it doesn't have any of that , all you can do is write a
> wrapper for DEFCLASS which stores the information you want [like list of
> slots] for further use with other macros.

Kent Pitman has answered that one.

https://www.nhplace.com/kent/PS/EQUAL.html

--
Laat hulle almal sterf. Ek is tevrede om die wêreld te sien brand en die vallende
konings te spot. Ek en my aasdier sal loop op die as van die verwoeste aarde.

Re: Why doesn't Common Lisp have COPY-INSTANCE ?

<jwvh6lwb65r.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17747&group=comp.lang.lisp#17747

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why doesn't Common Lisp have COPY-INSTANCE ?
Date: Wed, 08 Nov 2023 10:47:06 -0500
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <jwvh6lwb65r.fsf-monnier+comp.lang.lisp@gnu.org>
References: <DXtbolEBBTECtCaXE@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="ee3d5009d6326716e4bf056dfb704cb6";
logging-data="1753319"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18epleTv4WJKopzAdZhsCCcacL2xi/WQHk="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:D3Ckcxu6SQU0/1AFL0wdjEk6Kt0=
sha1:2nabsRHD2O929Bp2SoQMLnE0xkA=
 by: Stefan Monnier - Wed, 8 Nov 2023 15:47 UTC

> I mean something analogous to COPY-STRUCTURE but for copying class instances.
> I am thinking of something like
>
> (defgeneric copy-instance (object) ... )

More interesting would be a functional update operation, i.e. something
like your function above but with additional parameters to set some of
the slots to different values than those of the original object.
Especially useful for read-only slots.

Stefan

Re: Why doesn't Common Lisp have COPY-INSTANCE ?

<hjk8CmySzETcF0CQb@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17748&group=comp.lang.lisp#17748

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: Why doesn't Common Lisp have COPY-INSTANCE ?
Date: Thu, 9 Nov 2023 06:08:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <hjk8CmySzETcF0CQb@bongo-ra.co>
References: <DXtbolEBBTECtCaXE@bongo-ra.co> <jwvh6lwb65r.fsf-monnier+comp.lang.lisp@gnu.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 9 Nov 2023 06:08:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="59d82974bb140a7d512527a0b6de9780";
logging-data="2189278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197tMiWTz9XtgqSNb6hNPOS"
Cancel-Lock: sha1:YFXQpmrVQndFnc2bToYE5rqo11Y=
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
In-Reply-To: <jwvh6lwb65r.fsf-monnier+comp.lang.lisp@gnu.org>
 by: Spiros Bousbouras - Thu, 9 Nov 2023 06:08 UTC

On Wed, 08 Nov 2023 10:47:06 -0500
Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> > I mean something analogous to COPY-STRUCTURE but for copying class instances.
> > I am thinking of something like
> >
> > (defgeneric copy-instance (object) ... )
>
> More interesting would be a functional update operation, i.e. something
> like your function above but with additional parameters to set some of
> the slots to different values than those of the original object.
> Especially useful for read-only slots.

One could come up with many variations but having at least one of those
variations available would be nice.

Re: Why doesn't Common Lisp have COPY-INSTANCE ?

<uihubc$230f6$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17749&group=comp.lang.lisp#17749

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jbb@notatt.com (Jeff Barnett)
Newsgroups: comp.lang.lisp
Subject: Re: Why doesn't Common Lisp have COPY-INSTANCE ?
Date: Wed, 8 Nov 2023 23:31:03 -0700
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <uihubc$230f6$1@dont-email.me>
References: <DXtbolEBBTECtCaXE@bongo-ra.co> <874jhwgex7.fsf@wyrd.be>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 9 Nov 2023 06:31:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9846ea517ee3e51620015af42f281c1d";
logging-data="2195942"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sOLKiUvvvFnWvYdVLkigVhARi2ZG9Nqg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Go/kusScWqMb3cIZB5XLrFzMzxY=
In-Reply-To: <874jhwgex7.fsf@wyrd.be>
Content-Language: en-US
 by: Jeff Barnett - Thu, 9 Nov 2023 06:31 UTC

On 11/8/2023 1:37 PM, Lieven Marchand wrote:
> Spiros Bousbouras <spibou@gmail.com> writes:
>
>> I mean something analogous to COPY-STRUCTURE but for copying class instances.
>> I am thinking of something like
>>
>> (defgeneric copy-instance (object) ... )
>>
>> which returns a fresh object of the same class. Bound slots in the
>> object argument will have the same value in the fresh object ; unbound
>> slots in the object argument will be unbound in the fresh object.
>>
>> CL doesn't offer convenient facilities to write it yourself either [although
>> a built-in construct could probably be made faster by using knowledge of
>> internals]. For example if it it had something like
>>
>> (defgeneric slots-list (class) ...)
>>
>> which returns a list of the names of the slots for the class , it would help.
>> Or you could have analogous constructs which return additional information
>> for the class like the names of initargs , names of accessors [if any] ,
>> etc. But , since it doesn't have any of that , all you can do is write a
>> wrapper for DEFCLASS which stores the information you want [like list of
>> slots] for further use with other macros.
>
> Kent Pitman has answered that one.
>
> https://www.nhplace.com/kent/PS/EQUAL.html
The Pitman reference brings back memories. I believe I first saw it
around 20 years ago. It's well written and answers a lot of obvious
questions that one doesn't think about until they really burrow in. I
believe that reading the material will make one a much better Lisp
programmer; in particular, it illuminates many of the important issues
that need be considered when designing structures for complex
(complicated) applications and environments.
--
Jeff Barnett

Re: Why doesn't Common Lisp have COPY-INSTANCE ?

<wk6yH+pzPWdCMujwo@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17750&group=comp.lang.lisp#17750

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: Why doesn't Common Lisp have COPY-INSTANCE ?
Date: Thu, 9 Nov 2023 06:44:53 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <wk6yH+pzPWdCMujwo@bongo-ra.co>
References: <DXtbolEBBTECtCaXE@bongo-ra.co> <874jhwgex7.fsf@wyrd.be>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 9 Nov 2023 06:44:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="59d82974bb140a7d512527a0b6de9780";
logging-data="2199992"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18F8WnjKNzAe5Blm+8qS5e9"
Cancel-Lock: sha1:bw9ImV63sCCaKUZk1cXlCTZdxcQ=
In-Reply-To: <874jhwgex7.fsf@wyrd.be>
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Thu, 9 Nov 2023 06:44 UTC

On Wed, 08 Nov 2023 21:37:08 +0100
Lieven Marchand <mal@wyrd.be> wrote:
> Kent Pitman has answered that one.
>
> https://www.nhplace.com/kent/PS/EQUAL.html

The link doesn't answer what I asked. It discusses related issues and
what it says could just as well be seen as an argument in favour of
the language providing something like COPY-INSTANCE .The document
doesn't say anything about why the language doesn't give you a way
to access the information given in a DEFCLASS .

Re: Why doesn't Common Lisp have COPY-INSTANCE ?

<20231109083851.335@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17751&group=comp.lang.lisp#17751

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Why doesn't Common Lisp have COPY-INSTANCE ?
Date: Thu, 9 Nov 2023 16:46:52 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <20231109083851.335@kylheku.com>
References: <DXtbolEBBTECtCaXE@bongo-ra.co> <874jhwgex7.fsf@wyrd.be>
<wk6yH+pzPWdCMujwo@bongo-ra.co>
Injection-Date: Thu, 9 Nov 2023 16:46:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e33510ae532c387a4eca237a5d32ef21";
logging-data="2410319"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rV1nS/K3YnyDdGPbeN1ljvd/ewxsarw0="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:XEtnRTdqwppq8Wa28GOkV+KBqWA=
 by: Kaz Kylheku - Thu, 9 Nov 2023 16:46 UTC

On 2023-11-09, Spiros Bousbouras <spibou@gmail.com> wrote:
> On Wed, 08 Nov 2023 21:37:08 +0100
> Lieven Marchand <mal@wyrd.be> wrote:
>> Kent Pitman has answered that one.
>>
>> https://www.nhplace.com/kent/PS/EQUAL.html
>
> The link doesn't answer what I asked. It discusses related issues and
> what it says could just as well be seen as an argument in favour of
> the language providing something like COPY-INSTANCE .The document
> doesn't say anything about why the language doesn't give you a way
> to access the information given in a DEFCLASS .

Mainly, the reason is that those kinds of things are in the Common Lisp
Meta-Object Protocol, which is not ANSI, but a de facto standard.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Why doesn't Common Lisp have COPY-INSTANCE ?

<20231109091053.952@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17752&group=comp.lang.lisp#17752

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Why doesn't Common Lisp have COPY-INSTANCE ?
Date: Thu, 9 Nov 2023 18:16:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 99
Message-ID: <20231109091053.952@kylheku.com>
References: <DXtbolEBBTECtCaXE@bongo-ra.co> <874jhwgex7.fsf@wyrd.be>
Injection-Date: Thu, 9 Nov 2023 18:16:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e33510ae532c387a4eca237a5d32ef21";
logging-data="2453560"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19U3lbC43QWHO9h76EPDY2KYKb6UjMqtJs="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:MqVCk4hP7WBrHOUT4M54FDlSMBc=
 by: Kaz Kylheku - Thu, 9 Nov 2023 18:16 UTC

On 2023-11-08, Lieven Marchand <mal@wyrd.be> wrote:
> Spiros Bousbouras <spibou@gmail.com> writes:
>
>> I mean something analogous to COPY-STRUCTURE but for copying class instances.
>> I am thinking of something like
>>
>> (defgeneric copy-instance (object) ... )
>>
>> which returns a fresh object of the same class. Bound slots in the
>> object argument will have the same value in the fresh object ; unbound
>> slots in the object argument will be unbound in the fresh object.
>>
>> CL doesn't offer convenient facilities to write it yourself either [although
>> a built-in construct could probably be made faster by using knowledge of
>> internals]. For example if it it had something like
>>
>> (defgeneric slots-list (class) ...)
>>
>> which returns a list of the names of the slots for the class , it would help.
>> Or you could have analogous constructs which return additional information
>> for the class like the names of initargs , names of accessors [if any] ,
>> etc. But , since it doesn't have any of that , all you can do is write a
>> wrapper for DEFCLASS which stores the information you want [like list of
>> slots] for further use with other macros.
>
> Kent Pitman has answered that one.
>
> https://www.nhplace.com/kent/PS/EQUAL.html

I don't agree with his excuses and insinuations.

For a cons argument, a COPY function should definitely behave like
COPY-LIST; there is no question about it. Pitman didn't reason this
through to the use cases.

It is true that we don't know whether a CONS is just tree structure,
a list (sequence) or an assoc list. However, code is rarely polymorphic
in that dimension.

That is to say, we rarely write the same piece of
code that receives a cons argument which is either just tree structure,
a list or an alist, and is supposed to do something meaningful and
specific, without knowing which.

We do have this situation: code receives a sequence and wants to operate
on it uniformly, yet have it work for arrays, strings or lists.

For instance, we can imagine this function:

(defun non-destructive-sort (sequence predicate :key (key #'eql))
(sort (copy sequence) predicate :key key))

Code that knows it is working with alists or tree structure knows
the specific copy operation it needs.

Pitman apperas to be making exuses for EQUAL; but EQUAL is not nicely
defined, even if we take into account all the issues he discusses in the
article. Nothing in the article excuses the fact that EQUAL considers
two sequences to be equal by content if they are lists, but by address
if they are vectors, except when they are strings which is by content
again.

We should consider EQUAL to be related not to COPY, but to the entire
class of functions which make a similar object from an example object.
COPY is a small subset of that class; therefore it is fallacious to equate
all the issues of COPY with those of EQUAL.

Here is what I mean. Equality functions can apply arbitrary
transformations to the elements of an object; they can project the
object or its constituent elements to other values and then compare
those values instead.

A COPY function should never do that.

So that is to say, for instance, EQUALP considers the string "Foo"
and "fOO" to be equivalent. But we would never have a function called
COPY which, given "Foo", produces "fOO". It might be useful to have a
function which does that, but it wouldn't be understood as an object
copying function.

If I have to be somewhere across town in 45 minutes, I might consider a
Toyota Echo and a Porsche Carrera to be equivalent. A car copying
machine that produces a Toyota Echo when presented with a Porsche would
be considered comically defective, though.

A copy function may not change the values. The only variations allowed
in copying are:

- how much of the original object to reuse versus newly allocate

- of a object made of linked nodes
- how much of the graph shape to preserve
- handle circularity or not

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor