-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "Don't expose Go timers directly to lua" #3211
Conversation
This reverts commit 4ffc220. Reason for revert: some plugins happen to use raw Go timers via time.AfterFunc(), in an unsafe way (without synchronizing their async code with micro). Let them keep doing that for now, in an unsafe way but at least without immediate crashes. Fixes zyedidia#3209
Shall we wrap it and add deprecation warning? |
I can't see how. Lua is an interpreted language, all errors/warnings are runtime. Do we want users of those plugins to see a "this API is deprecated" warning every now and then? |
Well, right. So It would only be possible by exposing an Lua function including In case it isn't worth the effort then forget my idea. |
I don't use Lua often either, I don't know what is |
Maybe something like this: L.SetField(pkg, "AfterFunc", luar.New(L, func(d time.Duration, f func()) *time.Timer {
log.Println("The 'AfterFunc' function will be removed in version 2.0.15")
return time.AfterFunc(d, f)
})) But I believe this log will only be seen run with |
Yep.
Pushed 4718c98 with a TODO, so that we are a bit less likely to forget. Actually, I'd be even fine if we keep these raw APIs around forever (undocumented though). Let people shoot themselves in the foot if they prefer to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what is
@deprecated
(can't see anything about it in https://www.lua.org/manual/5.4/manual.html ?), so I don't quite understand what is your idea about.
Ok, then my search results are misleading and I've to excuse.
Explicit deprecated functions within the Lua src are only commented:
src/lauxlib.h:** Compatibility with deprecated conversions
src/lstate.c:** Deprecated! Use 'lua_closethread' instead.
src/lstrlib.c: case 'z' : res = (c == 0); break; /* deprecated option */
src/luaconf.h:@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
src/lmathlib.c:** Deprecated functions (for compatibility only)
src/lua.h:LUA_API int (lua_resetthread) (lua_State *L); /* Deprecated! */
So forget my thoughts. Separating and marking them with the TODO
is feasible enough.
This reverts commit 4ffc220.
Reason for revert: some plugins happen to use raw Go timers via
time.AfterFunc()
, in an unsafe way (without synchronizing their async code with micro). Let them keep doing that for now, in an unsafe way but at least without immediate crashes.Fixes #3209