Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!seal.cis.ohio-state.edu!ogden From: ogden@seal.cis.ohio-state.edu (William F Ogden) Newsgroups: comp.lang.eiffel Subject: Re: Reference Semantics (was: Functions without side effects) Message-ID: <131691@tut.cis.ohio-state.edu> Date: 7 Jun 91 21:16:40 GMT References: <1177@tetrauk.UUCP> <131263@tut.cis.ohio-state.edu> <1178@tetrauk.UUCP> Sender: news@tut.cis.ohio-state.edu Organization: The Ohio State University, Department of Computer and Information Science Lines: 38 In article <1178@tetrauk.UUCP> rick@tetrauk.UUCP (Rick Jones) writes: >> ... Now the problem, rephrased in these terms, >>is that our small object bias leads us to design classes with operations >>like Top which create multiple references to the same object. One of >>the challenges of object oriented programming is still to design classes >>so that excess copying can be avoided or (if you insist on reference >>semantics) so that multiple references can be avoided. >I strongly disagree that reference semantics are inherently a bad thing. There >are a large number of real problems which require multiple references in order >to produce a reasonable soultion. ... >Although good OO design and programming systems can emphasise abstract concepts >and isolate a programmer from implementation details, it should never attempt >to hide the distinction between value and reference. This is something that >both the designer and programmer must understand, and use both to best >advantage. The issue is not that reference semantics are inherently a bad thing any more than that dynamite is an inherently bad thing. Neither, however, is intended for every day or casual use. The problem is that building classes which force clients to use operations like Top that just return a reference to a stack entry is rather like building hardware stores which supply customers with sticks of dynamite whenever they ask for something with which to remove a tree from their lawns. If clients are careful or lucky they achieve their objectives. If not, you're left with a bloody mess. There's no problem with using multireference objects (or dynamite) and passing out references with a Top operation, if you like. The problem is with making this the normal rather than the exceptional way of doing business. -- /Bill