I’ll just cross my fingers for do expressions getting adopted. Before then functions work for me and none of the gist convinced me otherwise.
/* do */ {
const foo = “bar”
do_the_stuff(foo)
} /* while(JS_sux) */
Typing code on a phone is hard…There's also a GCC extension for this! https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
I'm using this for something a bit like Rust's unwrap (but uglier):
#define UNWRAP(expr) \
{{ \
auto result_ = (expr); \
if (!result_.present()) panic(); \
result_.disown(); \
}}
optional<int> foo();
void bar() {
int val = UNWRAP(foo);
}