#clojure log - Sep 17 2012

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

3:01 augustl: I want to write a java library and then special libraries for some of the JVM langs, clojure being one of them. It makes no sense to put this reusable java library on clojars I guess? Never published stuff for the java platform before ;)

3:29 aperiodic: i think that the bar for being published on clojars is, in general, purposefully pretty low (obviously, someone should speak up if they disagree)

3:30 i mean, i've thrown up a few forks of java libraries that i couldn't find in repos elsewhere up there, so if it has more thought put into it, all the better

3:31 perhaps i'm being a jerk

3:31 augustl: that being said, if it is java, why not put it on maven central or somesuch?

3:32 augustl: it'll be as good as clojars as far as clojure use is concerned, since lein searches those repos

3:32 i think it even trumps those, but don't quote me on it

3:32 augustl: aperiodic: maven central probably makes sense, yeah

3:33 would make sense if Groovy users wouldn't have to set up clojars as a repo ;)

3:33 aperiodic: yeah, definitely go for the lowest common denominator there

3:34 augustl: and now for something completely different

3:34 is there a built-in function to read a file that contains only a map, or a vector, or some other data structure, runtime?

3:39 aperiodic: i don't think so. i just do (binding [*read-eval* false] (try (-> file slurp read-string) (catch java.io.FileNotFoundException _ nil)))

3:40 (fun fact, you don't even need to import java.io.FileNotFoundException in your ns)

3:45 augustl: aperiodic: cool

3:50 hah, read-string is awesome

3:50 biscarch: If I find an oauth2 provider library in java, what potential problems will I face using it in Clojure?

3:51 augustl: biscarch: in general I make sure I only use java libraries that don't have singletons in them, so they can be "functional" in that you create new objects for every clojure function call

3:52 biscarch: so if the oauth2 provider library has a global singleton where it stores temporary data, for example, you will quite possibly not be able to have the clojure API you wanted

3:53 I do a lot of java interop in my code, in fact I think at least 50% of my code is java interop at this point, that's been unproblematic so far because the java libs I've been using are well designed

3:56 aperiodic: biscarch: on the subject of general stylistic approaches to take with java libraries in clojure, have you seen zach tellman's "distilling java libraries"?

3:57 biscarch: aperiodic: no I havent, but I'll check it out

3:58 augustl: ok. Thanks for the advice.

4:06 augustl: is there a sane way to test (clojure.test) whether a function has been called, other than having the function set a ref or something like that?

4:06 yes I know functions aren't supposed to have side effects etc. :)

4:25 amalloy: no

4:33 augustl: not sure if I want to make a library for it.. Bad for my image (easy side effects in Clojure yay)

4:33 amalloy: midje probably does it already

4:37 augustl: perhaps there's something in lazytest (I don't use midje)

4:40 why does this https://www.refheap.com/paste/5107 throw clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: my-ref in this context, compiling:(NO_SOURCE_PATH:12)?

4:41 amalloy: that eval is probably happening in a different namespace

4:41 augustl: hmm, is there something like eval where I can pass in the namespace?

