[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Removing limitations of OP_SELF
- From: "Soni L." <fakedme@...>
- Date: Wed, 17 Dec 2014 13:26:56 -0200
On 17/12/14 03:26 AM, Dirk Laurie wrote:
2014-12-17 4:54 GMT+02:00 Soni L. <fakedme@gmail.com>:
First of all I want to be able to _G:table.insert("something").
Secondly, I want to be able to _G:["print"]().
What exactly are these supposed to be syntax sugar for?
It's opcode sugar, actually.
_G:["print"](...) is already supported by the opcode, just use a
non-constant index. It basically translates to _G["print"](_G, ...) (but
_G only gets evaluated once).
_G:table.insert("something") is a bit trickier to implement. (it uses
more opcodes) But think about it like this: in the same way that
_G:print() translates to _G.print(_G), _G:table.insert("something")
translates to _G.table.insert(_G, "something"). (add `do local _ = _G
... end` boilerplate as needed)
And ofc, _G:["table"]["insert"]("something"), I guess you can guess what
this does.
--
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.