Re: Replacing the "if" statement with an "if" expression which supersedes it
Родион Горковенко <[email protected]> Fri, 26 Jun 2026 10:44:50 +0300
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <CAL2n1tx7wYXx+DfwNjeotAgQ2EEdob4T=immH_osVskXV-1LBA@mail.gmail.com> |
You probably may need to explain how it makes language "more powerful" as it seemingly duplicates existing "and / or" approach. Proposed "if expression" may be more argued as "more readable" but it will anyway bring a number of issues - "if statement" allows multiple expressions inside (including variables definition) - how do you suggest to manage this in "if expression"? So "it won't make language bigger" actually is a bit superficial glance. On Fri, Jun 26, 2026 at 3:41 AM 'Calimero' via lua-l <[email protected]> wrote: > 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 > . > -- 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/CAL2n1tx7wYXx%2BDfwNjeotAgQ2EEdob4T%3DimmH_osVskXV-1LBA%40mail.gmail.com.