Re: Replacing the "if" statement with an "if" expression which supersedes it

Lan Krownet <[email protected]> Sat, 27 Jun 2026 13:28:35 -0400
Newsgroups gmane.comp.lang.lua.general
Message-ID <CA+gUx_RrBWXXPKupfiLAL9xqvEFi1TY-bkiVPrLbYD6w4FeJEA@mail.gmail.com>
Operator assignment is not necessarily the only way to do it, because the
issue assignment operators are trying to solve is not having to retype a
really long variable, well, you could have a single unary prefix operator
with a number that basically takes the variable being assigned in the
expression and pastes it into the code like

areallylongvariable = $0+1

turns into

areallylongvariable = areallylongvariable+1

or it could point to any section, which is nice when you just want to swap
some variables

var1, var2 = $2, $1 -- variables are swapped

But anyway.

On Sat, 27 Jun 2026 at 13:12, Francisco Olarte <[email protected]>
wrote:

> On Sat, 27 Jun 2026 at 18:56, 'Calimero' via lua-l
> <[email protected]> wrote:
> > The conditional is a very fundamental notion in programming, and there
> is a fundamental flaw in not having an expression conditional.
> > I'm trying to deal with this.
>
> The conditional is fundamental, the ternary ( or the funky IF
> expression I drafted previously ) is not. After all we put some men on
> the moon more than fifty years ago without ternaries ( take "we" as
> "the humanity", assume no foul play in the banner photos ). And lot of
> languages do not have them.
>
> If-expression is nice, but I would put it after op-assign in priority,
> and maybe after elvis. But before postincrement, if I ever did that
> one, and anyway to bne useful that need to redefine what a expression
> is first.
>
> ( And I would vote against a pythonesque x if cond else y )
>
> Francisco Olarte.
>
> --
> 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/CA%2BbJJbw7igVMU6ziHXcWoC5CJTXqpTCQPy-go0dauhgEqo1VAw%40mail.gmail.com
> .
>

-- 
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/CA%2BgUx_RrBWXXPKupfiLAL9xqvEFi1TY-bkiVPrLbYD6w4FeJEA%40mail.gmail.com.