[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Adding direct enumeration of collections to Lua generic for loops
- From: Jean-Luc Jumpertz <jean-luc@...>
- Date: Tue, 3 Apr 2018 22:31:39 +0200
> Le 3 avr. 2018 à 20:57, Michal Kottman <k0mpjut0r@gmail.com> a écrit :
>
> What are the differences between your approach and "Self-iterating Objects" patch from http://lua-users.org/wiki/LuaPowerPatches ?
Good point, I was not of the existence of this specific power patch. After reading it, I would say that the need and the idea is essentially the same.
However it differs by the way it is implemented:
- the power patch modifies the behavior of the OP_TFORCALL instruction, executed at every iteration of the loop, and adds code for detecting if this is the first iteration, and in this case to modify the registers used by this instruction to force « self-iteration » iteration;
- my implementation adds a new instruction OP_TFORPREP that is executed only once when the loop is initialized, and is symmetrical with the OP_FORPREP used to initialize the numeric for. In this regard, I would consider it as less hack-ish than the power patch…
Although these differences are mainly implementation details, this thread could have the interest of bringing back the feasibility and benefits of this feature to the top of the stack. :-)