Xref: utzoo comp.lang.eiffel:1659 comp.object:3709 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!news.funet.fi!tukki.jyu.fi!sakkinen From: sakkinen@jyu.fi (Markku Sakkinen) Newsgroups: comp.lang.eiffel,comp.object Subject: Re: Reference Semantics Message-ID: <1991Jun14.074518.1601@jyu.fi> Date: 14 Jun 91 07:45:18 GMT References: <133154@tut.cis.ohio-state.edu> <1991Jun12.072557.7282@jyu.fi> <1991Jun13.074318.337@tkou02.enet.dec.com> Organization: University of Jyvaskyla, Finland Lines: 53 In article <1991Jun13.074318.337@tkou02.enet.dec.com> diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond) writes: >In article <1991Jun12.072557.7282@jyu.fi> sakkinen@jyu.fi (Markku Sakkinen) writes: >> ... >>I think that the need to share some objects is much more fundamental >>for object modelling than is the need to jump for imperative programming. >>The (visible) use of references should be restricted to a minimum, >>but accepted without remorse whenever it is necessary. > >I agree with that conclusion, but think that the reasoning and application >are backwards. Sharing and aliasing are sometimes necessary and should be >kept to a minimum, yes. I think the sharing and aliasing should be visible, >so that readers will know what to expect. The invisible aliasing generated >by reference semantics is worse than a label that is a target of multiple >gotos. An object gets changed when the user didn't expect it, and has to >do a lot of tracing to find out where.... Incidentally, I think similarly. I would have said: "I share your opinions", but of course my opinions do not change automatically if you change yours :-) What I meant by 'visible' was 'affecting semantics': it does not harm programmers if references are used only as an implementation device, which can be efficient for large objects. >Part of the problem with C pointers is that they are overused and abused >as a result of C's treatment of arrays. (A garbage collection in C can be >declared with [].) A fairer comparison would be Pascal-style pointers (or >even PL/I-style pointers) vs. the invisible sharing generated by reference >semantics. We agree even here. Pointer arithmetic has no place in a language that wants to be considered high-level. Also the fact that pointers in C and C++ can be made to point at any object of their referent type (as opposed to the restrictions of Pascal and Ada) makes them harder to manage, although it offers some advantages, too. To make my position clear: I regard it as a _good_ feature of C and C++ that 'widget' and 'pointer to widget', i.e. '*widget', are clearly distinct types. (Arrrgh: I already wrote and submitted something like this yesterday, but some testing of the news system here caused all articles to get lost.) ---------------------------------------------------------------------- "All similarities with real persons and events are purely accidental." official disclaimer of news agency New China Markku Sakkinen (sakkinen@jytko.jyu.fi) SAKKINEN@FINJYU.bitnet (alternative network address) Department of Computer Science and Information Systems University of Jyvaskyla (a's with umlauts) PL 35 SF-40351 Jyvaskyla (umlauts again) Finland ----------------------------------------------------------------------