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

Re: Law of good style for CLOS



>    All generic function calls inside a method M must have
>    one of the following objects passed by their first argument:
>        a value of M's parameters (including self) or
>        an immediate part of self.
    
As Scott's reply has indicated, I don't think it is reasonable to force
CLOS into the old Flavors style of programming. The point of generic
functions is that the client of a module need not care whether a
particular operation is implemented as a function or a generic function.

>    Objects created by the method and non-local objects
>    are viewed as being transmitted by arguments.
>    self is the name of the first argument of method M.

I'm not sure I understand you're meaning here, nor the motivation for
the first sentence. I disagree with the second, though. As is usual
for any function, the name of the first argument should be menumonic
for whatever it does. 

For example:

		(defmethod display 
		  ( (view text-window) (controller keyboard) (model resistor) )
			. . .
		)

		(defmethod display 
	          ( (view graphics-window) (controller mouse) (model resistor) )
			. . .
		)

might be a piece of code in the definition of a model-view-controller
implementation (ala` Smalltalk) in CLOS. To constrain the name of first 
parameter of the lambda list and the implementation of the methods as
your laws suggest would force model-view-controller back into the 
one dimensional world of restricted specialization, where only the
first parameter can be specialized. In that world, this same code
would look like:


		(defmethod display
		  ( (self text-window) controller model )

			(typecase model

			  (resistor  

			    (typecase controller

				(mouse   <do resistor/mouse thing> )


				...
	                     )
		           )

		           ...
			)
		)
	
If you want to enforce these laws, then I suggest you look into an embedded
language on top of CLOS. But I think you'd make life more difficult
for application programmers.

			jak