|
To Roberto,
tá bom! I have only been learning Lua for a
month. But, tables are really, really cool! So, I don't have
much to give except for the following (in order of precedence):
1) It would be great to have a C Unit
Test with the Lua C compiler. It should be a C Unit Tester that
tests every method. This would be HUGE! And, if the framework
is established with the source code, the Community could
contribute in creating tests for Lua!
2) Sets -- In page 15 of Programming
in Lua, third edition you state, "We use tables to
represent ordinary arrays, sets, records, and ...". The
one thing that I miss from Pascal in modern programming
languages is Pascal's set, especially inside an if statement.
(In Pascal)
Months = (Jan, Feb, Mar, Apr,
May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);
CurrentMonth := [Sep]
SummerMonths := [Jun, Jul, Aug];
if (CurrentMonth in SummerMonths)
then
end;
Is this possible in Lua? A switch
statement would not be needed (in my humble opinion) if an if
statement can operate from sets.
3) Switch statement. If sets are
allowed in an if statement, I would not go for adding a switch
statement. But, if you do, and if you follow C/C++/..., add nobreak
keyword. Forcing the programmer to end every case with either a
break or nobreak would prevent bad things from
happening. A nobreak indicates that you intentionally
want to go to the next case. No more missing breaks within
a switch statement!
4) Switch statement. If you plan to
add a switch statement, but only if you do. I suggest that
within the switch() { .. }, you can add variable declarations
from the first brace '{' and before the first case statement
like this (it would be great to have sets from #2 here also.
You will notice a Pascalish case here also):
switch (SummerMonths)
{
temp = "Summer is still ON!"
case Jun..Aug:
print(temp)
otherwise:
print("Where did summer go")
}
5) This was syntactic sugar that I
suggested to Microsoft over 10 years ago for their C++/CLI
compiler. Instead of:
if (x > y) and (y > z)
can we instead say:
if x > y > z
That's all folks!
Thanks for the opportunity to express
my ideas.
As soon as I heard about Lua tables,
I knew that this was a language for me to learn.
Boa noite!
In the process of learning Lua,
Richard Green
On 9/14/2018 3:22 PM, Roberto
Ierusalimschy wrote:
i would add support for binary and octal integer literals like 0b1001011 or 0o0755 as in Python and Ruby. octal integer literals are helpful when working with unix (file) modes/permissions (which i do frequently).function Oo(x) return tonumber(x, 8) end function Ob(x) return tonumber(x, 2) end print(Ob"1001011") --> 75 print(Oo"0755") --> 493 :-) -- Roberto |