On Sun, 28 Jun 2026 at 15:07, 'Calimero' via lua-l
<
lu...@googlegroups.com> wrote:
>
Le 27/06/2026 à 19:02, Francisco Olarte a écrit :
> > The original extension was not specified nearly enough for me, and
> > further clarificacions were not of much help, as they began to mix
> > if-expressions with "(nearly) every statement is an expression", what
> > allows C to do a=b=1.
>
> Ouch no, I do not want "every statement is an expression". Statements should remain satements.
> Thankfully, allowing *expressions* to qualify as statements doesn't allow something like a=b=1!
Why thankfully? It is an useful idiom, used not in every page but a
lot on languages that allow it.
> I think there is no need to say that statements must be expressions to achieve valued code blocks (and the if expression I propose as a drop-in replacement for the if statement).
mmmm, not, but you will probably need part of it. Unless you define a
valued code block as something like DO-stat*-exp-END.
> The fact that a code block ending in a statement gives `nil` when we try to derive a value from it does not change this.
Well, you can do it that way. Is just a little bit more complex.
> Statements still cannot be used as parts of an expression with just this.
Well, then your proposal is even more difficult to understand to me.
I'lkl just wait till this wraps aup a bit and rered it them.
> >> 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.
> No, the conditional expression is just as fundamental as the conditional statement.
You are missquoting me. I did not say "The conditional statement" is
fundamental. Anyone can see why I avoided it ( hint - we are talking
notion in programming, not lua programming there ).
> They are even two instances of the same idea, which is why I suggest to make them the same entity.
Here you are getting where I was, cond. stat. and cond. exp. are forms
of "The Conditional". What I was stating is you can have a language
with any form of "the conditional".
> Could you argue otherwise? (not involving personal preference for imperative code)
Itry to never argue after a missquote until I manage to be able to
understand its reason.
...
> There are no interactions to discuss between op-assign and if-expression topics, I think?
I fear a proper op-assign, in lua, will interfere with nearly
everything. Should I try to modify lua ( under my present constraints
I will probably not do it as the PUC development model makes it
difficult and I would not want to risk a fork ) I will probably start
with ternaries ( or if expression if you like ) as I feel they should
be reasonably easy to do. I wrote a proposal using IF IIRC some
messages above, this would deal with ternary-equivalent. But your
proposal, allowing arbitrary statements, is much more ambitious and
will need to redefine things, probably define something like a
block-expression, and once you go in there I probably would prefer to
just drop lua and use another language.
> As far as conditionals are concerned, op-assign is an instruction like any other, and as far as op-assign is concerned, if-expressions are an expression like any other.
See, this talking of "instruction" and "expression" intermixed is what
makes reasoning on your proposal hard.
> If they are indeed unrelated, then there is surely no reason to discuss these unrelated features in this thread.
>
> And in any case, on my end I have no intention to make any claims on what should be a priority in the development of lua.
>
> > ( And I would vote against a pythonesque x if cond else y )
> You didn't say your reasons, that would be interesting to know.
Sexy reasons :->... No, I just dislike how it reads. But it has the
real advantage of MANDATING if and else, i.e., ternary.
> It just so happens that I agree with your opinion, and I can give my reason for that:
> Lua already has a perfectly good conditional syntax, why should we need to invent another? Keep it simple!
Lua has a perfectly good conditional statement syntax. It has no
conditional expresion. If you do it in my simplified like IF cond THEN
then-exp ELSE else-exp END ( I would start with mandatory ELSE, think
on optional one later, as the value has three perfectly legal default
else ( nil, false and whatever cond returns, which makes it equal to
'cond AND then-exp ). You could probably fix it. If you want to allow
multi-line ifs wyou have to defie the syntax ( remember in lua an
expresion is not an statement, so you can not reuse the "block"
syntax, you would have to make something like "{stat} exp", then
decide on the nil default if youlike it. Simple ternary is easy,
adding elseif also easy ( but nor that easy as I forgot the danglinl
else problem in a previous mail ).
You could try to do a minimal augmentation to "the complete syntax of
lua" to present the alternatives, this would let people, me the first,
see a bit clearer.
ta-ta.
Francisco Olarte.