Created
December 4, 2014 08:13
-
-
Save mnemnion/288bead5c490cadb3bc8 to your computer and use it in GitHub Desktop.
Inconsistent behavior between Lua 5.1 and LuaJit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function advise (adviceFn, ogFn) | |
| return function (...) adviceFn(unpack(arg)) ogFn(unpack(arg)) end | |
| end | |
| function foo (x) | |
| print ("foo") | |
| print (x) | |
| end | |
| function bar (x) | |
| print "bar" | |
| print (x) | |
| end | |
| function main () | |
| foo = advise(foo,bar) | |
| print "working" | |
| end | |
| foo(12) | |
| main() | |
| foo(12) |
Author
Author
NB: this is because arg is deprecated. use adviceFn(...) directly, or a, b = ... to dereference/unpack. Hat-tip Neffi on #lua freenode.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
I admit, I'm stumped. Did I hit some undefined behavior?