We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Lua

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
Lua
Paradigm(s) prototype-based
Designed by Roberto Ierusalimschy, Waldemar Celes, Luiz Henrique de Figueiredo
Appeared in 1993
Computational class Turing complete
Reference implementation PUC-Rio Lua (GitHub mirror)
Major implementations LuaJIT
Influenced by Awk, C++, CLU, DEL, Modula-2, Python, SNOBOL, SOL, Tcl
Influenced Luau
File extension(s) .lua

Lua is a programming language designed in 1993 by Roberto Ierusalimschy, Waldemar Celes, and Luiz Henrique de Figueiredo of PUC-Rio, and implemented by Ierusalimschy in 1993, to be a simple, embeddable, and extensible language that met the growing demands of Tecgraf during an era of Brazilian protectionism which prevented their clients from importing foreign software.[1]

Self-interpreter

Lua supports running arbitrary Lua code through the loadstring (4.0-5.2) or load (5.3+) function, which returns a function or nil if the code is not valid.

local load = loadstring or load
local func = load([[
  -- Code goes here
]])
func()

One can pass input from the standard input stream into the function with io.read() as well.

local load = loadstring or load
local func = load(io.read())
assert(func, "Code is not valid.")
func()

See also

References

  1. R. Ierusalimschy, L. H. de Figueiredo, and W. Celes, "The Evolution of Lua". History of Programming Languages III, 2007. https://www.lua.org/doc/hopl.pdf