Fork me on GitHub
#interop
<
2020-07-11
Crispin10:07:10

Hi everyone. I have some java code I'm porting and I've never seen this try form before

Crispin10:07:28

try ( MemoryStack stack = stackPush() ) {
   ...
}

Crispin10:07:13

how is the part that appears inside the () executed? Why is it not inside the try block after the {?

Crispin10:07:32

It is some kind of auto try/finally with-* kind of context manager?

Crispin10:07:40

because at the end the demo code says:

Crispin10:07:18

} // the stack frame is popped automatically

Crispin10:07:07

So I just use (with-open [stack (stackPush)] ...)

Crispin10:07:15

:the_horns: