Re: Replacing the "if" statement with an "if" expression which supersedes it
"'Calimero' via lua-l" <[email protected]> Fri, 26 Jun 2026 10:17:28 +0200
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
Hello! Here's a explicit recap of the answers to your concerns: On 26/06/2026 09:44, Родион Горковенко wrote: > You probably may need to explain how it makes language "more powerful" as it seemingly duplicates existing "and / or" approach. The and/or approach has its caveats with falsy values that a proper if-then-else construct does not have. http://lua-users.org/wiki/TernaryOperator says : >The main caveat is that if |a| or |c| evaluates to true while |b| or |d| respectively evaluate to false, then this expression will not behave exactly like the ternary operator. > 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"? This is my suggestion to handle multiple statements: >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). And to complete it, I could add that any statement that is not an expression (like a variable definition indeed) can be considered to have the value `nil`. > So "it won't make language bigger" actually is a bit superficial glance. What I mean by bigger is if it is one more syntactic feature. Removing the current if statement and adding an if expression (that supersedes it perfectly) would not increase the total count of syntactic features! This is what I meant by "not making the language bigger". -- 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/6347a9ea-2bf8-7fdb-c59a-8d4d93ead14a%40free.fr.