4:42 amalloy: no. instead use qualified symbols, eg by using ` instead of '

4:43 ideally don't use that eval, but i assume you have some crazy reason for doing it

4:44 augustl: I see

4:44 amalloy: the data/code comes from read-string on a file

4:46 the data/code also needs to be evaluated in the contest of the caller, not from the namespace where my function that currently calls eval lives..

4:46 I suppose my API could take the namespace as its first argument

4:50 is there a function to evaluate a form in a specific namespace?

4:50 clgv: augustl: you can use `in-ns` or binding *ns* should work as well

4:52 augustl: clgv: and then just (eval form) it?

4:52 clgv: augustl: no. you got to use `in-ns` in your eval

4:53 augustl: clgv: ah

4:54 hmm, in-ns takes a symbol, not a clojure.lang.Namespace

4:56 what's the use of *ns*? Seems that all APIs take namespace names, not Namespace objects

5:01 (in-ns (.getName the-ns)) works, seems a bit hacky though..

5:08 Sgeo: ,(macroexpand-1 '(-> *ns* .getName in-ns))

5:08 clojurebot: (clojure.core/-> (clojure.core/-> *ns* .getName) in-ns)

5:08 Sgeo: ,(macroexpand '(-> *ns* .getName in-ns))

5:08 clojurebot: (in-ns (clojure.core/-> *ns* .getName))

5:09 clgv: augustl: there is ns-name

5:10 ,(-> 'clojure.core the-ns ns-name type)

5:10 clojurebot: clojure.lang.Symbol

5:10 clgv: ,(-> clojure.core ns-name type)

5:10 clojurebot: #<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.core, compiling:(NO_SOURCE_PATH:0)>

5:10 clgv: ok, the first one was the minimal for demo ^^

5:12 augustl: clgv: ah, nice

5:32 mindbender1: hi All

5:34 kral: namaste

6:16 augustl: is there a built-in method for reading a file by path from file system _or_ classpath?

6:17 clgv: augustl: load-file

6:18 ah you want both?

6:18 stain: load-file would also evaluate it

6:18 augustl: but.. you mean with different URIs?

6:18 augustl: or to try both witnh a relative path?

6:21 clgv: augustl: you can try whether the file exists via clojure.java.io und File methods and if not use `resource` to find it on the classpath

6:25 augustl: stain: something like that

6:26 stain: (slurp file) if it exists, use (.getPath (clojure.java.io/resource file))

6:26 ..if the file doesn't exist on the fs

6:28 stain: (resource n) gives you URI for a resource - you could use that and (file) with (reader) - but I don't know of anything that 'fail over' like you say

6:28 of course one way to do that would be to put the folder in question on the classpath

6:28 and always use (resource)

6:29 but you might need to make your own classloader then if you don't have control of how you are launched

6:29 augustl: (slurp (or (clojure.java.io/resource file) file)) basically

6:29 ah, wasn't aware of `resource`

6:30 stain: resource just gives you the URL, it does not read it

6:30 so it should work with slurp like that

6:33 augustl: any function not in http://clojure.org/cheatsheet I'll never know about :)

6:33 stain: we'll need to do something serious about Clojure documentation soon

6:38 augustl: is there a way to get the namespace a function was defined in from within the function? *ns* seems to be the namespace of the caller (the actual current namespcae run-time)

6:43 clgv: augustl: why would you want to do that?

6:44 augustl: clgv: I'm writing a config file reader. The config file is a clojure map and I want the values of this map to be evaluated in a specific namespace

6:44 clgv: augustl: you could (def this-ns *ns*)

6:45 augustl: so that you can call helper functions in the config file, for example

6:45 and refer to symbols required from the namespace where the function that calls the config file reader lives

6:45 clgv: hmm, best so far at least :)

6:46 clgv: if you implement the load-config function in the namspace all its inters should be available. you can have a look at leiningen for that

6:46 I think in: leiningen.core.project

6:46 augustl: clgv: the function is implemented in a library that the user depends on

6:46 if I understand "implement the load-config funciton" correctly :)

6:47 xeqi: https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/project.clj#L424

6:47 clgv: augustl: thats ok as long as the config symbols are available there as well

6:48 augustl: but I would suggest you to use clojure files with namespaces for the configs. I have tried without but finally changed it for several advantages.

6:49 xeqi: ah right it uses the binding approach

6:51 augustl: still need to get the actual ns though :)

6:51 clgv: by using clojure files with namespaces I guess you mean to create one namespace per config and (def foo {:config "here"})?

6:52 clgv: augustl: yes, but usually you have a macro like "defproject"

6:52 augustl: it makes sense if you plan to be able to put parts of the config in separate files for reuse of common config values

6:53 augustl: I currently have an API like (read-config ["path/to/file.clj" "other-file.clj"] {:foo 123})

6:53 the files are read with read-string and is expected to contain a map

6:54 works fine, except from the "evaluate the values of the map in the namespace where the function calling read-config was defined" part..

6:54 clgv: augustl: well look at the source from leiningen xeqi linked

6:55 augustl: it seems to take advantage of the fact that it always uses leiningen.core.project

6:55 clgv: and you dont have a static namespace where your config commands are defined?

6:56 augustl: no, my library will be used in applications

6:56 so the namespaces will be myapp.core and what not

6:56 (def this-ns *ns*) and passing in this-ns would work for that

6:57 clgv: augustl: what if you want to have commands from multiple namespaces?

6:57 augustl: I never wanted that, so it's not supported :)

6:57 clgv: ok.

6:58 otherwise. use (ns myconfig (:use myapp.core)) (defconfig ...) ;)

6:58 augustl: I'm starting to see how a namespcae perhaps is a weird source of symbols for free floating .clj files with maps in them though

6:58 stain: clgv: then make a new namespace, and require those in there with :refer (aka old (use))

6:59 augustl: clgv: the separate config namespace does make sense, as putting "config" functions in the core namespace as I do now is a bit hacky

6:59 clgv: stain: yeah thats an option as well. temporary namespaces ^^

7:00 augustl: temporary namespaces you say?

7:01 clgv: yeah. `create-ns` + (binding [*ns* ...] ...)

7:01 augustl: ah

7:01 clgv: ah, and finally remove-ns

7:06 augustl: simply eval-ing the values of my config does not seem to be a good idea though..

7:06 at least not when the value is a Java object

7:08 clgv: augustl: you have java objects in a config?

7:11 augustl: clgv: yes, a mongodb object

7:11 it's more of an environment than a config I guess

7:12 stain: uhu..

7:12 (flash :warning-lights)

7:12 augustl: what's wrong with that?

7:12 clgv: (inc stain)

7:12 lazybot: ⇒ 1

7:12 augustl: also, seems to be a clojure record, but that's just a java object I guess

7:13 part of the environment is which DB object to use. This object will be passed to all functions performing db operations. I find it quite nice.

7:13 stain: oh, you mean, you make the db objects, and then the 'config' just selects one that has been pre-made?

7:14 augustl: something like that :)

7:14 the .clj config file that contains a map has a default :db which is a (congomongo/create-connection ...) type thing

7:14 this can also be overridden by providing a map as the 2nd argument, with the key :db

7:15 stain: does it mean you make lots of database connections (which might not work) that you then might not use?

7:15 augustl: since the values from the config files are lazily evaluated, the create-connection call in the config file isn't called, yay

7:15 stain: ah

7:15 augustl: :D

7:15 so it has left to right presedence but is lazy

7:16 and (eval some-java-object) in isolation works fine so I'm probably just reading the stacktrace wrong

7:18 hmm no it works on the objects I test in isolation, but not this particular object, for some reason

7:18 "CompilerException java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined: oiiku-central-api, compiling:(NO_SOURCE_PATH:1)"

7:22 kind of hard to grok what eval actually does by reading http://clojuredocs.org/clojure_core/clojure.core/eval

7:22 seems it's only meant for lists, not arbitrary objects?

7:27 clgv: augustl: you get the exception above if you create an object during macroexpansion and try to use it in the code at runtime

7:28 augustl: hmmm

7:28 I'm evaling the result of read-string

7:29 clgv: augustl: read-string usally evals itself if you do not disable it

7:29 augustl: ah, that's the problem then

7:29 but, but, my tests are passing! Now what do I do? :P

7:30 Fossi: wtrite better tests :>

7:31 augustl: weird though, read-string doesn't eval in my tests, only when I use it from another project

7:31 clgv: augustl: hmno, I just tried ##(read-string "(hash-map :a 1 :b 2)")

7:31 lazybot: ⇒ (hash-map :a 1 :b 2)

7:31 clgv: it's not evaling that one

7:31 maybe it was `read`

7:32 augustl: in my test, the result of read-string is {:a a, :b b, :foo a, :c (dosync (ref-set some-ref a))}. Those are the actual contents of the file.

7:32 when actually using it, a file that contains {:db (oiiku-mongodb.db/create-db "oiiku-central-api")} is {:db #oiiku_mongodb.db.Db{:conn #<Mongo Mongo: /127.0.0.1:27017>, :db #<DBApiLayer oiiku-central-api-test>}} though

7:35 jaley: hey guys - (name :a/b) returns "b", is there a function to get the "a"?

7:35 clgv: jaley: namespace

7:35 jaley: clgv: aha! merci

7:36 clgv: i've been hammering away at ns-<TAB><TAB> for a while wondering where it is

7:36 augustl: tried wrapping it in (binding [*read-eval* false] ...), no dice

7:44 it's read properly so that's not the problem.. Exception occurs when merging the read-string map with another map

7:44 still haven't been able to reproduce in a test, working on it...

7:45 doh, ok, I'm eval-ing the values from the provided map too.. No wonder, then.

7:49 jkbbwr: Why does clojure put spaces in when smashing a string together like so (println "Hi" name)

7:50 augustl: jkbbwr: use (str) to control how a string is concated

7:50 ordnungswidrig: jkbbwr: use (println (str "Hi" name))

7:50 clgv: jkbbwr: thats printing. use (str ...) for concatenation

7:51 jkbbwr: I was just wondering. I know the difference

7:53 ordnungswidrig: jkbbwr: I think it's a design choice, not necessarily something you can derive logically.

7:53 jkbbwr: ordnungswidrig: thanks :)

7:53 ordnungswidrig: I'd prefer it as it is now

7:53 (e.g.)

8:01 augustl: jkbbwr: I would also have designed it like that, so I can (println "[PREFIX]" foo)

8:20 jkbbwr: Im just starting off learning clojure, I have heard its da bomb and it looks it so far but its gonna take some practice

8:23 joegallo: jkbbwr: welcome.

8:23 jkbbwr: joegallo: its a very new and kinda scary world

8:29 antares_: jkbbwr: according to The State of Clojure survey this year, about 70% of people come from either Java or Ruby/Python, so sounds like it's doable :)

8:30 jkbbwr: It gets really complicated really really quickly :s

8:30 I get the basics already but it starts getting trippy fast

8:39 dhofstet: I'm using an agent to println to stdout from other agents, however, it also outputs "nil" everytime. Is there a way to suppress those "nil"s?

8:40 I tried println-str, but then there is no output at all

9:08 clgv: dhofstet: paste your code e.g. on refheap.com

9:11 dhofstet: and try to have a minimal example

9:15 dhofstet: clgv: https://www.refheap.com/paste/5110

9:16 clgv: dhofstet: thats by far not minimal

9:16 dhofstet: clgv: ok, I try to make it more minimal

9:17 clgv: dhofstet: but your error is that you send the "naked" println. the first argument to the function you send is the state of the agent. thus you get the nil printed

9:17 dhofstet: you could send (fn [_ s] (println s))

9:26 augustl: https://github.com/weavejester/lein-ring mentions "development mode" and "production mode" - what's that?

9:26 is it a ring concept? A leiningen contept? Something else?

9:26 weavejester: augustl: "If the LEIN_NO_DEV environment variable is not set, the server will monitor your source directory for file modifications, and any altered files will automatically be reloaded."

9:27 augustl: it could be explained better.

9:27 dhofstet: clgv: thanks, this works. Seems like I have to reread the agents chapter again, as I don't yet fully understand what happens ;-)

9:27 augustl: weavejester: so it's only for "lein ring server"?

9:27 weavejester: augustl: It really only applies to Lein2

9:27 augustl: Um, I mean Lein1

9:27 augustl: yep

9:28 augustl: I see, thanks

9:54 Blkt: good day everyone

9:55 is there anyone using clojureql or korma with an Oracle database via SID?

9:58 augustl: what are the correct types to use for a multimethod that takes a list or a map?

10:01 chouser: java.util.List and java.util.Map

10:03 augustl: chouser: a clojure map is java.util.Map?

10:03 chouser: yes

10:03 clojurebot: yes isn't is

10:07 augustl: what about using clojure.lang.IPersistentVector and clojure.lang.IPersistentMap?

10:36 clgv: augustl: then you are more specific and dispatch only on these

10:44 shoky: just making sure cause i'm a noob - on http://clojure.org/agents in the example description, it should say that the chain is of m agents, and there are n actions, right? (not the other way around like the actual text says)

10:45 clgv: shoky: the example?

10:45 shoky: yes

10:45 where it says "Example"..

10:46 clgv: yes

10:47 shoky: great. thank you

11:03 one other thing about that example- i don't understand why the check for (zero? i) in the relay function

11:03 won't that make only the last "action" be reported?

11:05 hm i guess that's the intention

11:05 clgv: seems like thats the goal

11:13 callen: okay, how do I get clojure.xml/parse to take a non-validating XML document?

11:13 the non-validating DTD example I found on Google is old and doesn't work

11:13 I keep getting "I java.net.MalformedURLException: no protocol" when I attempt to parse the XML

11:17 clgv: called: you should post a gist of your code so that someone can help you

11:20 callen: ^^

11:27 babilen: callen: I typically use clj-tagsoup to parse "XML" / "HTML" and hand it over to clojure.zip/xml-zip as this allows me to get the data I'm after with clojure.data.zip.xml/xml-> (and xml1->)

11:29 danielglauser: Does anyone know if the bindings in let are lazy?

11:32 clgv: danielglauser: no they are not. only lazy-sequences are lazy in clojure

11:32 danielglauser: clgv: Thanks!

11:39 renatocaliari: Hi all

11:41 naeg: hi renatocaliari

11:43 renatocaliari: Well, I've worked as developer since 1998 but I've started study Clojure a few months ago. Now I've decided join to channel #clojure and meet the people.

11:45 Some people I already follow on Twitter. So, I'd like to know if that channel is a good place for clojure community =)

11:45 naeg: renatocaliari: it is. there are a lot of helpful and friendly people online here

11:47 renatocaliari: Cool! =) Tks.

11:47 callen: babilen: that ended up being my solution, didn't see you until now.

11:48 babilen: thanks.

11:48 babilen: trying to understand xml-> now.

11:48 dhofstet: renatocaliari: there is also the clojure google group

11:48 hfaafb_: is there a de facto clojure style guide that says something about linebreaks and indentation

11:50 sundbp_: anyone got tips how to get tools.jar onto classpath using lein 2?

11:50 callen: and it's not returning anything o_o

11:50 naeg: hfaafb_: last time I asked a question about a convention, I was linked to this: http://dev.clojure.org/display/design/Library+Coding+Standards

11:51 hfaafb_: but identation is usually taken care of by your IDE

11:51 sundbp_: oops - didn't realize there was a lein channel. moving it there.

11:51 hfaafb_: yeah i guess my question was really about linebreaks

11:52 naeg: hfaafb_: you're probably better off asking this question directly. the library coding standards don't seem to say something about linebreaks

11:52 babilen: callen: http://stackoverflow.com/questions/1194044/clojure-xml-parsing helped me a little

11:54 callen: babilen: yeah, been there done that.

11:54 https://www.refheap.com/paste/5112 <--- I can't get anything out of this zipped xml.

11:54 (zipxml/xml-> zipped :data :location :location-key zipxml/text), (zipxml/xml-> zipped :location :location-key zipxml/text) (zipxml/xml-> zipped :location-key zipxml/text) all don't work.

11:57 babilen: callen: Could I see the underlying XML?

11:58 callen: babilen: "http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdXMLclient.php?zipCodeList=94043&product=time-series&begin=2012-01-01T00:00:00&end=2013-04-21T00:00:00&maxt=maxt&mint=mint"

11:58 this is getting kinda ridiculous though

11:58 I could've had this parsed ages ago in Python

12:00 TimMc: What's the goal here?

12:01 Firefox doesn't complain about this XML. It doesn't validate, you say?

12:02 callen: TimMc: long past that.

12:02 TimMc: I mean, it doesn't, but I used tagsoup to sidestep that

12:03 TimMc: now I can't get data.zip.xml/xml-> to return anything from the parsed and zipped document.

12:03 which is kinda ridiculous because I have a working example with Python and minidom that took me maybe 2 minutes to start yanking data with.

12:05 using map and filter I could probably get the whole thing parsed in Python in maybe ~10 minutes. Not sure why Clojure is so cantankerous for such a simple task.

12:07 TimMc: I'm not sure why you're using zippers to access it.

12:08 My first inclination would be XPath.

12:29 callen: TimMc: this is how I saw everybody else doing it.

12:29 TimMc: everybody that talks about accessing parsed XML uses the zip-xml approach.

12:31 TimMc: more profoundly, I'd like to know why the goddamned code doesn't work.

12:31 I don't want to just cargo-cult around, if something doesn't work, I want to know *why*

12:37 duck11232: zip-xml is great for parsing xml unless you need namespace support

12:37 I've found XOM to be the easiest to use from clojure

13:21 rabbler: Hello Clojure peeps. I have a large application written in Java using spring and maven (blah, I know). Does anyone know the best way to add add the ability to connect to the server using a clojure repl? Basically, is there any spring (blah) bean to the context which opens a port that allows connecting a repl? I'm trying to start injecting some clojure into the application to start encouraging dabbling in clojure.

13:21 wow, bad engish.

13:22 hit return too quickly. But, I think you get the idea. I just want to add a REPL to a spring based java application (running in Tomcat) at the moment.

13:22 jsabeaudry: rabbler, perhaps you could be interested in nrepl

13:22 rabbler: Blurg, typing too fast.

13:22 technomancy: rabbler: a dumb socket repl is trivial to add, but nrepl will get you better interop and tooling.

13:23 rabbler: techonomancy, you gave up swank! :-)

13:23 but, I am no expert on Clojure. Though, I've been to two clojure-conj. heh.

13:23 Does nrepl require emacs?

13:23 technomancy: swank needed to die; the needs of the many outweigh the needs of the few, &c

13:24 rabbler: hahj.

13:24 technomancy: no, nrepl is client-agnostic

13:24 you can connect via `lein repl :connect host:port` or via emacs/IDEs

13:26 rabbler: I'll see if I can figure it out. Thanks. This is the correct site? :https://github.com/kingtim/nrepl.el

13:26 technomancy: no, that's the Emacs client

13:26 rabbler: that's what I thought.

13:26 technomancy: the server is just "nrepl"

13:26 rabbler: heh. hence why I asked about emacs. heh.

13:27 jsabeaudry: rabbler, https://github.com/cemerick/nREPL

13:27 oops

13:27 rabbler: heh, not: https://github.com/clojure/tools.nrepl

13:27 ?

13:27 jsabeaudry: yes my bad

13:27 heheheh

13:27 rabbler: Cool, cool.

13:27 Thanks everyone.

13:40 yankov: what happens on a low level when you pass a list (or anything else) to a function? Does it create a copy of the entire list in memory?

13:42 augustl: yankov: it's passed by reference

13:44 so, no copying

13:44 yankov: augustl: thanks. now if I add an element to this list and pass it to another function, memory usage is still not doubled?

13:44 augustl: yankov: no, that's the "persistent" part of clojure's collections

13:45 yankov: tree structures are utilized internally, the new object shares most of it's structure with the original

13:45 yankov: here's a great article explaining the specifics, if you're into details :) http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/

13:46 yankov: augustl: awesome, thanks! reading that

13:47 augustl: yankov: using existing terms to describe clojure data structures can get confusing fast.. You don't add an element to the original list, for example.

13:47 you create a new list that has the item added to it

13:47 someone should make a "how to talk about clojure data structures" cheat sheet..

13:49 yankov: do you know if it's different to other programming languages? like if you do the same thing with an array in Java or C. How do they handle that.

13:49 augustl: it's very different from the typical mutable collections in other programming languages

13:51 the general concern about mutability is time complexity. In concurrent programs you need to utilize locks to ensure that data used in calculations doesn't suddenly change because of some other part of your system changes it.

14:00 scriptor: there are still some issues with having to copy the path to the node when, say, appending to a vector

14:01 but if that ever becomes a problem, there's always zippers

14:13 oich: do you know how oracle jdb could be deciding that my hostname within my LAN is the dns name my ISP gives to my external IP address? For example, hostname returns my hostname and /etc/hosts contains localhost and localhost.localdomain, but jdb creates a hostname like 75-101-23-17-dsl.sonic.net.

14:14 nDuff: oich: ...sure this is the channel you intended to be in?

14:14 oich: urggh... sorry. It is actually about ritz-nrepl. but wrong channel sorry.

14:14 nDuff: oich: I'd check whether a reverse DNS of the IP address used on your default route comes back to that, by the way.

14:36 Sgeo: If I install JDK6 or JRE6 after having installed JDK7, what will my default be?

14:37 technomancy: Sgeo: depends on your OS

14:37 Sgeo: Windows 7.

14:37 cemerick: weavejester: Looks like :tag#id.class works in hiccup 1.0.1, but #tag.class#id doesn't. Intentional?

14:39 nDuff: Sgeo: I'm not sure there'll be a lot of folks in #clojure who know how Sun's Java packaging works on Windows. It'd be easier to try it yourself and run java -version.

14:40 technomancy: choosing between installed JVMs is typically done by adjusting your PATH

14:49 amalloy: cemerick: it's certainly known, and i'm pretty sure i've heard weavejester tell people about it. presumably if he wanted both ways to work he could do that

15:04 cemerick: amalloy: Noted. Interesting how my defaults are so often diametrically opposed to others'. :-P

15:04 amalloy: i think i tried it your way as well

15:04 so never fear, you are not alone

15:20 TimMc: cemerick: You mean :tag... not #tag..., right?

15:21 cemerick: TimMc: Yes, I meant :tag.class#id

15:26 bhenry: i get this error when using 08/29/2012, but 08/28/2012 works fine. (they are both #inst when i print them) java.lang.IllegalArgumentException: Cannot format given Object as a Date

15:26 any ideas?

15:28 hiredman: bhenry: I don't think either of those are valid data formats for #inst, http://en.wikipedia.org/wiki/ISO_8601

15:29 bhenry: they are already inst. but one errors and one does not. it makes 0 sense to me. why would one inst be able to be formatted as a date, but not another?

15:29 hiredman: errors how? when?

15:31 firesofmay: Hi, How can I run commands like whoami? inside of clojure and get output?

15:31 augustl: firesofmay: https://github.com/Raynes/conch is a good library

15:31 emezeske: bhenry: Maybe post a code snippet?

15:31 bhenry: hiredman: it's not my code, but the dates originally come from a web form. they are turned into inst and then apparently formatted somewhere along the line (interestingly, the format doesn't happen in the line given in the error). the form is processed and successfully returns data for the report on 8/28 and all dates before that, but starting at 8/29 noir prints those lines to the console

15:31 augustl: or you can just call the java stuffs yourself of course

15:31 firesofmay: augustl, okay thanks.

15:32 bhenry: emezeske: i'll try to see what happens with a generic sample.

15:33 emezeske: bhenry: Yeah, step one with a problem like that should usually be "build the minimal reproduction"

15:55 gtrak`: is it possible to un-munge the clojure function's AOT class name directly without ever running the initializer of its NS, in order to avoid class-loading overhead?

