I think those are necessary operations -- if you're going to use the intstack in the first place. And personally, I don't intend to. I think it's much easier to deal with a separate data structure than something tied into the interpreter struct. A free-floating intstack, if you will. But this has some of the same problems, which I'll talk about later.
I will soon be submitting a patch for an IntArray PMC (which should probably be called IntList or IntArrayList). It's a wrapper around a reworking of intstack.c. intarray.c operates almost exactly like intstack.c, only it's more suitable for calling via a PMC. Also, it seemed like it was so close to the oft-mentioned integer-only array (declared in perl6 with something like 'my int @array'), that I finished off the other common operations (shift, unshift) so that it can be used for that, too. Given this intarray, I intend languages/regex to target it instead of the user stack or the integer stack. (This partly came about because in trying to deal with dynamically-modifiable rules, I realized it would be far easier to have two integer stacks instead of one.) So instead of having to revert the stack back to some initial depth, I'll just discard the whole thing. Also, it should be easier to implement restartable regexes to implement things like perl6's :each flag (everyone else's /g flag) without going whole-hog and using continuations or coroutines. On Mon, Sep 02, 2002 at 11:46:41AM -0700, Sean O'Rourke wrote: > On Mon, 2 Sep 2002, Dan Sugalski wrote: > > > I think I'm really, *really* close to tossing the last pretense of > > being a stack-based system and move all the way to routine-based > > frames instead, which'd definitely make some things easier. > > I don't think frames help us here. This is basically a poor man's > exceptions. It's useful for regexes, where you are only accumulating > state on the intstack, so using full exceptions or (heaven forbid) > continuations is overkill. I don't know if it's a useful approach outside > of a limited regex-backtracking context. What about nested scopes? Isn't there any variable-sized stuff that needs to be popped off en masse on a scope exit? Pads or stash override chunks or whatever? C certainly has this for local variables, but I've lost track of what perl6 is supposed to use. But as for exceptions vs continuations vs whatever, I know very well where Sean is coming from. In a match where we expect to backtrack a few thousand times, I'd really rather not create a few thousand Exception or Continuation objects. So doing something lightweight with the integer stack or intarrays seems much more workable. On the other hand, hypotheticals in combination with restartable regexes are still going to be a headache. I don't know how messy that gets -- if we allow arbitrary BACK{} blocks, then it seems like we'll need to be doing the same thing for the regex instack(s) as we already have to do with the other stacks to support continuations. Maybe. I haven't really thought it through.