This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-06-09
Channels
- # admin-announcements (74)
- # beginners (10)
- # boot (3)
- # cider (3)
- # clojure (94)
- # clojure-brasil (7)
- # clojure-czech (9)
- # clojure-france (4)
- # clojure-nl (2)
- # clojure-russia (50)
- # clojure-sg (7)
- # clojure-uk (1)
- # clojure-ukraine (1)
- # clojurescript (244)
- # core-async (1)
- # datomic (13)
- # editors (28)
- # euroclojure (9)
- # jobs (6)
- # ldnclj (78)
- # off-topic (12)
- # onyx (16)
- # reading-clojure (1)
- # reagent (10)
- # sneer (2)
- # sydney (1)
i have a weird question to community: how many columns considered to be a standard style for clojure source code width?
i think we’ve settled on 100, which is the widest that two panes of code can fit side by side on one of our engineer’s funny 1280x900 laptops
we all have an emacs thing that colours stuff beyond that point differently
i guess we have no one, consider my question like a poll or something. i'm in doubts, so happy to hear numbers and reasoning, exactly in the same way @robert-stuttaford wrote (thanks!). I'm using 80 for a year, chosen it just to stick to smth. sane, but sometimes it seems too narrow, code becomes too much extended vertically, especially taking in account lisp-style argument alignment
Here's an argument from authority for <=80 loc: https://github.com/bbatsov/clojure-style-guide#80-character-limits
otherwise i just turn off whitespace-mode (the emacs thing that highlights columns >80)
@escherize: thanks for the link, when i've read this guide last time it had no note about character limit
There was a reason for 80 chars, back in the day when we thought vt100 terminals were cutting edge. But, surely, not any more. I'm absolutely a 100 char guy these days. That 80 char thing was a completely arbitrary limit forced by hardware and nothing to do with a good software reading/layout experience.
narrower columns make for nice side-by-side diffs or three-way diffs. helps!
I’ve found that 80 character width is just too narrow - 100 characters works well for me
Sometimes a wider row can be a code smell, but a value between 100 and 120 is working well for the team.
does any shortcut already exist to extend protocol for several types with identical functions? like this:
(extend-protocol IProtocol
AType
BType
(protocol-fn [_] "hello!"))
instead of
(extend-protocol IProtocol
AType
(protocol-fn [_] "hello!")
BType
(protocol-fn [_] "hello!"))
@ul Perhaps define your own simple extend-protocols
macro? Don't think there's a shorthand in core
yes, that the path i will follow if no smth. standard. and i guess it actually doesn;t exist
@ul there is clojure.core/extend (http://conj.io/store/v1/org.clojure/clojure/1.7.0-alpha4/clj/clojure.core/extend/)
I like to stick to 80, because my font (Monaco 14) and side-by-side Emacs windows wrap at 86 chars. But no biggie.
you should try M+ as a font: http://mplus-fonts.osdn.jp/
it’s very narrow but still readable, ideal if you split windows a lot
@martinklepsch: Ah cool, I'll check it out!
http://www.fsd.it/fonts/pragmatapro.htm#.VXbD8Sp7ZE4 for me - the best font ever for programming
@delaguardo: that looks also interesting, thx
@ul 80 columns for me. I just disable Lisp argument alignment in all my editors. I find it unbearable. 2 space indent always except for data structure literals.
@dnolen: Is there an easy way to do that in Emacs or do you just redefine all these: https://github.com/clojure-emacs/clojure-mode/blob/master/clojure-mode.el#L798-L869
@dnolen the day it is the indentation in my code that makes it ugly is the day I will be happy 😉
I got this Scala method : def apply[T](clauses: (Double, Element[T])*) which I would like to call from Clojure.
Reflecting on the method I see clauses is a scala.collection.Seq - but what is it a Seq of?
@steph: my guess would be Tuple2's
but i've been out of that game for quite awhile
@stephen: no prob
@stephen: i’ve used this a bit while trying do use sparkling https://github.com/t6/from-scala
Wondering: (first (remove nil? (map (fn [x] (println x) x) [:tolo nil :test])))
in my understanding this should be lazy and only print :tolo
— why isn’t it?
(first (remove nil? (map (fn [x] (println x) x) '(:tolo nil :test))))
works as expected
I don’t really need it but now I’m wondering how I can turn a vector into a lazy seq, is that possible at all?
If you run this: (first (remove nil? (map (fn [x] (println x) x) (seq [:tolo nil :test]))))
it’s not lazy @stig
ghadi: that might be it. But why did the literal ‘(:tolo nil :test) work as expected then?
Maybe it’s the right time to go “one level up”: What I’m really trying to achieve is some short circuit like behaviour that returns the first non-nil result — not executing f
on any remaining items
it’s not about the side effect, the function that returns nil
or something (which I want) is expensive
the vector literal has it's own evaluation semantic
err, its
@martinklepsch: : e.g. it behaves like (vector 1 2 (doto 3 println))
, evaluating its contents before returning itself
relevant: https://github.com/Prismatic/plumbing/blob/master/src/plumbing/core.cljx#L172-L195
Thanks everyone, somehow I thought that if I use map
it will just treat any passed list as lazy
@martinklepsch: Perhaps make use of reduced
to terminate?
(reduce (fn [acc x] (println x) (if-not (nil? x) (reduced x))) nil [:tolo nil :test])
(You’d apply your f
inside the nil?
check, perhaps saving the value with an if-let
or somesuch.)
@martinklepsch: (reduce (fn [acc x] (println x) (if-some [y (identity x)] (reduced y))) nil [:tolo nil :test])
, replacing identity
with your f
?
New blog post on Reader Conditionals - http://danielcompton.net/2015/06/10/clojure-reader-conditionals-by-example
on the top-level thing, in some cases you could also wrap in a (do ) instead of splicing, although at that point you should probably question whether you should be using reader conditionals in the first place or just provide different namespace implementations specific to the platform
@alexmiller: I thought I did describe that? > or use a do to wrap all of the top level functions:
or do you mean somewhere else?
you did :)
I hadn't finished reading :)
I think my pull request for the clojure-maven-plugin went in today to support cljc files :)
@alexmiller: I was wondering about that. Will that support .cljc test files too?
I still don't get what `'~ does, is there any article or simple explanation about it
sometimes you want macro to put one of its arguments literally as it is typed in source code