Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 2.14 KB

README.md

File metadata and controls

45 lines (31 loc) · 2.14 KB

Lua & Luajit Compound Operators Patch

Adds the following operators to lua5.2.4 and luajit 2.1.0-beta3 (latest release):

  • Compound assignment: +=, -=, *=, /=, ..=, %=
  • Increment: ++
  • Continue keyword continue.

Metamethods "just work", eg a+=7 will invoke __add(a, 7) and assign result to a.

Lua5.2.4 and Luajit 2.1.0 are both supported so that you can use Lua when debugging and LuaJit on release

This is distributed as a patch so that you can apply it to future versions (rather than this becoming yet another unmaintained lua/luajit fork)

How to Use

Download relevent sources and then use patch and then build as usual.

Alternatively use fetch_and_apply_lua*.sh to automatically download and patch

Contributing

Edit files makediff_lua*.sh to make a new lua*.patch. Set A to the unmodified source directory and B to the modified source and run the script.

Hairy Bits

  • Tupple assignements are not supported (no a,b,c+=1337). They do work in patched PUC lua, but not patched luajit
  • Increment a++; is a post-increment and should be an isolated statement (no t[a++], terminate with ;)
  • There is no a--;, instead use a-=1;

Implementation Credits, Etc

Luajit continue from [https://github.com/zewt/LuaJIT/commit/c0e38bacba15d0259c3b77]

Luajit compound operaters based on [https://github.com/mingodad/ljsjit]

Lua compound operators SvenOlsen's powerpatch [http://lua-users.org/wiki/LuaPowerPatches] (control-f: "Compound Assignment Operators (5.2)")

Lua continue from zewt's continue branch [https://github.com/zewt/lua/compare/master...zewt:continue?expand=1]

To Be Done

Probably won't be done unless someone submits a PR

Support binops: &,|,^,~

License

Public Domain