guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Goops: Setting Immutible Classes?


From: Mark H Weaver
Subject: Re: Goops: Setting Immutible Classes?
Date: Fri, 06 Oct 2017 02:24:56 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Christopher Howard <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]