#clojure log - Nov 30 2013

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

0:19 brainproxy: is there an option for the cljs compiler to include the sources in the generated .map file?

0:36 technomancy: yaaay sweet new slamhound release with a fancy screencast from mr. guns: http://vimeo.com/80650659

0:36 <3

0:42 majyk: yeah that was impressive, I want to use slamhound now!

0:47 bitemyapp: (inc guns)

0:47 lazybot: ⇒ 1

1:17 bitemyapp: `cbp: boo

1:19 ivan: that was impressive, I am using slamhound now

3:03 logic_prog: in core.async, is there any _non_blocking_ put? (a channel with 10 elements might still buffer/cause a wait)

3:05 amalloy: logic_prog: the point of >! is that it doesn't actually block, it just sorta registers a callback so that when there's room it can start back up

3:05 logic_prog: well no, suppose I need a "multiplexer of sorts"

3:05 where on a update, I need to message 1000 different ports

3:05 I think, if the first >! on the first port blocks, the other 999 don't receive their messages

3:05 so >! doesn't block a java-thread, but it blocks the go-thread, no?

3:06 amalloy: so start a thousand go blocks. they're cheap, right?

3:06 logic_prog: so I start a new go block for every message I need to send?

3:06 from within a go block?

3:06 I have never thought about coding like this

3:06 nightfly: welcome to erlang!

3:07 logic_prog: this is like saying: you need to go from LA to NY? dig your own tunnel from LA to NY, labor is cheap

3:07 amalloy: if you want to send to a thousand of them all at once, and you worry some of them may be unwilling to receive the message, that's the solution that jumps out at me; but i'm not a core.async expert

3:07 logic_prog: are go blocks in core.async as cheap as erlang threads?

3:07 amalloy: logic_prog: that seems like a totally irrelevant analogy?

3:07 logic_prog: it's a bad analogy

3:07 but something I previously thought was expensive

3:07 is apparently now very very cheap

3:07 and this is now warping my thinking

3:09 alright, one more dumbass question

3:09 is there something like "gops" where it lists all go processes/threads ?

3:10 s/go/core.async/

3:11 amalloy: i'm pretty sure there isn't; i don't think it would be possible in cljs, and i'm not sure on the jvm

3:12 logic_prog: so I'm writing multiple go blocks that while (while true ... blocks in them)

3:12 and it's not clear to me when they'll get gc-ed

3:14 amalloy: i mean, never, right? you told them to work forever, and there's no way to stop that other than throwing an exception

3:18 bitemyapp: logic_prog: set up control channels with alts!

3:19 logic_prog: or promises

3:19 logic_prog: short-circuit the loops if you send something down those channels.

3:22 amalloy: bitemyapp: promises? doesn't blocking on a promise go against everything core.async stands for?

3:22 bitemyapp: amalloy: you don't block on the promise.

3:22 you check realized?

3:22 control channel is better.

3:23 amalloy: i guess that's okay, but it does seem like just a bad way of doing a control channel

3:23 bitemyapp: lets you short-circuit without waiting for a run of the loop

3:23 amalloy: the suggestion was an artifact of something I did that didn't involve core.async

3:23 I'm just putting options out there

3:23 if I have to hold the standards of everything I toss out there to perfection, nobody gets any help

3:24 so it's best not to be petty and disincentivize contribution when they're really not that bad or far off and the trade-offs are understood.

3:32 logic_prog: amalloy: do you have a blog? your insight of "create a new go block" is changing the way I think about core.async/cloojure

3:33 amalloy: haven't blogged anything for like three years. also haven't written any core.async

3:33 logic_prog: i've been playing with erlang recently, and this allows me to work in some erlang style error techniques

4:00 bitemyapp: logic_prog: http://github.com/michaeldrogalis/dire/

4:00 logic_prog: yeah

4:00 saw that today

4:01 very nice

4:30 makkalot: hi, having to use global variables when doing testing in clojure seems broken to me, can't i just pass arguments from fixture to testing function ?

4:38 bitemyapp: makkalot: let

4:39 makkalot: when i do let, variables are not passed from fixture to test , any example ?

4:39 bitemyapp: makkalot: let inside the test

4:40 makkalot: bitemyapp, then what is the purpose of fixture ?

4:40 amalloy: fixtures can only perform side effects, really

4:40 bitemyapp: you're the one complaining about using fixtures.

4:41 makkalot: bitemyapp, not complaining trying to figure out the way of proper testing without defining lots of globals

4:42 amalloy, that makes more sense

4:43 yedi: bitemyapp, are you callen

4:44 logic_prog: I would like to validate a string vs a regex. In particular, I want to take a string, and strip out all characters taht does not satisfy [a-zA-Z0-9]. So for example "../foo" becomes "foo"

4:44 How do I do this in clojure/java ?

4:46 Rhymor_: ,(apply str (re-seq #"[a-zA-Z0-9]" "../foo"))

4:46 clojurebot: "foo"

4:47 Rhymor_: don't know bout performance

4:49 logic_prog: this is fine

4:49 it's amking sure no one is doing funky things in their username

4:49 thanks for the code line

4:52 amalloy: yedi: yes

4:53 alsm: This is probably really simple but how can I replace the whole content of a vector in an atom when doing a swap! ?

4:53 yedi: no wonder i was so entertained by their msgs

4:54 alsm: I have a two value vector and a function that returns two values, I want to change the original with the two values from the function

4:55 Rhymor_: alsm: does your function return a vector, or a sequence? Do you want to pass the old vector as a parameter?

4:58 alsm: let me just check, I think I return a vector and I do pass the elements of the old one as parameters

4:58 Rhymor_: alsm then that's just what swap! does.

4:58 alsm: (swap! me (next-location (first @me) (second @me) (second robo-info) 15.0)) is the line

4:59 and I get Exception in thread "main" java.lang.IllegalArgumentException: Key must be integer

5:00 referencing that line in my code

5:00 Rhymor_: ,(doc swap!)

5:00 clojurebot: "([atom f] [atom f x] [atom f x y] [atom f x y & ...]); Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be called multiple times, and thus should be free of side effects. Returns the value that was swapped in."

5:01 Rhymor_: I take it next-location does not return a function?

5:01 alsm: nope

5:01 Rhymor_: You want something like (swap! me #(next-location (first %) (second %) ...

5:02 alsm: println on it's output shows a vector; [-0.20089877715863735 51.49498633535638]

5:02 Rhymor_: In your line you are passing the result of the next-location call to swap! instead of a function

5:03 pepijndevos: Is Docjure still maintained? It seems to have a lot of unmerged pull requests

5:03 alsm: ahh, ok, thanks

5:03 francis_wolke: http://common-lisp.net/project/bknr/static/lmman/toc.html

5:04 Is anyone able to see the contents of the links on that page?

5:04 Wait.

5:04 nevermind

5:18 alsm: Rhymor_: thanks, sorted that now.

5:18 Rhymor_: yw

5:27 makkalot: how do you unit test core.async on clojurescript ?

5:31 amalloy: i think that's still in the "banging rocks together" phase, makkalot, although maybe dnolen knows of something

5:33 makkalot: amalloy, take! doesnt work on clojurescript right ?

5:34 amalloy: isn't that blocking? if so, it clearly wouldn't be implemented for js

5:35 makkalot: amalloy, yeah

5:36 amalloy, my tests are finishing before my go block finish

5:37 amalloy: i have no idea how to test cljs, let alone core.async

5:37 makkalot: amalloy, thanks

5:45 yedi: (inc bitemyapp)

5:45 lazybot: ⇒ 15

5:53 dsrx: was going to suggest makkalot look at the core.async cljs tests for inspiration

5:55 solidus_: why is pprint throwing exception: RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:219)

5:55 it happens when i try to pprint expandmacro output

6:01 modulus: Hi there. Is there a way to do conditional binding, so if x is true, y gets bound to z, otehrwise to w, and then code runs using the value of y?

6:03 Rhymor: modulus: (let [y (if x z w)] ())

6:03 Pupeno: Is the book The Joy of Clojure still good or is it out of date?

6:03 modulus: ah, so i'm allowed to use if expressions on let bindings...

6:04 should have guessed, thanks a lot!

6:04 arcatan: you can use any expressions there

6:05 modulus: because of the vector form of it i had the impression that i could not

6:06 that's going to simplify my code some, i was going to put the post-binding code on an anon function and do (if x (let [y z] (anon) etc

6:09 jph-: does clojure handle open paths like "~/.config"

6:10 or do i have to lookup $HOME and create/expand the path string?

6:11 llasram: Empiricism will answer many questions :-)

6:11 But turning `~` into the user home directory is a shell feature, not an OS feature

6:12 jph-: yeh i know, i wasnt sure if there was any automagic baked in

6:12 arcatan: i don't think there's a function do that in the standard library

6:13 jph-: guess i'll lookup $HOME then

6:13 llasram: Clojure just uses the Java facilities there on the JVM. The older File class I don't believe does, but the Java 7 Path class may

6:13 jph-: yeh i come from rubyland, i dont know the java std library yet

6:14 arcatan: jph-: i guess the java way of looking it up would be (System/getProperty "user.home")

6:15 jph-: yeh i just figured i'd ask here instead of googling for a change

6:15 :)

6:27 alsm: Does anyone know why the following loop might work once then get a null pointe exception?

6:27 (while (not (empty? @robots))

6:27 (do (let [[robo-id robo-info] (first @robots)]

6:27 I haven't included the rest of the body

6:28 robots is an atom with a priority-map

6:28 amalloy: modulus: generally in clojure every expression has a value (even if it's nil), and you can use any expression in a context where a value is expected. if, let, and so on aren't special "statements"

6:28 alsm: because all the code you decided not to include mangles robots in some way

6:29 alsm: pretty sure it doesn't, although something outside it does update it

6:29 xificurC: Hi, I am working through some code from 'Clojure in Action' but I have trouble with the simplest things. I have a lein project with two files in src/chapter08 - date_operations.clj and date_operations_spec.clj . However when trying to evaluate (ns chapter08.date-operations-spec (:use chapter08.date-operations)) I get an error saying the file is not on my classpath

6:30 amalloy: modulus: eg, you can even use another let inside the right-hand side of a let: ##(let [coords (let [xs [-1 0 1]] (for [x xs, y xs] [x y]))] coords)

6:30 lazybot: ⇒ ([-1 -1] [-1 0] [-1 1] [0 -1] [0 0] [0 1] [1 -1] [1 0] [1 1])

6:30 alsm: is there not a way for it to reevaluate reference when it loops?

6:30 amalloy: (that's usually not the most readable choice, but sometimes it can be nice)

6:31 llasram: xificurC: FYI, /Clojure in Action/ is quite out of date. Are you sure the "not found" is for the included source namespace, and not for a missing obsolete contrib namespace?

6:33 xificurC: llasram: I know its a bit out of date but I thought it might be a nice start. I only have that one :use inside the ns, so it has to be it

6:34 llasram: xificurC: refheap the full stack trace?

6:35 xificurC: And it's really, really out of date. Principles haven't changed, but you'll have a struggle to get any big chunks of example code working due to the contrib changes

6:37 xificurC: llasram: https://www.refheap.com/21366

6:38 llasram: really? well thats a shame

6:39 llasram: I think Amit said at the Conj that he's working on a new edition, but understandably has his hands full with other things

6:41 Huh, yeah, totally just can't find `chapter08/date_operations.clj`. Double-checking filenames is the only concrete suggestion I have ATM :-/

6:41 xificurC: llasram: so is there another book/resource with some real code examples (that preferably arent 10 lines long)?

6:42 llasram: Are you just looking for larger chunks of code to read?

6:42 xificurC: llasram: well, some explanation of the code would be nice too

6:43 the names are ok, can there be something wrong with my setup?

6:43 llasram: Assuming you launched your REPL from inside the Leiningen project, nothing obvious comes to my mind

6:44 azsxdcfvgbhnjm: ciao a tutti

6:45 llasram: xificurC: If you want a book, /Clojure Programming/ (Emerick, Carper, & Grand) has a few longer examples

6:46 xificurC: llasram: I launched it from a project's subfolder I think.. restarting it helped.. I feel like IT Crowd'd

6:46 llasram: Heh

6:46 xificurC: But there's plenty of readable code in real projects. I actually think Leiningen is a good place to start. It's well designed, the code is clear, and is something you're already actually using :-)

6:48 xificurC: so theres 'Clojure Programming' and 'Programming Clojure', nice

6:48 llasram: Yeah... May actually be worse than Scala's /Programming Scala/ vs /Programming in Scala/

6:49 xificurC: llasram: thanks for the tips. I am not just learning the language but also trying to learn how to program, ehm, right?

6:49 my daily job is VBA coding which holds me pretty far from right :)

6:49 llasram: Ahhhh

6:50 Well, I think reading real well-designed code is going to be the biggest help there. That's been my experience anyway!

6:53 xificurC: llasram: yeah thanks :) If you feel like giving more pointers, here is what I played around with yesterday https://www.refheap.com/21367 based on this http://rosettacode.org/wiki/Flipping_bits_game

6:57 llasram: xificurC: Cool! I don't have the attention to dig too deeply, but one comment: I see you calling `recur` (and `loop`) several times. In practice, you can usually avoid explicit recursion/looping by using `map` etc or `reduce`, usually making your code clearer and more flexible in the process

6:59 Oh, and just because I both love and hate `>`/`<` in lisps: (and (> fst-int 47) (< fst-int 58)) -> (< 47 fst-int 58)

7:02 amalloy: xificurC: it's not clearly "better", but you might note that (if x (grid-indices grid :row foo) (grid-indices grid :col bar)) could be written as (apply grid-indices (if x [:row foo] [:col bar]))

7:03 xificurC: llasram: thanks for the < > tip! I try to use map/filter/reduce all the time so when you see a loop/recur it means i didnt know how to write it otherwise

7:03 amalloy: that pattern seems to come up a few times in your code, so surely at least once it would help to switch to my way :)

7:05 xificurC: line 59 looks kinda like (let [goal (first (drop-while #{grid} (iterate shuffle grid)))])

7:07 the loop in line 28 is another iterate: you want (nth (iterate (fn [grid] ...) grid) (* 3 n))

7:11 xificurC: amalloy: thanks for the tips! On the last note - what you suggest creates a list of steps of the shuffled grids and then taking the nth of it, correct?

7:11 amalloy: yeah

7:11 xificurC: wouldnt think of that in a year

7:11 amalloy: it's a handy pattern to keep in mind

7:11 comes up a lot

7:12 xificurC: I was thinking more in the terms of repeat first but that doesnt work (or wouldnt know how it would)

7:12 the imperative mind

7:12 amalloy: fwiw i'd probably actually write it as (-> grid (->> iterate (fn ...)) (nth (* 3 n)))

7:13 but if you're not comfortable with all the arrows yet, the original way is fine

7:13 er, (-> grid (->> (iterate (fn ...))) (nth (* 3 n))). all these parens are tricky to get right in irc sometimes

7:14 xificurC: amalloy: arrows are nice

7:14 thanks for the tips

7:14 nested arrows, thats a bit trickier

7:15 I'll have to dwelve on that for a day

7:15 does the overall design make sense though?

7:16 amalloy: eh, i dunno. i was looking through a microscope

7:16 didn't look atrocious, but i didn't try to figure out what the overall goal is

7:18 xificurC: amalloy: okay, thanks a lot

7:18

8:12 dsrx: amalloy_: enable paredit in ERC, problem solved ;)

8:16 jph-: gotta say, coming from ruby, clojure feels like a functional ruby

8:16 at least it's dead easy to pickup

8:28 what's the sexy web framework of the moment with clojure?

8:41 heiz: Hello! Tell me please how I can enable leiningen profile by default. I expect I need override default profile or something like that...

8:42 cYmen: Good morning!

8:43 justin_smith: heiz: maybe you want lein with-profile :something ...

8:45 heiz: I have some profile, but I don't want run "lein with-profile some-profile" each time.

8:45 hyPiRion: heiz: Just place stuff directly in the project.clj profile, or if you want to have this on a user-default basis, put the details within the :user profile in ~/.lein/project.clj

8:46 I meant ~/.lein/profiles.clj

8:46 cYmen: oohh..could I use that to always have clojure/tools.trace available in my repl?

8:47 justin_smith: cYmen: for that use ~/.lein/profile.clj :plugins

8:47 llasram: cYmen: That sort of thing is pretty much what the :user profile is for :-)

8:47 justin_smith: that is how I make sure I always have criterium at dev time

8:47 heiz: But what if I have two profiles which I want to be able to switch.

8:47 hyPiRion: cYmen: sure thing, but be a bit careful when doing that in a project which either has some stuff tools.trace depends on, or tools.trace itself

8:48 cYmen: Why?

8:48 clojurebot: Why is why

8:48 justin_smith: versioning for example

8:48 or things working locally and not on deploy

8:48 heiz: Indeed I don't understant the line "The :default profile is defined to be a composite of [:base :system :user :provided :dev], but you can change this in your project.clj just like any other profile." from leiningen tutorial

8:49 justin_smith: heiz: it merges all of those profiles to construct default

8:49 hyPiRion: cYmen: It may break the project because you enforce some other version of the dependency

8:50 heiz: How can I add my profile to this list of profiles?

8:52 justin_smith: heiz: lein with-profile takes a comma separated list of profiles to use

8:52 you can make a shell script if you find that tedious

8:52 hyPiRion: justin_smith: or lein aliases :)

8:53 justin_smith: hyPiRion: a shell alias? or is there a lein alias command I have not upgraded to yet?

8:53 hyPiRion: https://github.com/hyPiRion/dotfiles/blob/master/.lein/profiles.clj <- lein math sets up some dependencies and imports their names

8:53 justin_smith: ahh cool, so much to learn

8:58 cYmen: General question: Do you usually create a leiningen project for repl experiments?

8:58 stdev: @cYmen yes because vim-fireplace

8:59 justin_smith: I usually start with an existing project with similar enough dependencies, up to a certain complexity

8:59 stdev: (equally applicable to M-x nrepl connect, non)

8:59 justin_smith: stdev you likely mean nrepl-jack-in

9:00 stdev: @jph- looks like compojure and mustache to me

9:00 justin_smith: I prefer to start repls from the terminal regardless, and connect by port

9:00 stdev: @justin_smith yeah that one

9:00 been bouncing between emacs+nrepl, slimv, and fireplace tring to find what i like

9:00 justin_smith: also you can nrepl-jack-in from a non-project dir, you just get a default non-project repl iirc

9:01 stdev: keeo forgetting whats what

9:01 jph-: stdev: im trying out caribou atm, seems interesting

9:01 stdev: but you don't get dep-management, right?

9:01 @jph- sweet, will peek

9:01 jph-: stdev: http://let-caribou.in/

9:01 comes with a nice video

9:02 justin_smith: stdev: yeah, lein just gives it a projectless repl

9:02 jph-: and admin/migrations/etc baked in

9:02 justin_smith: so another option is not making a project yet, and using pomegranate to load dependencies

9:02 but I find the pomegranate syntax a little clumsy, easier to edit a project.clj

9:02 stdev: ooh! today i learned and it's not even 9 here yet

9:02 justin_smith: jph-: oooh you're talking about the thing I helped write

9:02 stdev: thank you @justin_smith, @jph-

9:03 jph-: justin_smith: i'm used to padrino in rubyland, and caribou feels very familiar

9:03 i lvoe the web-based model generation, perfect for a lazy dev like me

9:03 rubber-duck: is there a naming convention for async functions (ie. functions that return aync channels) ?

9:04 justin_smith: the lineage is that the senior partner at my company made a rapid website builder with a cms in php - and hammered out lots of websites real fast and built a company. Then they upgraded to ruby because php can get hard to maintain. Then they upgraded from ruby to clojure because ruby inflates hosting costs

9:05 jph-: cool. glad you like it.

9:05 jph-: justin_smith: it'll be interesting to see how it works as i get further in

9:05 i haven't had to learn a whole bunch of weird rake tasks (or equivalent) to do anything yet

9:05 cYmen: amalloy_: Is there any way to view solutions with low code golc scores on 4clj?

9:06 justin_smith: jph-: keeping things simple and frictionless to use is a big priority

9:06 rubber-duck: is something like (<! (xhr-async)) or some variant prefered over standard (<! (xhr)) :\

9:06 justin_smith: jph-: I have coworker that are hired for their creative / visual skills and ability to translate that to html, and they need to be able to use caribou

9:07 *coworkers

9:07 jph-: justin_smith: if it stays like padrino (ie, a bit more helpful than sinatra, without bloat of rails) i'll be very happy

9:07 justin_smith: jph-: if you find issues or suggestions, feel free to get in touch

9:07 jph-: im very new to clojure so i was curious which frameworks had mindshare and active dev

9:07 so first up is caribou :)

9:07 the tutorial video really sells it

9:07 simplicity wise

9:08 reminds me of the rails "make a blog" tutorial 5+ years ago, only better

9:08 justin_smith: I don't know about mindshare, but we have a couple of us working at my company that use it nearly full time, and work on the project itself when not using it to do client stuff

9:08 thanks

9:09 we had a big todo list about things to streamline to make things that turnkey

9:09 it was worth it

9:09 jph-: if you havent heard of padrino, take a look, it's awesome and incredibly unfortunate so few know about it

9:09 i love padrino since it hits the sweet spot

9:10 caribou kinda looks like it's similar

9:12 justin_smith: yeah looks like we have some similar priorities (keeping compatibility and flexibility with other libs, providing a nearly complete stack of functionality out of the box, easy to create and insert template helpers)

9:12 jph-: yep

9:12 justin_smith: I think my next todo is non-sql storage

9:12 jph-: why it feels so familiar :)

9:12 justin_smith: for datomic, neo4j, etc.

9:12 jph-: yah

9:12 that's the other nice thing with padrino, lots of ORMs, lots of backends

9:13 basically sinatra with lots of cool stuff pinched from rails

9:13 and elsewhere

9:13 justin_smith: we support h2 / mysql / postgres

9:13 jph-: yep

9:13 how soon should i ditch h2?

9:13 heh

9:14 is it the equivalent of sqlite?

9:14 never used it before

9:14 justin_smith: it is a local in-process sql

9:14 with a single file on disk

9:14 jph-: only for dev then

9:14 justin_smith: yeah - it is there to make first bootup and experimentation seamless

9:14 jph-: what's the right approach for serving a caribou site? reverse proxy via nginx or straight to web

9:14 glosoli: hmm caribou does look interesting

9:14 justin_smith: so the first step of the tutorial isn't "install and configure mysql or postgres"

9:15 jph-: justin_smith: yeh that's perfect

9:15 the padrino equiv defaults to sqlite

9:15 stdev: (that said it holds up shockingly well for single/low user envs)

9:15 (h2, that is)

9:15 jph-: yep

9:15 justin_smith: jph-: we have been using war inside tomcat behind nginx and varnish

9:15 jph-: justin_smith: oh packaging up the webapp as a war?

9:15 justin_smith: but I think we can use http-kit and drop tomcat and nginx out of the stack

9:15 * jph- is completely new to serving java webapps

9:16 jph-: is there any doco on that on the caribou site?

9:16 justin_smith: it is a feature of ring

9:16 jph-: or jsut track down generic clojure/war/tomcat serving info should be ok?

9:16 justin_smith: lein ring uberwar

9:16 jph-: ahh

9:16 yes i've seen that mentioned

9:16 justin_smith: it should be mentioned on the caribou docs if it isn't

9:16 * jph- pencils it down

9:17 justin_smith: the thing is, I was looking at some benchmarks, and directly using ring+httpkit without the tomcat layer would boost performance

9:17 but that means replicating the other things tomcat does

9:17 jph-: ahh

9:17 justin_smith: logrotate, service interface

9:17 etc.

9:17 jph-: whatever is nice and simple

9:17 stdev: war protocol is p solid despite the computational overhead

9:18 i wanted to hate it

9:18 justin_smith: simple is a variable of scale - for a one of java -jar is simple, for a big project, service tomcat restart is invaluable

9:18 stdev: but couldn't

9:18 noncom: what is the clojure equivalent for javas MyClass.class

9:18 ?

9:18 justin_smith: *one off

9:18 jph-: justin_smith: just keep it simple, that's what is attractive

9:18 dont take it to the dark side of java

9:18 * jph- has horrible memories of xml config files

9:19 justin_smith: noncom: maybe (. Class forName "MyClass") ?

9:19 ,(Class/forName "java.lang.Integer")

9:19 clojurebot: java.lang.Integer

9:20 noncom: yes, looks like it is

9:21 justin_smith: noncom: wait

9:21 ,(class [])

9:21 clojurebot: clojure.lang.PersistentVector

9:21 justin_smith: I think that is what you want

9:21 noncom: that's getting a class of an instance

9:21 justin_smith: ahh, right

9:21 noncom: but the first one you said is more like MyClass.class

9:23 xificurC: javadoc opens a window with really small and unreadable documentation, is that normal?

9:23 I dont even see how to zoom in or anything

9:23 pepijndevos: What was this nice idiom to append to a key in a map or create it if it doesn;t exist?

9:24 justin_smith: xificurC: what UI?

9:24 xificurC: justin_smith: hm?

9:24 I am running nrepl inside emacs if thats what you asked

9:25 justin_smith: ,(update-in {:a [0]} [:a] conj 1) ; pepijndevos

9:25 clojurebot: {:a [0 1]}

9:25 justin_smith: xificurC: does the javadoc open in an emacs buffer or a browser?

9:25 xificurC: justin_smith: it opens in a jframe i guess

9:25 #<JFrame javax.swing.JFrame[frame1,32,32,700x900,invalid,layout=java.awt.BorderLayout,title=,resizable,normal,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,5,25,690x870,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]>

9:25 pepijndevos: &(update-in {:a [0]} [:b] conj 1)

9:25 lazybot: ⇒ {:b (1), :a [0]}

9:25 pepijndevos: ah ok

9:26 justin_smith: ,(conj nil 1) ; pepijndevos

9:26 clojurebot: (1)

9:26 justin_smith: that is what it is effectively doing

9:26 pepijndevos: got it

9:27 I did Python for a while so now my head is fille with {}.setdefault and other crazynes

9:27 hyPiRion: eventually use fnil to set type of list

9:27 ,(update-in {:a [0]} [:b] (fnil conj []) 1)

9:27 clojurebot: {:b [1], :a [0]}

9:27 hyPiRion: ,(update-in {:a [0]} [:a] (fnil conj []) 1)

9:27 clojurebot: {:a [0 1]}

9:27 xificurC: ,(doc javadoc)

9:27 clojurebot: excusez-moi

9:27 justin_smith: ,(update-in {:a [0]} [:b] (fnil conj []) 1)

9:27 clojurebot: {:b [1], :a [0]}

9:28 justin_smith: xificurC: I bet there is some env variable that would tell the jframe to use a better font

9:30 xificurC: justin_smith: any tips where to search for it?

9:30 justin_smith: hmm

9:31 for me, javadoc opens a window in chrome

9:31 pepijndevos: <3 fnil

9:31 xificurC: justin_smith: I'd appreciate FF too

9:32 justin_smith: xificurC: I think mine is using my default browser

9:33 it looks like it is calling browse-url

9:33 cYmen: hmpf

9:33 sometimes I think all those fancy modern IDEs have left me unable to remember the most common and simple argument orders

9:34 justin_smith: xificurC: (when *open-url-script* (sh/sh *open-url-script* (str url)) true)

9:34 xificurC: I bet you that is a dynamic binding that you can shadow

9:34 the fallback is open-url-in-swing, which is clearly what is being called in your case

9:37 xificurC: justin_smith: so how would you get it to open in firefox or even inside emacs?

9:37 justin_smith: xificurC: first, we have to find out where *open-url-script* is resolved

9:37 then, bind it in a binding form

9:37 pointing at the shell script to call

9:40 xificurC: I did (use 'clojure.java.browse) and then (binding [*open-url-script* "firefox"] (javadoc SimpleDateFormat)) which opened it in firefox

9:40 how can I make that the default binding on start?

9:41 justin_smith: hmm

9:41 it is using xdg-open-loc

9:41 https://github.com/clojure/clojure/blob/master/src/clj/clojure/java/browse.clj#L21

9:43 oh!

9:44 *open-url-script* should be an atom

9:44 so you can use reset

9:45 that is, reset!

9:45 xificurC: what OS are you on?

9:46 xificurC: Slackware 14.0

9:46 justin_smith: I wonder if the xdg stuff does not work with your desktop

9:46 xificurC: so you meant something like (reset! *open-url-script* "firefox") ?

9:46 justin_smith: yeah, it looks like it should be an atom, so that should work

9:46 I had not realized before it would be an atom

9:46 xificurC: getting a NullPointerException

9:47 justin_smith: yeah me too

9:49 xificurC: `which xdg-open' returns /usr/bin/xdg-open

