lua-users home
lua-l archive

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


On Tue, Jun 9, 2015 at 1:08 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2015-06-09 1:44 GMT+02:00 Simon Cozens <simon@simon-cozens.org>:
>> On 08/06/2015 21:47, Dirk Laurie wrote:
>>> 2. Rework bit32-compat.lua to detect which Lua _VERSION is being
>>> used and provide a module that equips Lua 5.3 with bit32. This has
>>> the advantage that I might need it anyway sooner or later for other
>>> 5.2 programs but the disadvantage that the dependence on Lua 5.2
>>> with 5.1 compatibility turned on may rear its head elsewhere too.
>>
>> And Paul Kulchenko appears to have just done this, in a pull request
>> merged just now.
>
> Great! Sile 0.9.2 can typeset simple.sil under Lua 5.3 without recompiling
> if one copies over lua-libraries/bit32-compat.lua and core/utilities.lua.
>
> The new version contains the code
>
>     lib = false
>       or (pcall(require, "bit") and require("bit"))
>       or (pcall(require, "bit32") and require("bit32"))
>
> Is there a subtle reason for the construction
>      (pcall(require, "bit") and require("bit"))
> rather than just
>      pcall(require, "bit")
> ?
>

Because pcall returns true in its first return value.

/s/ Adam