lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 4 September 2013 13:08, Philipp Janda <siffiejoe@gmx.net> wrote:
> Am 03.09.2013 22:09 schröbte Hisham:
>>
>> Hi,
>
>
> Hi!
>
>
>>
>> Feedback, contributions, pull requests and criticism are welcome!
>
>
> 1) You do:
>
>     local unavailable = function() error("compat52: Do not use this
> function. It is incompatible with Lua 5.2") end
>
>     setfenv = unavailable
>     getfenv = unavailable
>
> This breaks code like
>
>     ...
>     if setfenv then
>       setfenv( chunk, env )
>     end
>     ...
>
> which, I think, is a common idiom for code targeted at both Lua 5.1 and 5.2.
> See e.g. here[1] ...
>
>   [1]:  http://comments.gmane.org/gmane.comp.lang.lua.general/99000

Good point. (I even do that myself in the LuaRocks codebase, but since
your pull request I'm even thinking about adopting compat52 there too
and just using loadfile :) )

My intention was to catch 5.1-isms when running under Lua 5.1 (ie, to
help one to write code that runs on both), but I guess it's better to
leave the symbol untouched, or perhaps to add a "strict mode".

> (It also breaks my preferred idiom (`if _VERSION == "Lua 5.1" ...`), but
> since I cache all my globals I can just load my modules before require'ing
> compat52.)
>
> How about a warning on stderr that you can disable via an environment
> variable instead of the error?
>
>
> 2) `table.unpack` is still available as a global `unpack` in Lua 5.2 if
> `LUA_COMPAT_UNPACK` is defined.

Not sure about how to deal with the deprecated stuff. Maybe a
compat52.strict module is really a good idea. :)

-- Hisham
http://hisham.hm/