15:56 or to completely inline stuff?

15:56 nbeloglazov: I'm looking for open source project to participate. I've to do final project at my university during this year. And I want to contribute to open source during this project. Does anyone know projects in clojure that contains some "scientific" part and in active development?

15:57 nDuff: nbeloglazov: Incanter, perhaps?

15:57 emezeske: nbeloglazov: Maybe "incanter"?

15:57 nDuff: Heh.

15:57 emezeske: :)

16:00 nbeloglazov: Incanter is grown and advanced project and I doubt I can really contribute much to it.

16:04 Raynes: nbeloglazov: You can contribute to refheap. It is scientifically proven to be awesome. :P

16:05 scriptor: what's it built on?

16:05 nbeloglazov: Raynes: :) The only thing left to do is to prove it to my teachers.

16:06 Raynes: scriptor: What is refheap built on?

16:06 scriptor: Raynes: yep, compojure?

16:06 Raynes: Noir, but I plan to move to Compojure. Just lazy.

16:10 bsbutler: drop-last seems to neatly subsume butlast. Is there any plan to deprecate/remove butlast?

16:10 I assume no. Just curious if there's a rationale.

16:11 Raynes: &(doc drop-last)

16:11 lazybot: ⇒ "([s] [n s]); Return a lazy sequence of all but the last n (default 1) items in coll"

