Executing Lua closure from Go
まだ誰も着手していません。
評価
調査の方向性
Start with the calls in the report: l.Register, l.ToValue(1), l.PushLightUserData and l.Call in the go-lua API. The question is whether a Lua closure saved as a Go value can be pushed back and invoked, and why the push yields a nil call. Done means a reproducible test that stores a closure from a Lua callback and calls it later from Go, or a clear statement of what the API supports.
索引モデルが issue の本文から書いたものです。
説明
If I have a *lua.State where I register a function:
l := lua.NewState()
var closure interface{}
l.Register("myCallback", func(l *lua.State) int {
closure = l.ToValue(1)
return 0
})
is it possible to call the function in Lua and pass a closure that can be executed later:
myCallback(function()
print("hello!")
end)
So then I can call l.Call() on the body of the script which executes my callback to my registered function. Then I tried pushing it back on the stack and calling:
l.PushLightUserData(closure)
l.Call(0, 0)
However, I get this error:
runtime error: [string "main"]:4: attempt to call a nil value
I checked closure and verified that it's a *luaClosure.
Is it possible to save a closure and call it later from Go?
/cc @aybabtme
- 主要言語
- Go
- スター
- 3.5k
- フォーク
- 217
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Shopify/go-lua のほかの issue
-
Numeric modulo fast path disagrees with Lua 5.2 and the library fallback for negative operands対応中かも @efegokdemir が 35 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
io.write discards spaces after trailing numbers対応中かも @flynn-eye が 25 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
State.close leaves closed upvalues in the open list, so calls get slower without bound対応中かも @efegokdemir が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
limitlessprojects/Go-Hybrid#4764 ·
メンテナーはふだん 1 日以内に返信
-
[bug]: lint fails on main, generated CLI docs out of date対応中かも @bupd が今日担当しました。 オープンbug documentation
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
goharbor/harbor-cli#1180 ·
メンテナーはふだん 1 日以内に返信
-
crane: mutate --env adds duplicate PATH on Windows images when key case differs対応中かも @aad1tyaaaaa が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
google/go-containerregistry#2523 ·
メンテナーはふだん 4 日以内に返信
-
bosh_io_stemcell_type: regular does not work for noble and resolute as it adds -go_agent as suffixオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
cloudfoundry/bosh-deployment-resource#138 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100