unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Christopher Allan Webber <cwebber@dustycloud.org>
To: Mark H Weaver <mhw@netris.org>
Cc: Guile User Mailing List <guile-user@gnu.org>
Subject: Re: Goops: Setting Immutible Classes?
Date: Fri, 06 Oct 2017 10:46:53 -0500	[thread overview]
Message-ID: <87tvzcb7o2.fsf@dustycloud.org> (raw)
In-Reply-To: <87wp48ztc7.fsf@netris.org>

Mark H Weaver writes:

> Christopher Howard <christopher.howard@qlfiles.net> writes:
>
>> Hi, is the a way I could use goops such that I the classes are non-
>> mutating, but have setters that simply return a new instance of the
>> class (instead of modifying the original)?
>
> We provide such a mechanism for SRFI-9 Records.  Search for "Functional
> Setters" in section 6.6.16 (SRFI-9 Records) of the Guile manual.
>
>> I suppose I could simply use define-method to create setter methods
>> which create a new instance of the object; but that would get rather
>> complicated, wouldn't it, if the object had superclasses? So I need
>> some kind of shallow copy mechanism for the whole object, or a chained
>> copy mechanism...?
>
> For GOOPS classes, take a look at the built-in 'shallow-clone' generic
> function.  It is described in section 8.10 (GOOPS Object Miscellany).
>
>       Mark

See also
https://lists.gnu.org/archive/html/guile-user/2017-01/msg00030.html
which includes both a slot-fset approach and a clone macro.  Personally
I've come to like the clone macro more over time.



  reply	other threads:[~2017-10-06 15:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-06  6:00 Goops: Setting Immutible Classes? Christopher Howard
2017-10-06  6:24 ` Mark H Weaver
2017-10-06 15:46   ` Christopher Allan Webber [this message]
2017-10-06 12:55 ` Thompson, David

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tvzcb7o2.fsf@dustycloud.org \
    --to=cwebber@dustycloud.org \
    --cc=guile-user@gnu.org \
    --cc=mhw@netris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).