clojure-emacs / orchard

A fertile ground for Clojure tooling
Eclipse Public License 1.0
326 stars 54 forks source link

Infer var metadata for 'proxy' vars #171

Closed vemv closed 1 year ago

vemv commented 1 year ago

Part of https://github.com/clojure-emacs/cider-nrepl/issues/788

Use case explained over there.

...I had attempted this before: https://github.com/clojure-emacs/cider-nrepl/pull/790 but it was targeting the wrong middleware. This impl is simpler / more predictable, needing no pmap-like parallelism.

I've tried this one locally, and it works as intended.

Works on CLJ and CLJS, tests added for both.

Cheers - V

bbatsov commented 1 year ago

Is proxy/proxied the right terminology here? I think alias/aliased is much more accurate way to describe this.

vemv commented 1 year ago

I can see how 'proxy' is an overloaded term, but 'aliased' immediately brings to mind namespace aliases, which would seem greatly confusing to me (particularly in a project that already deals with aliases).

delegate might work, but I'd fail to see a difference with proxy.

bbatsov commented 1 year ago

When I hear of Clojure and proxy I immediately think of https://clojuredocs.org/clojure.core/proxy That's why I don't like this. And your examples in the tests are really aliases, after all this terminology extends to more than namespaces.

I'm open to other suggestions, even if I can't offer anything better than alias myself. @alexander-yakushev Any suggestions from you are welcome as well!

bbatsov commented 1 year ago

Btw, I don't want us to spend too much time on this - the implementation seems good and solves a real problem. If we don't come up with a better name relatively quickly (a day or so), I'm fine to stick with the current terminology.

alexander-yakushev commented 1 year ago

When I hear of Clojure and proxy I immediately think of https://clojuredocs.org/clojure.core/proxy That's why I don't like this. And your examples in the tests are really aliases, after all this terminology extends to more than namespaces.

I absolutely agree; I was reading through the code waiting and waiting where a proxy finally comes up, and only understood what it is about when looked at the tests.

I think it's worth picking up a better term. alias has its confusion too but still better than proxy. Maybe something like "indirect"? "Pass-through"?

vemv commented 1 year ago

Thanks for the input! I'll consider those.

How about "delegate vars"?

bbatsov commented 1 year ago

I think I like the most indirect as it's hard to confuse with anything else. When I here of delegate I immediately think of https://en.wikipedia.org/wiki/Delegation_pattern :-)

alexander-yakushev commented 1 year ago

Same, I think of delegates in C++/C# (i.e., function pointers).

vemv commented 1 year ago

Merging. btw, I tested out this with Compliment and it works there too 🍻