[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Law of good style for CLOS
- To: karl lieberherr <lieber@corwin.ccs.northeastern.edu>
- Subject: Re: Law of good style for CLOS
- From: Gregor.pa@Xerox.COM
- Date: Thu, 26 May 88 16:36 PDT
- Cc: commonloops.pa@Xerox.COM, rpg@SAIL.STANFORD.EDU
- Fcc: BD:>Gregor>mail>outgoing-mail-2.text.newest
- In-reply-to: <8805261937.AA22252@corwin.CCS.Northeastern.EDU>
- Line-fold: no
Date: Thu, 26 May 88 15:37:02 EDT
From: karl lieberherr <lieber@corwin.ccs.northeastern.edu>
----------------------------------------------------------------
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.
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 can't figure out what this law is. Part of my problem is that I don't
understand what you mean by "non-local objects". In addition, you seem
to be suggesting that the first argument to a generic function is
special in some way that I don't understand.
Let me try to rephrase what I understand you to be proposing. That way
you will be able to tell me how I have misunderstood what you are
proposing.
Within the body of a method M, the first argument passed to any generic
function must be one of:
- one of the arguments received by M
- an "immediate component" of the value of M's first argument
- a newly created object
- a "non-local object"
Where "immediate component" probably means the value of one of the
slots of M's first argument.
and "non-local object" means some combination of:
- the value of a lexical variable
- the value of a special variable
- the values returned by a function call
from within the body of M
One critical question is what "non-local object" means.
Another critical question is why are you treating the first argument
specially. CLOS is not a `message sending' system. In CLOS the generic
function determines which methods are applicable for the arguments it
received. This is in contrast to Smalltalk in which the object
determines which method is appropriate for the message it received.
A possibly related law is:
Inside the body of a method M, the only legal use of slot-value
is on "self", where self means the first argument, and the only
argument which is specialized.
How does this differ from what you are proposing?
A paper on the Law of Demeter and its implications
will be presented at OOPSLA '88. For a short version, see IEEE Computer,
June 88, Open Channel. We use a version of this Law which we can enforce
efficiently at compile-time.
I can't understand what it would mean to enforce this at compile time
until I understand what the law is exactly. It seems to me that all
bets are off if non-local object includes the values returned by a
function call.
I am interested to know whether CLOS programmers are willing to
constrain themselves to follow this Law. I look forward to your
feedback.
An important thing missing from your message is any motivation for
following this law. What does this law buy me?
-------