Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!ukc!pyrltd!tetrauk!rick From: rick@tetrauk.UUCP (Rick Jones) Newsgroups: comp.lang.eiffel Subject: Re: Functions without side effects (was Old confusion) Message-ID: <1177@tetrauk.UUCP> Date: 6 Jun 91 17:12:47 GMT References: <1991May30.141218.3446@mstr.hgc.edu> <327@alfrat.uucp> <1991Jun3.145924.28406@mstr.hgc.edu> <130242@tut.cis.ohio-state.edu> Reply-To: rick@tetrauk.UUCP (Rick Jones) Organization: Tetra Ltd., Maidenhead, UK Lines: 30 In article <130242@tut.cis.ohio-state.edu> ogden@seal.cis.ohio-state.edu (William F Ogden) writes: | [ on the subject of large objects ] | | Probably the most significant feature of large objects, as opposed to | small objects like integers, is that they are usually quite expensive (if | not impossible) to replicate. Consequently operations like Top make poor | choices as primary operations, since their implementation inevitably ^^^^^^^^^^ | involves making a copy of a data structure entry. The proper choice | of primary operation for the stack then is the procedure (not function | -- see above) Pop which does return the top value, since this does not | entail replicating an entry. Top can be provided as a secondary operation, | but clients should be warned that it is potentially an expensive operation. You are presuming a system with value semantics. OO systems often work very effectively with reference semantics (in Eiffel reference semantics are the default unless you specify "expanded" variables or classes). In this case the Top operation simply returns a pointer to the object on the top of the stack, which is highly efficient. In fact I would suggest that a system in which large objects are used is best handled using reference semantics, otherwise there will be a lot of inefficiencies elsewhere resulting from copying. The programmer must of course be aware of this, and use "clone" operations where required. -- Rick Jones, Tetra Ltd. Maidenhead, Berks, UK rick@tetrauk.uucp Any fool can provide a solution - the problem is to understand the problem