9:49 justin_smith: weird

9:49 yeah, there is some magic going on with that dynamic atom that I don't get

9:49 xificurC: heh

9:52 (clojure.lang.Reflector/invokeStaticMethod "java.awt.Desktop"

9:52 "isDesktopSupported" (to-array nil)) from open-url-in-browser returns false

9:53 justin_smith: xificurC: returns true here

9:53 that is our difference

9:54 http://stackoverflow.com/questions/8258153/how-to-get-desktop-class-supported-under-linux

9:54 seems you need gnome installed

9:54 even if you don't have gnome running?

9:54 xificurC: justin_smith: yes but why can't i just rebind *open-url-script*

9:54 justin_smith: I have no clue

9:55 there is something weird going on there

9:55 it is a special var, not bound in my thread

9:55 which is not too abnormal for something declared :dynamic

9:58 likely your options are to fork javadoc so you can get something simpler and controllable, or get java to recognize xdg on your system (likely involving gnome installation)

10:00 xificurC: justin_smith: I did this: (defmacro jdoc [sym] `(binding [*open-url-script* "firefox"] (javadoc ~sym)))

10:00 justin_smith: cool

10:01 xificurC: justin_smith: but I'll lose that the moment I close emacs or nrepl, where could I put it so it auto-loads?

10:03 justin_smith: you could put it in a project and lein install that project, and make it a deps in your profiles.clj under the :user key

10:03 or make it an :injections task to evaluate that macro def

10:03 the former probably makes more sense

10:04 xificurC: sounds like ten things I have never done yet, so let's try it!

10:04 justin_smith: that's the spirit!

10:17 xificurC: justin_smith: I created a new project and put the macro in its core.clj but when I eval it and try to run it in nrepl it doesnt seem to treat it as a macro

10:17 it tries to evaluate the argument and fails

10:17 justin_smith: well that's weird

10:19 xificurC: justin_smith: https://www.refheap.com/21369

10:20 justin_smith: trying switching to that ns

10:21 http://sprunge.us/YdFQ

10:21 it kinda worked here, but it got me the URL in crome instead of firefox

10:32 xificurC: justin_smith: it works for me with java.lang.Integer but doesn't work if I simply put SimpleDateFormat, which worked before

10:32 justin_smith: are you providing the full class name?

10:32 xificurC: probably because I had it in the ns I was calling it

10:33 yeah, java.text.SimpleDateFormat works as expected

10:33 justin_smith: so the next step is lein install

10:33 then add it as a dep under :user in ~/.lein/profiles.clj

10:34 xificurC: what does lein install do exactly? creates a jar?

10:35 justin_smith: creates a jar

10:35 puts it in ~/.m2

10:35 makes it available to other projects

10:35 then the user dep gets merged with your normal deps

10:35 and then you can use jdoc in any of your projects (locally)

10:35 but it won't ship with uberjars

10:36 sveri: anyone using lighttable here? i am looking for an overview over the basic shortcuts

10:36 xificurC: justin_smith: i dont have profiles.clj under ~/.lein/

10:37 justin_smith: you could :)

10:38 {:user {:dependencies [[your-grou/jdoc "version"]]}}

10:38 that can be the entire file if you don't have one yet

10:38 it gets merged with project.clj

10:39 though it may make more sense to add it to :dev or :repl

10:39 rather than :user

10:39 xificurC: i never used those yet and didnt know they exist

10:40 what do you mean by `your-grou'?

10:40 justin_smith: whatever your group is in your project.clj for jdoc

10:40 I missed the p

10:40 xificurC: still, what would you mean by that :)

