This is a Lua 5.3 VM and compiler written in Go. This is intended to allow easy embedding into Go programs, with minimal fuss and bother. It can also run in a browser by Webassembly.
This repository is forked from milochristiansen/lua, and I made some incompatible changes. So it's unlikely to be merged into the original repository.
The strftime function and string pattern matching is currently copied from yuin/gopher-lua. It may be rewritten in the future.
package main import ( "github.com/ofunc/lua/util" ) func main() { l := util.NewState() util.Run(l, "main.lua") }
local js = require 'js' local window = js.global window:setTimeout(function() window:alert('Hello world!') end, 1000)
Please refer to the README for standard libraries.
The following standard functions are not available:
collectgarbage
(not possible, VM uses the Go collector)xpcall
(VM has no concept of a message handler)next
(I don't need it at this time)load
(violates my security policy)dofile
(violates my security policy, use require
)loadfile
(violates my security policy, use require
)string.dump
(violates my security policy)string.pack
(I don't need it at this time, use msgpack)string.packsize
(I don't need it at this time, use msgpack)string.unpack
(I don't need it at this time, use msgpack)The following standard modules are not available:
package
(violates my security policy, use util.AddPath
)debug
(violates my security policy)coroutine
(no coroutine support yet, use goroutine)The following modules are not implemented exactly as the Lua 5.3 specification requires:
math.random
(initialize the seed by default using program startup time)os
(Go style functions)io
(Go style functions)There are a few things that are implemented exactly as the Lua 5.3 specification requires, where the reference Lua implementation does not follow the specification exactly:
#
(length) operator always returns the number of positive integer keys. When the table is a sequence, it's exactly equal to the sequence's length.%
) is implemented the same way most languages implement it, not the way Lua does. This does not matter unless you are using negative operands.The following core language features are not supported:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3