WattleScript’s Lua mode contains minor differences and a few additions, inherited from MoonSharp.
collectgarbage() a no-op.x[1,2,i] is parsed correctly but might raise an error if x is not a userdata.|x, y| x + y is shorthand for function(x,y) return x+y end.__iterator metamethod has been added. It’s called if the argument f of a for ... in ... loop is not actually a function.f of a for ... in ... loop is a table without __iterator or __call metamethods. The provided result is value, key unlike ipairs or pairs.\u{xxx} escapes, where x are up to 8 hexadecimal digits, are supported inside strings and will output the specified Unicode codepoint, as it does in Lua 5.3loadsafe and loadfilesafe methods, same as load and loadfile but defaulting to the current top-of-the-stack _ENV instead of the default one, for easier sandboxingdynamic.eval and dynamic.prepare functions to handle dynamic expressionsstring.unicode method, just like string.byte but returning a whole unicode codepointstring.contains, string.startsWith and string.endsWith methods allow easier and faster performing string ops without having to rely on patterns for simple scenariosjson module to support JSON<->table conversions