Welcome! Please see the About page for a little more info on how this works.

0 votes
in Macros by
retagged ago by

I've noticed something strange when macroexpanding (with-open ...)

The (finally ...) part looks something like this:
(finally (. stream clojure.core/close))

While this code does work, it just doesn't feel right to me.
I assume that, if, at some point in the future, the functin clojure.core/close is added to the core namespace, it might break.

Am I right or, maybe, the fact that the method close got namespace-qualified is irrelevant since any functio that goes inside the dot special form invocation (. object method) will be trated as a method name, regardless of its namespace?

2 Answers

0 votes
by
selected by
 
Best answer

It does look like a bug in terms of expansion (should be just (. stream close)) but you're correct - the dot form ignores the namespace of the method symbol.

+1 vote
ago by

Yep, should be cleaner in the expansion (but ignored during compilation). Added ticket and patch:

https://clojure.atlassian.net/browse/CLJ-2683

...