This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-29
Channels
- # aleph (1)
- # announcements (10)
- # aws (1)
- # beginners (110)
- # calva (4)
- # cider (26)
- # clj-kondo (14)
- # cljdoc (24)
- # cljsrn (16)
- # clojure (76)
- # clojure-europe (3)
- # clojure-ireland (2)
- # clojure-italy (15)
- # clojure-nl (8)
- # clojure-spec (23)
- # clojure-sweden (4)
- # clojure-uk (92)
- # clojurescript (37)
- # cursive (19)
- # datomic (59)
- # duct (1)
- # emacs (4)
- # fulcro (7)
- # graalvm (7)
- # graphql (1)
- # hoplon (69)
- # jobs (4)
- # jobs-rus (1)
- # kaocha (2)
- # leiningen (5)
- # luminus (2)
- # pathom (8)
- # reagent (6)
- # reitit (11)
- # spacemacs (12)
- # sql (3)
- # tools-deps (9)
- # unrepl (1)
- # vim (57)
is this the only way to typehint "strings array"? #^"[Ljava.lang.String;"
(not only strings, but array of any non-primitives)
@misha You can use ^{:tag (class (into-array TheType []))}
@seancorfield I get reflection warning with your method (in repl)
Show your code...
Is there any reason syntax-parse style macros are not available on Clojure? They seem very convenient for a large class of macros.
(set! *warn-on-reflection* true)
(let [spans (into-array opennlp.tools.util.Span [])
s "foo"]
(opennlp.tools.util.Span/spansToStrings
^{:tag (class (into-array opennlp.tools.util.Span []))}
spans
^java.lang.String
s))
@seancorfield: I'm no asking about reader macros. I'm asking about Scheme hygienic macros of syntax-case / syntax-parse.
@misha Pretty sure :tag
only works on vars, not locals or expressions...
That would work (but I know isn't ideal). I'm not sure what exactly you need to explicitly hint an expression with type expression... I'd have to dig in the compiler source I expect...
why there is no array?
predicate in core? Is it useless to know the collection is an array without knowing elements' class as well?
@misha what sort of collection? Only primitive arrays have an inherent element type, right? Not any of Clojure's collections...
like the array of custom Spans from example above. This is mostly (or only) for interop with java/js
Anyone know of simulation tools (like simulant) that do something with time manipulation? E.g. https://github.com/Datomic/simulant/wiki/Todo#variable-clock
When using namespaced keywords, is it possible to create a short alias when the namespace part of the keyword does not correspond to an actual Clojure namespace? I tried
(alias 'dom 'my.awesome.app.domain)
{::dom/greeting "hello"}
but it fails with
> Syntax error ... Caused by: java.lang.Exception: No namespace: my.awesome.app.domain foundHas anyone ever faced such an issue with lein-modules
lein plugin? https://github.com/jcrossley3/lein-modules/issues/42
Hello. I'm often developing for Android and I was wondering: Is Clojure on Android dead, as of 2019?
@hi135 Not exactly what you asked, but it's worth knowing that React Native + ClojureScript is often used to target Android. (I don't know the answer to the question you asked.)
Hello, is there an equivalent to clj-time.spec
in clojure.java-time
?
what is this time format? "2015-09-27D00:01:48.788186000" how do i parse this with java-time? clj-time.coerce/from-string manages to parse it when I replace the D character with T! I still can't find a way to parse it with java-time though.
@veix.q5 I had the same problem, and I also changed the D for T to make it work, I’m interested in knowing if you find a different answer for this , thanks!
Just a guess: “D” for “Daylight Savings Time”?
that datetime doesn't have a zone on it, so it's unlikely to have random info about DST
Yeah, not finding any online references to a “D” in place of a “T”
(import java.time.Instant)
(import java.time.ZoneOffset)
(import java.time.format.DateTimeFormatter)
(def fmt (-> (DateTimeFormatter/ofPattern "yyyy-MM-dd'D'HH:mm:ss.n")
(.withZone ZoneOffset/UTC)))
(Instant/from (.parse fmt "2015-09-27D00:01:48.788186000"))
#object[java.time.Instant 0x121c54fa "2015-09-27T00:01:48.788186Z"]
@veix.q5 simplest way to turn it into a java.time.Instanthas anyone paid attention to the what the Elixir folks are doing with Phoenix LiveView?
AFAICT the webpage basically opens a websocket connection to the server and the server handles streaming updates to the DOM based on user interactions
I assume that this scales OK for Elixir because of it’s ability to spin up thousands of light-weight processes to handle each page session
with how much people talk about BEAM, OTP and Erlang/Elixir’s concurrency story I figured it must be better than using a thread pool
if you’re talking about core.async, I thought core.async is basically a state machine / scheduler on top of a thread pool?
honestly I’m totally naive about the way both core.async and BEAM actually work so I’m just going off of shallow readings I’ve done about both
It is a state machine, yeah. But that is copied from the .net model for the same kind of thing. That's basically what green threads are I think.
Right, so I guess my question still is: how does core.asyncs green threads scale in this case compared to BEAMs processes?
i have a compojure/routing question. i've got a login process that reroutes to a certain URL, let's call it /loginsuccess
, that should launch some work then redirect.
so I have a function that does some work then returns (response (redirect "/"))
to get to my original root-URL.
but now /loginsuccess
ends up being used as referer, so it shows up in the browser as /loginsuccess/#/browser-route
instead of /#/browser-route
@veix.q5 Now I’m not sure what you’re asking. IIUC, the #(…)
macro generates an anonymous closure. invoke
is called on the resulting closure (`IFn`) when… well, invoked. Am I grokking the question?
@penryu I was wondering what is the equivalent of the idea of (fn[f x] (f x)), if there is a core function that names it for example. I was not conscious that functions are implementations of an interface under the hood though.
Ah, yes. So to At the clojure level, #(%1 %2)
just yields an anonymous closure (fn [f x] (f x))
which implements IFn
, as above. When the form is evaluated, invoke
is called on the resulting IFn
object.
I'm trying to use jsonista custom encoders to emit epoch milliseconds when given a ZonedDateTime... anyone know why this isn't working? It's copied almost directly from the custom encoder example:
(let [encoders {java.time.ZonedDateTime
(fn [zdt gen] (.writeString gen (-> zdt .toInstant .toEpochMilli str)))}
mapper (j/object-mapper {:encoders encoders})]
(j/write-value-as-string (java.time.ZonedDateTime/now) mapper))
I guess jackson-databind which jsonista uses has its own date handlers, which seem unable to be overridden like this. Is there another way to override them easily or is this not meant to be done?
How do I call public static Path get(String first, String... more)
from Clojure? (Paths/get "mydir")
fails because it invokes get(URI path)
. There must be better way then (Paths/get "mydir", (into-array String nil))
, no?
clojure's interop is generally more jvm interop then java interop, and varargs like that exist in java the language, not the jvm, where you must pass an array like that
T...
is Java's syntactic sugar for T[]
at the JVM level -- which is what all non-Java languages have to interop with.