Executing Lua closure from Go
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 18/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- Go
- Estrelas
- 3.5k
- Forks
- 217
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de Shopify/go-lua
-
Numeric modulo fast path disagrees with Lua 5.2 and the library fallback for negative operandsTalvez já em andamento @efegokdemir assumiu há 35 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
-
io.write discards spaces after trailing numbersTalvez já em andamento @flynn-eye assumiu há 25 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
-
State.close leaves closed upvalues in the open list, so calls get slower without boundTalvez já em andamento @efegokdemir assumiu há 17 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 25/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
Todas as issues de Shopify/go-lua
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
limitlessprojects/Go-Hybrid#4764 ·
Mantenedores costumam responder em até 1 dia
-
[bug]: lint fails on main, generated CLI docs out of dateTalvez já em andamento @bupd assumiu hoje. Abertabug documentation
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
goharbor/harbor-cli#1180 ·
Mantenedores costumam responder em até 1 dia
-
crane: mutate --env adds duplicate PATH on Windows images when key case differsTalvez já em andamento @aad1tyaaaaa assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
google/go-containerregistry#2523 ·
Mantenedores costumam responder em até 4 dias
-
bosh_io_stemcell_type: regular does not work for noble and resolute as it adds -go_agent as suffixAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
cloudfoundry/bosh-deployment-resource#138 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100