stuff.lua
· 897 B · Lua
Brut
Playground
-- quotation.lua
local function quotation_call(quote, env)
if rawget(quote, "namespace") then env.namespace:push(quote.namespace) end
for _, item in ipairs(quote.body) do
local typ = type(item)
if typ == "number" or typ == "boolean" or typ == "string" or (typ == "table" and item.type == "quote") then
env.data:push(item)
else
item(env)
end
end
if rawget(quote, "namespace") then env.namespace:pop() end
end
-- gilded.lua
builtins["call"] = function(env)
env:assertHeight(1)
local quote = env.data:pop()
return quote(env)
end
-- snipped --
local env = enviroment.new()
for _, item in ipairs(program) do
local typ = type(item)
if typ == "number" or typ == "boolean" or typ == "string" or (typ == "table" and item.type == "quote") then
env.data:push(item)
else
item(env)
end
end
| 1 | -- quotation.lua |
| 2 | local function quotation_call(quote, env) |
| 3 | if rawget(quote, "namespace") then env.namespace:push(quote.namespace) end |
| 4 | for _, item in ipairs(quote.body) do |
| 5 | local typ = type(item) |
| 6 | if typ == "number" or typ == "boolean" or typ == "string" or (typ == "table" and item.type == "quote") then |
| 7 | env.data:push(item) |
| 8 | else |
| 9 | item(env) |
| 10 | end |
| 11 | end |
| 12 | if rawget(quote, "namespace") then env.namespace:pop() end |
| 13 | end |
| 14 | |
| 15 | -- gilded.lua |
| 16 | builtins["call"] = function(env) |
| 17 | env:assertHeight(1) |
| 18 | local quote = env.data:pop() |
| 19 | return quote(env) |
| 20 | end |
| 21 | |
| 22 | -- snipped -- |
| 23 | |
| 24 | local env = enviroment.new() |
| 25 | for _, item in ipairs(program) do |
| 26 | local typ = type(item) |
| 27 | if typ == "number" or typ == "boolean" or typ == "string" or (typ == "table" and item.type == "quote") then |
| 28 | env.data:push(item) |
| 29 | else |
| 30 | item(env) |
| 31 | end |
| 32 | end |