Re: [Proposal] Thread Metatable
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: [Proposal] Thread Metatable
- From: "Soni L." <fakedme@...>
- Date: 2015年6月23日 16:45:19 -0300
On 23/06/15 04:31 PM, Sean Conner wrote:
It was thus said that the Great Soni L. once stated:
On 23/06/15 03:57 PM, Sean Conner wrote:
On Tue, Jun 23, 2015 at 2:11 PM, Soni L. <fakedme@gmail.com> wrote:
__call and co() makes it look like a function call, which may be kinda
confusing. On the other hand OOP syntax co:resume() is more Lua-like, as
strings have it too. You also cannot index functions.
Yes you can.
function foo(x)
return 3 * x + 5
end
mt =
{
__index = function(obj,idx)
local d = string.dump(obj)
return d:sub(idx,idx)
end
}
debug.setmetatable(foo,mt)
Try it without debug.
lua_getglobal(L,"foo");
lua_getglobal(L,"mt");
lua_setmetatable(L,-2);
-spc
...
File handles can use oop syntax;
Strings can use oop syntax (only thing you don't call a library function
to create that has a metatable);
So why can't threads? They're like file handles, as in you call a
library function to create them. This would just increase consistency a
bit. (another option would be to make it so file handles don't have a
metatable and you have to call io.write(fd, ...) and such instead)
(I can't think of anything else that would feel "better" with
metatables... adding metatables to numbers (with __index being `math`)
would be just weird: n:tointeger(), n:pow(0.5), etc (mostly because
they're, y'know, _math_ functions. if we had a `number` library then
/maybe/ I'd be ok with it.))
--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.
- References:
- [Proposal] Thread Metatable, Soni L.
- Re: [Proposal] Thread Metatable, Dirk Laurie
- Re: [Proposal] Thread Metatable, Luiz Henrique de Figueiredo
- Re: [Proposal] Thread Metatable, Sean Conner
- Re: [Proposal] Thread Metatable, Soni L.
- Re: [Proposal] Thread Metatable, Rena
- Re: [Proposal] Thread Metatable, Soni L.
- Re: [Proposal] Thread Metatable, Sean Conner
- Re: [Proposal] Thread Metatable, Soni L.
- Re: [Proposal] Thread Metatable, Sean Conner