1. RE: Eu's design
- Posted by kbochert at copper.net Aug 18, 2003
- 379 views
On 18 Aug 2003 at 7:57, Matt Lewis wrote: > > > It seems that what you'd like to do is store the stack > > > itself outside of the stack code's source file, and > > > pass it by reference. You could still do somehting > > > like this, albeit without the pass by reference (think > > > append/prepend). It wouldn't be very elegant, but that's > > > what you get for forcing a design. > > > > Forcing a design? What's wrong with doing it efficiently? > > Please read the last posts. > > I don't see what efficiency is really gained by storing > the data locally and passing by reference versus storing > the data where it will be manipulated and passing an > index. Either way, you're passing a 'pointer' of sorts. > You've just decided that one 'pointer' is good, and > another is bad, and I don't understand the reasons > behind the judgment. > The issue is a combination of efficiency and modularization. If a function is intended to operate on a single instance of a sequence, then indexes work fine. If a function is designed to work sometimes on one sequence, and sometimes on another, then the sequence being operated on is a 'variability' of the function, and should be passed in as an argument. Think of a library function that is intended to transform a sequence containing XML for instance. Because it doesn't know ahead of time what sequence it must operate on, it must be passed the sequence. A small change to the XML can result in a huge amount of copying, referencing and dereferencing without some way of PBR'ing. Karl Bochert