This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-19
Channels
- # admin-announcements (1)
- # arachne (3)
- # atlanta-clojurians (5)
- # beginners (6)
- # boot (37)
- # braveandtrue (1)
- # cider (128)
- # clojars (3)
- # clojure (224)
- # clojure-belgium (5)
- # clojure-boston (43)
- # clojure-czech (8)
- # clojure-france (2)
- # clojure-greece (17)
- # clojure-hamburg (4)
- # clojure-russia (285)
- # clojure-seattle (1)
- # clojure-uk (12)
- # clojurescript (209)
- # core-async (2)
- # core-matrix (8)
- # core-typed (1)
- # cursive (2)
- # data-science (2)
- # datascript (1)
- # datomic (18)
- # emacs (12)
- # events (2)
- # hoplon (15)
- # immutant (1)
- # jobs (1)
- # ldnproclodo (23)
- # leiningen (10)
- # mount (8)
- # off-topic (7)
- # om (126)
- # onyx (6)
- # overtone (2)
- # parinfer (5)
- # proton (24)
- # re-frame (16)
- # reagent (14)
- # untangled (105)
- # yada (1)
re a macro taking multiple arguments from before, i'm not sure if you solved your issue but i ran across a neat way to handle it inside of zach tellman's primitive arithmetic library. Here, he's jacking with the standard addition, subtraction, etc, and making it a macro call. you can see that if name was +
here, it would turn into (+ (+ arg1 arg2) arg3 arg4)
=> (+ (+ (+ arg1 arg2) arg3) arg4)
by calling the macro repeatedly. nice implemntation here
I can't seem to get compojure to grab all URLs at once, is that possible? I want all routes that don't match the previous ones to go to the SPA
a (ALL ....) at the end should do it, or just put your ring handler for the spa at the end
well, (GET "*" request handler)
is too greedy as it matches clojurescript's required base.js and such files, which I can't figure out how to move
e.g. if middleware is trapping requests that 404 on the routes, any catch all route you create is going to interfere with the middleware
hmm, something is making it write out js/compiled/out/goog/base.js
but I'm too much of a newb to figure out where that particular bit is coming from
do I need to do anything to make lein 2.6.1 + Java 1.8 + clojure 1.8.0 see .cljc files besides adding it to :source-paths
in project.clj
?
It looks like this person is having the same issue as I am: https://stackoverflow.com/questions/35255367/clojure-not-requiring-a-cljc-file/35257070
Hi everyone! I have a question about some Clojure execution details. Yesterday me and a colleague were interviewing a candidate who made an interesting remark. He said that in the following form, expression-1
and expression-2
are not guaranteed to be executed in that order.
(defn my-func []
(expression-1)
(expression-2))
I cannot find support for this notion anywhere in the Clojure documentation. In fact, it says here: https://en.wikibooks.org/wiki/Learning_Clojure/Special_Forms about do
:
> (We typically don't use do very frequently because a function body is effectively an implicit do that usually meets our needs.)
So what are your thoughts? Is the candidate wrong in this, or am I missing something?@daan: I think they're wrong, as the compiler cannot determine whether (expression-1) has any side effects.
Can someone suggest a Clojure websocket client that supports the 'permessage-deflate' extension? By support I dont mean just configuring it in the handshake, but also performing the actual compression/decompression. I have tried gniazdo, aleph, and http.async.client already
@nxqd: you mean permessage-deflate? yes it definitely helps. I need this for a test tool so I can benchmark my websocket server with this extension enabled
@moizsj: it seems sente doesn't support it either, but this discussion might be relevant: https://github.com/ptaoussanis/sente/issues/72
@pastafari: executed has a pretty clear meaning right?
@daan: what if expression-1 looked like this (future ginormous-db-scan)
and expression-2 looked like {:status 202, :url ‘…’}
obviously I'm not talking about expressions that in themselves are inherently asynchronous for some reason, and therefor cannot be reasoned about as far as ordering goes 😉
the future is put into effect, regardless of how long it takes. The future is "scheduled" at that point
But from a language standpoint, like, how does the compiler translate the code, and how does the JVM interpret that bytecode, you can safely say that expression-1
is "put into effect" before expression-2
@daan: the reader reads an expression into Clojure data. If the thing in function position is a function (not a macro), then the arguments are evaluated and the function is invoked.
thanks for the clarification @alexmiller
Hi, guys, could somebody help me with example solution of state-space problem on clojure ?
Didn't realize how using Double/NaN would break deep equality check via =
, since (= NaN NaN) ; => false
!
yeah, you can’t compare NaN to anything, it’s not equal to itself either 😄
what is NaN?
Not a Number
thanks
but check this
> typeof NaN
'number'
its like an uncertain number
this should be in #C03S1L9DN
why? is there no NaN in clojure?
err, no uncertainty?
i thought NaN is specific to javascript
(defn NaN?
"Test if this number is nan"
[x]
; Nan is the only value for which equality is false
(false? (== x x)))
sometimes, it would be nice if some random grandmother was returned when i ask for a NaN
scratch that, it might be best to just use Double/isNaN
I have NaNs deep inside big maps which previously I was comparing with =
… time for Plan B
If a
and b
are hash-maps this will merge
them, if they are vectors this will concatenate them...
@xcthulhu: thanks! But I would like something like (merge my-collection-with-hash-maps)...
Assuming my-collection-with-hash-maps
looks something like [{:foo :bar} {:baz :bot, :blah 8}]
@xcthulhu: But would it work with [ {:name range :ranges ({:initial 1234 :end 5678} )} {:name range :ranges ({:initial 4321 :end 8765} )} ] ?
@xcthulhu: hmm... I see... But I want something like [ {:name range :ranges ({:initial 1234 :end 5678} {:initial 4321 :end 8765} )} ] ...
You could try (reduce (partial merge-with #(cond (every? coll? [%1 %2]) (into %1 %2), :else %2)) my-collection-with-hash-maps)
hey folks. any alternatives to clojure.java.shell that allow for more bash like experience? i'm trying to execute some docker commands, which would be easiest if i could run "eval $(docker-machine env machine-name)" to set environment vars docker-machine requires. or even to run "export FOO=123" for the same. but clojure.java.shell/sh doesn't support "eval" or "export", even if i call them with "/bin/bash".
i know about setting environment vars with sh's :env or with-sh-env, but that'll require a lot of string manipulation to reform perfectly good "export" statements.
bitsynthesis: one method I've seen used (generically) is to write a bash script you execute that prints out the envvars that you then read in. at the very least that gets you out of guessing if you've parse the script correctly
ruby handles this no prob, fwiw
so "docker-machine env machine-name" will give me a file of export statements
how can i use those statements without converting them to a map for with-sh-env?
@bitsynthesis: the problem is that to start a subprocess with certain environment variables you would have to set them on the java process before starting the subprocess, people get around this by wrapping their command in a shell. Ruby does the same
managing subprocesses from a JVM can be painful, especially when you want to communicate with the subprocess. That said the JRuby folks have done some great work in jnr-process https://github.com/jnr/jnr-process
@plexus: so is wrapping my command in a shell an option in clojure? you mean like "bash -c"?
@bitsynthesis: seems this does what you're looking for https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec%28java.lang.String,%20java.lang.String[]%29
Posting again in the hope of more people seeing this -- Can someone suggest a Clojure websocket client that supports the 'permessage-deflate' extension? By support I dont mean just configuring it in the handshake, but also performing the actual compression/decompression. I have tried gniazdo, aleph, and http.async.client already, and they dont do the job. Thanks! I need it for writing a benchmarking tool for a websocket server of ours.
thanks @plexus this is interesting, a good lead
I have an odd problem: I’ve changed a (:use …) to a (:require [… :refer :all]) in a ns form and it broke a build… but only for clojure 1.5.0.
the symbol causing the exception was introduced in 1.6.0, so I can’t figure out why it worked prior.
@moizsj: The jetty websocket client supports permessage-deflate. https://github.com/eclipse/jetty.project/blob/master/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/PerMessageDeflateExtensionTest.java
@cmcfarlen: was hoping to find a Clojure one
If I’d like to use checkout deps in lein for an unreleased project… how can I get that into my depenedencies vector?
check out ‘lein install'
iirc that just installs it to your local .m2 directory so lein can find it
@tel: what I do is lein-install
a -SNAPSHOT
version of a lib I’m working on then depend on that that -SNAPSHOT
in my app
Can you please suggest me the way how can I send huge number of keys to memcached in a fastest way. I've checked spyglass
client for memcached it support only set
and it’s blocking. Based on that, even if set will take 1ms putting 1M keys will take 1K seconds, which is too long I guess.
is it possible to use binding
or something like it force alter-var-root
to only affect a var within binding's body?
@rmuslimov: I'm sure you can use any java-based memcache clinet easily
@pesterhazy: Sorry for newbie question, do you think will need any java code in my project, or just clojure-java interop will be enough?
@rmuslimov interop should be enough most of the time, you'll sometimes need knowledge of inner Java workings though. Like overloads needing static type hints, generics having no real arguments and such.
@rmuslimov: you never need actually java code (java libraries are more easily used from clojure than from java)
@d-side: @pesterhazy Thanks, for explanation - I will try. I’ve took a look to that spyglass
code which has some java code inside, and that’s why i’ve asked. Btw, great, hope it will work!
@rmuslimov: easy of integrating java libs is clojure's strength
It seems clojure.java.api.Clojure.read("foo") and clojure.java.api.Clojure.read("'foo") both return a Symbol. What is the reasoning behind it?
for example clojure.java.api.Clojure.read("false") returns a Boolean and not a Symbol
I'm having some trouble with JSON and PSQL. Essentially what I'm doing is encoding a clojure map into JSON with clojure.data.json
, then using jdbc/insert!
to put it into a database. That part works fine. The thing I need advice on is when I query it at a later date. Some of the keys in my map have ?
in them, which I didn't realize at the time would count as parameterized query. Now my code is littered with references to this ?
key. My question is, can I somehow escape all instances of ?
in my JSON database entry (not necessarily in the database itself, but for future inserts), or is my best bet to go through and remove all the ?
from my code?
when i want to store clojure data structures i default to datomic instead of serializing them to json
i personally would go so far as to actually write a sql schema if i were going to use postgres.
hello, how do I create an issue/pull-request for a specific docs page (and my subtle implication is why is there no link to the source on the docs page)? Example: http://clojure.org/reference/atoms
@cnilliams: do you mean this? http://clojure.org/community/contributing_site
hey guys i have a qq about AOT compilation. I’m experimenting with AOT compiling incrementally. In this scenario I’m compiling clojure/tools.logging
and then compiling clojure/java.data
with the output from tools.logging
in the classpath. Everything is fine there so far, but compiling java.data
produces a few files like clojure/tools/logging$eval32.class
, even though I AOT compiled every single file in tools.logging
. This is currently exclusive to tools.logging
and prismatic/schema
. Is this a bug or intentional?
@borkdude In a sense but not really, why isn't there a link to the page on github? I have to read all that before I can suggest the example is poor?
@cnilliams: dunno, try @alexmiller
@cnilliams: anyway, we can help you understand atoms here, but it doesn't take way the problem you noticed in the docs
No worries, I appreciate the offer. I will read the big long contributing guidelines in the morning
@cnilliams: I'm looking at the docs and it surely doesn't read as a gentle tutorial. It is terse.
mikekap: it is hard to say why additional class files are showing up without looking at your exact setup, but there are definitely reasons they do
@cnilliams: well, atoms are mutable references that you can change with swap!
if you want to use the old value and reset!
when the old value isn't important. The change happens synchronously. Atoms are implemented using Java's AtomicReference.
@hiredman: well the files aren’t bad per se, the issue is that they sometimes collide (if you AOT from different processes)
they will be bad at some point, and you will spend a day trying to figure out why your build doesn't work
the only place you should aot, if you are going to aot, is at the very end of your build pipeline, if you are produce some kind of application (never if you are produce a library)
except it takes like 2 minutes right now, so I thought by AOT compiling the third party deps I can cut down on the time
what is your end goal? do you care about direct linking? or do you really just care about startup time?
I appreciate the explanation @borkdude, will save til I'm in a clearer frame of mind. Unfortunately your explanation requires a lot of context too, so I will have to get back into Clojure mode to
@hiredman: execution time - at the end of the day this is making an uberjar for a web server
the clojure code gets executed 3-4x in the build pipeline (tests, etc.) so AOT compiling has quite a bit of savings
depending on how long that is taking, I would be inclined to take the longer build times vs aot
@cnilliams: An atom is a name that can refer to different values over time. Some code can ‘dereference’ the atom, which means to ‘get the value it’s referring to at that time’. Even if the value of the atom changes, that code’s dereferenced value stays the same.
@amonks: okay I'm familiar with dereferencing from C etc. which confirms my thinking that doc page is just pretty bad 😕
to be clear, I am not saying aot is buggy, I am saying the way it interacts with the rest of the language has some odd behaviors that people don't take in to account in their mental model of clojure, so you can end up with weird problems
@cnilliams: dude the link to the source is 2 clicks away
@bvulpes I think @cnilliams meant the source of the documentation page
e.g. 'this doc page is not helpful, can I offer a suggestion quickly?' (answer appears to be no).
I think the next stage in coming to understand the badness of aot is asking" ok, well for example what could go wrong?"
so here is a jira issue http://dev.clojure.org/jira/browse/CLJ-1886
if you're distributing your libraries AOT compiled you're either hitler or clojure.jar
i’m not distributing any libraries; though i was hoping to get incremental compilation & faster startup times
yeah, to be entirely fair, that issue is a result of distributing aot'ed jars as a library, I meant it more as example of the kind of stacktraces you will see, and what it will take to figure out the problem
yea though the build tool is smart enough to recompile when the clojure version changes (or any other deps for that matter)
I think most of the actual AOT bugs have been fixed in the past few releases, but that's still not going to save you from the combined effects of AOT and version conflicts
@cnilliams: having a link from the site page to the github page is a good idea and very doable. If you file a GitHub issue on clojure-site to remind me, I'd be happy to add that
part of my hope was to run the clojure code during development, so it’d have to run in < 5s (including booting the jvm)
@alexmiller: Awesome, thanks will do!
Even on Clojure 1.8 I encounter issues with AOT-compiled files in development.
http://dev.clojure.org/jira/browse/CLJ-1544 and http://dev.clojure.org/jira/browse/CLJ-1874 are the only remaining AOT bugs I'm aware of
@alexmiller: done, thanks
Thanks, I'm moving right now so won't be able to look at it for a few days
No worries, I'm just a Clojure lurker, so I won't hold you to anything. I just feel like it will help and appreciate you responding so fast.
if you have an app you want to start up faster, aot can help with that, and if you are deploying to certain environments (like some kind of app server) where the app server doesn't let you monkey with classloaders
@bvulpes: man, I was hoping not to use datomic :P We tried using it the start of the project and ran into problems, which is why we're using postgres now. I didn't consider that JSON was lossy, but I don't expect that to be a problem since it will only ever be strings and ints in the nested map structure.
alright well I think I’ll open a jira just in case; though I’ll just work around it for now via disabling AOT
@bvulpes: not sure if that's a good fit for this particular project since we have a close deadline on it, but I'll keep that in mind for future stuff!
http://dev.clojure.org/jira/browse/CLJ-1916 in case anyone is curious