lua-users home
lua-l archive

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


2017-07-27 12:40 GMT+02:00 Pierre Chapuis <catwell@archlinux.us>:

> I tried to do something like this:
>
>     local mp = require "MessagePack"
>     local pretty = require "pl.pretty"
>     pretty.dump(mp)
>
> the Penlight code does something like:
>
>     for _ in ipairs(mp.packers) do end
>
> and it fails with:
>
>     lua: /usr/share/lua/5.3/MessagePack.lua:46: pack '1' is
>     unimplemented
>
> because of a metamethod on the `packers` table [1].
>
> How would you keep the feature of raising an error on direct access, but
> still make it work with `ipairs`?

Choose one.

1. Tell the developers of the two modules to get their act together.

2. Modify the copy of Penlight on your machine.

3. Redefine the global 'ipairs' (pl.pretty does not cache it locally)