On Mar 23, 2007, at 3:45 PM, Guyren Howe wrote: > On Mar 23, 2007, at 2:12 PM, C. S. Wyatt wrote: > >> Functions should return one value. > > Every reply to my post so far has said this. Not one of them has said > why. > > So go on: why? I've provided some arguments in favor (for example: > clearer than ByRef argument. When you pass a ByRef variable, there's > nothing to show that it's going to get modified, but an lvalue is > clearly being modified). This would also be very valuable in calling > Events (cf ListBox.CompareRows event -- when you're writing the > super's end of that, it's rather fiddlier). Also, all the languages > mentioned seem to find this a useful feature. > > "It makes me uncomfortable" is not a good answer. :-)
Well, Perl appears to find everything a useful feature. Perhaps the ability to return multiple values could be useful, but I am not entirely convinced. Consider your example of returning lists of words and counts for each word in a string. On grounds of efficiency, it would almost certainly be better to be able to compute and return both at the same time. But perhaps the better way to do it would be to introduce an object to represent the concept of a word count -- a dictionary with a more focused interface. One reason I would not find convincing would be the ability to return both a function result and an error code; that still has the usual problems that come with returning error codes. Charles Yeomans _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
