If you feel like frustration hacking on that branch, you are very welcome!
My plan would be something like that:
1) Rebase to current 8.1 (will do that now) 2) Fix the current state. I do not remember what the problem really was, but I do recall that it does not pass the testsuite. 3) Cleanup 4) Optimize 5) New features. With a better API it might be feasible to implement continuations and possibly other things. Its worth a discussion. By the way, when is the next pike conference?
Some details: 3) - As I mentioned in my previous email, the tail recursion optimization creates a new frame and then replaces the previous one on the stack. This could be improved by resetting the current frame, so that execution resumes at the beginning of the function. I suspect that it works the way it does currently because the previous API makes it hard to do the call _without_ setting up a new frame. - That new branch introduces frame->type, which did not previously exist. It makes struct pike_frame even bigger than it already is. Not all members of the frame struct are used for all frame types, so it would make sense to place some of them inside of a union.
4) - Use the new API in more places like filter and automap. - I also really like your idea of caching the last frame. I was thinking about something similar, except that I did not think of using the frame for that, but instead cache it globally. Also, in many situations it is actually not enough to cache only one frame, instead we need 2 or more:
foreach (foo; mixed key; mixed val) bar();
During one iteration, this calls both next() in the iterator of foo and bar(). Its probably a good idea to experiment with that.
Arne
On 04/11/16 20:41, Martin Karlgren wrote:
Ah, very interesting. Now that you mention it, I recall seeing something about this on the list but apparently I failed to recall it before implementing something on my own… ;) Your refactoring looks much more appealing though, so I’ll definitely vote for your branch. What’s left to be sorted out?
Another idea I had, which I don’t know whether it’s feasible or not, was to populate a frame cache in the parent frame when a function is likely to be called repeatedly (e.g. inside foreach) – but let’s sort out the basic stuff first...
(I have very little spare time because of kids, but every once in a while I’ll make a “frustration hack” ;) )
/Marty