Re: Rob: Q: Constant Scope
- Posted by Robert Craig <rds at RapidEuphoria.com> Apr 20, 2005
- 526 views
Jason Gade wrote: > copied from Rob Craig's post (a few years ago): > There's an optimization which is near the top of my list, that would > eliminate the need for copy-on-write in many cases. Consider: > > function sort(sequence s) > > s[i] = ... > > end function > > sequence x > ... > x = {5,6,7,8} > ... > x = sort(x) > > It would be possible to detect that the value of x, as passed to > sort(), will never be needed again. The implementation could then > arrange that the value passed to sort() will have only *one* > reference count (from s), rather than 2 (from x and s). This would > eliminate the need for a copy. > > I think that this is a very reasonable optimization that eliminates most > of the arguments for modifying "pass by reference" values. Have you > ever implemented it? No I haven't, but it's still near the top of my list. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com