16:11 Raynes: I didn't know that existed.

16:12 * bsbutler shrugs

16:12 bsbutler: butlast is lifted directly from CL, it would seem

16:12 http://www.lispworks.com/documentation/HyperSpec/Body/f_butlas.htm

16:13 * bsbutler is more often known as redline6561

16:14 amalloy: butlast is eager, amazingly

16:15 bsbutler: heh. so it was *really* lifted from CL. ;)

16:15 technomancy: you can always tell when something comes from CL because its name doesn't make sense

16:15 luckily clojure didn't lift any functions ending in -p

16:15 amalloy: what's wrong with butlast?

16:15 technomancy: it's not hyphenated

16:17 amalloy: neither is defmacro. the name for that is lifted from cl, so i guess it's not really a counterargument, but i don't think anyone would want def-macro

16:17 bsbutler: haha

16:18 amalloy: whoa, i didn't know about ##(doc find-keyword). that got added in 1.3, apparently, after i did my main studying of clojure.core

16:18 lazybot: ⇒ "([name] [ns name]); Returns a Keyword with the given namespace and name if one already exists. This function will not intern a new keyword. If the keyword has not already been interned, it will return nil. Do not use : in the keyword strings, it will be added automatically."

16:30 augustl: is there a list of functions that works with and also returns maps anywhere? I often end up using "recur" when I need to build a map step-by-step

