A fresh new minor release of ABS: always be shipping! 🚢
This is a small one, but we wanted to get defer
out of the way, after lying in our 2.6.x
branch for months.
Ability to defer
functions
Sometimes it is very helpful to guarantee a certain function is executed
regardless of what code path we take: you can use the defer
keyword for
this.
echo(1)
defer echo(3)
echo(2)
When you schedule a function to be deferred, it will be executed right at
the end of the current scope. A defer
inside a function will then
execute at the end of that function itself:
echo(1)
f fn() {
defer echo(3)
echo(2)
}
fn()
echo(4)
You can defer
any callable: a function call, a method or even a system
command. This can be very helpful if you need to run a cleanup function
right before wrapping up with your code:
defer `rm my-file.txt`
"some text" > "my-file.txt"
...
...
"some other text" >> "my-file.txt"
In this case, you will be guaranteed to execute the command that removes
my-file.txt
before the program closes.
Be aware that code that is deferred does not have access to the return value
of its scope, and will supress errors -- if a defer
block messes up you're
not going to see any error. This behavior is experimental, but we would most
likely like to give this kind of control through try...catch...finally.
What else has changed?
- Bump follow-redirects from 1.13.3 to 1.14.9 in /docs by @dependabot in #472
- Bump postcss from 7.0.35 to 7.0.39 in /docs by @dependabot in #471
- Bump minimist from 1.2.5 to 1.2.6 in /docs by @dependabot in #470
- Bump url-parse from 1.5.1 to 1.5.10 in /docs by @dependabot in #468
- Bump async from 2.6.3 to 2.6.4 in /docs by @dependabot in #473
- Bump prismjs from 1.23.0 to 1.27.0 in /docs by @dependabot in #467
Full Changelog: 2.5.2...2.6.0