> Another point about packages, though not specifically about colons: if
> you find yourself naming a lot of functions or variables foo-this and
> bar-that (e.g. mail-read, mail-send, mail-retrieve), this should
> signal to you that these functions belong in their own package:
> mail:read, mail:send, mail:retrieve.

What are people's opinion about the above in the contest of CLOS accessor 
methods (or other methods)? (Assuming you don't want to use a package for 
each class...)

I find the one thing that annoys the hell out of me with CLOS is that I cannot 
decide on how I prefer to name methods. In message passing systems this 
problem is eliminated due to the implicit namespace created by each class, 
but this is of course not the case in CLOS. I have seen various versions but 
none of them seem clearly superior:

(1) Just use the verb/noun; i.e., "do-stuff".

Least verbose, reads nicely and feels natural. The problem is that you very 
very quickly start running into name clashes; and renaming slots just to fix 
this feels dirty to me (I have even managed to run into a clash between two 
versions of SBCL in a <100 line test program the first time I was fiddling 
with CLOS... turned me off this pretty quick).

(2) Use class-do-stuff (e.g., socket-read etc).

Mostly eliminates nameclashes, but requires a lot of typing and steals 
horizontal space in code. On the other hand it does provide a 
self-documenting factor to the code (i.e., it specifies which class is 
providing the interface, even if the actual dispatched method may be 
specializing on something mroe specific).

What are people's opinion? I must say that for accessors I would probably 
prefer explicit slot access, if it weren't for the fact that it bypasses 
accessor methods.

What are people's opinions?

I think I would prefer being able to use proper names accessors (no prefixes 
or similar), have the accessor methods' name be irrelevant and then use 
(slot-value) or similar for access by name (is there something like this that 
I am missing?). In other words, I would like something like:

(defclass person ()
  ((age .....)     ; default accessor generated
   (...)
   (calculated-attribute ....)))

(defreader (person calculated-attribute) (person)
  (some-function (primitive-slot-value person 'calculated-attribute)))

(defwriter (person calculated-attribute) (person value)
  (setf (primitive-slot-value person 'calculated-attribute) (....))

(let ((p (make-instance 'person :age 47)))
  .... (slot-value p 'calculated-attribute))

On the one hand it is a bit "ugly" to special-case accessors instead of just 
letting them be regular functions, but on the other hand accessors are 
particularly prone to name clashes and all these naming difficulties.

-- 
/ Peter Schuller, InfiDyne Technologies HB

PGP userID: 0xE9758B7D or 'Peter Schuller <[EMAIL PROTECTED]>'
Key retrieval: Send an E-Mail to [EMAIL PROTECTED]
E-Mail: [EMAIL PROTECTED] Web: http://www.scode.org

_______________________________________________
Gardeners mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/gardeners

Reply via email to