16:33 chronno: augustl: Check http://clojure.org/cheatsheet

16:33 hiredman: augustl: reduce

16:33 TimMc: augustl: into/for with 2-element vectors, zipmap...

16:34 augustl: the list of functions under "map" on the cheat sheet is sparse..

16:34 s/"map"/"Maps"

16:35 bsbutler: also in the category of "why is this here?": ##(doc ffirst)

16:35 lazybot: ⇒ "([x]); Same as (first (first x))"

16:35 bsbutler: we have pervasive destructuring!!! gah ; though this does work if you don't know the type being passed.

16:35 augustl: hah

16:36 a lot of the built-in map functions uses reduce, persistent! and transient. Seems I should learn what the last two does..

16:40 dnolen: augustl: persistent! and transient are optimizations, they don't really change the overall approach.

16:41 augustl: dnolen: are you aware of any blog posts describing this in more detail? :)

16:42 is the idea that you create a mutable map while building, then return a persistent one?

16:42 Sgeo: Reminds me of the ST monad

16:42 Well, so does the fact that set! exists.

16:42 Although set! is usable for larger impurities I think

16:44 metellus: augustl: look into transient and persistent!

16:44 amalloy: bsbutler: fnext, baby. in case you really miss your cadr, and second is just too wordy for you

16:44 augustl: persistent! and transient seems to be the ultimate proof that Clojure is very pragmatic as far as immutability goes :)

16:44 dnolen: augustl: you can't just bang on it - it still needs to be used in a functional way.

16:45 scriptor: augustl: http://clojure.org/transients is a good read

16:45 bsbutler: amalloy: OMG *why* would second be too wordy? :P

16:45 augustl: scriptor: nice, thanks

16:46 dnolen: I just did a very imperatice set of assoc! calls :)

16:46 pjstadig: amalloy: fnext and second are both "words", maybe you meant too charactery? :)

16:46 amalloy: well, you know common lispers are used to nice short names like multiple-value-bind

16:46 technomancy: delete-if-not

16:47 amalloy: a classic

16:47 bsbutler: remove-if-not is more common. but those are nothing compared to terpri and rplaca. ;)

16:47 rplacd even.

16:48 yeah, the clojure core certainly feels more consistent. fnext, ffirst, butlast are just interesting exceptions.

16:48 technomancy: http://www.jwz.org/blog/2008/11/ejacs/

16:49 bsbutler: ha! hadn't read that. Everybody loves Miyazaki!

16:49 And, of course, what kind of car does that make Clojure?

16:50 hiredman: http://www.military-today.com/apc/stryker.jpg

16:50 technomancy: http://machinegestalt.posterous.com/if-programming-languages-were-cars

16:50 scriptor: http://en.wikipedia.org/wiki/Sidecar

16:51 augustl: I have two maps, values {"some_attr" 123} and attr-types {"some_attr" "text"}. What's a good way to check that each attr is of the correct type, given I have a way to get a function doing the check from "text"?

