Re: Pass by Reference
- Posted by dcuny Jan 13, 2015
- 2190 views
petelomax said...
Just after you posted I suggested return[2] or return[2..8] (which could be read as "return at least two and at most eight values"), but I'll accept you pipped me to it.
The number of values returned will be enforced by the compiler. That is, if you wrote:
function foo(integer x) if x = 0 then return 1, 2 else return 3 end if
You should get an error along the lines of:
Error: Return count mismatch. foo() expects 2 return values, not 1 return 3So the declaration of the number of values doesn't need to be declared, it just needs to be consistent.
If you want a variable number of parameters, the de-sequencing operation should be used instead. Yes, I know: Euphoria allows optional parameters.
But above all, I'd stay away from using the square brackets. This looks like an index:
return[2]
and this looks like a slice:
return[2..8]
- David