-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugdocumentationimprovementImproves the way that an existing feature works, in a backwards-compatible way.Improves the way that an existing feature works, in a backwards-compatible way.
Milestone
Description
The lua {...} syntax was intended as a sort of escape hatch, to allow for use of Lua libraries/methods/etc. which fundamentally don't have any way to model in Huck. However, it is currently unclear what exactly the programmer should expect to be in the Lua scope into which the lua block will be expanded.
In scope:
- Any locally-bound variables in scope at the
luablock (e.g. function arguments, case arm bindings) - Any Lua globals that your runtime provides (e.g.
string.find,require,io.popen)
Is this list complete? Should there be any more items? Should any of these items not be allowed?
We can probably enforce this a bit after #31.
Here is an example of a Lua interface to be wrapped in Huck (lua_library.lua):
local Object = {}
Object.__index = Object
function Object.new()
return setmetatable({x = 0}, Object)
end
function Object:activate()
self.x = self.x + 1
print("Incremented x.")
end
function Object:getVal()
return self.x
end
return ObjectHuck wrapper:
foreign import "lua_library" (new as newObject : () -> IO Object);
type Object = Object;
activateObject : Object -> IO ();
activateObject obj = lua { obj:activate() };
getObjectVal : Object -> IO Int;
getObjectVal obj = lua { obj:getVal() };
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugdocumentationimprovementImproves the way that an existing feature works, in a backwards-compatible way.Improves the way that an existing feature works, in a backwards-compatible way.
Projects
Status
Todo