Replacing the "if" statement with an "if" expression which supersedes it
"'Calimero' via lua-l" <[email protected]> Fri, 26 Jun 2026 02:02:45 +0200
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
Hello! I suggest outright replacing Lua's existing "if statement" with an "if expression". The expression variant would completely supersede the current statement variant, keeping exactly the same syntax. This does not make the language bigger, but it does make it more powerful. It would be a fully backwards-compatible change, with the value of the expression being simply ignored in existing codebases. Details: - Lack of an "else" branch would simply mean the value to be "nil" if no condition is true (in if or elseif branches). - This drags along with it the idea that a block of statements evaluates to the value of its latest statement (possibly nil, if no value). Naturally, I have read http://lua-users.org/wiki/TernaryOperator before posting this. I am interested in knowing whether this will be implemented, or failing that, why it won't be! -- You received this message because you are subscribed to the Google Groups "lua-l" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/lua-l/5f7ef457-8e06-e0a9-9583-144a6dbea73b%40free.fr.