#clojure log - Mar 14 2016

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

2:47 MONODA: I have a fully qualified symbol, how can I get the value associated with it?

2:47 (eval A) works but I've been told eval is evil and usually not necessary

2:51 ben_vulpes: ,(def A :foo)

2:51 ,A

2:51 clojurebot: #'sandbox/A

2:51 #error {\n :cause "Unable to resolve symbol: A in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: A in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: A in this context"\n ...

2:51 ben_vulpes: ,(println A)

2:51 clojurebot: :foo\n

2:51 dysfun: MONODA: ns-resolve ?

2:56 MONODA: That'll give me the var

2:56 what I want is the actual value

2:59 opqdonut: you can deref the var

3:01 ,((deref (ns-resolve 'user 'clojure.core/clojure-version)))

3:01 clojurebot: "1.8.0"

3:02 MONODA: of course, thanks

3:50 bendlas: has somebody figured out, how to use a recent cider with custom started piggieback clojurescript repl?

5:31 sagittarian: n

6:11 dazlow: How do I make leiningen to build another leiningen project inside my project and use it? I've modified some stuff in a clojar library but not sure if changes will see the upstream

6:12 MJB47: i think https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#checkout-dependencies

6:12 is what you want

6:14 dazlow: Ok I'll check that out

6:14 kwladyka: Is any shortcut for: (if bar (bar foo) foo) ?

6:15 dysfun: not in core, probably somewhere on the internet

6:15 part of the normal clojure writing process is noticing repeatable things and defining them as utility functions

6:17 urzds_: Hello!

6:18 I see a weird error after creating a project using `lein new compojure `: Exception in thread "main" java.io.FileNotFoundException: Could not locate //handler__init.class or //handler.clj on classpath., compiling:(/tmp/form-init5006717142541663053.clj:1:73)

6:18 Any idea what's going on here? I ran the same thing yesterday on my other computer and it worked...

6:19 MJB47: kwladyka: if you are expecting bar to be a map and foo a keyword you can do:

6:19 ,(let [bar nil] (or (:foo bar) :foo))

6:19 clojurebot: :foo

6:19 MJB47: but outside of those conditions it gets more complicated :(

6:20 ridcully_: urzds_: are your namespaces sane? are your file locations matching the ns?

6:20 dysfun: isn't that (get bar :foo :foo) ?

6:20 kwladyka: MJB47 thx. Unfortunately it is a little more complicated.

6:20 MJB47: dysfun: indeed it is, dont know why i overcomlicated it lol

6:21 urzds_: ridcully_: I just tried the command again with `lein new compojure folder` instead of `lein new compojure . :force` and compared the differences: Apparently the latter form creates a garbage project.clj where it uses "." in weird places instead of falling back to a sane default for the current directory.

6:21 ridcully_: Thanks, though!

6:40 kwladyka: i messed in my mind... is it possible to use anonymous fucntions with -> and ->> ?

6:40 ,(-> 2 (fn [x] 3))

6:40 clojurebot: #error {\n :cause "Parameter declaration 2 should be a vector"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Parameter declaration 2 should be a vector"\n :at [clojure.core$fn invokeStatic "core.clj" 4375]}]\n :trace\n [[clojure.core$fn invokeStatic "core.clj" 4375]\n [clojure.core$fn doInvoke "core.clj" 4357]\n [clojure.lang.RestFn invoke "RestFn.java" 490]\n [clojure.lan...

6:41 ridcully_: ,(-> 2 ((fn [x] 3)))

6:41 clojurebot: 3

6:45 kwladyka: hmm

6:45 dysfun: kwladyka: (fn will be read later

6:45 ridcully_: "hmm" is the proper reaction. that construct there is just ugly ;)

6:46 kwladyka: ;)

6:49 ridcully_: for your earlier question: not shorter ((or bar identity) foo)

6:54 kwladyka: ridcully_ sounds good

