interop

Crispin 2020-07-11T10:32:10.016300Z

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

Crispin 2020-07-11T10:32:28.016700Z

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

Crispin 2020-07-11T10:33:13.017600Z

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

Crispin 2020-07-11T10:33:32.018100Z

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

Crispin 2020-07-11T10:33:40.018300Z

because at the end the demo code says:

Crispin 2020-07-11T10:34:18.018700Z

} // the stack frame is popped automatically

Crispin 2020-07-11T10:43:39.019300Z

and that led me to https://stackoverflow.com/questions/46670958/try-with-resources-in-clojure

Crispin 2020-07-11T10:44:07.019900Z

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

Crispin 2020-07-11T10:44:15.020100Z

:the_horns: