This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-27
Channels
- # announcements (10)
- # bangalore-clj (1)
- # beginners (130)
- # calva (8)
- # cider (66)
- # circleci (2)
- # clojure (197)
- # clojure-europe (2)
- # clojure-italy (8)
- # clojure-nl (5)
- # clojure-spec (14)
- # clojure-uk (35)
- # clojurescript (46)
- # code-reviews (5)
- # cursive (4)
- # datomic (88)
- # duct (1)
- # emacs (2)
- # figwheel-main (15)
- # fulcro (20)
- # graalvm (1)
- # graphql (3)
- # jackdaw (2)
- # leiningen (2)
- # off-topic (64)
- # pathom (53)
- # re-frame (52)
- # reagent (12)
- # reitit (43)
- # rewrite-clj (1)
- # shadow-cljs (38)
- # spacemacs (3)
- # sql (17)
- # tools-deps (6)
- # vim (30)
I think the version on the site is an older version of Clojure, like 1.4 or 1.5 so you may find a few differences like this
oh right you can't use transducing arities on 4clojure, I always forget
I suspected that, but it doens’t say which version is using, do you guys have any good vids for transducers, read the docs, and watched rich’s video, but i’m having a hard time wrapping my head around how to use/implement them
awesome thx!
the 95% use case is chaining transducers together with into
and comp
such that (->> (range 100) (filter odd?) (map inc) (take 10))
can be rewritten w/transducers
as (into [] (comp (filter odd?) (map inc) (take 10)) (range 100))
the former is lazy, potentially infinite, and makes 3 intermediate sequences
the latter is eager (and thus can't be infinite), and does the work in a single pass
if you get that much, you can probably defer understanding other uses or how it works for much later down the line
and I would not worry at all about implementing your own, that's rarely needed
ok, in that sentence the transducer would be this part right? (comp (filter odd?) (map inc) (take 10))
yeah - that's just a function, which has the same shape as (filter odd?)
or (map inc)
that is, essentially a fancy reducing function
cool thx, another question, a “stateful transducer” would be a fn like the one on reduce which accumulates the state ??
a stateful transducer holds some mutable object (often a volatile) to track internal state that isn't pure / reflected in args and return values
for example, partition-all will collect state until it can build and emit a partition
oohh ok, i see
hi, how can i make two websocket with different path and same port in with http-kit?
what JVM supports REBL? I tried to install many with SDKMan but does not work with Caused by: java.lang.ClassNotFoundException: javafx.application.Platform
It has
================================================================================
Available Java Versions
================================================================================
Vendor | Use | Version | Dist | Status | Identifier
--------------------------------------------------------------------------------
AdoptOpenJDK | >>> | 12.0.1.j9 | adpt | installed | 12.0.1.j9-adpt
| | 12.0.1.hs | adpt | | 12.0.1.hs-adpt
| | 11.0.4.j9 | adpt | | 11.0.4.j9-adpt
| | 11.0.4.hs | adpt | | 11.0.4.hs-adpt
| | 8.0.222.j9 | adpt | | 8.0.222.j9-adpt
| | 8.0.222.hs | adpt | | 8.0.222.hs-adpt
Amazon | | 11.0.4 | amzn | | 11.0.4-amzn
| | 8.0.222 | amzn | | 8.0.222-amzn
Azul Zulu | | 12.0.2 | zulu | | 12.0.2-zulu
| | 11.0.4 | zulu | | 11.0.4-zulu
| | 10.0.2 | zulu | | 10.0.2-zulu
| | 9.0.7 | zulu | | 9.0.7-zulu
| | 8.0.222 | zulu | | 8.0.222-zulu
| | 7.0.232 | zulu | | 7.0.232-zulu
| | 6.0.119 | zulu | | 6.0.119-zulu
Azul ZuluFX | | 11.0.2 | zulufx | | 11.0.2-zulufx
| | 8.0.202 | zulufx | | 8.0.202-zulufx
BellSoft | | 12.0.2 | librca | | 12.0.2-librca
| | 11.0.4 | librca | | 11.0.4-librca
| | 8.0.222 | librca | | 8.0.222-librca
GraalVM | | 19.2.0 | grl | | 19.2.0-grl
| | 19.1.1 | grl | | 19.1.1-grl
| | 19.0.2 | grl | | 19.0.2-grl
| | 1.0.0 | grl | | 1.0.0-rc-16-grl
| | 14.ea.10 | open | | 14.ea.10-open
| | 13.ea.33 | open | | 13.ea.33-open
| | 12.0.2 | open | | 12.0.2-open
| | 11.0.2 | open | | 11.0.2-open
| | 10.0.2 | open | | 10.0.2-open
| | 9.0.4 | open | | 9.0.4-open
SAP | | 12.0.2 | sapmchn | | 12.0.2-sapmchn
| | 11.0.4 | sapmchn | | 11.0.4-sapmchn
================================================================================
can anybody help me with clojurescript interop for this? `myElement.attr({ x: position_x, y: position_y });`
(.attr myElement (clj->js {:x position_x :y position_y}))
how can I solve “manifest type not detected” error when I try to load a github dependency in my deps.edn?
tools.deps needs to statically understand the project you're referencing. It needs either deps.edn or a pom file I believe
solve the manifest problem after adding a pom file, but still can’t locate the file in classpath 😢
you could clone it and refer to it as a local dep
and use lein pom to make it workable
just a temporary approach, short of cloning
add a pom instead can solve the manifest detection issue, but still can’t find the class
class, or namespace?
clj -Spath
will tell you what your classpath is if that helps track it down
can’t spot anything strange in the classpath, project did checkout under ~/.gitlibs and included in classpath
but since deps.edn works, I’ll stick to it at the moment, many thanks 🙇:skin-tone-2:
hi, what should be used to update a map if update is not available?
thnx!!
the idiom before update existed: (assoc m k (f (m k)))
bonus, you can operate on multiple keys in one assoc call
right, though I see that update-in does exist, weird, I guess the shorthand was added later
question with assoc i need to get the value before if I want to manipulate it right??
(f (m k))
right!!!!
no, it's immutable
so the order doesn't matter
I know, but I meant if I'm producing the new value from what was in the key before
right, sure, but it's not like you have to order the operations - you want the old value, you read it in the function producing the new one
cool, yeah!! thanks!!
hello all, I just curious to know, is it a bad thing if i interop java? is there any best practice to do it (more idiomatic)?
interop exists because it is a useful and pragmatic way to leverage the host ecosystem, so IT'S ALL GOOD
wow, thats great! i worried about it sometimes. when some library isn't enough for my purpose, i interop some java library to achieve it, and the big question getting on my head "am i doing good or bad?"
you are using Clojure in the way Rich intended :)
I will leave you to judge that as good or bad :)
@ragil.rynaldo I think you might like this too https://gist.github.com/plexus/645f133fc4c154d1b7497c1b63efdf24 Call it like
(import my.java.thing)
(defwrapper my.java.thing "my-pred")
(apropos "my-pred-") ;; to find the functions now available
awesome! what i've done just plain , no wrapper. but this is good advice to do some interop
I do a ton of java interop for my job, we have a futures trading platform written in Java that I interop with a ton. defwrapper
has saved me a ton of time
so the point is not "good or bad", but most likely how we achieve our need, am i right?
However, I'm very comfortable with the .
special form, which I think is important to know so that your fundamentals can still be leaned on when you need them
Hey guys, in other languages I would avoid doing:
return 5;
preferring instead:
return UNABLE_TO_CONNECT;
The clojure code base I'm currently working in has cases of the former strewn about. Since I prefer not to perpetuate bad habits, is just leaving in a constant value like that the norm for clojure? What is the typical naming convention for const values and where do you put them (separate file, top or bottom of the same file, etc)?all values are considered const unless explicitly shown otherwise
if you mean magic numbers, sure, use a def
(def code-unable-to-connect 5)
that's the normal way to do it
or (def error-codes {:unable-to-connect 5 ... ...})
and then look up the code by name
except I wouldn't bother with HTTP codes - I assume anyone qualified to work on http code either knows them or has them ready to look up
Wouldn't you want (def ^:const unable-to-connect 5)
instead? (or the obvious dictionary version)
no, that's not what :const is for, and you probably don't want it
this goes back to the first point, values are considered const
In this case I'm wanting to set the return value of -main
and I want to attach some meaning to the value instead of having it be a magic number.
also there's no obvious dictionary version, the const annotation is not for values that are not primitives
Right, but I don't need to look them up at run time, this is purely for the programmer.
but you don't do math on a return value
that optimization does nothing here
the reason it's faster is the compiler avoids boxing, there's no such benefit for a signal value
which is what I meant by "this isn't what :const is for"
it doesn't and also that reference lookup is cheap
it's the boxed math that makes things slow
you aren't doing math
It is, and in my current instance its an unnecessary micro optimization, just kind of wondering about best practices.
best practice is to put things in def, and not use unneeded metadata annotations
const is meant for values that can be inlined and unboxed in math heavy code
it makes things harder to read
(for humans)
TBH when I see ^:const
I usually think "this person probably doesn't know what they are doing but wants their code to be faster", but in a perfect world it would be a signal that some value is being used extensively in numeric code
ok, so I assume I should still avoid the magic numbers and put this in a def
. Do you put magic number defs at the top or bottom?
In general you need to have things defined before use. You can use a “declare” expression (statement?) but you can run the risk of getting an uninitialized value of the def is used in another def of some other situations. Better to put at the top or perhaps in a config namespace if there are many such values
user>
(declare x)
(def y {:a x})
(def x 3)
#'user/x#'user/y#'user/x
user> y
{:a #object[clojure.lang.Var$Unbound 0x4e3257c4 "Unbound: #'user/x"]}
yeah - my usages would usually have a hash-map from name to numeric code in a config or other auxilliary namespace
What is wrong with my project.clj file? I am not getting any errors per-se but I cannot figure out why lein-env
is not building out a .lein-env
file. None of my environment variables are in the env
map. Here is my project.clj file.
I think you want +clj,+dev
otherwise you use them instead of the task's target profile, and usually what you want is to merge not replace