This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: goops and encapsulation
- To: guile@cygnus.com
- Subject: Re: goops and encapsulation
- From: Marius Vollmer <mvo@zagadka.ping.de>
- Date: 23 Jun 1999 23:27:55 +0200
- References: <m10wrBe-000H3vC@debian>
Klaus Schilling <Klaus.Schilling@home.ivm.de> writes:
> Is there a simple way to disable accessing slots of objects bia
> slot-ref and slot-set! from outside the module in which its class
> was defined, thus letting access to slots be controlled by methods
> defined in the module that also defined the class and exported?
I don't think this would be a good idea. A class should publicize and
document its preferred interface, which would normally consist of
accessor methods. Everyone who is not using this protocol and is
instead using slot-ref and slot-set! explicitely is consciously
breaking the abstraction barrier erected by the dicumented interface
and very likely has a good reason for this.
Documenting rules and making it easy to follow them should be
preferrable to enforcing strict limits. There are always exceptions
to rules and when your code does not allow for them, it will loose
immediatly. If instead people can devise workarounds, it will win.
This is one point where the Lisper's mind differs from the C++ mind, I
think. You should not make it hard for people to break your
abstraction, you should make them not needing and not wanting to.
Just my opinion.
- Marius