home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!sdd.hp.com!ux1.cso.uiuc.edu!cs.uiuc.edu!johnson
- From: johnson@cs.uiuc.edu (Ralph Johnson)
- Newsgroups: comp.object
- Subject: Re: Object hidden state and side effects
- Message-ID: <BzKv4J.3Lt@cs.uiuc.edu>
- Date: 20 Dec 92 21:45:54 GMT
- References: <1992Dec16.65250.10645@kei.is.s.u-tokyo.ac.jp> <1992Dec16.175126.14968@midway.uchicago.edu> <BzIFGp.K7@cs.uiuc.edu> <1992Dec20.155809.14236@midway.uchicago.edu>
- Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
- Lines: 48
-
- dave@alex.uchicago.edu (Dave Griffith) writes:
-
- >>>But most languages have no way to _enforce_ the requirement that they "only
- >>>allow operations that are in line with their essential sameness".
-
- I then argued that most languages have no way of enforcing most interesting
- things. In particular, I said:
-
- >>We can't really enforce that a subclass provides the same behavior
- >>as a superclass.
-
- Dave Griffith replied:
-
- >Eiffel (with the exclusion of a few egregious features like
- >"undefine") can and does enforce that a subclass has the same behavior as
- >a superclass.
-
- This is a common misconception. I'm a fan of Eiffel, and I applaud the
- attempt to put more design information in programs by using assertions and
- invariants, but there is still a lot of interesting behavior (in fact,
- most interesting behavior) that can't be specified. Reusing an earlier
- example, try specifying that equality is symmetric, reflexive, transitive,
- and substitutabilty of equals for equals should hold in all cases. I think
- that symmetry should be easy to specify. Reflexivity and transitivity
- are usually easy to prove, but I don't think you can express them in Eiffel,
- since it doesn't have a "for all" construct. Probably you can enforce
- reflexivity by stating that an object is equal with itself whenever you
- create a new object. I don't have any idea about transitivity, nor about
- substitutability of equals for equals.
-
- If it turns out that there is a way to express that in Eiffel, how about
- my example of requiring that a function used by a sorter provide
- a total ordering on the collection to be sorted. I guess you could
- do this for any particular finite collection by checking all triples.
- However, I don't think Eiffel allows loops in assertions.
-
- It is not hard to make an assertion language that is more
- powerful than the one in Eiffel. However, it would then
- become much more expensive to check.
-
- Getting back to objects vs. values, I agree that reasoning about
- side effects is important. Promising approaches are Gifford's
- "effects" system that was described in a POPL'88 (and other places
- that I forget) and Hogg's "Islands" that was described in OOPSLA '91.
- I'm just not convinced that making a hard and fast distinction
- between objects and values is necessarily a good idea.
-
- -Ralph Johnson
-