LuaSocket, Lua 5.2 and Redis

无人久伴 提交于 2019-12-10 13:49:19

问题


Has anyone been able to get these working together? I've gotten 5.2 working great, and it can find lua-redis (redis.lua), however it fails loading the socket module, which I can't seem to get working with lua (LuaSocket version 2.0.2). Anyone have any tips to get this working?

I've tried making luasocket, however it fails completely, which I'm assuming is due to my lua version 5.2.

Is the answer just to revert back to lua 5.1, or is there another fix that i'm not aware of?


回答1:


The current release of LuaSocket, as many Lua libraries, does not support Lua 5.2. For Lua changes in the second digit of the version indicate major releases, and backwards-compatibility is not maintained (except in some cases via compilation flags to re-enable deprecated features).

Lua 5.1 is stable, and there is no particular reason not to use it unless you need a feature that was added in 5.2.

That said, many libraries are currently being updated to be 5.2-compatible, including LuaSocket. If you are determined and happy to compile from source and tweak makefiles, try this repository which is a 5.2 compatible version of LuaSocket.

Note that Lua 5.2 must have been built with LUA_COMPAT_MODULE defined for this version of LuaSocket to compile with it. You'll also need to edit the makefiles to adjust for the correct paths on your system.

Given another 3-4 months or so and I think many of the common libraries will be 5.2 compatible. However in my opinion unless it's small stuff, I think it is early days to be basing projects off 5.2. Porting code to 5.2 down the line is not that hard (especially if you familiarise yourself with the deprecated features so you can avoid depending on them too much in 5.1 - especially setfenv() and module()).



来源:https://stackoverflow.com/questions/9739688/luasocket-lua-5-2-and-redis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!