[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [Patch] Make some brackets optional (for Lua 5.2).
- From: "Thomas Jericke" <tjericke@...>
- Date: Thu, 22 May 2014 21:25:01 +0200
Hi list
So here is the first version my patch that makes some of the parentheses in the Lua 5.2 syntax optional.
I created this patch out of interest and for fun and getting to know the Lua parser better.
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.0:tostring -- equals (43.0):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 fully backward compatible to vanilla Lua 5.2, so any existing code should still work.
I so far only tested it with the Lua test suite and some simple test scripts I wrote myself. So if you want to
use it in any "real" project, I advice you to run your own tests as well.
http://lua-users.org/files/wiki_insecure/power_patches/5.2/optbrackets-5.2.2.patch
--
Thomas