[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Law of good style for CLOS
- To: karl lieberherr <email@example.com>
- Subject: Re: Law of good style for CLOS
- From: kempf@Sun.COM
- Date: Fri, 27 May 88 08:02:37 -0700
- Cc: commonloops.pa@Xerox.COM
- In-reply-to: Your message of Thu, 26 May 88 20:36:17 -0400. <880526-173709-3581@Xerox>
- Redistributed: commonloops.pa
> 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.
( (view text-window) (controller keyboard) (model resistor) )
. . .
( (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:
( (self text-window) controller model )
(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.