7:10 m_m: Hi. Is it possible to create light processes/threads in clojure like in erlang ? I mean for example 100.000 on reasonable amount of memory.

7:13 MasseR: clojure threads are OS threads. So, afaik no

7:13 But, the threading is done automatically with thread pools

7:28 m_m: How about actors etc ?

7:30 dysfun: no, we don't have actors, we use other mechanisms

7:30 core.async is a popular choice. it models 'channels' (like from go)

7:31 there's also manifold which operates on similar lines but it built atop netty

7:32 the execution of those is modelled by the flow of data and uses an erlang like 'lightweight thread' mechanism based on a thread pool

7:33 it is very easy to write something that behaves like an actor in core.async

8:11 kwladyka: #(or (nil? %) (= region %)) <- how to write better this condition? I tried with sets, but nil value makes a problem. I need to know the value is nil or region

8:17 ridcully_: i guess if you call it? what about contains? ,(contains? #{nil :a} nil)

8:18 also if this is an important check, then maybe a anon fn is not the right place? make it a defn with a nice name and the need to "compress" it vanishes.

10:51 dysfun: ridcully_: symbolic programming, yo :)

10:52 justin_smith: (-> x ((fn [] ...))) isn't any worse than (-> x (f)), and many prefer that over (-> x f)

10:53 ((fn [] ...)) means you are calling the fn immediately, and indeed that's what you are telling that form to do

10:56 sdegutis: What is f? (f [1 2 5] [3 4]) => [1 2 3 4 5]

10:57 justin_smith: into

10:57 err, no that is wrong

10:57 sdegutis: Hmm. Never mind actually.

10:57 Thanks :)

10:58 justin_smith: (comp vec sort into) heh

10:58 sdegutis: I actually meant this: (f [1 2 3 4 5]) => [3 4 5]

10:58 Ah, nthrest.

10:58 justin_smith: or (partial drop n)

10:58 sdegutis: Hmm. Interesting.

10:59 justin_smith: which might be the same as nthrest actually

10:59 dysfun: i often find that i want a variant of comp which puts the params given up front after the params given later

10:59 sdegutis: ,(source nthrest)

10:59 clojurebot: Source not found\n

10:59 sdegutis: Weird, nthrest uses loop, pos? seq, rest, dec, and recur.

10:59 justin_smith: it's eager, yeah

11:00 sdegutis: Okay. So it's the same as drop but the only difference being it's eager.

11:00 Makes sense.

11:00 justin_smith: drop uses a volatile

11:00 (for the transducer arity that is)

11:02 sdegutis: Oh wait, destructuring does this more easily.

11:02 Woot.

11:03 dysfun: destructuring is pretty ace

11:39 mr_rm: is anyone using Atom editor with proto-repl plugin? I can't seem to get a working repl and not sure why

12:19 justin_smith: opqdonut: for the case where you have a fully qualified symbol, it makes more sense to just use resolve instead of ns-resolve. But ns-resolve is good if you have eg 'str/join and the ns maps clojure.string :as str

12:52 opqdonut: justin_smith: thanks, I had forgotten about resolve

13:56 amalloy: nthrest. that's not a function i've seen used a lot. nthnext i use occasionally myself; i think i'd forgotten nthrest even exists

13:57 tolstoy: Is there a handy lib that'll turn raw XML into hiccup-like syntax?

13:58 justin_smith: tolstoy: how close does clojure.data.xml get you?

13:59 tolstoy: I think it's the same as clojure.xml: {:tag :foo :attrs {:a "1"} "data"} rather than {:foo {:a "1"} "data"}.

13:59 justin_smith: I assume you mean [:foo {:a "1"} "data"]

13:59 tolstoy: yeah.

14:00 amalloy: tolstoy: why would you do that? hiccup data structures are a bear to work with

14:00 justin_smith: that looks like a trivial transformation, but you could also see how well enlive works on xml

