[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: Lua 5.3 -- Named Return Values
- From: Stéphane Aulery <lkppo@...>
- Date: Wed, 20 Nov 2013 15:03:01 +0100 (CET)
> De: Sir Pogsalot <sir.pogsalot@gmail.com>
> Envoyé: Wed, 20 Nov 2013 12:26:28 +0100 (CET)
>
> Might be a little confusing ;> I understand you probably want this for
> convenience as it makes the code more concise, but I would suggest trying
> to get used to explicit return statements... I'm not sure upstream Lua
> would be in favor of this, but best of luck \o/
I seek less to shorten writing to make explicit the meaning of the values returned without having to worry about re-read the code. I can comment on each return value to know for example that it is an error code but it will not be exploited by an IDE and prone to problems inerrant comments. The name could be optional.
Syntaxical example:
function add (a, b)
return (a + b)
if (b <0)
return error = 10
else
return error = 0
end
end
--
Stéphane Aulery