This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: goops and encapsulation


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]