Hi William, 

> https://www.gnu.org/software/g-golf/manual/html_node/GOOPS-Notes-and-Conventions.html

> I found a paragraph which states "Except for virtual slots, there is 
> currently no way to effectively prohibit (block) a user to mutate a 
> goops class instance."

Actually, there is a way, but there is a bug which i recently asked to
be looked at - if the bug is fixed, i'll try to remember to let this
list know ... otherwise, the fix will appear in the log of the guile's
main branch (ofc) ...

What currently works is when the init-value is an integer:

        (define-class c ()
           (x #:class <read-only-slot> #:init-value 1))
        (make <c>)

but any other value would raise an exception:

        (define-class <foo> ()
          (bar #:init-value 'bar #:class <read-only-slot>))

        (make <foo>)
        ice-9/boot-9.scm:1676:22: In procedure raise-exception:
        Wrong type (expecting exact integer): bar

> So perhaps you can figure out how to define a slot-ref procedure that 
> works normally and a slot-set procedure which does nothing.

Fwiw, I wouldn't do that.

With all the above said, i totally agree with David Kastrup's answers
that in this context, what he proposes is an order of magnitude
better then the original proposal, fwiw.

Cheers,
David

Attachment: pgp0UglLvkz7a.pgp
Description: OpenPGP digital signature

Reply via email to