In a current thread on c.l.l. there was a discussion about how to "hide" bits and pieces of a data structure (the discussion was really about mutable strings). That got me thinking about how to provide more "hiding" than what you can achieve with the package system and with CLOS.
The following is a cute - I believe - hack to make the life of the
slot-value user much more difficult. Remember that
slot-value is just a function.
CL-USER 7 > (defclass foo () ((#.(gensym (random 42)) :reader foo-slot :initarg :slot))) #
CL-USER 8 > (describe (make-instance 'foo)) # is a FOO G21 # CL-USER 9 > (describe (make-instance 'foo :slot 42)) # is a FOO G21 42 CL-USER 10 > (defclass foo () ((#.(gensym (random 42)) :reader foo-slot :initarg :slot))) # CL-USER 11 > (describe (make-instance 'foo :slot 42)) # is a FOO G5 42
So, the trick is to generate random slot names, which can be accessed only via CLOS accessors (readers and writers). Plus, in order to make life difficult for any program "inspecting" the guts of a class, you can just redefine it at random times during your application's lifetime.
Not foolproof, but, as I said, cute.