This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-23
Channels
- # adventofcode (135)
- # announcements (9)
- # babashka (27)
- # beginners (97)
- # bristol-clojurians (8)
- # calva (7)
- # chlorine-clover (1)
- # cider (3)
- # clara (16)
- # clj-kondo (9)
- # cljdoc (137)
- # clojars (4)
- # clojure (110)
- # clojure-europe (118)
- # clojure-taiwan (8)
- # clojure-uk (19)
- # clojurescript (30)
- # conjure (6)
- # cryogen (32)
- # datomic (11)
- # depstar (1)
- # duct (4)
- # emacs (6)
- # fulcro (73)
- # graalvm (9)
- # keechma (7)
- # leiningen (16)
- # luminus (1)
- # malli (35)
- # meander (3)
- # off-topic (45)
- # pathom (1)
- # pedestal (2)
- # re-frame (3)
- # reagent (31)
- # reitit (2)
- # reveal (17)
- # shadow-cljs (34)
- # tools-deps (11)
- # xtdb (14)
@U050SC7SV because git diff?
no, often the aligned version ends up in a mess, and visually I prefer to have things paired close to each-other
personally I think it's easier to read, but I know it's quite personal, some people like one or the other
Maybe this should be an editor feature: render like you would like to see it, without touching the source code
@U04V15CAJ you mean, like, tabs!
cljfmt can enforce one way (non aligned via :remove-multiple-non-indenting-spaces?
) not the other way around
it's a bit wild with the aligned version, you have to decide on thresholds if you want to do it consistently. It's not as easy for tooling
tools, by default, align afaict; probably because bbtasov's https://guide.clojure.style/#bindings-alignment
emacs (cider) doesn't align by default, not in the way we mean with "align" on this thread at least
Yes, although the example given shows the vars being the same length, and the alignment affecting the names. It would have been better to show the vars of different lengths and either keep the values together, close - or to align the values to clearly show that the names of the keys are not important.
fwiw I just turn the setting on in clojure-mode on emacs ( (setq clojure-align-forms-automatically t)
) and never need to tweak or configure it from there. If something gets really awkward I just add an extra line which resets the alignment level
(let [thing-one-is-really-long 1
another-long-one 5
x 4
abc 4])
(let [thing-one-is-really-long 1
another-long-one 5
x 4
abc 4])
I align maps and don't align let bindings. Only the former tend to be homogeneous (same types of key/values). clojure.test/are
is also ace to align.
As a maybe interesting experience to share, I aligned nothing and actively hated alignment for many years. But once I was forced to use it, I haven't wanted to go back ever since.
The key thing is to see alignment as "tables" instead of some fanciful rearrangement. tables rock, you can see e.g. make a table
in https://clojure.org/dev/developing_patches (I know that's a totally unrelated context, but you'll see tables coming up in various talks)
From my (rather limited) experience, alignment cannot work consistently in LISPs due to their extensibility, and those inconsistencies really bother my OCD.
In theory, it's easy: just align the pairs in let
s and maps. What about binding forms in doseq
s?— I guess, yes, but what about their inner :let
s? Ok, we can teach the editor to detect all these in clojure.core, but what about taoensso.encore/when-let
? With all the macros everywhere, I either have to spacebar the alignments manually, or the IDE has to be really, really smart (haven't seen one smart enough yet).
Same for maps, {:k1 v1 :k2 v2}
are obvious, but what about map-like constructs, like vararg pairs in (assoc x :k1 v1 :k2 v2) — same problem with consistently detecting what is a map and what isn't, in my opinion.
Add to that the bugs in editors, which sometimes lead to alignment not being triggered — all those inconsistencies made me give up on the beauty, and just opt for predictability.
i'm making a geocache puzzle, and the solution of the puzzle is a list of numbers (the coordinates for the next cache). i'm looking for a simple checksum operation that can be used to verify the results, does anyone know a simple checksum that can be computed using pen and paper?
there's the one that numerology uses: keep recursively summing digits until you have just one digit
that's easy on pen and paper, and a lot of people can do it in their head
What do you mean recursively? Compute sum of digits, then compute the sum of digits of the sum, etc? The result is just x mod 9 then, and if x is positive and divisible by 9 it is 9.
@U051SS2EU thanks, this is definitely suitable for pen and paper.
@UQ4RJ22EA I think you are right, it's not a very sophisticated algorithm, but it's a very simple one that many people already know, and will catch 8/9 errors on average I guess
The https://en.wikipedia.org/wiki/Luhn_algorithm while easy to do on paper, is probably not possible to do in one's head.