This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-04
Channels
- # announcements (5)
- # aws (12)
- # beginners (76)
- # boot (29)
- # cider (24)
- # circleci (9)
- # clojure (64)
- # clojure-dev (27)
- # clojure-europe (3)
- # clojure-houston (1)
- # clojure-italy (33)
- # clojure-nl (19)
- # clojure-poland (1)
- # clojure-spec (6)
- # clojure-uk (20)
- # clojurescript (103)
- # clojutre (1)
- # code-reviews (60)
- # cursive (76)
- # data-science (20)
- # datomic (20)
- # duct (58)
- # figwheel-main (4)
- # fulcro (36)
- # graphql (6)
- # kaocha (4)
- # onyx (1)
- # pathom (15)
- # quil (3)
- # re-frame (15)
- # reagent (15)
- # reitit (9)
- # remote-jobs (2)
- # rewrite-clj (16)
- # ring-swagger (7)
- # shadow-cljs (132)
- # spacemacs (12)
- # sql (5)
- # vim (9)
- # xtdb (12)
- # yada (4)
my web server is not serving pages ... everything is a 404.. it will show me the 404 page i specify though. hrm.
typo is why xD
Hi all. ((fn [a [b c]] (println a)) 5 [7 9])
works but ((fn [a (b c)] (println a)) 5 (7 9))
doesn't. Is there a way to make the later work? As in even if the 7
were a function it wouldn't get called and would just get bound to b
. I guess the question is, can the "higher-level" function being called dictate if the "nested" functions actually get called?
the binding doesn't change (fn [a [b c]] ...
. Clojure is strictly evaluated. Which means it will evaluate all args to a function and then call the function with the results. If you like you can write a macro that does what you want but there's probably better ways to get where you need to be
There's no particular use case in my mind. I'm just exploring the language for now. I am wondering can we write some kind of structure where nested function calls don't happen if the function on top wants to prevent it. Perhaps this can be molded to some kind of debugging/logging tool.
So, perhaps (debug (f 4 2))
be somehow able to see the f
, the 4
and the 2
instead of seeing the result of (f 4 2)
.
So, perhaps (debug (f 4 2))
be somehow able to see the f
, the 4
and the 2
instead of seeing the result of (f 4 2)
.
Hi everyone! ๐ What do you guys use to generate reports for the coverage of your unit tests? Iโm currently playing around with Cloverage, but Iโm struggling to get it to output a single report with a summary of my test coverage. I have one master project with several sub-projects, but Cloverage seems to work only on level project. Does anyone have experience with this tool (or a similar one), and know how I can get it to output a single report with a test coverage summary, including the sub-projects? Cheers!
I use it as well and I think that cloverage as you said works only on level project
btw, do you know perhaps what does % Form
means in the table results?
following ...
about the % Form
: I opened an issue and the author answered here FYI: https://github.com/cloverage/cloverage/issues/252#issuecomment-528043131
In specs, how can I check that two values in a map, which are sequences, have the same number length/size/count?
Write a function that checks that
Predicate functions are specs
@alexmiller I am sorry, I donโt see how it solves the issue.
(s/valid?
#(= (-> % :a count) (-> % :b count))
{:a [1 2 3] :b [4 5 6]})
hey everyone i have a quick question: when reading/looking at other codebases i see a lot of single letter variables. are descriptive variables/args frown upon?
I like expressive variable names myself. Thereโs a few common conventions like f
for functions, coll
for collections, and so on. But definitely, if you like descriptive names, go for it.
@tjb https://guide.clojure.style/#idiomatic-names says "sometimes" ๐
but this is a good page to bookmark, thanks @clojurians-slack100!
@tjb The use of short variable names is fairly common in functional programming because you often have functions that are a lot more generic, so they accept arguments that sometimes just don't even have "sensible" names. Personally, I'd probably have gone for filter-opt
in the example you linked, since I'm used to f
meaning "function".
is it possible to use a function to generate a clojure spec or it has to be defined only in a def
statement?
i'm trying to do something like
(defn user-input-regex [max-bound]
(re-pattern (str "[0-" max-bound "]","[0-" max-bound "]")))
(defn generate-input-spec [max-bound]
(spec/def ::input-spec (spec/and string? #(re-matches (user-input-regex max-bound) %))) )
but it seems to not be working ๐
spec/def (and spec/and) are macros here that capture their forms so it will use the symbol max-bound, not the closed over value
it is possible to do this with a macro that does that replacement however
oh i see
(this is an area with substantial changes in spec 2 fyi)
I'm trying something on refernce types. So, I've one ref.
(def available (ref #{})) .
I'm setting it up using ref-set.
`(ref-set available (into #{} (mapcat (fn[levels]
(map #(vector (key levels) %) (range 1 (inc (val levels)))))
{0 3})))`
which gives me ref as :- #{[0 3] [0 2] [0 1]}
, which is i want.
Now i want to set this value using "alter". So i am trying something like below.
`(alter available conj (into #{} (mapcat (fn [levels]
(map #(vector (key levels) %) (range 1 (inc (val levels)))))
{0 3, 1 2}))`
Which gives me :-
#{#{[1 1] [0 3] [0 2] [1 2] [0 1]}}
.
But i am expecting something like :- #{[0 3] [0 2] [0 1] [1 1] [1 2]}
Sets are unordered.
Oh, you mean the nesting?
Yeah, probably the extra set nesting
(alter available into (mapcat ...))
instead of conj
ing a new set in?@parth.12282 ref
is very rarely used in Clojure, just FYI. atom
is more common.
a good rule of thumb is to use an atom with data under keys of a hash-map until contention / retries become a problem
usually contention / retries never become a problem
hello,
I stuck with a problem of default
interface method call in clojure
I have really ancient project written on mix scala/java/clojure
and I have to upgrade the code to be java 1.8 compatible
and scala generates a lot of interfaces with default
methods
the problem is when I use gen-class
to generate class
which implements these interfaces. gen-class
generates it's own methods for all interface methods definition and override the defaults
exposes-methods
does not help
I don't use gen-class much but I find that surprising - most clojure functions that create new classes simply ignore methods not specified, letting you get a NoSuchMethodError at runtime
it is really interesting to decompile bytecode generated by gen-class
it creates all the methods and see if they are actually bound to clojure functions,
and when they not bound - it will raise NoSuchMethodError
oh - that would interfer wouldn't it - I guess one tedious option is to make method functions that delegate to an instance of the superclass
maybe a macro could make that less onerous
concrete inheritance in clojure tends to be clumsy, generally
spend several days on that, no luck,
and low on macros experience
here's something I did in the past when I got fed up with gen-clas: https://github.com/noisesmith/clj-jsvc-adapter/blob/master/src/java/org/noisesmith/Cljsvc.java
it's a very thin java class, that calls a configured clojure namespace for every method implementation
it might be simpler to make a small java file and delegate to clojure for the "meat" of everything
Also if deftype
does what you need (it might not), I do not believe that it shares that property you found about gen-class
can deftype do the right kind of interface-with-default-methods inheritance for this? I wouldn't expect it to.
I was under the impression it didn't do any sort of concrete inheritance
there's proxy and proxy-super except proxy-super is a bit buggy in multi threaded code
the problem is that is core library, and a lot of code depends on the class generation. so changing to proxy is not an option, will try deftype other option is to create Abstract class with explicit overriding of method, and then gen-class
I just actually looked up Java interface with default method, and what I found said it was introduced in Java 8, and while the latest Clojure versions support only Java 8 and later, there is very little in Clojure that takes advantage of features added to Java that "late".
I have little experience in this area, so out of my depth here, but will throw in a half cent (because worth less than the usual 2 cents) that when Clojure class creation methods run out of steam, Java is the escape hatch that of course gives you full access to all supported options/features.
And those can often be made very 'thin shims' that have most/all of their implementation in Clojure.
I might make a small lib to simplify that kind of shimming
solution via abstract class works, updated repo, just FYI