[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Has Lua reached perfection?
- From: Marc Balmer <marc@...>
- Date: Sun, 28 Jan 2018 11:13:17 +0100
> Am 28.01.2018 um 10:36 schrieb Dirk Laurie <firstname.lastname@example.org>:
> 2018-01-28 10:52 GMT+02:00 KHMan <email@example.com>:
>> I'd like a native switch. :-) Please, pretty pretty please :-)
> So which do you want? Like Pascal's 'case' statement 
> or like C's 'switch' statement?
> Personally I heartily detest the C 'switch'. You need to put
> 'break' all over the place. I never use the fall-through trick.
> It's a fast-track to lurking bugs.
Have you ever heard of duff's device?
> I am willing to keep an open mind on 'case'. I don't
> really think Lua needs it, but the workarounds are not pretty.
I usually create a table of functions and use the value I would use
in a C switch as the index.
That not only works well, but structures the code nicely and in
practive the function calling overhead is small.
>  I was a Pascal user from Wirth's first report until one
> needed p2c to run it under Linux. Now that Free Pascal
> has reached stability, I use Pacal again. Think of it as
> C with Lua readability. One can write Lua API code in
> Pascal and call Lua code from Pascal.