lua-users home
lua-l archive

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


On Sat, Aug 15, 2015 at 1:14 AM, Thomas Jericke <tjericke@indel.ch> wrote:
> On 08/14/2015 07:55 PM, Soni L. wrote:
>>
>>
>> - -Fallthrough-by-default (on most programming languages). (clarity)
>>
> I don't agree with this statement. Fallthrough-by-default is a typical
> feature of the C-syntax family of programming language
> (C,Java,JavaScript,...) but it is not for other languages. Fortran, Ada,
> Pascal (correct me if I am wrong) all have break-by-default. And I think Lua
> syntax is much closer to those languages, so I would prefer break-by-default
> for Lua if it ever introduces a switch case syntax.
>
> Additionally I think fallthrough-by-default is error prone, many tools like
> Lint and Eclipse CDT actually warn you if you are missing a break after your
> case block.
>
> --
> Thomas
>

I think it's worth noting that C# is a C-syntax language and doesn't
have fallthrough-by-default. It requires that each case explicitly
define an exit -- usually break and frequently return, but fallthrough
is available and even generalized by the ability to use "goto" to jump
to another case as an exit. (It allows multiple case statements to be
put together without explicit fallthroughs but they're treated as a
single block with multiple conditions.)

Explicit fallthrough is a perfectly reasonable way to go about it. I
use a "// fallthrough;" comment when I use explicit fallthrough. I
wouldn't mind a compiler that would enforce that for me.

/s/ Adam