Skip to content
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

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

dmaluka
Copy link
Collaborator

@dmaluka dmaluka commented Mar 24, 2024

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

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
@JoeKar
Copy link
Collaborator

JoeKar commented Mar 24, 2024

Shall we wrap it and add deprecation warning?
In case no, then it can immediately being merged.

@dmaluka
Copy link
Collaborator Author

dmaluka commented Mar 24, 2024

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?

@JoeKar
Copy link
Collaborator

JoeKar commented Mar 24, 2024

Lua is an interpreted language

Well, right. So It would only be possible by exposing an Lua function including --- @deprecated.
But to be honest, I don't know if it will cause what I expect it to do, since I don't use Lua that often.

In case it isn't worth the effort then forget my idea.
Hopefully we remember then, that the support shall be dropped.

@dmaluka
Copy link
Collaborator Author

dmaluka commented Mar 24, 2024

I don't use Lua often either, 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.

@taconi
Copy link
Contributor

taconi commented Mar 24, 2024

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 -debug and examine the log.txt

@dmaluka
Copy link
Collaborator Author

dmaluka commented Mar 24, 2024

But I believe this log will only be seen run with -debug and examine the log.txt

Yep.

Hopefully we remember then, that the support shall be dropped.

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.

Copy link
Collaborator

@JoeKar JoeKar left a 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.

@JoeKar JoeKar merged commit 838f371 into zyedidia:master Mar 25, 2024
3 checks passed
@dmaluka dmaluka mentioned this pull request Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backwards incompatible changes in plugin API
3 participants