16:52 octagon: in cljs this produces an error: (apply (symbol "map") [identity '(1 2 3)]). but (ifn? map) works and returns true. is runtime resolution possible in cljs? i notice there is no resolve function available

16:53 hiredman: octagon: that will not work the way you want in clojure either

16:53 augustl: all I can think of is some kind of for loop

16:53 hiredman: ,(apply (symbol "map") [identity '(1 2 3)])

16:53 clojurebot: (1 2 3)

16:53 hiredman: ,(apply (symbol "map") [inc '(1 2 3)])

16:53 clojurebot: (1 2 3)

16:53 augustl: then again, I want to end up with {"some_attr" "Some error message"}. But map doesn't take/return a map..

16:53 octagon: hiredman: it works in a clj repl, is that an artifact of the repl?

16:54 hiredman: octagon: but no, vars are not reifed in cljs, so no runtime resolution

16:54 octagon: 'map is not the function map

16:55 ,(symbol "map")

16:55 clojurebot: map

16:55 hiredman: ,'map

16:55 clojurebot: map

16:55 hiredman: ,map

16:55 clojurebot: #<core$map clojure.core$map@2d1127ff>

16:55 hiredman: ,#'map

16:55 clojurebot: #'clojure.core/map

16:56 hiredman: http://clojure.org/data_structures#Data%20Structures-Symbols

16:56 amalloy: octagon: it doesn't work in a clj repl. you just happened to pick a functon, identity, for which it works by coincidence

16:56 octagon: hiredman: i understand what you're saying there, that (symbol "map") should merely produce a symbol and not bind it to the function itself, but it does appear to resolve it to the core/map function in my clj repl

16:57 hiredman: oh wow

16:57 hahaha you're right

16:58 bsbutler: holy crap. map-indexed is a thing. O_O

16:58 * bsbutler hugs clojuredocs

16:59 octagon: thanks, hiredman

17:18 bsbutler: opinions on which drop-nth is more readable/idiomatic/etc? https://www.refheap.com/paste/5119

17:18 mmitchell: anyone here use korma?

17:19 * nDuff used it, hated it, dropped it.

17:19 Frozenlock: bsbutler: I prefer the first, easier to read

17:19 nDuff: ...well, not so much "hated it" as "spent much, much too much time trying to work around it"

17:20 mmitchell: yeah, i can't seem to get the simplest select working. I get a mysql syntax error just by doing (sql/select my-entity (sql/limit 10)) -- which is exactly what the docs use for an example. hmm.

17:20 scriptor: mmitchell: what's the query it generates?

17:20 mmitchell: scriptor: how can i get that?

17:21 scriptor: good question

17:21 bsbutler: Frozenlock: me too, though I think the latter might be the better implementation. I assume it would be more performant with actual Lists, at least. (as opposed to Nth doing a bunch of O(n) traversals.

17:21 TimMc: mmitchell: I remember there being a command to get the SQL isntead of running it.

17:22 scriptor: mmitchell: looks like if you wrap the call to select in (sql/sql-only …) ?

17:22 mmitchell: TimMc: is it dry-run?

17:22 ok i'll try that

17:23 Frozenlock: bsbutler: Perhaps. I don't really need to optimize speed over readability very often.

17:23 bsbutler: True.

17:23 Frozenlock: My time is more precious than machine time :P

17:24 mmitchell: this is what I get: "SELECT "users".* FROM "users""

17:27 amalloy: bsbutler: neither of those drop-indexed impls are any good

17:28 the first has that awful n^2 behavior you mentioned, and the second doesn't work for seqs which contain false as an element

17:30 instead: (for [[i x] (map-indexed vector seq (range)) :when (pos? (mod (inc i) n))] x)

17:32 Frozenlock: $ (re-find "my" "hello my name is")

17:32 What's the bot key again?

17:32 antares_: ClojureWerkz now has a blog: http://blog.clojurewerkz.org/

17:32 Raynes: &(+ 3 3)

17:32 lazybot: ⇒ 6

17:32 antares_: plus, Quartzite 1.0 is out: http://blog.clojurewerkz.org/blog/2012/09/18/quartzite-1-dot-0/

17:32 Frozenlock: &(re-find "my" "hello my name is")

17:32 lazybot: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.regex.Pattern

17:32 Frozenlock: Raynes: thanks

17:32 &(re-find #"my" "hello my name is")

17:32 lazybot: ⇒ "my"

17:33 Frozenlock: What is '#' in this context?

17:34 Raynes: It creates a regex.

17:34 #" is a reader macro.

17:34 See http://clojure.org/reader

17:34 bsbutler: amalloy: I just found map-indexed and keep-indexed and was working on something similar. Thanks. :)

17:38 octagon: is there a way to :require cljs namespaces in a clj namespace? i'm writing a macro that needs to call functions defined in a cljs namespace

17:39 Frozenlock: Hmmm.. How can I search a string in another string without '#'? (defn matching-string [string1 string2] (re-find string1 string2)) doesn't work.

17:39 amalloy: $javadoc String

17:39 lazybot: http://docs.oracle.com/javase/6/docs/api/java/lang/String.html

17:40 Frozenlock: I'm in clojurescript

17:40 mmitchell: dang, i just can't get korma to work :/

17:41 emezeske: octagon: AFAIK there's no simple way to do that. You'd have to build the cljs code, set up an execution environment for it (e.g. rhino), and handle conversions between types in Clojure and types in ClojureScript (which are not necessarily trivial)

17:41 dnolen: Frozenlock: JS has an indexOf String method.

17:42 Frozenlock: dnolen: Thanks. This means there's no clojure function to find a string?

17:42 octagon: emezeske: thanks, i just wanted to make sure

17:42 emezeske: octagon: Although it is definitely a possible thing to do, especially if you take advantage of pr-str and read-string for communication between the two languages

17:42 octagon: Why do you need to call cljs from clj? Maybe there's some other approach?

17:43 octagon: emezeske: well i'm writing an interpreter and i wanted to make some convenient macros to wrap the cljs reader to feed forms to my interpreter

17:44 dnolen: Frozenlock: I don't see why you can't just use re-find. (js/RegExp. some-string)

17:44 emezeske: octagon: You are aware that you can use macros in clojurescript? (albeit they are written in clojure)

17:45 octagon: I guess that's where you're hitting trouble -- the clojure macro wants to use some handy clojurescript utility function?

17:45 octagon: emezeske: yes, but you can't use cljs things in your clj macro namespace

17:45 emezeske: octagon: I have done exactly what you're talking about

17:45 octagon: emezeske: i want to use cljs.reader/read-string :/

17:46 emezeske: octagon: Oh... nevermind!

17:46 octagon: I've called meant-to-be-shared cljs code from clj, but not unmeant-to-be-shared cljs code :)

17:46 octagon: emezeske: well not exactly, i really wnat to call a function in cljs that calls read-string

17:46 Frozenlock: dnolen: I'll try it. I was just wondering if there was a clojure way. Not being very good with js, it was my first reflex.

17:46 octagon: emezeske: i don't need to call read-string directly

17:46 emezeske: octagon: Are you sure you need to call that cljs function at compile-time?

17:47 octagon: emezeske: can i do some kind of "extern" declaration maybe to get the macro to compile?

17:47 emezeske: octagon: If you don't need to actually call the cljs read-string at compile time, you shouldn't have a problem

17:47 octagon: If you really want to call cljs read-string at compile time, that's a little (lot) weird.

17:48 octagon: emezeske: oh wait, i think i can use the clj reader actually

17:48 emezeske: octagon: That would probably make your life a lot easier.

17:49 octagon: emezeske: the macro will run at compile time anyway, so that makes sense

17:49 emezeske: thanks for talking me off the ledge

17:51 emezeske: octagon: haha I think you talked yourself off the ledge :)

17:54 mindbender1: is anyone having success with piggieback in emacs?

17:55 It keeps throwing IllegalStateException at me

17:59 Here is the gist: https://gist.github.com/3740028

17:59 xeqi: mindbender1: what does your project.clj look like?

18:00 Frozenlock: What's the advantage of piggieback vs inferior-lisp?

18:01 mindbender1: xeqi: here https://gist.github.com/3740038

18:04 xeqi: heh, is that a custom version of enlive?

18:04 lein deps :tree might be better here

18:05 cemerick: should there be a 0.0.1 tag for piggieback on github?

18:06 cemerick: xeqi: there is now

18:06 xeqi: cemerick: thanks

18:08 cemerick: Frozenlock: if you don't use inferior-lisp, or Emacs even, lots :-P

18:08 mindbender1: xeqi: still need that deps :tree?

18:09 xeqi: could be helpful

18:09 mindbender1: xeqi: kk.. here : https://gist.github.com/3740062

18:10 xeqi: though I would have expected wrap-cljs-repl in that stacktrace somewhere...

18:12 mindbender1: xeqi: does tools.nrepl have a wrap-cljs-repl?

18:12 cemerick: mindbender1: what version of lein?

18:12 mindbender1: cemerick: leiningen 2.0.0-preview10

18:12 xeqi: piggieback does, its part of the middleware stack in injections

18:13 cemerick: mindbender1: :nrepl-handler needs to be in :repl-options https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L118

18:13 mindbender1: but it'd be easier to just use :nrepl-middleware if adding piggieback is all you're doing nREPL-wise.

18:14 mindbender1: cemerick: it might also help to know that I'm trying to get it work from nrepl.el 0.1.4-preview

18:14 cemerick: That should be irrelevant.

18:15 mindbender1: cemerick: ok

18:15 cemerick: I mostly don't know anything about nrepl.el though.

18:16 xeqi: it should start and eval fine w/ nrepl.el, though some things like loading files doesn't work yet

18:17 nrepl's :describe and :load-file are planned for 0.1.5 last I read; which would solve that

18:19 whitaker: Looks like ztellman is not on channel at the moment, but I'll ask anyway: anyone here use aleph's websocket-client in midje test definitions? I'm trying to compose a test which validates that an http GET /someuri request gets successfully upgraded to a websocket. For all my searching, I can't find a midje test example that illustrates use of the websocket-client defined in

18:19 https://github.com/ztellman/aleph/blob/perf/src/aleph/http/websocket.clj

18:24 Different question, same purpose: does anyone here know of a lightweight web socket client good for testing in the context of 'lein test' or 'lein midje'?

18:25 Something which doesn't require ginning up a .js test fixture and invoking it manually (ugh) in a browser?

18:29 The target application is Aleph/Compojure; a typical working midje predicate for a non-websocket route looks like (routes {:request-method :get :uri "/hello"}) => "Hello")

18:31 Where routes is in (defroutes routes ……) in core.clj

18:40 I'm wondering whether websocket-client actually even *works*, given https://groups.google.com/forum/?fromgroups=#!topic/aleph-lib/KSjGbFJcr1U and https://github.com/ztellman/aleph/issues/57

18:40 Anyone?

18:40 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

18:40 whitaker: Nice.

18:41 Bot's on a 15-minute delay.

18:42 lnostdal: any sane way of doing stuff like this: http://cljbin.com/paste/5057a657e4b0c74e0067a3f8 ..? i.e., "forward" keyword args

18:43 whitaker: As for "the question [for which I] really want the answer," it was asked in the context surrounding the line on which clojurebot reacted.

18:43 amalloy: lnostdal: don't do it, man

18:43 lnostdal: amalloy: i guess pass a map directly instead?

18:43 amalloy: yes

18:44 lnostdal: ok, right .. this stuff seems broken

18:44 so yes .. ok .. thanks

18:44 amalloy: kwargs are a very mild syntactic convenience for the outermost layer of your API

18:45 personally i'd rather type the two {} characters than deal with kwargs

18:47 hyPiRion: Wow, I never knew programming could be so exhausting.

19:02 emezeske: hyPiRion: Based on your comment, I guess that you are dealing with XML

19:03 casion: obviously using regex to deal with xml no less

19:04 whitaker: <- waiting for clojurebot to make a snarky comment about regex ("…now you have two problems…")

19:04 hiredman: ~regex

19:04 clojurebot: Sometimes people have a problem, and decide to solve it with regular expressions. Now they have two problems.

19:04 whitaker: Ah, needed to be invoked

19:04 hiredman: regex?

19:04 clojurebot: Sometimes people have a problem, and decide to solve it with regular expressions. Now they have two problems.

19:04 lnostdal: perhaps he's doing CSS

19:04 hiredman: clojurebot: what about xml?

19:04 clojurebot: XmL is case-sensitive

19:07 mattmoss: befunge?

19:32 whitaker: BTW, in case anyone didn't already know: ztellman rocks. For the record. Helped me elsewhere. He is "helpful" personified.

19:32 ztellman: haha

19:33 gfredericks: (inc ztellman)

19:33 lazybot: ⇒ 1

19:33 ztellman: you shamed me into actually logging onto IRC

19:53 gjcourt: hey guys, i have a ?

19:53 http://pastie.org/4743548 is a macro im trying to define

19:53 hiredman: :(

19:54 gjcourt: i can use macroexpand and it looks like it works, but passed as an argument to a function i get

19:54 hiredman: you want reify

19:54 gjcourt: hiredman instead of new?

19:55 hiredman: instead of defrecord

19:55 amalloy: instead of the whole thing

19:55 hiredman: yes that

19:56 gjcourt: so something like (reify Handler (process ...

19:58 sweet, thanks hiredman amalloy

20:04 akhudek: FYI to anyone using ring + https + IE clients: https://github.com/ring-clojure/ring/issues/17

20:10 lnostdal: why not let the front-end HTTP server handle static content, akhudek?

20:11 kind of on the side, but still

20:11 akhudek: lnostdal: that's a good idea too, though people might still run into this like I did

20:25 weavejester: akhudek: I'll fix that tomorrow and release a patch

20:25 akhudek: weavejester: thanks!

20:27 muhoo: i'm so spoiled by clojure, i'm reaching for stuff like this when forced to use java on android with no clojure: http://functionaljava.org/examples/1.5/

20:31 jlewis: hi, anyone know why PersistentArrayMap doesn't use a binary search algorithm for its indexOf if keys are sortable?

20:31 amalloy: because keys aren't sortable

20:31 jlewis: not in general, but what if they happen to be?

20:31 TimMc: array-map is just for small collections, right?

20:32 jlewis: yep

20:32 TimMc: so... why optimize?

20:32 jlewis: but log(n) is a lot better than n even for small collections

20:32 amalloy: jlewis: not if the constant factor is large, which it probably will be. plus there are related issues

20:33 eg, the fact that it's impossible to tell if they're all sortable

20:33 jlewis: yeah that's a good point

20:33 :)

20:34 leafw: Would appreciate comments on the better use of the parser monad, particularly regarding performance. Also on why macros fail inside domand blocks. http://albert.rierol.net/clojure-monads.html

20:38 mpan: hm, I feel weird switching between writing different languages

20:39 casion: you get used to it

20:39 emezeske: mpan: Keep it up! It makes you a much better programmer IMHO.

20:39 casion: I have projects that have 5 languages in the same file

20:39 it's confusing for a while… then you get used to it and you get annoyed when you're stuck in one language

20:40 mpan: well it's definitely a learning experience

20:40 amalloy: leafw: that is like a thousand pages. if you want comments on something in particular i recommend linking to a smaller sample

20:43 leafw: amalloy: it's a complete program that works. Got tired of finding only trivial examples of usage of monads in clojure.

20:44 hamzaaa: Hi guys, How can I create html element using clojurescript browser dom for the following, <div data-role="controlgroup"></div> tried the hiccup way [:div {:data-role "controlgroup"} ...] but it does not work?

20:45 leafw: amalloy: on macros inside domonad, it is likely that my assessment (that macros don't work inside a domonad block) is wrong

20:45 amalloy: yes, that assessment sounds pretty nuts since basically everything is a macro (eg, let)

20:45 leafw: right

20:46 amalloy: leafw: i'm sure it's a lovely blog post. but i consider myself one of the people most likely to follow a link that solicits help, and i am never going to read all that. just suggesting, if you want feedback from someone in #clojure, you should probably narrow it down

20:46 leafw: amalloy: makes sense. Will try to write a minimal example.

20:49 mpan: how do I pass the function representing a java static method?

20:49 e.g. I can call Integer/parseInt, but how do I pass a fn representing it?

20:49 or just create the fn?

20:49 xeqi: #(Integer/parseInt %)

20:49 mpan: so create it? ok thanks!

20:57 is there a better way to get the max of a seq than passing identity fn to max-key?

20:58 hiredman: ,(doc max)

20:58 clojurebot: "([x] [x y] [x y & more]); Returns the greatest of the nums."

20:58 mpan: thing is I have a seq, and I'm afraid to use apply because it might be large

20:58 I mean, what happens if you apply with too many args?

20:58 amalloy: apply works fine with infinite seqs

20:59 &(apply (fn [& args] (take 10 args)) (range))

20:59 lazybot: ⇒ (0 1 2 3 4 5 6 7 8 9)

20:59 mpan: ,(doc range)

20:59 clojurebot: "([] [end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity."

20:59 mpan: oh

21:00 cool

21:00 thanks

21:00 I thought I heard something about a max of some # of args

21:03 gjcourt: any ideas why destructuring would fail here? https://www.refheap.com/paste/5126

21:03 mpan: performance-wise, is having lots of args an issue? (for use w/ apply)

21:08 gjcourt: also, from the repl is there a good way to do (ns :reload NS) on your current namespace?

21:08 emezeske: mpan: No.

21:14 gjcourt: I think *ns* refers to the current namespace, if that's helpful

21:16 muhoo: mpan: the switching between languages thing is natural if you come from web development background. in one file, you've often got html, css, javascript, and serverside stuff (jsp, php, asp, whatever) all tangled together.

21:17 mpan: muhoo: not just languages, but styles

21:17 like, this assignment uses functional style, previous 2 assignments used imperative style, because some classes do require a language and some don't

21:19 ah it's this error again: CompilerException java.lang.RuntimeException: Unable to resolve symbol: defn in this context, compiling:(NO_SOURCE_PATH:2)

21:19 I'm really wondering what's breaking the repl so I can avoid it in the future

21:20 amalloy: mpan: you probably have an in-ns form somewhere without a refer-clojure or an ns

21:21 mpan: I'm not currently using in-ns

21:21 like I'll get that from compiling all manner of unrelated but wrong things

21:21 the actual root cause this time seems to be using a symbol that wasn't bound to anything

21:22 but idk why it manifests as that error

21:23 jimduey: leafw: I skimmed your post and the problems you cite are valid. I did a version of monads for clojure using protocols that you might find helps on performance and the macro issue.

21:23 leafw: https://github.com/jduey/protocol-monads

21:24 amalloy: mpan: nobody else will ever know either, if you only provide an error message with no stacktrace or source

21:25 mpan: oh!

21:25 the exception is caused by a different one that can't resolve something different

21:25 but that something different is actually in my code

21:25 thank you!

21:25 didn't realize there was more than one exception happening

21:26 hamzaaa: How can I create html element using clojurescript browser dom for the following, <div data-role="controlgroup"></div> tried the hiccup way [:div {:data-role "controlgroup"} ...] but it does not work?

21:27 gfredericks: hamzaaa: it should

21:28 * gfredericks tries it

21:29 gfredericks: I believe it worked for me

21:30 hamzaaa: gfredericks: this (dom/element [:div {:asd :asd} [:li "as"]]) returns <div><li>as</li></div> for me?

21:31 gfredericks: what is dom/element? is that from domina?

21:32 I've never heard that you can do hiccup-style things with domina; crate is the cljs hiccup library

21:32 hamzaaa: gfredericks: nope it is from, https://github.com/clojure/clojurescript/blob/master/src/cljs/clojure/browser/dom.cljs

21:32 gfredericks: how did you generate it?

21:32 gfredericks: ah; well same comment but for cljs.clojure.browser instead of domina :)

21:33 hamzaaa: gfredericks: then let me rephares how would you generate it? without using strings

21:36 gfredericks: hamzaaa: using the crate library; that's how you do hiccup in cljs

21:37 hamzaaa: gfredericks: thanks.

21:44 casion: does anyone use ac-nrepl? I'm constantly getting "java.lang.ClassNotFoundException: complete.core"

21:47 oh, ok, I see a discussion about it now

22:05 mpan: is clojure doing implicit int-coercions for me in java interop?

22:08 casion: mpan: it seems to

22:08 I had a lot of trouble with that recently

22:34 luxbock: do I need to install clojure.contrib separately, or is it a part of the clojure package?

22:35 when I try to do (require 'clojure.contrib.math) in repl I get a FileNotFoundException

22:36 xeqi: ~contrib

22:36 clojurebot: Monolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

22:37 luxbock: hmm I see

22:40 so I see that clojure.contrib.math has moved to clojure.math.numeric-tower

22:41 how do I go about installing that?

22:43 leonardoborges: luxbock: something like [org.clojure/math.numeric-tower "0.0.1"] in your project.clj

22:43 or whatever version you need.

22:45 luxbock: I'm trying to follow the book Programming Clojure, but I can't get one of the examples (as typed by me) to run in REPL because it requires that module

22:45 how would I enable myself to play around with things from clojure.contrib in REPL?

22:46 I'm using the nREPL in Emacs to be more specific

22:48 mpan: uh, so are you using any sort of dependency management?

22:49 (I'm sorry in advance if this isn't right, because I'm also new)

22:49 leonardoborges: luxbock: I'd recommend using leiningen. Create a project with it and then start a repl session in the project root. You should be good to go.

22:49 luxbock: I'm just trying to play around with things in REPL

22:49 mpan: so there's a jar that contains that namespace and you can get it directly here http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22math.numeric-tower%22

22:49 BUT

22:49 leonardoborges: afk

22:50 mpan: the preferred way is to use a tool such as leiningen to manage dependency requirements for you

22:50 luxbock: got it

22:50 xeqi: luxbock: then you probably have leiningen installed. use `lein new progclj` to create a project. Edit the project.clj file to add [org.clojure/math.numeric-tower "0.0.1"], then run M-x nrepl-jack-in from that file

22:50 * add to the :dependencies vector

22:50 mpan: so if you put the clojure jar and that jar on your classpath and run the repl, you will have it, but

22:51 as others are mentioning, the preferred way is to have a dependency manager (lein is the most popular, I think?) to do it for you

22:52 if you want to use lein, its project readme has setup instructions: https://github.com/technomancy/leiningen/blob/master/README.md

22:52 luxbock: how do I make nrepl to run from a specific file? does it just use whatever file is open in clojure-mode when I run it?

22:52 xeqi: yep

22:52 luxbock: ah great

22:52 thanks

22:57 arrdem: ,(System/currentTimeMillis)

22:57 clojurebot: 1347936741435

22:57 gfredericks: the first half of that number is starting to feel familiar

22:58 arrdem: hum.... any ideas why for some atom foo I can't just (swap! foo System/currentTimeMillis)?

22:58 gfredericks: because that's not a function

22:58 arrdem: I'm getting a 'no such static member' from lein

22:58 gfredericks: I expect what you want is (reset! foo (System/currentTimeMillis))

22:59 arrdem: ,(doc reset!)

22:59 clojurebot: "([atom newval]); Sets the value of atom to newval without regard for the current value. Returns newval."

22:59 gfredericks: but java calls (both instance methods and static methods) can't be used directly as functions

22:59 you could also do (swap! foo (fn [_] (System/currentTimeMillis)))

22:59 if you prefer it with swap!

23:01 luxbock: how do I run the code that I have typed up in my clojure-mode buffer in the nrepl session for that file? I tried C-c C-k but that just gives me a load of errors

23:02 not sure if I'm using the wrong command or or there's something wrong with the setup

23:02 arrdem: cheers gfredericks

23:31 ,(doc nth)

23:31 clojurebot: "([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."

23:59 mpan: ,(doc get)

23:59 clojurebot: "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."

Logging service provided by n01se.net