As you may have noticed, I have added the :defer command.
It works mostly like it does in the Go language: you can define a
function to be called when the current function returns.
The arguments are evaluated at the :defer command, thus you can also use
it inside a loop, e.g. when creating a bunch of temp files:
for n in range(5)
var fname = $'tempfile{n}'
CreateFile(fname)
defer delete(fname)
# do some work here
endfor
On top of that, the writefile() and mkdir() functions have a new flag
that tells them to defer a delete() function call to clean up what was
written. This is especially useful in tests, where we often create a
script file that needs to be deleted once the test is done. Many times
the delete() was missing or used the wrong name.
for n in range(5)
writefile(text[n], $'tempfile{n}', 'D')
endfor
Please give it a beating and see if it works as advertised.
I'll update the tests to use these new features soon.
--
hundred-and-one symptoms of being an internet addict:
32. You don't know what sex three of your closest friends are, because they
have neutral nicknames and you never bothered to ask.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///