Thomas Jericke

lua-users home
wiki

We use Lua in our automation framework McRobot?[1]

This page is used to distribute patches that I made in my private time. They should be tested by anyone who is applying them as I never tested any of them on productive Lua code.

It is important to consider that this patches are more for fun (yet).

Currently there is one patch available:

Optional redundant brackets

This patch makes many of the brackets ( Parentheses ) which don't add any information to the code optional.

In the current version of the patch, brackets the following brackets can be left away. Method call without any arguments:

 

object:method 

-- equals

object:method()

Method invocation on any literal (string, number, true, false, nil)


"Hello":upper

-- equals

("Hello"):upper()

43:tostring

-- equals

(43):tostring()

Obviously this change is only practical once a meaningful metatable was set for string, number etc.

Operators on tables (except call operator)


a = { a = 12 }.a 

b = { 1 = 14, 12 = "t" }[a]

The patch should be backward compatible for existing Lua 5.2 scripts. This was tested with the Lua test suite where it passed all test with exception of some which tested an error output.

[Download for 5.2.2)]


RecentChanges · preferences
edit · history
Last edited May 21, 2014 9:18 pm GMT (diff)