Will Leshner wrote:
> There is also a feature request (that I think we should *not* make for
> RB) that would have functions able to return more than one value. So you
> could do something like:
>
> (a, b) = foo(3)
>
> where foo returns two values.
>
> I assume that isn't what you are asking for, right?
Actually, I think this would be a great feature. Less error-prone and fiddly
than ByRef for returning multiple values.
When you use ByRef, and you're reading the code, you have to remember which
variables are the results of the function and track where they are assigned
to. If you can just do
Return x, y, z
You know what's getting returned when. Your code is much more
self-documenting.
Equally, when you are calling a method that returns multiple values using
ByRef, you again have to track which variables are the actual arguments to
the function and which are its return values. OTOH this:
a, b = foo(32)
is clear as crystal.
Doing this stuff with ByRef is basically a kludge, IMHO. It is much cleaner
and more natural to allow multiple returns from functions. I don't know why
more languages don't have it.
Care to elaborate on why you don't like this idea?
Guyren G Howe
REALbasic/4th Dimension Consultant
Technical Writer/Trainer
|