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

Multi-line namespaced maps #144

Open
Looveh opened this issue Dec 14, 2016 · 3 comments
Open

Multi-line namespaced maps #144

Looveh opened this issue Dec 14, 2016 · 3 comments
Labels

Comments

@Looveh
Copy link

Looveh commented Dec 14, 2016

What is the suggested level of indentation of multi-line namespaced maps?

;; no indentation
#:my-ns 
{:k :v}

;; one space
#:my-ns 
 {:k :v}

;; two spaces
#:my-ns 
  {:k :v}
@bbatsov
Copy link
Owner

bbatsov commented Jan 5, 2017

Someone else should answer this. I've never seen such map in my life. :-)

@skadinyo
Copy link

skadinyo commented Jan 8, 2017

Personally when using namespaced maps i avoid giving a newline after the namespace.
I want put the namespace before the maps explicitly and my cider repl print it without giving newline.

experiment> (identity
             #:my-ns{:k :v})
#:my-ns{:k :v}

experiment> (identity
             #:my-ns {:k :v})
#:my-ns{:k :v}

But i still confused whether giving space between the namespace and maps or not.

;; no newline
#:my-ns{:k :v}

;; no newline with space
#:my-ns {:k :v}

I think it's like putting metadata notation from the guide.

;; good (from the guides)
(def ^:private a 5)

;; bad (just examples, not from the guide)

(def ^:private 
  a 5)

(def ^:private
     a 5)

(def ^:private
      a 5)

(def ^:private
       a 5)

Maybe it need to be added to the guides after discussing it first of course. It will be a rule about using namespaced maps.
The possibilities are

;;from Looveh

#:user
{:username "foo"
 :role :bar}

#:user
 {:username "foo"
  :role :bar}

#:user
  {:username "foo"
   :role :bar}

;; without newline

#:user{:username "foo"
       :role :bar}

;; without newline but with space

#:user {:username "foo"
        :role :bar}

;; sometimes i use this to if the maps are small

{:user/username "foo"
 :user/role :bar}

@kgann
Copy link

kgann commented Jan 10, 2017

For those like myself who were previously unaware of namespaced maps, see http://dev.clojure.org/jira/browse/CLJ-1910

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

No branches or pull requests

4 participants