4 ms·
So what happens if we pass a stack closure containing a ret into another function? For example, what would this code print out: fn foo(f: fn()) { log(inf
by vilya 15y ago
So what happens if we pass a stack closure containing a ret into another function? For example, what would this code print out:
fn foo(f: fn()) {
log(info, "calling f");
f();
log(info, "called f");
}
fn bar() {
log(info, "calling foo");
foo({||
ret;
});
log(info, "called foo");
}
I'm not clear on whether the ret would return from foo or from bar - or whether it would be a compile error.
BTW thanks for taking the time to reply - I appreciate it!
- kibwen 15y agoTried compiling this myself with a main function that just calls bar(), resulting in a compiler error: `ret` in block function