This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-26
Channels
- # announcements (2)
- # beginners (46)
- # calva (16)
- # cider (5)
- # clj-kondo (1)
- # cljdoc (11)
- # cljsrn (4)
- # clojure (42)
- # clojure-dev (2)
- # clojure-spec (6)
- # clojure-uk (1)
- # clojurescript (18)
- # cursive (7)
- # datomic (18)
- # duct (1)
- # fulcro (11)
- # graalvm (1)
- # hoplon (9)
- # leiningen (1)
- # off-topic (8)
- # shadow-cljs (16)
- # spacemacs (9)
- # specter (3)
- # sql (33)
- # vim (3)
- # xtdb (8)
It's so that the body isn't evaluated if the predicate check fails.
Exactly. The implementation of when
actually just uses if
.
If you want (. [1 2 3])
from (.)
and [1 2 3]
, you could do (concat '(.) (list [1 2 3]))
. Using cons
gives the list (.)
as the first element instead of just .
.
(cons '. (list [1 2 3]))
also works
I can't seem to truly grasp how others use namespaced keywords in practise and what the thought behind it is (or well I do, unique keys). Let's say I have a danger.core.login.specs
namespace. If I want to construct maps with namespaced keywords I would have to require the danger.core.specs
namespace with an alias everywhere I want to use it? e.g (:require [danger.core.login.specs :as entity])
and then ... ::entity/login-form
`? Is that idiomatic?
There’s a shorthand for defining namespaced maps:
#:my-cool-ns.whatever {:name "example" :age 51}
I usually don't use the :: sugar unless I don't want my keyword being used outside of the namespace I'm defining it in
I usually find it better to manually namespace things. But then they can get real long 🙁
True that require is needed for aliasing. It would be weird to require a namespace only for aliasing keywords.
require
is not needed for aliasing.
user=> (alias 'foo (create-ns 'bar.quux))
nil
user=> ::foo/x
:bar.quux/x
user=>
That's what we use at work to provide aliases without requiring a namespace -- since our keywords don't need to match namespaces.Also, we use qualified keywords for partitioning keywords into "domain groups" so they can't conflict.
e.g., :api/country
, :membership/transaction-id
ah, cool. Thanks for the insight everyone!
yeah I just tried it out in cljs, got the same issue
I'll go with the manual aliasing aka constructing maps like @valtteri mentioned for cljs. I really want my specs to guide me when I look at the code 6 months later 🙂.
why would I be getting "circular dependency detected" when I require/reload in cljs?
I promised to give Clojurians some experiences regarding Purely Functional training web site (https://purelyfunctional.tv/). I have watched the first sessions in the "Repl-Driven Development in Clojure" series and it looks really promising. I really like Eric's teaching style. He gives nice background regarding topics he's teaching. And in the latest session I started to watch he explains the way he uses the Clojure REPL as part of his development process. You can clone the repository he is using as an example, and it's really nice to be able to pause the video and try the same expressions yourself in your own REPL session. I'll give you more experiences later. But already I can say that if you are an absolute beginner Eric can give you a quick start in your Clojure study path.
I just finished watching the last few lessons last night. It's a great course -- and a subject that I've been very passionate and vocal about: learning a productive and instinctive REPL-based workflow.
@seancorfield Is the db as a first arg to functions a personal preference or is there more to it? https://github.com/seancorfield/usermanager-example/blob/master/src/usermanager/model/user_manager.clj
@lockdown- I typically put arguments that change the least at the front -- so you could partial
them. I try to do that with all my code.
@papachan -C
will only bring in classpath-elements. Generally you'll want -R
for resources (dependencies) and you may need -M
for main options, for actually running tests. So -A:test
makes more sense here: -R
+ -C
+ -M
.
@papachan -C:test
would just add :extra-paths
, so just the "test"
path. In general tho' you're going to have test dependencies, such as test.check
etc which would need a -R
option for :extra-deps
, and you may have a test runner involved that would need a -M
option to bring in its :main-opts
(hopefully that's clearer than my previous message).
From my dot clojure file https://github.com/seancorfield/dot-clojure/blob/master/deps.edn#L17-L27
@lilactown yes. Using this project: https://github.com/vigilancetech-com/shadow-hoplon-electron
I compiled it (had to do npm install jquery
) and connected to it with cider from the main.cljs file, switched over to it with , s N
(which sends the ns
declaration) then I tried just adding a def to the file (def foo "abc")
and did (require 'app.main :reload)
and get that circular error. In the repl I find that foo
is unknown/null
Your cljs code by default hot reloads on file change so you shouldn't need to require it like thay
But also I'm not sure how you're connecting to the REPL, if you've successfully gotten into a CLJS repl or a Clojure repl
I use the cider-connect-cljs command