This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-27
Channels
- # announcements (12)
- # babashka (18)
- # bangalore-clj (3)
- # beginners (110)
- # calva (14)
- # cestmeetup (4)
- # cider (4)
- # clj-kondo (2)
- # clojure (34)
- # clojure-colombia (5)
- # clojure-europe (11)
- # clojure-nl (8)
- # clojure-spec (19)
- # clojure-uk (11)
- # clojurescript (16)
- # clojureverse-ops (8)
- # community-development (4)
- # conjure (65)
- # core-async (19)
- # cursive (22)
- # data-science (7)
- # datascript (1)
- # datomic (20)
- # devcards (1)
- # figwheel-main (64)
- # fulcro (10)
- # graalvm (3)
- # helix (3)
- # kaocha (22)
- # malli (68)
- # meander (6)
- # off-topic (39)
- # pathom (6)
- # pedestal (2)
- # reagent (5)
- # remote-jobs (2)
- # reveal (30)
- # rum (4)
- # shadow-cljs (83)
- # specter (3)
- # tools-deps (9)
- # xtdb (18)
are there guidelines for how question marks, asterisks, and exclamation points should be used for variable and function names anywhere? i definitely don't feel like i'm consistent and it feels like other people's code might not be either
The Clojure Style Guide has some suggestions on this: https://github.com/bbatsov/clojure-style-guide#naming
I would say that only the verse is true. Not always adding ?
just because of the return type makes sense.
Apart from predicates, ?
s are also used for just vars that contain only booleans and for optional function arguments.
exclamation points are for fns with side effects
Again, not necessarily. For example, clojure.core/volatile!
.
But of course, such cases are a minority.
asterisks are less common---should always be used with dynamic vars
though I have seen them used on internal library fns as well to signify that they are not out-facing
Side effects is limited in scope when discussing !. Sometimes it's only for interaction with clojure's STM, some people use it for all IO. I'd say there's some uncertainty there.
The Clojure Style Guide has some suggestions on this: https://github.com/bbatsov/clojure-style-guide#naming
I am using clojure 1.10.1
and I run into an error while evaluating this expression. Is it normal?
(:a (sorted-map "a" 1 "b" 2))
(same for (get (sorted-map :a 1 :b 2) "a")
)
That's inconvenient when we have mixed types of maps in the data and we blindly query things.
Did you check out https://stackoverflow.com/questions/37410580/sorted-map-throws-exception-on-failed-key-look-up ?
sorted-map-by
is a good workaround
Earlier today I hit the following while code-reloading:
syntax error (OutOfMemoryError)
Compressed class space
...in a REPL session had lasted a few days. I had yourkit enabled so I could see that the class count had been growing but pretty slowly, nothing spectacularly bad.
(I understand that any growth can hit a limit sooner or later)
Anyone has a Clojure-specific insight that might be helpful?
Else I guess I'll bump CompressedClassSpaceSize...Has anyone here used the xelery XSD-parsing package? I tried to add it to my project, adding the dependency [com.akolov/xelery "0.4.6"] to my project.clj and using it in my namespace as shown here: (ns cql-parser.core (:require [clj-antlr.core]) (:require [xelery :as x])) This is all as is shown in https://github.com/kolov/xelery. However, when I try to bring up my project, using lein repl, I get the following error: #error :cause Could not locate xelery__init.class, xelery.clj or xelery.cljc on classpath. :via [{:type clojure.lang.Compiler$CompilerException :message Syntax error compiling at (cql_parser/core.clj:1:1). :data #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source cql_parser/core.clj} :at [clojure.lang.Compiler load Compiler.java 7648]} {:type http://java.io.FileNotFoundException :message Could not locate xelery__init.class, xelery.clj or xelery.cljc on classpath. :at [clojure.lang.RT load RT.java 462]}] :trace ... } I checked target/stale/leiningen.core.classpath.extract-native-dependencies (which appears to be the closest thing to a cache of project dependencies I could find) and there doesn't seem to be any reference to xelery there. I tried to do lein clean before I started lein repl, but that didn't seem to help either. Any ideas what is happening here and/or how to fix it?
the exception says: Could not locate xelery__init.class, xelery.clj or xelery.cljc on classpath.
Thank you. Changing xelery to xelery.core worked. Is there any way to find out what namespaces a project provides without looking through the source?
and that's not meant to be snarky. but there must be some documentation about how to use a library. if there isn't you're left with just reading the source
Understood about that. In my opinion, any snark about documentation for most open source projects is warranted. That being said, I'm glad I don't have to grub through the xsd to get the sructures within. So it goes...
This isn't actually fixing the issue. I'm still getting that error when I start lein repl. And even though requiring xelery.core seems to get rid of the error when evaluating the ns form, any attempted use of the functions from xelery.core fail.
> I'm still getting that error when I start lein repl. You are still getting an error that xelery.clj cannot be found?
> :message Could not locate xelery__init.class, xelery.clj or xelery.cljc on classpath.
@fadrian I notice you have multiple :require
forms in one ns
form - that isn't expected to work
change (ns cql-parser.coreย (:require [clj-antlr.core]) (:require [xelery :as x]))
to (ns cql-parser.core (:require [clj-antlr.core] [xelery.core :as x]))