I don’t know you’re getting much benefit from the apparent
contiuationess of this so much as the captured binding. I think you
get the same effect from something like the following
yeah, we were calling it a “poor man’s continuation” when we were
hacking on it. it’s not really a continuation, yet it is a thing which
allows you to continue. (so to speak.)
To Giles: no this is not a continuation, I have however never been up
to the task to understand continuations, so unfortunately I cannot
really answer your questions.
OTOH Why use the complicated stuff if the simple does? Or do you have
a hidden agenda ;).
Actually I hacked on it some more and ended up with a much simpler
version, no continuations or bindings, much easier to work with.
It just creates an object which stores stuff, basically.
I’m curious though about the difference between a continuation and a
proc you call manually when you want to continue with it. I had a book
somewhere that explained what callcc is really for, it showed how to
use call/cc in Lisp, I think Scheme, but I’m not sure where I left it.
Actually I think it was “The Scheme Programming Language.”
@closure.call if @closure
rescue => error
I think the file.rewind might not be necessary any more. I think
refactoring it into a method like that was a good idea. reopen was
kind of a hack in the original, the more fully worked-out version will
automatically reopen if you created a file (and will create different
buffers if you use different editors, brag brag brag) but I think you
could accomplish very much the same thing if you combine #vi and
#reopen like this:
(@closure ||= closure).call
rescue => error