Executing Lua closure from Go
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 18/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Go
- Star
- 3.5k
- Fork
- 217
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Shopify/go-lua
-
Numeric modulo fast path disagrees with Lua 5.2 and the library fallback for negative operandsCó thể đã có người làm @efegokdemir đã nhận 35 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
io.write discards spaces after trailing numbersCó thể đã có người làm @flynn-eye đã nhận 25 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
State.close leaves closed upvalues in the open list, so calls get slower without boundCó thể đã có người làm @efegokdemir đã nhận 17 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Tất cả issue của Shopify/go-lua
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
docker/model-runner#1118 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Screenshot missing in READMEĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100