10:40 justin_smith: so (defproject your-group/jdoc ...) in your project.clj

10:40 for jdoc

10:41 if it is just (defproject jdoc ...) then you can just specify jdoc in the profiles file

10:41 maybe your-org would be more idiomatic than your-group

10:42 https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L11

10:42 in the example project it is org.example/

10:42 xificurC: hm, got an error when starting nrepl

10:43 justin_smith: what is the error?

10:43 xificurC: now it loaded

10:43 couldnt find the file

10:43 I had "0.1.0" as version and changed it to "0.1.0-SNAPSHOT"

10:44 justin_smith: yeah, you have to require the version you lein installed

10:44 :)

10:44 xificurC: so now I should be able to go (jdoc java.lang.Integer) ?

10:44 justin_smith: you still need to require the ns

10:45 (require '[jdoc.core :refer [jdoc]]) or somesuch

10:45 and that part you could make an injection

10:45 if you really want it to run for every repl

10:45 the example project.clj also shows how to do injections

10:47 xificurC: justin_smith: and I have to write that every time manually in my project.clj?

10:47 justin_smith: no, that can go in profiles.clj

10:48 just as you can add dependencies there, you can add injections

10:50 xificurC: justin_smith: and that finishes your whirlwind tour through creating and installing a project successfully. Thanks!

10:50 justin_smith: {:user {:dependencies [[your-grou/jdoc "version"]] :injections [(require '[jdoc.core :refer [jdoc]])]}}

10:50 np

10:51 glad we sorted this out!

10:51 xificurC: its still strange, but yeah

10:51 atoms

10:51 justin_smith: :dynamic

10:51 even more weird

10:51 atoms are not that bad, but ^:dynamic can do weird things

10:51 xificurC: I only wished to check 2 java classes and look where I got :)

10:52 justin_smith: we are all the wiser for it

10:53 xificurC: yes, I hope I wont forget everything in a day!

10:53 (because I don't remember anymore which 2 classes I wanted to check :D )

10:53 justin_smith: I need to learn most things 7 or 8 times before they stick

10:54 xificurC: well at least I'll have a working mini-project on my machine that I can check for the basics

10:54 (and javadoc "working")

11:06 pepijndevos: Can I pass clojure datastrucutres as command-line arguments?

11:08 guns: pepijndevos: Yes, just supply EDN strings as your argv or stdin, then read with clojure.edn/read-string

11:08 justin_smith: -main gets the args with lein run

11:08 pepijndevos: right

11:25 xeqi: brainproxy: no flag to include sourceContent for compiled js that I know of. The ability to do so for repl interactions was just added yesterday

12:16 pepijndevos: Is htere any non-ugly way to iterate over 2 seqs at the same time using for?

12:17 llasram: pepijndevos: You mean like (for [[a b] (map vector as bs)] ...) ?

12:18 pepijndevos: I guess that's the best you can get. Other alternative is to do a loop over a range and use get.

12:20 S11001001: pepijndevos: which only works well if you have good seq indexing on both

12:20 pepijndevos: Python has eaten my brain. So maybe there is a better way to do all of this, but I think this is okay.

12:21 justin_smith: pepijndevos: there is also just using map, which takes multiple sequences and moves through them in parallel

12:21 pepijndevos: justin_smith, I know, but this code would look really bad in a map

12:22 I think 7 LOC is acceptable for several levels of doseq.

12:26 xificurC: justin_smith: what if I want to adjust my installed project?

12:26 justin_smith: xificurC: you could edit it and run lein install again

12:27 of course if you share with others you would also change the version, but locally that should be less of a concern

12:27 xificurC: ok thanks

12:27 clojurebot: excusez-moi

12:38 xificurC: justin_smith: javadoc, unlike doc throws me in stacktrace when providing an unknown class. How can I force it to just return nil?

12:39 justin_smith: hmm

12:39 you could use a try catch?

12:39 the thing is, it is something you would only normally call from the top level, so the exception isn't breaking other code

12:39 xificurC: I have but it doesnt seem to work

12:39 justin_smith: just very verbosely saying it can't find the calss

12:39 *class

12:39 hmm

12:39 feel free to paste what you have

12:40 xificurC: try doing (try (javadoc fda) (catch Exception e nil))

12:40 justin_smith: is the thing thrown a subclass of Exception?

12:40 xificurC: I thought everything is

12:40 CompilerException java.lang.RuntimeException: Unable to resolve symbol: dfa in this context, compiling:(/tmp/form-init8412589436928102776.clj:1:6)

12:41 justin_smith: so try catching RuntimeException

12:41 xificurC: still a no

12:41 justin_smith: oh

12:41 xificurC: isnt there a way to catch all exceptions?

12:42 justin_smith: the exception is happening at the read stage

12:42 that happens before the try block happens

12:42 xificurC: yeah, Throwable, though catching Throwable can make bad things happen

12:42 but the issue here is that the exception happens before the try form is entered

12:42 xificurC: ok but good to know, thanks

12:43 so you cannot override it?

12:43 justin_smith: (try (javadoc (Class/forName "fda")) (catch Throwable e nil))

12:43 if you use Class/forName it does not resolve the class at read time

12:44 but don't use Throwable, oops!

12:44 xificurC: heh

12:44 srruby: Is clojure getting much traction in the real world of jobs ?

12:44 justin_smith: (try (javadoc (Class/forName "fda")) (catch ClassNotFoundException e nil))

12:44 best to be as specific as you can

12:44 srruby: I do clojure at work

12:44 llasram: ditto

12:45 xificurC: justin_smith: that works, thanks!

12:45 lucky you guys

12:45 lucky you

12:45 srruby: Thanks.

12:45 xificurC: try workin with Excel's wonderful VBA for a year

12:46 justin_smith: I'd rather not, thanks

12:46 xificurC: that language gives no guarantees the code you write will run the way you wrote it

12:47 or the same way on another machine

12:49 it still throws me a runtime exception after saving and doing lein install

12:49 justin_smith: and you restarted the repl that is using it?

12:49 xificurC: yes

12:50 justin_smith: that is weird

12:52 xificurC: (macroexpand-1 '(jdoc fa)) shows

12:52 (clojure.core/binding [clojure.java.browse/*open-url-script* "firefox"] (try (clojure.java.javadoc/javadoc (java.lang.Class/forName (clojure.core/str fa))) (catch java.lang.ClassNotFoundException jdoc.core/e nil)))

12:52 justin_smith: it tries to resolve fa before making a string out of it

12:53 xificurC: ugh

12:53 justin_smith: try putting a quote in there, so the class name is treated as a literal symbol

12:53 and not resolved

12:53 (class 'java.lang.Integer)

12:53 ,(class 'java.lang.Integer)

12:53 clojurebot: clojure.lang.Symbol

12:54 justin_smith: ,(class 'java.lang.ThisDoesNotExist)

12:54 clojurebot: clojure.lang.Symbol

12:54 xificurC: hah

12:54 that doesnt seem right

12:56 now I get

12:56 CompilerException java.lang.RuntimeException: Can't bind qualified name:jdoc.core/e, compiling:(/tmp/form-init8836743777557140171.clj:1:1)

12:57 works now

12:59 like this https://www.refheap.com/21373

12:59 justin_smith: nice

13:01 also, fyi catch has an implicit do, so technically the nil is redundant

13:01 but looks like we are all set, until you want to change where it looks up the doc :)

13:02 after that a "make stackoverflow best answers write my code" macro

13:03 http://gkoberger.github.io/stacksort/

13:05 xificurC: heh

13:06 cYmen: I don't quite get where to put dots and where to put slashes when I want to use a function from a package...

13:06 Is clojure.contrib.math/round right?

13:06 justin_smith: cYmen the package name is composed of directory names separated by dots

13:07 the slash goes between the name of the file it is in, and that function

13:07 it is easier if you do (require '[clojure.contrib.math :as cmath]) and call cmath/round

13:07 cYmen: hm...okay

13:07 justin_smith: or similar

13:07 (in the repl)

13:07 in a file you would use the :require subform in the ns declaration

13:09 cYmen: need a lein project to get those deps

13:09 no idea how to do it manually

13:09 justin_smith: or you can use pomegranate

13:09 lein project is easier

13:09 https://github.com/cemerick/pomegranate

13:10 cYmen: Anyway, if I need to get it with lein I won't be able to use it on 4clojure anyway.

13:10 justin_smith: you can put it in your user profile in profiles.clj

13:10 ahh, you want to use the library in 4clojure

13:10 likely they won't even let you load any libraries

13:10 beyond things like clojure.string and such

13:11 don't use pomegranate in 4clojure problems

13:11 lol

13:14 bender_: so i tried to write a permutations function, but it blows up the heap after around 9 items. any idea what i can do to prevent that? http://pastebin.com/y9bx9JTh

13:14 this is just a learning exercise, i know there's already a lib for it :)

13:22 justin_smith: bender_: I think what you need is to use lazy-seq around each of your calls to cons

13:22 not just on the outside sequence

13:22 which is being called on a mapcat, which is already lazy

13:25 actually: (first (perms (range 70)))

13:25 that works just fine

13:25 the heap blowup is likely because you are holding onto a head you don't need somewhere

13:29 chouser: bender_: well, the normal approach is to use an accumulator so that you can move the recursion to the tail position, and then use 'recur'

13:29 This is not necessarily easy to do.

13:30 justin_smith: well he said it blew up the heap

13:30 maybe he meant stack

13:30 bender_: nah, it was an OOM

13:30 chouser: oh, really. well then my advice is no good.

13:30 justin_smith: yeah, that sounds like holding onto the head to me

13:31 bender_: holding onto the head in the function or in the actual call to it?

13:31 justin_smith: could be either

13:32 I can run (first (perms (range 70))) with no issues

13:32 I do get a stack overflow with (first (perms (range 700))) though :)

13:33 bender_: interesting do you start your repl with a bigger heap?

13:34 i just did a lein repl, pasted that function in and got:

13:34 user=> (first (perms (range 70)))

13:34 OutOfMemoryError Java heap space

13:36 chouser: (last (perms (range 10))) works for me. Eventually.

13:37 coventry: ,(. (Runtime/getRuntime) totalMemory)

13:37 clojurebot: #<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)>

13:38 coventry: bender: What does that tell you in the repl?

13:38 Mine says ~0.5G. (first (perms (range 70))) works for me.

13:41 Actually, I guess you want maxMemory, not totalMemory.

13:47 bender_: thanks, i bumped up my heap size and it does complete. but i think that's just a bandaid, sounds like there is something that's not getting GC'd properly, but since its such a simple function there are only so many places it could be :/

13:52 sm0ke: guys, i was asking this before couldnt still figure it out

13:52 ,```y

13:52 clojurebot: (clojure.core/seq (clojure.core/concat (clojure.core/list (quote quote)) (clojure.core/list (quote sandbox/y))))

13:52 sm0ke: ,'''y

13:52 clojurebot: (quote (quote y))

13:52 sm0ke: what is it with syntax-quote evalutaion?

13:53 rplaca: sm0ke: the syntax quote version namespaces symbols by default

13:53 to support more hygenic macro creation

13:53 justin_smith: it namespaces things to avoid all the stupid bugs macros would cause in common lisp

13:53 sm0ke: rplaca: yes but its seem much more than simple namespace resolution

13:54 rplaca: sm0ke: how so?

13:54 sm0ke: shouldnt it be look like just ##''`y

13:54 lazybot: ⇒ (quote (quote clojure.core/y))

13:54 justin_smith: it is turning (quote whatever) into its expansion

13:54 Rhymor: ,'(:a)

13:54 clojurebot: (:a)

13:54 Rhymor: ,`(:a)

13:54 clojurebot: (:a)

13:54 Rhymor: ,``(:a)

13:54 clojurebot: (clojure.core/seq (clojure.core/concat (clojure.core/list :a)))

13:55 rplaca: sm0ke: the rules are here: http://clojure.org/reader

13:56 Rhymor: I think I never quite understood the syntax quote.

13:56 sm0ke: yea its beyond me too

13:56 although i am just a newbie

13:58 rplaca: sm0ke: it's expanding to be what's necessary to create the structure (quote y)

13:58 but I agree that that's more than I expected it to do there

13:59 Rhymor: Without the namespaces it turns ```y into (seq (concat (list 'quote) (list 'y)))

13:59 rplaca: but remember that the idea is that that whole structure will be evaluated at compile time and, therefore, simplified

14:00 Rhymor: Which of course would return (quote y)

14:01 sm0ke: Rhymor: is the (seq) form necessary?

14:01 and does 'quote 'y really need to be in a list, to be concated

14:02 may be its the way internal algorithm handles it

14:02 rplaca: sm0ke: think about it this way: every "extra" layer of ` requires an extra "eval" to undo it

14:02 sm0ke: cant really argure without much knowledge of how it works

14:03 rplaca: ,`y

14:03 clojurebot: sandbox/y

14:03 rplaca: `(eval `y)

14:03 ,`(eval `y)

14:03 clojurebot: (clojure.core/eval (quote sandbox/y))

14:03 rplaca: ,(eval `y)

14:03 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

14:04 rplaca: yeah, that sandbox won't let me do that

14:04 but

14:04 try (eval ``y)

14:04 (eval (eval ```y))

14:04 etc.

14:04 and you'll seee

14:04 sm0ke: whats the point? i dont see it

14:04 rplaca: in practice you don't nest `

14:05 unless there's a ~ escape in between

14:05 brainproxy: xeqi: thanks for the clarif

14:05 rplaca: the only reason you might is if you were writing a macro to write macros

14:05 Rhymor: sm0ke: the backquote allows for ~ and ~@ while quote doesn't. So quote can simply return whatever is quoted while the backquote needs to create the quoted list so it could insert unquoted content

14:05 rplaca: which is not a common case

14:06 sm0ke: +1 for Rhymor

14:06 sm0ke: Rhymor: makes sense i guess

14:07 rplaca: consider:

14:08 ,(let [a 12] `[y ~a])

14:08 clojurebot: [sandbox/y 12]

14:08 brainproxy: anyone working on a runner/wrapper that would provide integration for karma and clojurescript.test?

14:08 sm0ke: yes,but the same argument should hold for ##``y

14:08 lazybot: ⇒ (quote clojure.core/y)

14:08 sm0ke: i expected some list there

14:09 zerokarmaleft: can imports be reversed with ns-unmap?

14:09 rplaca: sm0ke: there are some nice uses for ` for various kinds of templating but it probably makes the most sense at first just to think about them wrt to writing macros

14:09 sm0ke: btw did you guys noticed that y resolved to clojure.core?! weird

14:10 rplaca: sm0ke: that resolves to user/y in my repl

14:10 Rhymor: it resloves to the current namespace.

14:10 sm0ke: yes but look at the lazybot response

14:10 Rhymor: So clojure.core is just an artefact of clojurebot which runs in the clojure.core namespace for whatever reason

14:10 rplaca: laybot efaults to running in clojure.core? interesting

14:11 sm0ke: ,`y

14:11 clojurebot: sandbox/y

14:11 rplaca: *defaults

14:11 Rhymor: Ok, now I'm puzzled

14:11 I'll just shut up and let the grown ups talk :)

14:11 sm0ke: clojurebot is playing mindgames here

14:11 rplaca: right, you're using two different bots there

14:11 sm0ke: ,``y

14:11 clojurebot: (quote sandbox/y)

14:11 sm0ke: aha!

14:12 Rhymor: :D

14:12 rplaca: sm0ke: why are you fixated on the nested ` case?

14:12 * sm0ke ignores rplaca for having no reason at all. :P

14:13 rplaca: you're basically going double meta there and things get weird :)

14:13 Rhymor: wanting to understand something is reason enough

14:13 rplaca: yes it is, but there's a lot to understand about the actual use cases for that model that I think would make it clearer

14:14 as in: what's the context in which that makes sense?

14:14 and that context is macro writing macros or similar double meta things

14:15 sm0ke: well to be honest i was just playing around, no conrete usecase

14:15 Rhymor: Yea, but I for one was able to use the syntax quote in macros without actually understanding how it works. I think I know now more than I did 10 minutes ago.

14:15 rplaca: hah! :)

14:16 my advice: file this conversation until you have reason to try something double meta, then reexamine the behavior in that context

14:16 slatevero: Noob question: What's the idiomatic way of creating a list with N items each resulting from a function call?

14:16 rplaca: it *is* good to understand and you may be able to do something crazy powerful with it when you get the chance

14:17 slatevero: calling the same function over and over with the same (or no) arguments?

14:17 slatevero: same function, same args

14:18 rplaca: slatevero: http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/repeatedly

14:18 slatevero: any then something like (take N (repeatedly f)) ?

14:18 justin_smith: ,(repeatedly 4 #(println "hello"))

14:18 clojurebot: (hello\nhello\nnil hello\nnil hello\nnil nil)

14:18 rplaca: (repeatedly n #(f a1 a2 a3))

14:19 will do it

14:19 slatevero: ahh, ok cool

14:19 justin_smith: slatevero: repeatedly takes a count argument

14:19 Rhymor: slatevero: why does the function return different things when called?

14:19 slatevero: thank you

14:19 rplaca: Rhymor: common reasons are reading I/O and generating random values

14:19 slatevero: it returns the same thing, like for creating a pool of connections

14:19 justin_smith: ,(repeatedly 3 rand)

14:19 clojurebot: (0.06532742636001476 0.8633735928031471 0.5121772655897804)

14:19 Rhymor: Ok, that makes sense

14:20 sm0ke: does rand should be renamed to rand!

14:20 haha

14:20 justin_smith: ! is for things that are unsafe in a dosync

14:20 binski: is this kind of SQL possible with sqlkorma? http://stackoverflow.com/questions/2334712/update-from-select-using-sql-server

14:20 llasram: That's not strictly true

14:20 sm0ke: oh i thought any function with side effect/ unpure

14:21 llasram: It's mostly just conventionally for operations which have side-effects

14:21 justin_smith: then we would have print! slurp! spit! ...

14:21 llasram: rand isn't a pure function, but it doesn't have (strictly observable) side effects

14:21 coventry: I've heard the dosync story, too, but if it's true, I think the convention ought to change. Because, who uses dosync that much?

14:21 Rhymor: I guess it is to mark functions where it is not immediately obvious that they have side effects

14:22 llasram: justin_smith: It's not a strict thing. When the point of a function is the side-effect, doesn't seem as useful to indicate it :-)

14:22 sm0ke: well ! is just a convetion, so it wouldnt be idiomatic to have something like i-mutate-myself! kind of name, the name itself tell enough

14:23 hmm i was the one who started this i guess :P

14:24 all people seem to have same point of view, win win!!

14:25 gfredericks: !! for functions that are totally surprising. (defn identity!! [x] (System/exit 42))

14:25 llasram: heh

14:26 I think I'd make that one `identity!!!11one!`

14:26 Rhymor: !? for functions which have a side effect and return a boolean for success or failure

14:27 sm0ke: we should have tight ffi integration with C, and convention of having every function suffixed with !!!

14:27 justin_smith: ,(->> 'clojure.core ns-publics (map first) (map str) (filter #(re-matches #".*!" %)))

14:27 clojurebot: ("set-agent-send-executor!" "pop!" "assoc!" "conj!" "alter-meta!" ...)

14:27 justin_smith: these are only things unsafe in a dosync

14:28 coventry: I like to name my vars after Daily WTF URLs.

14:28 gfredericks: ,'http://gfredericks.com

14:28 clojurebot: http://gfredericks.com

14:28 gfredericks: o_O

14:28 llasram: Nice symbol you've got there

14:28 gfredericks: I honestly hadn't expected that

14:28 justin_smith: oh wait - persistent! is in there

14:29 gfredericks: ,(let [http://gfredericks.com 42] http://gfredericks.com)

14:29 clojurebot: #<CompilerException java.lang.RuntimeException: Can't let qualified name: http://gfredericks.com, compiling:(NO_SOURCE_PATH:0:0)>

14:29 llasram: ,(namespace 'http://gfredericks.com)

14:29 clojurebot: "http:/"

14:29 sm0ke: haha reminds me of the C trick, where http://gfredericks.com is valid code

14:29 coventry: Can you really not build up a transient in a dosync?

14:29 justin_smith: no, that's were I realized it wasn't true

14:30 llasram: Oh, entirely w/in the dosync. That makes senes

14:30 justin_smith: ,(dosync (let [a (transient [])] a))

14:30 gfredericks: ,(dosync (into [] (range 5)))

14:30 clojurebot: #<TransientVector clojure.lang.PersistentVector$TransientVector@50646c>

14:30 [0 1 2 3 4]

14:31 justin_smith: so it seems core uses it for transients, metadata, and dosync-unsafeness

14:31 llasram: metadata?

14:31 justin_smith: alter-meta!

14:32 llasram: Oh, but that actually mutates the metadata for something

14:32 vary-meta is unexcited :-)

14:33 justin_smith: ,((juxt identity meta) (alter-meta! #'alter-meta! assoc :wow "really?"))

14:33 clojurebot: [{:arglists ([iref f & args]), :ns #<Namespace clojure.core>, :name alter-meta!, :column 1, :added "1.0", ...} nil]

14:33 justin_smith: truncated, but it does work

14:33 oh, returns the meta and not the var

14:34 (get (meta #'alter-meta) :wow)

14:34 ,(get (meta #'alter-meta) :wow)

14:34 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve var: alter-meta in this context, compiling:(NO_SOURCE_PATH:0:0)>

14:34 justin_smith: err

14:34 ,(get (meta #'alter-meta!) :wow)

14:34 clojurebot: "really?"

14:35 llasram: Oh my

14:35 justin_smith: very similar to the common lisp practice of proplists on symbols

14:35 llasram: The "oh my" was that clojurebot allows it

14:36 coventry: Hmm, that looks like a potential hole in the sandbox.

14:36 justin_smith: yeah, you could do some sneaky stuff that way

14:36 llasram: ,(alter-meta! #'alter-meta! assoc :doc "A very safe function.")

14:36 clojurebot: {:arglists ([iref f & args]), :ns #<Namespace clojure.core>, :name alter-meta!, :column 1, :added "1.0", ...}

14:36 llasram: ,(doc alter-meta!)

14:36 clojurebot: "([iref f & args]); A very safe function."

14:36 justin_smith: ROFL

14:37 sm0ke: cats are out of the bag!

14:38 coventry: (alter-meta! #'deliver assoc :macro true)

14:38 justin_smith: ,(alter-meta! #'juxt update-in [:doc] #(str % "\n\nAND IS TOTALLY AWESOME!"))

14:38 clojurebot: {:ns #<Namespace clojure.core>, :name juxt, :arglists ([f] [f g] [f g h] [f g h & fs]), :column 1, :added "1.1", ...}

14:38 coventry: ,(alter-meta! #'deliver assoc :macro true)

14:38 clojurebot: {:arglists ([promise val]), :ns #<Namespace clojure.core>, :name deliver, :column 1, :added "1.1", ...}

14:38 coventry: ,(deliver 1)

14:38 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$deliver>

14:38 justin_smith: (doc juxt)

14:38 clojurebot: "([f] [f g] [f g h] [f g h & fs]); Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)] AND IS TOTALLY AWESOME!"

14:39 llasram: coventry: My mind when the same place...

14:39 s,when,went, even

14:40 justin_smith: ,@(deliver (promise) 1)

14:40 coventry: (alter-meta! #'deliver dissoc :macro)

14:40 clojurebot: 1

14:40 coventry: I wonder how often it resets.

14:41 ,(do (alter-meta! #'deliver assoc :macro true) @(deliver (promise) 1))

14:41 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$deliver>

14:48 xificurC: writing after losing connection and wondering why noone is answering, hehe

14:48 I found that you can get the methods of a Java class via (:members

14:48 (clojure.reflect/reflect foo)). Is this still actual and precise?

14:48 and why is January 0 in a Java Calendar?

14:54 justin_smith: there is also bean - sometimes useful

14:54 (bean java.lang.String)

14:54 ,(bean java.lang.String)

14:54 clojurebot: #<ExceptionInInitializerError java.lang.ExceptionInInitializerError>

14:54 justin_smith: ,(bean "hello")

14:54 clojurebot: #<NoClassDefFoundError java.lang.NoClassDefFoundError: Could not initialize class sun.awt.AppContext>

14:55 justin_smith: ,1

14:55 clojurebot: 1

15:00 xificurC: justin_smith: thanks

15:04 sm0ke: ,(bean (java.util.Date.))

15:04 clojurebot: #<NoClassDefFoundError java.lang.NoClassDefFoundError: Could not initialize class sun.awt.AppContext>

15:06 sm0ke: ,(java.util.Date.)

15:06 clojurebot: #inst "2013-11-30T20:09:53.828-00:00"

15:06 sm0ke: ,(doc bean)

15:06 clojurebot: "([x]); Takes a Java object and returns a read-only implementation of the map abstraction based upon its JavaBean properties."

15:06 sm0ke: wth

15:07 llasram: Seems to be a sandbox thing

15:08 `cbp: ##(bean (java.util.Date.))

15:08 lazybot: ⇒ {:seconds 5, :date 30, :class java.util.Date, :minutes 21, :hours 12, :year 113, :timezoneOffset 480, :month 10, :day 6, :time 1385842865021}

15:12 rplaca: if you're messing around with dates and times, I highly recomend you look at clj-time which is a wrapper for joda time. It makes everything more sane.

15:18 llasram: The irony of someone using the handle `rplaca` talking about API sanity is pretty awesome :-D

15:18 justin_smith: lol

15:36 glosoli: hmm is there some way to check in REPL if custom stack size was applied ? (I set it in project.clj, but want to make sure)

15:36 * seangrove shakes his head at gender flamewars in the node community

15:38 sm0ke: glosoli: i think gettting stack size is not very sriaghtforward, you can try using jconsole to connect to your repl to get an idea of usage however

15:40 glosoli: sm0ke thanks

15:48 sm0ke: https://github.com/clojure/java.jmx can also be used at repl i guess

15:48 nice, that makes jmx pretty easy!

15:48 xificurC: rplaca: thanks, I was using the Java Calendar only because of a book example

15:49 but I will remember clj-time

15:49 justin_smith: there is also jvisualvm for tracking resource usage

15:56 seangrove: Wait, is it not possible to do ajax PUT requests?

15:57 yogthos|away: Trying to make a :put request with cljs-ajax, but getting an error that such a method doesn't exist

16:13 grncdr: does anybody else wish if-let allowed multiple bindings?

16:14 justin_smith: so, what, the first binding would be magic?

16:15 hiredman: the compiler needs magic to automatically chain let with things

16:15 let-try

16:15 try-let

16:15 etc

16:16 grncdr: justin_smith: the bindings would be implicitly "and"ed

16:16 justin_smith: oh, so you want and-let

16:16 grncdr: oh, is and-let a thing?

16:16 ,(doc and-let)

16:16 clojurebot: Huh?

16:16 justin_smith: no

16:17 seangrove: grncdr: It's been suggested before, but then you don't know where the failure is

16:17 justin_smith: just saying, if you are doing and on all the bindings, that isn't if, that's and

16:17 seangrove: Probably an easy enough macro to write if you feel strongly about it, grncdr

16:18 grncdr: yeah, I haven't had a case where I've felt that strongly about it yet

16:18 but it's been at least 2-3 times I've expected it to work and it hasn't

16:18 at least the error is good :)

16:18 seangrove: grncdr: Yeah, I agree. I understand the tradeoff though, so I'm not too upset about it

16:19 grncdr: hm, I don't know if I do...

16:19 seangrove: Generally just a (let [multiple bindings] (if (and all the bindings) ...))

16:20 grncdr: the tradeoff is that you don't know which binding is falsy… but doesn't that also happen when you do it manually?

16:20 e.g. (and x y z), you don't know if x or y or z was nil/false

16:21 anyways, this is straight-up yak-shaving so I understand if it's not that interesting to anybody else ;)

16:21 seangrove: grncdr: But an if-and-let is a pretty coarse level of control

16:22 It's rare that you want to do multiple bindings and fail if any of them fail... usually you have multiple bindings and different branches based on various combinations

16:22 Maybe a cond-let would be cool

16:22 ,(doc cond-let)

16:22 clojurebot: Cool story bro.

16:22 grncdr: hah

16:22 hiredman: are you familiar with maybe?

16:22 grncdr: no

16:23 seangrove: hiredman: Scala's Option?

16:23 llasram: I pull in algo.monads all the time just for the maybe monad

16:23 grncdr: ah, yeah, in my case I'm not really looking for a maybe monad

16:23 hiredman: ugh, I would like to the tests for algo.monads for examples, but the formatting is horrible and if you don't already know what maybe does they are not clear at all

16:23 llasram: grncdr: I actually think you are looking for Clojure's version of it

16:24 hiredman: link

16:24 llasram: It's basically an if-let with any number of bindings, which returns `nil` when the first one returns `nil`, and in which you can intersperse other (non-tested) lets and arbitrary boolean tests

16:24 grncdr: hm, well, I could see it being implemented using a maybe monad...

16:26 seangrove: llasram: Definitely would like to see a good example of it

16:26 Sounds like I'm missing out on a useful pattern

16:28 grncdr: I thought I understood the maybe monad, and I can see the similarity between what I'm asking and what it *could* do, but I feel like I was after something simpler

16:28 llasram: Here's an example from the code I'm working on right now: https://gist.github.com/llasram/7724741

16:28 The details are certain to be incomprehensible

16:29 But hopefully the structure is clear

16:30 grncdr: so I'm seeing the conditions (:when …) but not how to bind the result of a test

16:31 llasram: Oh, you can do arbitrary bindings with :let [...]

16:31 Those results aren't checked for the nil-ness

16:31 All the top-level bindings are though

16:31 grncdr: yeah, I was (slowly) realizing that after I asked

16:31 "right, it's the maybe-monad"

16:32 ok, that's actually pretty nuts

16:33 llasram: It keeps "bail with nil if something goes wrong at any point" type functions nice and flat

16:33 grncdr: (inc llasram)

16:33 lazybot: ⇒ 13

16:33 grncdr: yeah

16:34 so… now the dumb question: what namespace is `am` ?

16:34 contrib.monads?

16:34 llasram: Oh, https://github.com/clojure/algo.monads

16:34 grncdr: ah

16:34 not a dumb question after all :)

16:34 llasram: It's the "new" name for contrib.monads, but yeah

16:35 rubber-duck: can I reference vars not bound in ns by using full names (with ns) in clojurescript ? ie. is this code : (ns foo) (defn x [] ..,) (ns bar) (foo/x) - valid ?

16:36 grncdr: should be

16:36 you could try it on cljsfiddle if you're not sure

16:36 but I'm pretty sure I do that in this code I'm working on...

16:36 rubber-duck: I'm just worried about optimization not working if there are no references in ns declaration

16:37 grncdr: hm, that is a good point...

17:19 also: is there a reason cljs.nodejs set!s string-print instead of set-print-fn! ?

17:21 simply requiring cljs.nodejs and calling enable-console-print! means you get no newlines

17:25 noncom|2: what is the common way to dynamically load jars in a running clojure program?

17:26 * new jars

17:26 justin_smith: pomegranate

17:26 also: https://github.com/cemerick/pomegranate

17:26 llasram: From the REPL? You can directly use pomegranate, or use alembic for a slightly more convenient interface

17:27 https://github.com/pallet/alembic

17:28 noncom|2: cool! i'll check up both, thank you

17:28 xcthulhu: What is the correct term to use for someone who programs clojure?

17:28 ...is it a clojuror?

17:29 llasram: I'd just go with "Clojure programmer"

17:29 noncom|2: i've heard about clojurians

17:29 in several different places

17:29 clawjuror

17:30 justin_smith: clojerk

17:30 noncom|2: ahaha

17:30 clojerker

17:30 `cbp: clojodyte

17:30 justin_smith: the meetup group here in town is clojerks pdx

17:31 xcthulhu: hehe

17:33 Raynes: Oh man, Python can eat me with its explicit returns.

17:33 llasram: It wouldn't be so bad if it didn't implicitly return None without one...

17:35 brainproxy: how do I include a "preamble" (e.g. licensing info) in the cljs compiler's output such that the generated source map still points to the correct line numbers

17:35 simplying prepending such text messes up the line numbers

17:36 grncdr: brainproxy: I don't know, but I don't think it would be possible currently

17:37 brainproxy: grncdr: i was gueesing it's not but figured I would ask :)

17:37 grncdr: you could probably write something that modifies the sourcemaps themselves after the fact without too much fuss, if you need a quick & dirty solution

17:37 brainproxy: never know what subtle option I missed when looking over the source

17:37 grncdr: i was experimenting with uglifyjs for that purpose

17:38 but I think I'll make a feature request in any case

17:38 grncdr: another q&d would be to just throw your license into a giant string literal at the top of the file :P

17:38 brainproxy: haha, nice

17:38 justin_smith: isn't the point of the sourcemap that it translates from a place in an uglified concatenated file to an original file and line? if so wouldn't prepending a chunk of text leave those references accurate?>

17:39 brainproxy: justin_smith: i tried it an indeed the line numbers got foobar'd

17:39 justin_smith: oh

17:39 arrdem: Raynes: I mean... if you find that an attractive prospect whatever. Personally I like explicit returns more than Scala's implicit return shit

17:39 grncdr: justin_smith: the sourcemap maps from positions in the compiled output, so if you add data to the start of that, things get messed up

17:40 justin_smith: ok, I didn't think it would work that way

17:45 also: brainproxy: i wonder if something like this would work: https://github.com/thlorenz/combine-source-map

17:49 dnolen: brainproxy: preamble enhancement patch welcome - it looks like your preamble comment just needs a @preserve annotation for it to work - http://developers.google.com/closure/compiler/docs/js-for-compiler

17:50 brainproxy: dnolen: if I knew how to write the patch I would do it, I'm not sure I can dive off into that atm, but maybe my feature request will inspire someone with the know how

17:52 or even an example of a patch that did something broadly similar w.r.t. enchancing the cljs compiler

17:52 dnolen: brainproxy: open a minor enhancement ticket in JIRA - I'm unlikely to tackle this myself anytime soon, too many other fish to fry - it would require a fairly simple modifications to closure.clj

17:52 brainproxy: dnolen: I'll take it on if there is an example I can learn from

17:52 Raynes: arrdem: Yeah, it's just that I keep forgetting to do it.

17:52 dnolen: brainproxy: if you look at how we do the :output-wrapper you'll see it's not a particularly difficult enahancement

17:52 Raynes: It's more my problem than Python's.

17:53 also: dnolen: how does the output wrapper work with sourcemaps?

17:54 dnolen: also: this is a case where's it informative to look at the source ;), see cljs.closure/build

17:55 brainproxy: dnolen: do I need to do the CLA stuff to be able to submit to JIRA

17:55 that's not a problem, just never crossed that bridge

17:55 dnolen: brainproxy: not to open a ticket, but to submit a patch yes

17:55 brainproxy: dnolen: hmm, what's the access point for submitting ticket

17:55 googling jira clojurescript took me to something which required a login

17:56 dnolen: brainproxy: http://dev.clojure.org/jira/browse/CLJS

17:56 brainproxy: ok

17:56 dnolen: brainproxy: you might need to create an account but anyone can

17:56 brainproxy: ah

17:56 also: dnolen: yeah, i was looking at the source. it just wasn't clear to me how the newline added by add-wrapper was accounted for by the source map

17:57 dnolen: also: lines 1099-1105 in cljs/closure.clj

17:57 also: the source map is generated *after* we constructed the final concatenated source

17:57 brainproxy: dnolen: are there any plans to support sourceContent in the cljs compiler's source map output, or would the .map files be so huge that it would be silly?

17:57 dnolen: also: oh actually it's not!

17:57 also: :)

17:57 dnolen: also: so that's a bug

17:59 also: or actually I'm not sure ... simple and advanced are likely to remove the wrapping function?

17:59 also: dnolen: no, it sticks around

18:00 dnolen: also: so Closure never removes a top level function that's immediately invoked?

18:01 also: yeah it'll get removed in advanced

18:01 also: dnolen: well, stripping the function can change the value of this

18:01 dnolen: also: I'm now less convinced this an issue

18:02 also: if you're using source maps and :simple or :none there's little reason for the wrapper

18:02 also: and for production code people generally won't expose the source map

18:02 also: dnolen: yeah, i'm not super concerned about it. but it's the same as brainproxy's issue

18:03 bellkev: Say, I was just reading through the clojure.test source, and I was wondering if anybody knows why they went with the :test metadata scheme to run through all the tests in a namespace. Was there a reason not to just use a :test true flag in the metadata instead of put the whole test body in the metadata?

18:03 darklord5: question(sorry to interrupt): I am trying to map a function: (-> :content clojure.string/capitalize) to a list of maps structure like so: ({:tag :tt, :content ("305")})...but the problem is clojure attempts to evaluate ("305") before being passed to capitalize. So I tried to pass ("305") to quote via: (-> :content quote clojure.string/capitalize) but this isn't working either. What am i doing wrong here?

18:05 amalloy: darklord5: you've mis-identified the problem. and you can't really "call" quote on something at runtime, because all the compilation and quoting is already done

18:06 i mean, it seems to me like the issue is that (-> :content capitalize) isn't a function at all (in fact evaluating it will throw an exception), so everything after that assumption is broken

18:07 conceivably you might have meant #(-> % :content capitalize), which is IMO a less-clear way to write (comp capitalize :content)

18:08 also: dnolen: i still see the wrapper with :advanced

18:08 dnolen: also: yes because we add it afterwards to avoid problems

18:09 also: so you're right it would through of course maps, but I'm not convinced anyone should use :output-wrapper true w/ source maps enabled

18:09 s/through of/throw off

18:10 seangrove: "through of course maps"

18:10 go home dnolen, you're drunk.

18:11 dnolen: seangrove: haha

18:11 seangrove: dnolen: Thinking about coming out west for clojure/west?

18:12 dnolen: seangrove: likely if I submit a talk and it gets accepted :)

18:15 seangrove: dnolen: Well, get on it then ;)

18:16 dnolen: seangrove: haha

18:16 brainproxy: dnolen: to clarify, at present combining the output wrapper and source maps will result in a problem?

18:17 dnolen: brainproxy: a problem insofar as they are incompatible options

18:17 brainproxy: and likely will always be

18:17 brainproxy: yikes okay

18:18 dnolen: brainproxy: which is not true for preamble feature

18:18 brainproxy: i understand, but I was going to combine the two

18:18 dnolen: brainproxy: they are orthogonal

18:19 brainproxy: don't necessarily have to, but wanted my test build output to essentially look exactly like the release output

18:19 and there are projects that are distributing source maps with release code

18:19 so that devs don't have to have a non-minified build onhand

18:20 dnolen: brainproxy: and the source map links to a non-minified version on a CDN or something?

18:21 brainproxy: well two that come to mind are jquery and polymer

18:21 and no, they point to a .map file that's included in, say, the bower distribution

18:21 seangrove: rkneufeld: Are there any docs on pedestal 3.0's approach to UI? I'm working on some stuff similar and would like to see how you're approaching it

18:21 brainproxy: others do it as well, those two just jumped to my mind right away

18:22 dnolen: however, I do see your point, and I can live w/o it for sure

18:22 the :preamble being a still desired and different issue, as you noted

18:30 seangrove: Hrm, can't get ajax requests to show up in the network tab of chrome devtools.

18:31 also: dnolen: lein-cljsbuild 1.0 now adds :output-wrapper with :advanced

18:32 amalloy: seangrove: as long as the network tab is open before the ajax request starts, i've never had that happen. i speculate you're failing to send the ajax request

18:33 also: dnolen: so some source-map examples upgraded from lein-cljsbuild 0.3.2 will probably run into the issue

18:33 seangrove: amalloy: It's hitting the server, and showing up in the js console, just not the network tab

18:33 amalloy: check for ghosts

18:33 only an exorcist can help you now

18:33 seangrove: amalloy: Phew, I was wondering if there was a term "ghosts" I wasn't familiar with...

18:33 Deadron: lol

18:34 amalloy: yeah, i realized that would sound confusing, so i added that second one

18:34 dnolen: also: yeah, I don't really agree w/ that default, not a CLJS issue in any case

18:36 grncdr: dnolen: random question but, who's responsible for mix having :solo and :mute be the names used by mix/toggle ?

18:36 because that is awesome

18:53 munderwo: Hi all, new to clojure. Trying to make a simple web app. and I'm getting an exception while trying to use selmer? https://www.refheap.com/21377 I'm sure I'm doing something stupid here, but I'm not sure what.

18:54 coventry: munderwo: render-file is not in the ns. You might want selmer.parser/render-file, if that's where render-file lives.

18:55 mattmoss: Is there a function f such that (f #'x) gives me 'x ?

18:55 Seems like I'm just missing something obvious.

18:55 `cbp: munderwo: either use selmer.parser/render-file

18:55 or change your ns declaration to refer that symbol

18:56 munderwo: like (:use [selmer.parser :only [render-file]]) ??

18:56 lazybot: munderwo: Definitely not.

18:56 coventry: good boy, lazybot. :-)

18:56 also: haha

18:56 munderwo: ahhh… whats lazybot and what did it tell me not to do?

18:56 `cbp: munderwo: change use for require and only for refer and we're in business

18:57 coventry: (doc var-get) <-- mattmoss

18:57 clojurebot: "([x]); Gets the value in the var object"

18:57 mattmoss: coventry: I don't want the value, I want the name.

18:58 munderwo: `cbp: so In the code examples I've been using there is a :use for compojure.core and ring.adapter.jetty… should I not be doing that either? should it all be require?

18:58 `cbp: munderwo: they are outdated, use require

18:58 justin_smith: mattmoss: quote, but it only works at compile time

18:59 because looking at names only works at compile time

18:59 munderwo: righto. cheers! and refer instead of only?

18:59 `cbp: munderwo: yes

18:59 mattmoss: ,(quote #'x)

18:59 clojurebot: (var x)

18:59 coventry: ,(-> #'inc meta :name)

18:59 clojurebot: inc

19:00 coventry: That's not totally reliable, though. Depends on how the var is created.

19:00 akurilin: uhm actually don't answer that just yet, connection is going nuts for a sec.

19:00 mattmoss: Basically, doing some macros, returning value from a def (which is a var), want the name.

19:00 `cbp: there is no question!

19:00 justin_smith: ,(alter-meta! #'inc assoc :name 'dec)

19:00 clojurebot: {:ns #<Namespace clojure.core>, :name dec, :file "clojure/core.clj", :column 1, :line 874, ...}

19:00 justin_smith: ,(:name (:meta inc))

19:00 clojurebot: nil

19:00 coventry: mattmoss: You get the name (a symbol) in a macro for free.

19:00 justin_smith: ,(:name (meta #'inc))

19:00 clojurebot: dec

19:00 mattmoss: ,(:name (meta inc))

19:00 clojurebot: nil

19:01 also: ,(.sym #'inc)

19:01 clojurebot: inc

19:01 coventry: mattmoss: Worst case, you can grovel in the form which produces the def to get the name, if you're in a macro.

19:01 mattmoss: coventry: Perhaps... I'm still figuring that out, since it's clojure macros being used from cljs. Which means you may be correct, but my brain is rather warped at this point to fully realize that.

19:01 also: probably not that

19:02 rkneufeld: seangrove: No docs on Pedestal 0.3.0's UI approach exist yet.

19:03 seangrove: rkneufeld: Would you be up to talk about it sometime? Would definitely like to hear about it from a high level view

19:04 ,(= {:a 10} {:a 10 :b nil})

19:04 clojurebot: false

19:04 rkneufeld: seangrove: I actually haven't even had a chance to catch up on the dataflow engine changes yet–been heads down on the book for months :S. I'm expecting to dig in a little mid-December and over the holidays.

19:07 seangrove: llasram: This look like the place to use the maybe monad? https://www.refheap.com/21378

19:07 mlb-: Where might I find information on impementing a new host target for Clojure? This is from purely academic, self-educational curiosity.

19:08 seangrove: rkneufeld: Sure, no problem

19:08 rkneufeld: seangrove: what are you working on?

19:09 seangrove: rkneufeld: Working on a ui layer for clojurescript, trying to bring together declarative web-components-like markup, core.async internal widget behaviors, and pedestals' funcational-as-long-as-possible approach

19:10 rkneufeld: Neat! I know Tim and Brenton have been mulling over some stuff in this vain the last few months, but there isn't much concrete on the ground yet.

19:10 seangrove: I've found myself independently recreating a lot of pedestal's ideas, so I'd like to have a high-bandwidth talk with someone who knows what they're doing (not me) and see if this is worth the time

19:11 munderwo: hmm.. is there a reason that a tutorial is telling me I can do lein ring server , but it seems like I only have lein run ?

19:11 rkneufeld: Tim or Brenton would probably be the best people to talk to then.

19:11 munderwo: I seem to have something called lein-ring installed?

19:11 seangrove: rkneufeld: tbaldridge? I don't know Brenton...

19:12 rkneufeld: seangrove: Tim Ewald–though he has a vanishingly small online presence.

19:12 munderwo: oh wait… maybe Im stupid :)

19:12 rkneufeld: seangrove: If you want to ping the whole gang, drop an email to pedestal@cognitect.com

19:13 hiredman: mlb-: clojure isn't like a lot of schemes or lisps, it isn't a self contianed system to be ported, it places a lot of emphasis on host integration

19:13 seangrove: rkneufeld: Well, don't want to take up too much of their time. I'll keep going at it independently until I have something with more substance

19:13 rkneufeld: seangrove: It's a slow season right now, so don't expect us to beat you to the finish ;)

19:14 akurilin: I accidentally stumbled upon the last question shalloway ever answered on SO back 2+ years ago, heh.

19:14 seangrove: rkneufeld: No problem, maybe with a bit of luck that'll be my ticket to give a talk at clojure/west ;)

19:14 hiredman: mlb-: there have been a few ports of clojurescript to different targets, but (and opinions differ on this) I don't think clojurescript is clojure, in my experience it is a cut down set of functionality

19:15 I don't know if any of the clojurescript ports (like the lua one?) are active

19:15 mlb-: hiredman: I'd figured any development on a new target should start as a subset. I'm curious at which parts of the subset are necessary to implement first, etc.

19:17 hiredman: most of the big differences between clojurescript and clojure stem from clojurescript having very distinct compilation and runtime phases

19:17 where clojure doesn't

19:18 so for example macros in clojurescript are written in clojure, because the clojurescript language isn't really available at compile time, and compilation happens upfront before runtime

19:19 similarly clojure has a very nice reified linking construct (vars) which clojurescript doesn't have, it has the same sort of implicit linking the target has

19:21 mlb-: these certainly tell me a lot about differences between Clojure and ClojureScript, but not where one might begin to implement a new Clojure target

19:21 hiredman: mlb-: that information doesn't really exist

19:22 also: mlb-: check out some of cemerick's ports of clojure libraries to clojurescript libraries

19:22 hiredman: the only other clojure target is the clr port

19:22 tbaldridge: mlb-: If you want to talk sometime about this, feel free to contact me. I wrote clojure-py and learned a lot doing it. Mostly I learned how it was way harder than I thought.

19:22 mlb-: ah, alas. I was hoping given clojurescript, clojurec, clojureclr, clojurepy, etc. there might be more information

19:22 hiredman: and that wasn't done via a manual of how to port clojure

19:22 tbaldridge: mlb-: there's about 20 different ways to do "a port". Each is done a bit differently.

19:23 mlb-: tbaldridge: haha. You admitted what I was most afraid of, but had an intuitve assumption was the case.

19:25 hiredman: the other thing is there isn't a clojure standard, so while I have spent a lot of time reading and writing clojure and have strong opinions about what clojure is, other people have other opinions

19:26 grncdr: hm, does anybody know a good pattern for creating a "bus" in core.async without feedback issues?

19:26 hiredman: you mean an unbounded queue?

19:27 grncdr: not exactly… longer explanation forthcoming...

19:28 I want a mult channel that carries application state, and various go-loop blocks that tap that channel so they each have a view of the latest application state… that much is straightforward

19:29 what gets tricky, is I want some of those go-loops to have other inputs, and put a new version of the application state back on "bus" channel based on those inputs

19:30 hiredman: use an atom

19:30 grncdr: it seems to me that by doing that, the new state is going to show up as a new input

19:30 tbaldridge: grncdr: just store the app state in an atom.

19:30 grncdr: crap

19:30 I was doing that before ;)

19:30 chouser: is it safe to interact with atoms from inside go blocks in ClojureScript?

19:32 I guess I can't think of any reason why it wouldn't be, but without some channel involved somewhere, no go block will ever give up control to another.

19:33 hiredman: chouser: (go ((fn foo [] … (go (foo)))))

19:43 coventry: Can slamhound be configured to refuse to pick when there are multiple options?

19:45 amalloy: hiredman: does that really work, though? (go ((fn ...))) doesn't allow you to use <! and so on from inside the ..., because the core.async transformer doesn't reach inside lambdas, right?

19:49 hiredman: amalloy: depends I guess, the idea is just to get a control loop that yields to other go blocks without using channels

19:51 you could move … in to the (go …) and get the go transform of …, and then you would get rid of the outer (go …)

20:02 rovar: hey all.. I'm trying to understand what #' does.

20:02 I saw http://stackoverflow.com/questions/10945187/is-pound-quote-in-clojure-running-the-resolve-and-symbol-functions

20:02 but the thing is that (foo 10) will return the same result as (#'foo 10)

20:02 justin_smith: ,#'+

20:02 clojurebot: #'clojure.core/+

20:02 rovar: ,+

20:02 clojurebot: #<core$_PLUS_ clojure.core$_PLUS_@78f49c>

20:03 justin_smith: ,(map type [#'+ +])

20:03 clojurebot: (clojure.lang.Var clojure.core$_PLUS_)

20:03 justin_smith: one is the var, the other is the value of the var

20:04 rovar: so if I'm trying to pass a handler.. for instance in http-kit. I see some examples pass #'myhandler and others define the handler with fn

20:04 so one is passing a var, and one is passing a fn

20:04 justin_smith: the difference is when you pass the var in, it sees the new value if you rebind the var

20:04 rovar: so i should be able to pass myhandler directly without supplying the var, yes?

20:04 ah

20:04 justin_smith: because defining a new function does not replace the old one - both exist

20:04 rovar: but when executing a var is implicit?

20:04 justin_smith: but the var will point at the new one

20:05 the implicit thing is that symbols, unless quoted, get treated as vars

20:05 rovar: so its dereferencing the var automagically

20:05 justin_smith: yeah

20:05 rovar: meh

20:05 I mean.. I'm sure it makes things simpler

20:05 justin_smith: and you pass in the var if you want it to see new values of the var when you change it

20:05 rovar: sure..

20:06 justin_smith: you just use the symbol if you want it to resolve once and continue using that value

20:06 rovar: so in the example: https://github.com/http-kit/chat-websocket/blob/master/src/main.clj#L44

20:07 they pass in the var, in case someone decides to redefine msg-received at some point

20:07 justin_smith: right

20:07 it is useful during development

20:07 rovar: seems kind of janky. I'd rather pass the the function directly so noone can go and change it,

20:07 how would you make use of it during dev?

20:08 redefine it in the repl after you've launched the server?

20:08 justin_smith: yeah

20:08 I usually start a repl from within the server actually

20:08 so I can redefine things as I work without restarting

20:08 rovar: yea..

20:09 I've done a fair amount of scala and haskell and chicken scheme. Having a hard time with the fuzzy typing

20:10 being able to change methods as I'm running seems useful, though..

20:11 unrelated question: is there a timeout for doseq?

20:11 justin_smith: nope, if you hand it an infinite list it will go until you interrupt it or it runs out of heap

20:12 rovar: so I'd need a way to interrupt the generator, in such cases..

20:12 justin_smith: right

20:13 you could have a reduce, with a condition that calls reduced

20:13 reduce is eager

20:13 rovar: ok.. last question.. what is the postfix * operator?

20:13 justin_smith: there are no operators

20:13 rovar: oh.. nm

20:14 justin_smith: * in a name indicates something is internal

20:14 usually

20:14 if it is the end of the name

20:14 rovar: yea.. it's like prime

20:14 justin_smith: right

20:14 rovar: they're just making the next version of the hash and then reassigning it

20:14 justin_smith: so let expands to let*

20:14 fn expands to fn*

20:14 I just use prime

20:15 ,(reduce (fn [x x'] (if (= x' x) (reduced :OK))) [0 1 2 3 3 4])

20:15 clojurebot: nil

20:15 justin_smith: err

20:15 ,(reduce (fn [x x'] (if (= x' x) (reduced :OK) x)) [0 1 2 3 3 4])

20:15 clojurebot: 0

20:16 Bronsa: ,(reduce (fn [x x'] (if (= x' x) (reduced :OK) x')) [0 1 2 3 3 4])

20:16 clojurebot: :OK

20:16 justin_smith: that's what I wanted :)

20:16 thanks

20:18 hyPiRion: or like

20:18 ,(some (fn [[x y]] (= x y)) (partition 2 1 [0 1 2 3 3 4]))

20:18 clojurebot: true

20:18 arrdem: (inc brehaut)

20:18 lazybot: ⇒ 21

20:19 justin_smith: hyPiRion: the point was more the usage of prime', but yeah :)

20:19 hyPiRion: oh

20:19 pdk: ,(doc reduced)

20:19 clojurebot: "([x]); Wraps x in a way such that a reduce will terminate with the value x"

20:20 justin_smith: it is basically a return statement for reduce

20:20 hyPiRion: I just tend to see clojure expressions and attempt to make different variations of them

20:20 justin_smith: fair enough

20:20 hyPiRion: That is not always what people want though :p

20:21 andyf: Bronsa: Continuing thanks for all of the tools.analyzer work. When you say "it is trivial to use a custom macroexpander that passes as &env a localsym->localbinding map", is there an example of that somewhere?

20:21 justin_smith: hyPiRion: yours is definitely the better example of finding a duplicate, if that was what I were demonstrating

20:23 Bronsa: andyf: basically just replacing env with (:locals env) here https://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/jvm.clj#L128 should work for the core.async use case

20:23 amalloy: it occurs to me that (if (= x' x) (reduced :OK) x) can be rewritten as ({x' (reduced :OK)} x x). i don't think this is actually better, but it's a funny little thing

20:24 justin_smith: indeed it is

20:24 Bronsa: andyf: however if some library is using the value part of &env it's going to be trickier, you should transform the tools.analyzer map representation of a local to a Compiler$LocalBinding

20:24 andyf: Bronsa: I will give that a try. Is there any reason not to do such a thing when analyzing any Clojure code at all? I can make it an option for eastwood, if necessary, but better if the default works for most cases.

20:24 justin_smith: amalloy: wait, is that how reduced works?

20:25 amalloy: er, what, justin_smith? it's a generic conversion, which would work as well if we replaced (reduced :OK) with foo

20:25 hyPiRion: I find it more interesting that you can have the reduced outside of the reduction function

20:25 justin_smith: amalloy: I guess I thought calling it did the short circuit, but you have to return it?

20:25 Bronsa: andyf: the problem is that essentially there's no way &env is going to be 100% compatible, so I prefered to keep it different instead of making it maybe work and maybe not

20:26 amalloy: oh man, if calling it short circuited as a side effect, i think rich would spontaneously combust

20:26 justin_smith: yeah, I didn't understand, clearly

20:26 amalloy: reduced is just a one-arg deftype

20:26 justin_smith: cool

20:26 andyf: Bronsa: Is the goal that eventually tools.analyzer will be used as part of a Clojure compiler? If so, were you thinking of supporting &env in a different way than Clojure currently does, or not at all?

20:27 amalloy: (deftype Reduced [x]) is actually the whole body, i think? i guess there's probably a protocol like IReduced

20:27 ah, it's written in java, and implements IDeref

20:27 but it's like five lines long

20:28 justin_smith: cool

20:28 hyPiRion: heh, hm

20:29 akurilin: I'm still astounded by how much fun certain tasks can become with Clojure. I'm playing with instaparse, and between REPL-driven development, tests and functional programming the task becomes pure play.

20:29 justin_smith: akurilin: definitely

20:30 hyPiRion: ,(reduce #(deref %2) (map (comp reduced reduced) (range)))

20:30 clojurebot: 1

20:30 justin_smith: in the future zinga will be the worlds leading software development company, when they train all their users to write clojure code that passes unit tests in order to see colorful explosions

20:30 Bronsa: andyf: doubtfully tools.analyzer will be part of the clojure compiler anytime soon, &env is (I think) an undefined feature and is currently implementation specific

20:31 akurilin: justin_smith, lol what is that a reference to?

20:31 Bronsa: s/undefined/undocumented

20:31 justin_smith: akurilin: quick iteration, short term reward, that's what makes games successful

20:31 zinga is a very successful casual game company

20:31 hyPiRion: Isn't like... Clojure itself implementation specific? I haven't seen any implementation/design paper

20:31 akurilin: justin_smith, oh, very good point.

20:32 justin_smith: also a joke :)

20:32 Bronsa: andyf: the thing is, if I wanted to macroexpand using a &env compatible with Compiler.java's one I'd have to change the AST representation to use Compiler.java classes -- and avoiding that is one of the goals of tools.analyzer

20:32 akurilin: justin_smith, one of my biggest lessons from working with instaparse was making veeeeery small incremental changes, the more trivial the better, otherwise you lose your sanity. Combine these hundreds of "tiny victories" over a long stretch of time, and you're addicted.

20:33 justin_smith: right

20:33 unit-test farmville!

20:33 hiredman: I've only ever used the keys of &env

20:33 andyf: Bronsa: OK. I am not familiar with the gory details there yet (and may never be), but I was hoping to use tools.analyzer on as large a variety of existing code bases as possible, and core.async definitely uses &env

20:33 amalloy: it's very hard to use the vals of &env correctly

20:33 akurilin: justin_smith, i bet you there's a team doing that already :)

20:35 Bronsa: andyf: well, I've made macroexpand-1 to be an extension point of tools.analyzer so as I've said, just rebinding ana/macroexpand-1 to a macroexpand-1 similar to jvm/macroexpand-1 but that applies the macro using (:locals env) instead of env *should* be enough for most use-cases (I've never seen anybody use the values of &env)

20:35 andyf: So far most of the contrib libraries analyze without errors, and I've tested another 2 dozen or so Clojure libraries that are not contrib libs today. Things are looking fairly good.

20:36 Bronsa: WIll try that out soon. Need to go run an errand now, but will let you know how my testing goes. Thanks again.

20:36 Bronsa: andyf: you've done an invaluable job at testing tools.analyzer on those libraries I, Thank you!

20:37 amalloy: TBH I never seen anybody use &env vals, I cannot even think of a use-case where that would be needed

20:38 rovar: ,(reduce (fn [x x'] (if (= x' x) (reduced (str "duplicate:" x')) x')) [0 1 2 3 3 4])

20:38 clojurebot: "duplicate:3"

20:38 amalloy: oh wait, actually, i think i may have seen the vals used effectively once. let me check

20:39 Bronsa: maybe the only useful information they expose is whether the local is a fn arg or not?

20:39 amalloy: Bronsa: no, you can actually get at the types the compiler knows about

20:39 Bronsa: right

20:40 amalloy: https://github.com/flatland/useful/blob/develop/src/flatland/useful/datatypes.clj#L62 uses vals of &env to generate typehinted record-manipulation code

20:42 rovar: ,(reduce (fn [x x'] (if (= x' x) (reduced (str "duplicate:" x')) x')) (repeatedly #(rand-int 20)))

20:42 clojurebot: "duplicate:4"

20:42 rovar: hurray #

20:42 :)

20:44 Bronsa: amalloy: clever

20:51 bbloom: alex asked me to add some perf tests to CLJ-1200, but i ran in to something kinda strange & was wondering if somebody could verify that i'm not crazy

20:51 if you've got a clojure.jar lying around, run `java -jar clojure.jar` and then eval this expression:

20:52 (dotimes [n 10] (time (dotimes [i 5000000] ((fn [& args]) 1 2 3 4))))

20:52 Bronsa: bbloom: http://sprunge.us/FFdO

20:52 bbloom: on my box, the first time i do that, it averages about 2msecs, but if i eval it again, it averages 55ms

20:52 after that it averages 130ms each time

20:52 i'm wondering why it slows down after evals

20:53 changing the number of times doesn't seem to impact it

20:53 hiredman: https://gist.github.com/hiredman/7727659 not entirely unlike bronsa's in shape

20:54 bbloom: Bronsa: hiredman: ok now eval that expression again

20:54 hiredman: huh, interesting

20:54 coventry: bbloom: I see the behavior you describe.

20:54 Bronsa: bbloom: http://sprunge.us/WNjO

20:54 bbloom: https://gist.github.com/brandonbloom/7727665

20:54 hiredman: heh

20:54 it is slower everytime

20:54 bbloom: weird, right?

20:54 Bronsa: ok bbloom me too now

20:55 bbloom: so strange....

20:55 amalloy: same here. that's really weird

20:55 bbloom: one of you geniuses figure that one out while i try to benchmark the original issue lol

20:58 slatevero: what are the conventions for style when making a long function call? i've read Batsov's style guide but it doesn't really address this.

20:58 Ex: (create-channels (if channel-per-consumer consumer-count consumer-cxn-count) consumer-connections)

20:58 would you break that kind of thing into multiple lines?

20:59 Bronsa: bbloom: I don't see that behaviour with -XX:+TieredCompilation

20:59 bbloom: Bronsa: do you see the faster or slower speed? :-P

20:59 Bronsa: they keep around 50ms

20:59 there's no slowdown after evaluations

21:00 bbloom: hm ok

21:00 wtf does that flag do?

21:00 is there a good guide on what to do when benchmarking?

21:00 clojurebot: Gabh mo leithscéal?

21:00 amalloy: slatevero: i probably would, yes. one newline, after the if-expr

21:00 justin_smith: TieredCompilation sets the hotspot optimization level

21:01 slatevero: @amalloy tnx

21:01 amalloy: i guess i would put some inside the if-expr as well; i forgot that. but it's optional

21:01 justin_smith: bbloom: criterium makes it pretty easy, I just added as a dep in my dev profile

21:02 coventry: But you don't want to run criterium under leiningen because of the TieredCompilation issue, IIRC.

21:02 slatevero: is it typical to leave the first function argument on the same line as the function?

21:02 ..and put additional arguments on newlines if they're long?

21:03 justin_smith: slatevero: not everybody likes this, but it mostly reflects the norms https://github.com/bbatsov/clojure-style-guide

21:04 slatevero: @justin_smith - thanks. i read through it but it didn't really mention much about newlines for long function calls so i thought i'd ask

21:05 bbloom: is there a description of the tieredcompilation thing anywhere?

21:06 justin_smith: http://docs.oracle.com/javase/7/docs/technotes/guides/vm/performance-enhancements-7.html

21:06 Bronsa: bbloom: http://docs.oracle.com/javase/7/docs/technotes/guides/vm/performance-enhancements-7.html

21:06 duh.

21:06 justin_smith: lol, I think we got the same link

21:08 bbloom: anyone have a library that 1) makes heavy use of "&"-style variadic functions 2) has a benchmark suite?

21:08 Bronsa: thanks

21:16 CaptainLex: Hey Clojure room, I have some architecture questions

21:18 scape: how am I supposed to keep an nrepl connection consistent? i tried holding on to the connection and client references, but when re-evaluating the namespace it seems to always default to user; I can't seem to figure out how to get it to keep the namespace it's in

21:19 justin_smith: scape: are you using defonce to bind the connection?

21:19 or maybe I should ask, how are you storing the connection

21:19 scape: no, but i am placing it in a ref and it's not getting over written there

21:20 as in: (dosync (alter buffers conj {bid {:ch ch, :nrepl (nrepl/client (nrepl/connect :port 7888) 1000)}} ;;bid is buffer id

21:20 hiredman: scape: you need to have session middleware and keep the session key to send back and forth

21:20 scape: you should not do io in a transaction

21:20 scape: oh, so it's not necessarily the client or connection information, but the session?

21:21 i placed that for brevity, would a let suffice?

21:24 hiredman: would it make more sense then to have a single nrepl connection and hang on to the session keys? i want to be able to evaluate separately, from different threads

21:25 CaptainLex: Does anyone here know about shaders for OpenGL programming? The basic idea is I want to write shaders in Clojure instead of GLSL. This means "compiling" Clojure to GLSL. What should I use for the compilation steps. Would "simple" macros suffice? Should I invoke the reader somehow?

21:26 s/steps./steps?

21:27 scape: check out shadertone CaptainLex

21:27 CaptainLex: scape: Whoa thanks dude, I shall do this

21:31 scape: Do you know how I can contact that Roger Allen guy?

21:31 scape: I do not, sorry :\

21:32 CaptainLex: scape: No problem, I'll figure it out. He's on Twitter!

21:32 Thanks so much!

21:32 creese: What is the idiomatic way to open a database connection (and keep it open) using java.jdbc?

21:33 justin_smith: creese: best is probably to use a c3p0 pool

21:33 clojurebot: Ik begrijp

21:34 justin_smith: otherwise, if you are only going to be single threaded with your queries, you can reuse a connection by either passing it to each query, or have helpers that provide it to each jdbc function

21:34 then you can store it in an atom (if you really only need one connection / one pool) or have some other method for finding it

21:34 you could use a let surrounding an fn to capture it lexically

21:35 (let [connection (get-connection)] (defn query ...))

21:36 hiredman: :(

21:37 creese: justin_smith: does 'query' take a connection or config map?

21:38 hiredman: bad on many levels, a. hiding things b. global connection objects c. I am sure I could come up with more

21:39 justin_smith: hiredman: so would you go for the pass the connection to every function that uses the db route?

21:42 hiredman: justin_smith: depends

21:42 but definitely don't do a closed over let

21:44 creese: I need the connection for the entire request-response cycle, and I don't want to close it when the request is done

21:44 hiredman: creese: use c3p0

21:47 one way to approach this is to create db "workers" tasks that run on their own threads that take in queries and return responses from the database, so the db workers have to worry about re-connections, etc, but that has issues with handling errors and resource ownership

21:49 c3p0 sort of does this behind a jdbc interface, but c3p0 can be painful to configure, although once we got everything tuned at work I don't think we've had further problems with it

21:55 creese: thanks, I'll take a look

22:17 doug_: Hi all. I'm just getting started, and trying to get the core.logic library working. I am getting "unresolved symbol" errors but I am not sure why.

22:19 justin_smith: doug_: that usually means you are naming things that are not defined, or trying to name something not visible yet from the current namespace

22:19 bbloom: doug_: are you trying to introduce new logic variables? maybe you want the "fresh" macro?

22:19 coventry: doug_: Can you post the code and the stacktrace you're getting to refheap.com

22:20 doug_: All I'm trying to do is "(defrel man x)" and getting an error

22:20 coventry: What's your ns form?

22:20 doug_: I used lein, and added the core.logic to my deps, and confirm it downloaded. Then lein repl, and type (use 'clojure.core.logic

22:21 other commands, like (run) work finee

22:21 hiredman: doug_: can you pastebin the exception you get?

22:22 doug_: I believe defrel has been removed from the latest core.logic release

22:23 doug_: hiredman: thanks... wouldn't have even thought of that

22:26 bbloom: doug_: it's pretty easy to experiment for this sort of thing. more so with functions (which are applicative, and evaluate all their arguments), but also possible for macros too: you just try to eval the component parts

22:26 ,(let [x y] z)

22:26 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: y in this context, compiling:(NO_SOURCE_PATH:0:0)>

22:26 bbloom: ,y

22:26 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: y in this context, compiling:(NO_SOURCE_PATH:0:0)>

22:26 bbloom: ,let

22:26 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/let, compiling:(NO_SOURCE_PATH:0:0)>

22:27 bbloom: note "can't take the value of a macro"

22:27 it found it! but it can't get it's value :-P

22:27 functions are easier:

22:27 ,(+ x y)

22:27 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>

22:27 bbloom: ,+

22:27 clojurebot: #<core$_PLUS_ clojure.core$_PLUS_@c1e9ba>

22:27 bbloom: ,x

22:27 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>

22:27 bbloom: try experimenting that way for undefined symbols in the future!

22:28 doug_: OK, I posted it on the refheap with my errors https://www.refheap.com/21383

22:29 hiredman: yeah, there is some new thing that replaces defrel, I don't really know anything about it (not that I ever knew anything about defrel)

22:29 coventry: Hmm, defrel is still in the tutorial: https://github.com/swannodette/logic-tutorial#question--answer

22:29 doug_: coventry: my error from core.logic https://www.refheap.com/21383

22:31 coventry: defrel has been replaced by pldb, apparently. (Never heard of it.) https://github.com/clojure/core.logic/blob/master/CHANGES.md#changes

22:32 If you're going through that tutorial, I would downgrade to version 0.8.4.

22:32 doug_: coventry: thank you I will give that a try

22:37 coventry: THANK YOU! I should have asked about 2 hours ago.. it was driving me nuts :)

22:44 bbloom: another good trick: download the code and run `git grep defrel` and if that doesn't produce any results, run `git log -p` and then type `/defrel` to search for the most recent change that mentions it

22:45 i use those two tricks all the time whenever a readme or blogpost seems out of date :-)

22:46 doug_: bbloom: nice idea

22:47 bbloom: `git log -p` is like a magic cheat code for being the fastest team member to find what change introduced a bug :-P

22:47 coventry: doug_: NP. You might want to post an issue about it. https://github.com/swannodette/logic-tutorial/issues

22:47 doug_: BTW, pldb function appears to be "persistent logic database" but I'm not sure of all the implications

22:47 coventry: yes, great idea

22:48 avoid others from being as confused as I am :)

22:58 thanks all for the help... issue submitted on the tutorial

23:22 beppu: ,(let [bigfn identity] (eval '(bigfn 1)))

23:22 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

23:22 beppu: I get this: CompilerException java.lang.RuntimeException: Unable to resolve symbol: bigfn in this context, compiling:(NO_SOURCE_PATH:1:30)

23:23 Why doesn't bigfn resolve to the identify function that was assigned to it when used with eval?

23:23 coventry: I don't think eval gets the local bindings from the context in which it's called.

23:23 beppu: What are you trying to do?

23:24 beppu: coventry: http://www.4clojure.com/problem/58

23:26 justin_smith: you really don't need eval for that

23:26 coventry: Hint: Do you know the syntax for a variadic function signature?

23:27 beppu: [& args] ?

23:27 coventry: Hint 2: and do you know how to loop over a list?

23:27 beppu: I was trying to loop with reduce in this case.

23:28 I'll figure it out.

23:28 ..

23:28 I was just curious about eval's behavior.

23:29 justin_smith: eval usually isn't what you need

23:46 madisjc: Does anyone know where clojure.java.io moved to?

23:47 justin_smith: what, it moved?

23:47 madisjc: everything I see looks out of date

23:47 Raynes: It hasn't moved anywhere.

23:47 hiredman: madisjc: clojure.java.io is where it as has always been

23:48 Raynes: madisjc: http://clojure.github.io/clojure/clojure.java.io-api.html

23:48 madisjc: ah great

23:48 thanks for the link Raynes

Logging service provided by n01se.net