14:01 amalloy: enlive style structures are way better to consume. hiccup is popular because it's easy to produce

14:02 tolstoy: Can you use enlive with just random XML?

14:02 amalloy: of course

14:03 tolstoy: I have this "interesting" API where you ssh into a device with an old school menu, and instead of entering a number, you send blocks of XML.

14:03 Then you get XML back (blocks), as well as the menu stuff.

14:04 Fortunately, no namespace stuff.

14:06 I really just need to pull data out. I guess it's zippers, or some java-interop Xpath.

14:06 Or regex, actually.

14:06 justin_smith: tolstoy: I've had great luck with clj-tagsoup when it comes to data that is easy to detect regardless of nesting in doc structure

14:06 amalloy: tolstoy: just parse the data with c.d.xml and get a tree back. i bet you it'll be easy to get data out of without any extra tools

14:09 tolstoy: clj-tagsoup parses into hiccup-like syntax, which is what I asked for, but I bet just using the raw parse from clojure.xml is probably best.

14:10 justin_smith: tolstoy: oh, I meant the streaming mode (the truly soupy one), but yeah, if clojure.data.xml works, just use that

15:09 sdegutis: Ring is such a pain.

15:18 I'm using ring.middleware.flash/wrap-flash and I have returned {:status 200 :flash (:flash request) :body ...}, but the (:flash request) of the next request is nil.

15:37 Hi.

16:08 dysfun: flash requires sessions

16:10 and you have to wrap flash and sessions in the right order

17:12 sdegutis: dysfun: But I have sess -- ooh! ordering!

17:12 dysfun: thanks, I'll try that out

17:13 Ugh I hate Ring middleware. It's so prone to error.

17:13 I honestly think I'm just gonna rip out the middleware I have and combine them into a single function that wraps my Compojure handler.

17:14 Middleware is just such an error prone design.

17:22 benjyz1: hi. I'm having a small issue trying to return json from ring

17:23 I wrap the routes with (wrap-json-body) (wrap-json-params) (wrap-json-response)

17:24 and get back an escaped string... "{\"posted\":\"ping\"}"

17:27 dysfun: sdegutis: yes, but don't do that

17:28 sdegutis: dysfun: why not

17:28 dysfun: by all means write a function that wraps a handler with all the others, but don't try and combine them into one nasty middleware

17:29 you can do something like this https://github.com/irresponsible/qarma/blob/master/src/qarma/middleware.clj

17:30 TimMc: that's irresponsible

17:30 ;-)

17:30 dysfun: yeah and i'm working on irresponsible/emotional :)

17:30 also irresponsible/asylum

17:31 and every c++ programmer's favourite, irresponsible/overload

17:33 it was just another silly name. i never thought it would makes so many other silly names even sillier

17:55 rhg135: now we need responsible/X

17:56 dysfun: not really as satisfying though, is it?

17:56 * TimMc hacks dysfun's account via a github bug, creates repo irresponsible/disclosure

17:56 dysfun: :)

17:56 rhg135: irresponsible/fun

17:57 dysfun: the best kind!

17:58 rhg135: oh the puns!

17:58 dysfun: thing is though i've been choosing all the names assuming they were freestanding, so it's always a bonus when it works great together

18:10 sdegutis: dysfun: hmm, reordering wrap-session and wrap-flash didn't help at all, in fact it made it worse, since the flash no longer worked at all.

18:10 dysfun: which suggests that the wrap-flash middleware is working correctly and I'm using it correctly

19:48 spieden: yo clojureverse

23:48 mmercer: completely unsafe for work but it is so cool i have to post it! http://www.cam4.com/hotnoielya

23:49 TEttinger: that looks like spam, from that link

23:50 mmercer: no, it is just a cam girl with dildo backwards in her twat, making it look like she has a penis

23:50 it is glorious

23:51 the is the skills women need, not programming

23:53 (dildo has balls btw :) )

Logging service provided by n01se.net