Executing Lua closure from Go
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 18/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Go
- Estrellas
- 3.5k
- Forks
- 217
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Shopify/go-lua
-
Numeric modulo fast path disagrees with Lua 5.2 and the library fallback for negative operandsPosiblemente ocupada @efegokdemir la tomó hace 35 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
io.write discards spaces after trailing numbersPosiblemente ocupada @flynn-eye la tomó hace 25 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
State.close leaves closed upvalues in the open list, so calls get slower without boundPosiblemente ocupada @efegokdemir la tomó hace 17 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 25/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
Todos los issues de Shopify/go-lua
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
limitlessprojects/Go-Hybrid#4764 ·
Los mantenedores suelen responder en 1 día
-
[bug]: lint fails on main, generated CLI docs out of datePosiblemente ocupada @bupd la tomó hoy. Abiertobug documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
goharbor/harbor-cli#1180 ·
Los mantenedores suelen responder en 1 día
-
crane: mutate --env adds duplicate PATH on Windows images when key case differsPosiblemente ocupada @aad1tyaaaaa la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
google/go-containerregistry#2523 ·
Los mantenedores suelen responder en 4 días
-
bosh_io_stemcell_type: regular does not work for noble and resolute as it adds -go_agent as suffixAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
cloudfoundry/bosh-deployment-resource#138 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100