Guile Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: goops and encapsulation
> > 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.
I have no experience with CLOS at all, so this kind of thing kind of
bugs me, too. When it comes to object systems, I'm much more
comfortable in the Smalltalk camp. But I'm going to try to absorb the
CLOS mindset more before I complain. :)
Guile Home |
Main Index |