Moonscriptrepl
Pages 17
Clone this wiki locally
This is a simple interactive MoonScript prompt, which is already useful within its limitations. The main thing is that it cannot detect whether a statement starts a block, so you have to either use a final backslash or tab. If these are detected, then the block continues until an empty line.
If the moondump module is available (see Pretty Table Dumper it will use that. The Lua `linenoise' module is used on platforms that support it (available through LuaRocks) for basic line editing and history.
mooni does two hacks to make MoonScript work interactively; the first is to strip the first local statement from the generated Lua code, so that any created variables are global; the second is to keep track of created globals and force MoonScript to recognize them with a fake local declaration. The problem is the opposite of the usual 'destructive assignment' issue.
Example session (assumes that moondump is available):