with-open Close->Dispose ?
Closed this issue · 5 comments
Just a suggestion:
Maybe the .Close
call used in with-open should be replaced with .Dispose
.
Since we also have IDispose
, maybe a type-hint could be used to eliminate reflection.
Since this breaks the Clojure meaning of with-open
(use .close()
and reflection), maybe another macro with a similar name should be added to clojure-clr? using
? :-p
I think if we followed the intent of with-open and the suggested standards for handling resource release for things such as System.IO.Stream, the correct behavior would be to call .Dispose instead of .Close.
That's what I'm thinking too, but I worry about people expecting .close()/.Close() to be called. Using Dispose() and IDisposable feels the most natural alternative though (and switching platforms to the CLR for a Clojure JVM application isn't easy anyway - this would be just one more issue to keep in mind).
I don't see a lot of expectation for .Close because use of IDisposable is so widespread. Many more classes will have Dispose than Close, and the ones that have Close should have both. The people expecting .Close would be those coming from JVM Clojure with heavy Java experience, and they'll need to learn at some point whether the class they're using really has a Close method or not.
I'll change with-open to call Dispose.