on 3/23/07 5:42 PM, Guyren Howe at [EMAIL PROTECTED] wrote: > On Mar 23, 2007, at 4:28 PM, Chris Little wrote: > >>>> Functions should return one value. >>> >> I agree that being able to return multiple values would be useful. >> I'm not >> sure I like how you've proposed it. Coming from a C++ background >> the classic >> solution is to return a tuple or a result object. This keeps the >> return >> syntax the same. I didn't see in your FR how you would return the >> multiple >> values or how you would assign them at the point of calling. Could you >> provide an example of what you have in mind? > > Multiple lvalues would be allowed on an assignment: > > words(), counts() = CountWords(someString) > > A function can declare multiple return values: > > Sub CountWords(s As String) As string(), integer()
The problem with this is that you can't tell what each return value is. To use an example from another of your replies: Function ParseDate(stringDate as string) as integer, integer, integer How do you tell the order of the return values? The function signature loses all self documenting ability. You would at least have to have some kind of naming of return values. > If the number of lvalues differs from the number of return values, then: > > - if there are more lvalues, the excess values are Nil/0/""/etc > - if there are excess return values, the excess are ignored. > > Notice that these semantics lets the function return values in the > order that is most useful. CountWords then doubles as a handy "unique > words" function: I don't like this at all. It could lead to fragile code once when you start having to account for type conversions. Chris _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
