lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


What he proposes here is a kind of "fallthrough", like for branches of switches without break in C/C++, but here he wants to allow this also for if...end statements. "elseif" implicitly includes an implicit "break" before a new branch, i.e. exclusive conditions; and he wants inclusive conditions (which has very limited uses, just like break-less branches of switches that fall through.
However it has some usage (e.g. when compiling finite states automatas, or for "exit" procedures at end of blocks to perform cleanup of conditionally-allocated resources in backward direction).

Le lun. 23 déc. 2019 à 18:17, Soni "They/Them" L. <fakedme@gmail.com> a écrit :


On 2019-12-23 1:38 p.m., Chris Jones wrote:
> I don't think the proposed syntax really fits with what the word "or"
> means.

if x then
   ...
orif y then
   ...
end

is (effectively) equivalent to

if x then
   ...
end
if x or y then
   ...
end

but x only gets evaluated (and typed) once.

every way to describe this feature, you'll end up using "or" or even "or
if" somewhere, be that in code or in english. see also the subject line
of this email.

>
> On Mon, 23 Dec 2019 at 15:30, Soni "They/Them" L. <fakedme@gmail.com
> <mailto:fakedme@gmail.com>> wrote:
>
>     I'd like to have the ability to convert, say:
>
>     switch (op) {
>     case OP_TAILCALL: {
>        ...
>        /*fallthrough*/
>     }
>     case OP_CALL: {
>        ...
>        break;
>     }
>     }
>
>     into:
>
>     if op == OP_TAILCALL then
>        ...
>        -- fallthrough
>     orif op == OP_CALL then
>        ...
>     end
>
>     because it looks nicer this way I guess.
>
>
>
> --
> Cheers,
>
> Chris