Re: Pass by Reference
- Posted by dcuny Jan 14, 2015
- 2095 views
So, i request the comma way of writing the returned values. Also, not crashing when doing
a,b,c = return(1,2) ; a=1, b=2, c becomes some default value
Actually, it shouldn't even compile.
Hrm... Obviously, this is a bit more work for forward references, too. Not a big deal, but not to be forgotten about.
Because the compiler ensures the counts match, the only situation where a crash should be possible would be:
a, b, c = call_function( routine_id("foo"), {})
I'd initially agreed that this shouldn't be an error, but I no longer think that's the case.
Mainly, I figure that if you're trying to read more values back than a routine returns, it's a pretty strong hint that perhaps something is wrong.
After all, the parser treats it as a fatal error.
You've still go the de-sequencing operator to fall back to if you want to handle multiple values. But my assumption is that a routine should return a fixed number of parameters.
If you're just trying to avoid having Euphoria throw an exception, I figure better exception handling is the path to take.
Could you give an example of where you think you might encounter this use case?
- David