This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-11
Channels
- # adventofcode (31)
- # announcements (6)
- # babashka (5)
- # beginners (93)
- # calva (15)
- # cider (20)
- # cljs-dev (16)
- # clojure (159)
- # clojure-berlin (1)
- # clojure-dev (5)
- # clojure-europe (9)
- # clojure-italy (9)
- # clojure-losangeles (2)
- # clojure-nl (26)
- # clojure-spec (7)
- # clojure-uk (33)
- # clojurescript (54)
- # clojutre (5)
- # cursive (20)
- # datomic (23)
- # emacs (19)
- # events (1)
- # expound (1)
- # figwheel-main (1)
- # fulcro (104)
- # hyperfiddle (1)
- # jobs (1)
- # luminus (10)
- # malli (59)
- # nrepl (1)
- # off-topic (11)
- # pathom (5)
- # planck (15)
- # reagent (13)
- # reitit (8)
- # rewrite-clj (10)
- # ring-swagger (3)
- # shadow-cljs (129)
- # tools-deps (46)
- # xtdb (14)
- # yada (1)
Hi guys, I recently bought the Programming Clojure book and there is this code example
(defn preds-seq []
(->> (all-ns)
(map ns-publics)
(mapcat vals)
(filter #(clojure.string/ends-with? % "?"))
(map #(str (.-sym %)))
vec))
But I am not sure what is the .-sym
function, I couldn’t fine any docs about it.
Does anyone has an idea what function is that?
Thanks!.- is a Java interop call for field access
. Is Java interop for either method or field access - if both exist, the method takes precedence. .- is field only.
since the book came out, there's a new arity of symbol
that actually makes the field access here unnecessary
(->> (all-ns) (map ns-publics) (mapcat vals) (filter #(clojure.string/ends-with? % "?")) (map symbol) vec)
well almost - depends on whether you want symbols or strings at the end
but no need for .- there regardless
that looks like clojurescript interop where .-xxx
means read a property of xxx from the object
it's valid in all flavors of clojure, but it's more interesting in cljs because in clj the object can't have a method and property that share the same name (unlike cljs where it can)
Hi, functions that cause side-effect are suffixed !
, functions that accept varargs are suffixed *
. Is there a convention for a function that is both?
i'm not certain function names suffixed with *
have that meaning. https://stackoverflow.com/a/5084289
i'm not aware of any conventions for naming functions that accept var args
I saw someone use *name
to describe an atom/ref/agent, and I've started to pick up that habit. It's not particularly widespread though
I picked this up from Pedestal
. http://pedestal.io/api/pedestal.interceptor/io.pedestal.interceptor.chain.html See enqueue
and enqueue*
.
more often i've seen foo*
being used to describe an "uglier" interface to foo
but not private because it may still be useful to users
regardless, you can name a function foo!*
if you so desire
N00b clojurian here! I saw "Clojure cookbook" which I will definitely grab, but what would be the canonical book for the language itself (ideally with plenty of fp & lisp theory)? And any coljurescript books that are cookbook style? Any recommendations would be greatly appreciated!
Does httpkit+compojure enough for developing rest api or I need use any framework?
@artur.aralin97 I think most people use "ring" certainly frameworks like fulcro https://github.com/ring-clojure/ring
@cam.asoftware why ring? httpkit looks pretty simple
@artur.aralin97 I hadn't used either, I'm new to Clojure. But what I do know is this; when learning a new technology, walk the path most travelled. With that many GitHub stars, adoption by popular frameworks/libraries tells me that's the best approach.
Hi guys. Please help. Trying to make my first project with clojurescript, but I'm stuck a bit with tooling. Started from this example https://github.com/jacekschae/learn-re-frame-course-files/tree/master/increments/60-simplify-events Can't configure a stable dev environment, especially REPL. Can someone point me to a good tutorial? Or just name the right tools, I'm totally lost for now. (lein, boot, deps, figwheels, shadow-cljs, proto-repl, chlorine etc) I use windows 10 / java 11 (adopt-openjdk) and Ubuntu. Need setup for both.
If you want just clojurescript, you only need shadow-cljs.
I have build this example repo for my teammates, you can just clone it and follow the instructions: https://github.com/ReOrgpad/example-client
For installing Shadow-cljs, you just need NodeJS (npm) and run npm install -g shadow-cljs.
I would also recommend to invest into some IDE with build in REPL support, we personally are using IntelliJ and Cursive and it is great.
Thank you, Pavel. Do you use IntelliJ+Cursive on Windows or Linux/mac?
I am running on Windows, my friend on Linux, no real difference
And also, does java version matter?
not really
at least at the beginning
Ok, I'll try Cursive today. Thank you again.
Can somebody tell me, why the following code does not throw an exception?
(do
(for [x (range 4)]
(throw (RuntimeException.)))
nil)
for is lazy
since its results are not used, they are never computed
if you want to run them, you can use (doall (for ...))
btw. for doing sideeffects, doseq is better
But the following still does not throw an exception:
(doall
(for [x (range 4)]
(throw (RuntimeException.)))
nil)
It is different:
(do
(doall (for [x (range 4)]
(throw (RuntimeException.))))
nil)
Or just:
(do
(doseq [x (range 4)]
(throw (RuntimeException.)))
nil)
I've created a beginners guide for using Cursive and Intellji in Clojure: https://adriansmith.io/clojure-setup.html I created it for a local group I'm teaching but it might be useful to others, source code is in https://github.com/slifin/adrian-smith-io if you have improvements
hey everyone. Is there a simple way I can use back tick without name space resolution (and without resorting to macros)? i.e. Instead of
`(fn [] ~(inc 1))
=> (clojure.core/fn [] 2)
Have
=> (fn [] 2)
?I could tree walk this and replace the fully resolved name with a simple name, but maybe there's a simpler way
hey everyone. anyone have opinions on an emacs distribution that will work on linux?
is spacemacs a good call?
oh, but i want one with all the clojure/lisp stuff prepackaged
preferabbly one that feels like atom/vscode (my original goal was to clojure without emacs at all. that doesnt look likely or practical though)
spacemacs and doom-emacs are the two most popular with vim keybindings, both should run fine on linux
Spacemacs in Holy mode and with Ivy. It's not exactly VSCode like, in that some shortcuts are different like copy/paste and how selection works. But it's close. You could enable CUA mode to make it even more like VSCode
why would you choose Ivy over Helm? I've been using Spacemacs with Helm for the past 4 years and didn't have a problem with it yet. Is Ivy much faster? Or does it have a better interface?
@prakash You can definitely use Clojure without emacs - I use Cursive, and there are addons for both atom and vscode
iv heard that doom-emacs is less “bloated” — what does that mean?
@shaun-mahood thanks for the rec! iv never heard of Cursive, but ill check it out
While I'm an Emacs lover, it is a lot to learn. If you're also learning Clojure, the advice to try Cursive (IntelliJ), Calva (VSCode) or Chlorine (Atom) is probably a good one.
@didibus thats a good call
Calva looks cool
I'd be delighted if you gave Calva a spin. It definitely fits the prepackaged description. (No debugger though, but that will happen eventually.) #calva-dev is where we try to be the helpful bunch that you are used to in the Clojure community.
I've been using Calva on VSCode on Windows. I've struggled with almost all the other editor environments but Calva just worked. Not sure what I'd do without it