Re: Pass by Reference

new topic     » goto parent     » topic index » view thread      » older message » newer message
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 3 
So 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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu