Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognise alternative let-like formats #76

Open
vemv opened this issue Feb 2, 2021 · 4 comments
Open

Recognise alternative let-like formats #76

vemv opened this issue Feb 2, 2021 · 4 comments

Comments

@vemv
Copy link
Contributor

vemv commented Feb 2, 2021

Brief

The following vars:

(def let-like-forms '#{let if-let when-let if-some when-some loop with-open
dotimes with-local-vars})
(def defn-like-forms '#{defn defn- fn defmacro})
(def doseq-like-forms '#{doseq for})
(def letfn-like-forms '#{letfn})

represent closed sets and typically only will work over clojure.core symbols. So if one uses e.g. my/let, completion accuracy will degrade.

Proposal

In:

(cond (let-like-forms (first form))

Instead of doing (first form) (which will return let, my/let, etc), perform (-> form first name symbol). This way let-like-forms will work as usual, but also admitting alternative mechanisms that share the name but use a different namespace.

Same for defn, doseq, letfn.

Alternatives

Consumers could use alter-var-root! over the mentioned vars, although that doesn't seem a clean thing to do (and would also have to account for different ns aliases: my/let, com.domain.my/let, etc - which is not a closed set)

Thanks - V

@alexander-yakushev
Copy link
Owner

Hi, could you please check #77 first? Would it perhaps be enough if I merged something like that?

@vemv
Copy link
Contributor Author

vemv commented Oct 21, 2021

#77

@vemv vemv closed this as completed Oct 21, 2021
@alexander-yakushev
Copy link
Owner

alexander-yakushev commented Oct 21, 2021

Actually, I agree with your point that it makes sense having it "for free" for symbols that have names exactly like let and defn. I mean, what's the worst that can happen? We guard ourselves against errors already, so at worst we might suggest some redundant locals within such macros, whatever.

I'll keep this open for now.

@vemv
Copy link
Contributor Author

vemv commented Oct 21, 2021

Ok nice!

I have a patch around, should be at hand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants