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

Alias as better-cond #10

Open
vemv opened this issue Jan 10, 2018 · 5 comments
Open

Alias as better-cond #10

vemv opened this issue Jan 10, 2018 · 5 comments

Comments

@vemv
Copy link

vemv commented Jan 10, 2018

Hey there, great macro!

I find there's a 'usability' issue though:

  • I don't want to refer-clojure, it's ugly and I have to type it (potentially many times)
  • I don't want to create a meaningless :as alias like b or better, or a redundant one like better-cond

If you offered a defmacro better-cond ... alias, I could just:

  • Type better-cond
  • Hit some standard keyboard shortcut
  • Have [better-cond.core :refer [better-cond]] auto-inserted, just like with any other macro

WDYT?

Cheers - Victor

@vemv
Copy link
Author

vemv commented Jan 10, 2018

OTOH, it's not exactly expressive to have a contruct called better-cond in my code (it doesn't map to an human-language concept like when or if), but that's an acceptable tradeoff to me.

Another option would be to choose a more meaningful name. conditional? Not verbose, it has the same length as my proposed better-cond :)

@vemv vemv changed the title Alias as better cond Alias as better-cond Jan 10, 2018
@Engelberg
Copy link
Owner

Thanks for the comments, glad you find it useful.

I don't really see the benefit of your proposal.
better/cond and better-cond have the same number of characters.
And in the namespace declaration,
[better-cond.core :as better] has fewer characters than
[better-cond.core :refer [better-cond]]

So the existing mechanism is every bit as concise as your proposal.
And if you choose, you can shorten the characters even more by picking b as the alias.

@vemv
Copy link
Author

vemv commented Jan 10, 2018

Hmm, concision is not my exact concern, see the first two bullet points.

Personally I can type better-cond <keyboard shortcut> and have [better-cond.core :refer [better-cond]] auto-inserted.

I don't have to type much with either choice, but with my proposal, one's code becomes more meaningful. b is meaningless, and as mentioned I don't want to :refer-clojure

@Engelberg
Copy link
Owner

OK, if concision doesn't matter then it really comes down to:
better/cond vs. better-cond

Why do you prefer the hyphen over the slash? It's a pretty subtle difference, but I'd argue that better/cond is more meaningful because it conveys that you are using some new flavor of cond from another namespace.

But more importantly, the ability to provide an alias gives everyone total choice and preference over what matters to them. If you like the meaning of better/cond, that's your choice, and if someone else wants concision, they can choose b/cond or going through the refer-clojure ceremony to just use cond.
better-cond forces a long name on everyone, one that would get even longer for users who want to prepend an alias to make it clear where it comes from.

@vemv
Copy link
Author

vemv commented May 26, 2018

Hey there, apologies for letting this issue pile up in my email

Why do you prefer the hyphen over the slash?

Because my intended usage is requiring with :refer not :as. Introducing a thing called better is not particularly expressive. Why add the cognitive overload of introducing an alias (better) if I know it will have exactly one possible usage (cond?)

better-cond forces a long name on everyone

My suggestion was implementing better-cond as an addition, not a replacement. i.e.

(defmacro better-cond "An alias" [& args] `(cond ~@args))

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

No branches or pull requests

2 participants