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

+3 votes
in Clojure by

Coming from java you might expect proxy-super to be pretty innocuous, but proxy-super operates by mutating the proxy object then restoring it after the call to proxy-super is invoked. This can lead to very weird behavior. If you have a proxy with method M, which invokes proxy-super, then while that proxy-super is running all calls to M on that proxy object will immediately invoke the super M not the proxied M.

Actually making proxy-super safe (not just threadsafe, but also safe when invoked later on in the same callstack) seems like it might be really hard, but it would be nice. Alternatively some blinking hazard lights in the docstring might be a good idea.

3 Answers

+1 vote
by

Clojure's proxy implementation is a bit weird. Nathan Marz has built a competing library to provide proxy and I've extended it to support calls to superclass methods while we wait for someone to fix core Clojure.

There are some design issues; I can't see a way to mimic the semantics of Java where calls to the superclass are only made in controlled ways - Clojure's model seems to preclude that because the proxied methods could be coming from anywhere.

0 votes
by

Comment made by: freekpaans

I ran into this while trying to wrap calls to a queue: https://stackoverflow.com/questions/49862954/clojure-proxy-multithreading-issue

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-2201 (reported by hiredman)
...