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

nil punning confusing? #44

Closed
travis opened this issue Mar 26, 2013 · 5 comments
Closed

nil punning confusing? #44

travis opened this issue Mar 26, 2013 · 5 comments

Comments

@travis
Copy link

@travis travis commented Mar 26, 2013

This is probably getting dangerously close to personal preference territory, but

;; bad
(defn print-seq [s]
  (when-not (empty? s)
    (prn (first s))
    (recur (rest s))))

reads a lot better to me than

;; good
(defn print-seq [s]
  (when (seq s)
    (prn (first s))
    (recur (rest s))))

even after having used Clojure for 3 years, including lots of time writing it for my day job. Is there something we could link to explaining why nil punning is desirable/better here?

@jeremyheiler

This comment has been minimized.

Copy link
Contributor

@jeremyheiler jeremyheiler commented Mar 26, 2013

The only thing I can think of is that empty? is implemented as (not (seq coll)).

@bbatsov

This comment has been minimized.

Copy link
Owner

@bbatsov bbatsov commented Mar 26, 2013

Rich promotes the nil punning, which weighted in its favour.

@travis

This comment has been minimized.

Copy link
Author

@travis travis commented Mar 26, 2013

Ah, indeed, this seems like the relevant thread:

https://groups.google.com/forum/?fromgroups=#!topic/clojure/gWvXoHa7-t4

I can submit an update linking to that from the style guide if that sounds appropriate to you!

@bbatsov

This comment has been minimized.

Copy link
Owner

@bbatsov bbatsov commented Mar 26, 2013

Yep, that sounds good.

Cheers,
Bozhidar

On Tuesday, March 26, 2013 at 6:38 PM, Travis Vachon wrote:

Ah, indeed, this seems like the relevant thread:
https://groups.google.com/forum/?fromgroups=#!topic/clojure/gWvXoHa7-t4
I can submit an update linking to that from the style guide if that sounds appropriate to you!


Reply to this email directly or view it on GitHub (#44 (comment)).

@travis

This comment has been minimized.

Copy link
Author

@travis travis commented Mar 26, 2013

oh shoot, I missed that this is a dupe - #22

I think my patch will also attempt to qualify that style rule to reflect the lack of widespread agreement that @technomancy describes.

@travis travis closed this Mar 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.