-
Notifications
You must be signed in to change notification settings - Fork 279
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
Suggest ok to seemingly mask/shadow built-ins #204
Comments
Hej, I don't think that this is a common way how to do it. I see usage of
from https://stuartsierra.com/2015/05/10/clojure-namespace-aliases |
It might be worth some analysis across several code bases. The bigger point I guess I want to make (beyond in-project consistency) is that it'd be nice to standardize the community on some as much as possible. E.g., in my Emacs config for clj-refactor, I've enjoyed the consistency and auto-requiring of this: '(cljr-magic-require-namespaces
(quote
(("io" . "clojure.java.io")
("set" . "clojure.set")
("str" . "clojure.string")
("walk" . "clojure.walk")
("zip" . "clojure.zip")
("json" . "cheshire.core")
("xml" . "clojure.data.xml")
("as" . "clojure.core.async")
("mat" . "clojure.core.matrix")
("edn" . "clojure.edn")
("pp" . "clojure.pprint")
("spec" . "clojure.spec.alpha")
("csv" . "clojure.data.csv")
("time" . "java-time")
("spr" . "com.rpl.specter")
("http" . "clj-http.client")
("log" . "clojure.tools.logging")
("s3" . "amazonica.aws.s3")
("sql" . "hugsql.core")
("yaml" . "clj-yaml.core")
("sh" . "clojure.java.shell")
("w" . "clojure.walk")
("fs" . "me.raynes.fs")
("r" . "reagent.core")
("rf" . "re-frame.core")))) Those are personal and probably too broad for adoption, but the idea is sound for the most common ones. I don't care a lot whether the alias convention for Here are aliases that get used a lot (includes |
Hmm.... ;) I think the general rule (of the short name being the last component) is fine, but don't mind exceptions for a few commonly used namespaces (especially something like Thanks for the list and link though! |
Follow Idiomatic
require
aliasesThe most common way to require string is:
[clojure.string :as str]
. This may appear to mask clojure.core.str, but it doesn't. It's expected thatclojure.core/str
andclojure.string/*
to be used in a namespace asstr
andstr/whatever
without conflict.The same applies to
clojure.set :as set
and the built-inset
.Across a project, it's good to be consistent with namespace aliases; e.g., don't require string as
str
in one NS butstring
in another.The text was updated successfully, but these errors were encountered: