lua-users home
lua-l archive

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

On Tue, Oct 6, 2015 at 11:12 AM, Rena <> wrote:
> I think you could use a __serialize metamethod here, when you don't have a
> built-in handler. Then userdata, magic tables and other objects could define
> handlers as easily as they do other metamethods.


I've often used __tostring for this, but then that wrecks my (often
needed) method for pretty printing. I'm also guilty(?) of using two
underscores, which I believe is, by documentation (?), reserved for
the language. But I do it too...

Overall, however, a serialize metamethod has been my preferred way of
figuring this stuff out. We also found ourselves wanting to know if
the message was going inter-process or just inter-thread, but that's
too fancy for this purpose.

We've also wished for *one* way to marshal userdata to and from
threads. Love2D does this, but it's not at the API level. I believe
that others do it to. We played with our own method, which was
basically a wrapper struct.

.... I think that... things that make different Lua environments
(Love2D, Luvit, Lua 5.3, etc) interoperate with minimal glue code are
good... I don't get the impression that endless freedom is a "good
thing", at least in the way that it often is, when working with event
loops or timing libraries...