[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] luaproc 1.0-4
- From: Mason Bogue <scythe+lua@...>
- Date: Wed, 7 Oct 2015 11:06:47 -0700
After some consideration, I think you should allow passing light
userdata, but remark that they're explicitly unsafe (maybe require it
be allowed via a compilation flag?). Light userdata are after all just
(void *), which means they're really uintptr_t's, i.e. scalars, and so
all of the normal caveats of passing around a C pointer already
applies to them. One could after all imagine a function that does "x =
* (double *) &y;" being used to pass light userdata as numbers.
On Tue, Oct 6, 2015 at 9:50 AM, Andrew Starks <email@example.com> wrote:
> On Tue, Oct 6, 2015 at 11:12 AM, Rena <firstname.lastname@example.org> 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...