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

Access protection

Another possible advantage of C++ over CLOS is the private/public/protected
mechanism.  Roughly speaking, a public method or slot can be invoked on a class
instance by anyone.  A private method or slot can be invoked only by the direct
methods of a class, and a protected method or slot can be invoked by a direct
or indirect method (i.e., a method on a subclass) of a class.

If we were to use Common Lisp packages for this purpose, there seems to be a
few inconveniences.  First, suppose that I have a method and a setf method
defined for the symbol FOO.  Suppose I want the method FOO to be public, but
not the setf method FOO.  How can I do this without renaming my setf method?
Will the method specification (SETF FOO) have a package of its own in ANSI CL?

The Common Lisp export/import mechanism may be able to provide functionality
similar to the public/private mechanism in C++.  However, it is unclear how to
best implement the protected mechanism.  Things become even more difficult when
one allows a subclass to change an inherited method or slot from public to
private, as in C++.

Ideas, comments?