home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.object
- Path: sparky!uunet!cs.utexas.edu!torn!nott!cunews!cunews!knight
- From: knight@mrco.carleton.ca (Alan Knight)
- Subject: Re: Object hidden state and side effects
- Message-ID: <knight.724557211@cunews>
- Sender: news@cunews.carleton.ca (News Administrator)
- Reply-To: knight@mrco.carleton.ca (Alan Knight)
- Organization: Carleton University
- References: <1992Dec14.112222.13987@kei.is.s.u-tokyo.ac.jp> <1992Dec15.014420.6604@midway.uchicago.edu> <1992Dec16.65250.10645@kei.is.s.u-tokyo.ac.jp> <1992Dec16.175126.14968@midway.uchicago.edu>
- Date: Thu, 17 Dec 1992 01:53:31 GMT
- Lines: 51
-
- In <1992Dec16.175126.14968@midway.uchicago.edu> dave@alex.uchicago.edu (Dave Griffith) writes:
-
- >In article <1992Dec16.65250.10645@kei.is.s.u-tokyo.ac.jp> jeff@is.s.u-tokyo.ac.jp writes:
- >>In article <1992Dec15.014420.6604@midway.uchicago.edu> dave@alex.uchicago.edu (Dave Griffith) writes:
-
- > ... "Objects" as I have
- >been using the term use reference semantics. Two objects are only equal if
- >they are identical. "Values" use copy semantics for assignment. (What they
- >use for equality semantics is a deeper and IMHO more interesting question, but
- >I digress.) How these semantics are actually implemented is a implementation
- >decision and should not be considered here.
-
- This definitely seems to be the root of the confusion. You mean
- something different by "object" than I do, and I expect than Jeff
- McAffer or Jan Steinman do. If you call something an object only if
- equality and identity are the same operation, then most OO langauges
- already support the distinction being called for, since the equality
- operation can be defined to be anything you like. This is certainly
- the case for "value objects" in Smalltalk, such as Booleans, Numbers,
- Symbols, etc. Somebody just posted that the same thing is true in
- Eiffel. Maybe you can't do it in C++, but that's a whole other debate.
-
- >>about it. They are just objects to which I can send messages, pass as
- >>parameters... They have a protocol... and allow only those operations
- >>that are in line with their "essential sameness"
-
- >But most languages have no way to _enforce_ the requirement that they "only
- >allow operations that are in line with their essential sameness". They
- >treat their builtin classes as "special", and don't allow programmer defined
- >classes to be defined as special in the same way. It would be useful in C++
- >for instance to define a Bignum class which didn't allow the programmer
- >to set 3 equal to 5, even if that Bignum class is eventually subclassed.
- >Subclassing can blow away the original programmers intent of immutability,
- >with possibly disastrous effects on program correctness.
-
- The only "special" distinction in Smalltalk is between SmallIntegers
- and everything else. The distinction is effectively invisible in
- normal use. Also, what you are asking for is possible in C++ (but not
- in Smalltalk). In C++, private class members are not visible to
- subclasses. If you don't provide any destructive functions then they
- cannot be added when you subclass. I think you can circumvent this by
- writing "friend" functions, but that's an explicit mechanism provided
- to circumvent the language restrictions in the name of performance.
-
- --
- Alan Knight knight@mrco.carleton.ca +1 613 788 2600x1027
- Dept. of Mechanical and Aerospace Engineering
- Carleton University, Ottawa, Ontario, Canada, K1S 5B6
-
-