Skip to content

Accessing functions by name (or something?) #37

@jwoertink

Description

@jwoertink

Let's say I have a lua file like:

function one()
  print("one")
end

function two()
  print("two")
end

return one, two

Then I add these to the stack:

lua = Lua.load
code = lua.run File.new("./test.lua")

I can do a secondary run lua.run("one()"), but is there a way to gather these functions individually by a name or something?

What I'm looking to do is call them from within Crystal like one.as(Lua::Function).call. Then I can pass in args from Crystal. I know I can do this if I return a single function, but what if I return multiple functions, and I can't guarantee which order they were returned in?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions