lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> De: Sir Pogsalot <>
> 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
       return error = 0

Stéphane Aulery