#clojure logs

2012-09-17

03:01augustlI 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 ;)
03:29aperiodici think that the bar for being published on clojars is, in general, purposefully pretty low (obviously, someone should speak up if they disagree)
03:30aperiodici 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
03:31aperiodicperhaps i'm being a jerk
03:31aperiodicaugustl: that being said, if it is java, why not put it on maven central or somesuch?
03:32aperiodicaugustl: it'll be as good as clojars as far as clojure use is concerned, since lein searches those repos
03:32aperiodici think it even trumps those, but don't quote me on it
03:32augustlaperiodic: maven central probably makes sense, yeah
03:33augustlwould make sense if Groovy users wouldn't have to set up clojars as a repo ;)
03:33aperiodicyeah, definitely go for the lowest common denominator there
03:34augustland now for something completely different
03:34augustlis there a built-in function to read a file that contains only a map, or a vector, or some other data structure, runtime?
03:39aperiodici don't think so. i just do (binding [*read-eval* false] (try (-> file slurp read-string) (catch java.io.FileNotFoundException _ nil)))
03:40aperiodic(fun fact, you don't even need to import java.io.FileNotFoundException in your ns)
03:45augustlaperiodic: cool
03:50augustlhah, read-string is awesome
03:50biscarchIf I find an oauth2 provider library in java, what potential problems will I face using it in Clojure?
03:51augustlbiscarch: 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
03:52augustlbiscarch: 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
03:53augustlI 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
03:56aperiodicbiscarch: on the subject of general stylistic approaches to take with java libraries in clojure, have you seen zach tellman's "distilling java libraries"?
03:57biscarchaperiodic: no I havent, but I'll check it out
03:58biscarchaugustl: ok. Thanks for the advice.
04:06augustlis 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?
04:06augustlyes I know functions aren't supposed to have side effects etc. :)
04:25amalloyno
04:33augustlnot sure if I want to make a library for it.. Bad for my image (easy side effects in Clojure yay)
04:33amalloymidje probably does it already
04:37augustlperhaps there's something in lazytest (I don't use midje)
04:40augustlwhy 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)?
04:41amalloythat eval is probably happening in a different namespace
04:41augustlhmm, is there something like eval where I can pass in the namespace?
04:42amalloyno. instead use qualified symbols, eg by using ` instead of '
04:43amalloyideally don't use that eval, but i assume you have some crazy reason for doing it
04:44augustlI see
04:44augustlamalloy: the data/code comes from read-string on a file
04:46augustlthe 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..
04:46augustlI suppose my API could take the namespace as its first argument
04:50augustlis there a function to evaluate a form in a specific namespace?
04:50clgvaugustl: you can use `in-ns` or binding *ns* should work as well
04:52augustlclgv: and then just (eval form) it?
04:52clgvaugustl: no. you got to use `in-ns` in your eval
04:53augustlclgv: ah
04:54augustlhmm, in-ns takes a symbol, not a clojure.lang.Namespace
04:56augustlwhat's the use of *ns*? Seems that all APIs take namespace names, not Namespace objects
05:01augustl(in-ns (.getName the-ns)) works, seems a bit hacky though..
05:08Sgeo,(macroexpand-1 '(-> *ns* .getName in-ns))
05:08clojurebot(clojure.core/-> (clojure.core/-> *ns* .getName) in-ns)
05:08Sgeo,(macroexpand '(-> *ns* .getName in-ns))
05:08clojurebot(in-ns (clojure.core/-> *ns* .getName))
05:09clgvaugustl: there is ns-name
05:10clgv,(-> 'clojure.core the-ns ns-name type)
05:10clojurebotclojure.lang.Symbol
05:10clgv,(-> clojure.core ns-name type)
05:10clojurebot#<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.core, compiling:(NO_SOURCE_PATH:0)>
05:10clgvok, the first one was the minimal for demo ^^
05:12augustlclgv: ah, nice
05:32mindbender1hi All
05:34kralnamaste
06:16augustlis there a built-in method for reading a file by path from file system _or_ classpath?
06:17clgvaugustl: load-file
06:18clgvah you want both?
06:18stainload-file would also evaluate it
06:18stainaugustl: but.. you mean with different URIs?
06:18stainaugustl: or to try both witnh a relative path?
06:21clgvaugustl: 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
06:25augustlstain: something like that
06:26augustlstain: (slurp file) if it exists, use (.getPath (clojure.java.io/resource file))
06:26augustl..if the file doesn't exist on the fs
06:28stain(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
06:28stainof course one way to do that would be to put the folder in question on the classpath
06:28stainand always use (resource)
06:29stainbut you might need to make your own classloader then if you don't have control of how you are launched
06:29augustl(slurp (or (clojure.java.io/resource file) file)) basically
06:29augustlah, wasn't aware of `resource`
06:30stainresource just gives you the URL, it does not read it
06:30stainso it should work with slurp like that
06:33augustlany function not in http://clojure.org/cheatsheet I'll never know about :)
06:33stainwe'll need to do something serious about Clojure documentation soon
06:38augustlis 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)
06:43clgvaugustl: why would you want to do that?
06:44augustlclgv: 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
06:44clgvaugustl: you could (def this-ns *ns*)
06:45augustlso that you can call helper functions in the config file, for example
06:45augustland refer to symbols required from the namespace where the function that calls the config file reader lives
06:45augustlclgv: hmm, best so far at least :)
06:46clgvif you implement the load-config function in the namspace all its inters should be available. you can have a look at leiningen for that
06:46clgvI think in: leiningen.core.project
06:46augustlclgv: the function is implemented in a library that the user depends on
06:46augustlif I understand "implement the load-config funciton" correctly :)
06:47xeqihttps://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/project.clj#L424
06:47clgvaugustl: thats ok as long as the config symbols are available there as well
06:48clgvaugustl: 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.
06:49clgvxeqi: ah right it uses the binding approach
06:51augustlstill need to get the actual ns though :)
06:51augustlclgv: by using clojure files with namespaces I guess you mean to create one namespace per config and (def foo {:config "here"})?
06:52clgvaugustl: yes, but usually you have a macro like "defproject"
06:52clgvaugustl: it makes sense if you plan to be able to put parts of the config in separate files for reuse of common config values
06:53augustlI currently have an API like (read-config ["path/to/file.clj" "other-file.clj"] {:foo 123})
06:53augustlthe files are read with read-string and is expected to contain a map
06:54augustlworks fine, except from the "evaluate the values of the map in the namespace where the function calling read-config was defined" part..
06:54clgvaugustl: well look at the source from leiningen xeqi linked
06:55augustlit seems to take advantage of the fact that it always uses leiningen.core.project
06:55clgvand you dont have a static namespace where your config commands are defined?
06:56augustlno, my library will be used in applications
06:56augustlso the namespaces will be myapp.core and what not
06:56augustl(def this-ns *ns*) and passing in this-ns would work for that
06:57clgvaugustl: what if you want to have commands from multiple namespaces?
06:57augustlI never wanted that, so it's not supported :)
06:57clgvok.
06:58clgvotherwise. use (ns myconfig (:use myapp.core)) (defconfig ...) ;)
06:58augustlI'm starting to see how a namespcae perhaps is a weird source of symbols for free floating .clj files with maps in them though
06:58stainclgv: then make a new namespace, and require those in there with :refer (aka old (use))
06:59augustlclgv: the separate config namespace does make sense, as putting "config" functions in the core namespace as I do now is a bit hacky
06:59clgvstain: yeah thats an option as well. temporary namespaces ^^
07:00augustltemporary namespaces you say?
07:01clgvyeah. `create-ns` + (binding [*ns* ...] ...)
07:01augustlah
07:01clgvah, and finally remove-ns
07:06augustlsimply eval-ing the values of my config does not seem to be a good idea though..
07:06augustlat least not when the value is a Java object
07:08clgvaugustl: you have java objects in a config?
07:11augustlclgv: yes, a mongodb object
07:11augustlit's more of an environment than a config I guess
07:12stainuhu..
07:12stain(flash :warning-lights)
07:12augustlwhat's wrong with that?
07:12clgv(inc stain)
07:12lazybot⇒ 1
07:12augustlalso, seems to be a clojure record, but that's just a java object I guess
07:13augustlpart 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.
07:13stainoh, you mean, you make the db objects, and then the 'config' just selects one that has been pre-made?
07:14augustlsomething like that :)
07:14augustlthe .clj config file that contains a map has a default :db which is a (congomongo/create-connection ...) type thing
07:14augustlthis can also be overridden by providing a map as the 2nd argument, with the key :db
07:15staindoes it mean you make lots of database connections (which might not work) that you then might not use?
07:15augustlsince the values from the config files are lazily evaluated, the create-connection call in the config file isn't called, yay
07:15stainah
07:15augustl:D
07:15augustlso it has left to right presedence but is lazy
07:16augustland (eval some-java-object) in isolation works fine so I'm probably just reading the stacktrace wrong
07:18augustlhmm no it works on the objects I test in isolation, but not this particular object, for some reason
07:18augustl"CompilerException java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined: oiiku-central-api, compiling:(NO_SOURCE_PATH:1)"
07:22augustlkind of hard to grok what eval actually does by reading http://clojuredocs.org/clojure_core/clojure.core/eval
07:22augustlseems it's only meant for lists, not arbitrary objects?
07:27clgvaugustl: you get the exception above if you create an object during macroexpansion and try to use it in the code at runtime
07:28augustlhmmm
07:28augustlI'm evaling the result of read-string
07:29clgvaugustl: read-string usally evals itself if you do not disable it
07:29augustlah, that's the problem then
07:29augustlbut, but, my tests are passing! Now what do I do? :P
07:30Fossiwtrite better tests :>
07:31augustlweird though, read-string doesn't eval in my tests, only when I use it from another project
07:31clgvaugustl: hmno, I just tried ##(read-string "(hash-map :a 1 :b 2)")
07:31lazybot⇒ (hash-map :a 1 :b 2)
07:31clgvit's not evaling that one
07:31clgvmaybe it was `read`
07:32augustlin 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.
07:32augustlwhen 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
07:35jaleyhey guys - (name :a/b) returns "b", is there a function to get the "a"?
07:35clgv jaley: namespace
07:35jaleyclgv: aha! merci
07:36jaleyclgv: i've been hammering away at ns-<TAB><TAB> for a while wondering where it is
07:36augustltried wrapping it in (binding [*read-eval* false] ...), no dice
07:44augustlit's read properly so that's not the problem.. Exception occurs when merging the read-string map with another map
07:44augustlstill haven't been able to reproduce in a test, working on it...
07:45augustldoh, ok, I'm eval-ing the values from the provided map too.. No wonder, then.
07:49jkbbwrWhy does clojure put spaces in when smashing a string together like so (println "Hi" name)
07:50augustljkbbwr: use (str) to control how a string is concated
07:50ordnungswidrigjkbbwr: use (println (str "Hi" name))
07:50clgvjkbbwr: thats printing. use (str ...) for concatenation
07:51jkbbwrI was just wondering. I know the difference
07:53ordnungswidrigjkbbwr: I think it's a design choice, not necessarily something you can derive logically.
07:53jkbbwrordnungswidrig: thanks :)
07:53ordnungswidrigI'd prefer it as it is now
07:53ordnungswidrig(e.g.)
08:01augustljkbbwr: I would also have designed it like that, so I can (println "[PREFIX]" foo)
08:20jkbbwrIm just starting off learning clojure, I have heard its da bomb and it looks it so far but its gonna take some practice
08:23joegallojkbbwr: welcome.
08:23jkbbwrjoegallo: its a very new and kinda scary world
08:29antares_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 :)
08:30jkbbwrIt gets really complicated really really quickly :s
08:30jkbbwrI get the basics already but it starts getting trippy fast
08:39dhofstetI'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?
08:40dhofstetI tried println-str, but then there is no output at all
09:08clgvdhofstet: paste your code e.g. on refheap.com
09:11clgvdhofstet: and try to have a minimal example
09:15dhofstetclgv: https://www.refheap.com/paste/5110
09:16clgvdhofstet: thats by far not minimal
09:16dhofstetclgv: ok, I try to make it more minimal
09:17clgvdhofstet: 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
09:17clgvdhofstet: you could send (fn [_ s] (println s))
09:26augustlhttps://github.com/weavejester/lein-ring mentions "development mode" and "production mode" - what's that?
09:26augustlis it a ring concept? A leiningen contept? Something else?
09:26weavejesteraugustl: "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."
09:27weavejesteraugustl: it could be explained better.
09:27dhofstetclgv: thanks, this works. Seems like I have to reread the agents chapter again, as I don't yet fully understand what happens ;-)
09:27augustlweavejester: so it's only for "lein ring server"?
09:27weavejesteraugustl: It really only applies to Lein2
09:27weavejesteraugustl: Um, I mean Lein1
09:27weavejesteraugustl: yep
09:28augustlI see, thanks
09:54Blktgood day everyone
09:55Blktis there anyone using clojureql or korma with an Oracle database via SID?
09:58augustlwhat are the correct types to use for a multimethod that takes a list or a map?
10:01chouserjava.util.List and java.util.Map
10:03augustlchouser: a clojure map is java.util.Map?
10:03chouseryes
10:03clojurebotyes isn't is
10:07augustlwhat about using clojure.lang.IPersistentVector and clojure.lang.IPersistentMap?
10:36clgvaugustl: then you are more specific and dispatch only on these
10:44shokyjust 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:45clgvshoky: the example?
10:45shokyyes
10:45shokywhere it says "Example"..
10:46clgvyes
10:47shokygreat. thank you
11:03shokyone other thing about that example- i don't understand why the check for (zero? i) in the relay function
11:03shokywon't that make only the last "action" be reported?
11:05shokyhm i guess that's the intention
11:05clgvseems like thats the goal
11:13callenokay, how do I get clojure.xml/parse to take a non-validating XML document?
11:13callenthe non-validating DTD example I found on Google is old and doesn't work
11:13callenI keep getting "I java.net.MalformedURLException: no protocol" when I attempt to parse the XML
11:17clgvcalled: you should post a gist of your code so that someone can help you
11:20clgvcallen: ^^
11:27babilencallen: 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:29danielglauserDoes anyone know if the bindings in let are lazy?
11:32clgvdanielglauser: no they are not. only lazy-sequences are lazy in clojure
11:32danielglauserclgv: Thanks!
11:39renatocaliariHi all
11:41naeghi renatocaliari
11:43renatocaliariWell, 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:45renatocaliariSome people I already follow on Twitter. So, I'd like to know if that channel is a good place for clojure community =)
11:45naegrenatocaliari: it is. there are a lot of helpful and friendly people online here
11:47renatocaliariCool! =) Tks.
11:47callenbabilen: that ended up being my solution, didn't see you until now.
11:48callenbabilen: thanks.
11:48callenbabilen: trying to understand xml-> now.
11:48dhofstetrenatocaliari: there is also the clojure google group
11:48hfaafb_is there a de facto clojure style guide that says something about linebreaks and indentation
11:50sundbp_anyone got tips how to get tools.jar onto classpath using lein 2?
11:50callenand it's not returning anything o_o
11:50naeghfaafb_: last time I asked a question about a convention, I was linked to this: http://dev.clojure.org/display/design/Library+Coding+Standards
11:51naeghfaafb_: but identation is usually taken care of by your IDE
11:51sundbp_oops - didn't realize there was a lein channel. moving it there.
11:51hfaafb_yeah i guess my question was really about linebreaks
11:52naeghfaafb_: you're probably better off asking this question directly. the library coding standards don't seem to say something about linebreaks
11:52babilencallen: http://stackoverflow.com/questions/1194044/clojure-xml-parsing helped me a little
11:54callenbabilen: yeah, been there done that.
11:54callenhttps://www.refheap.com/paste/5112 <--- I can't get anything out of this zipped xml.
11:54callen(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:57babilencallen: Could I see the underlying XML?
11:58callenbabilen: "http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdXMLclient.php?zipCodeList=94043&amp;product=time-series&amp;begin=2012-01-01T00:00:00&amp;end=2013-04-21T00:00:00&amp;maxt=maxt&amp;mint=mint&quot;
11:58callenthis is getting kinda ridiculous though
11:58callenI could've had this parsed ages ago in Python
12:00TimMcWhat's the goal here?
12:01TimMcFirefox doesn't complain about this XML. It doesn't validate, you say?
12:02callenTimMc: long past that.
12:02callenTimMc: I mean, it doesn't, but I used tagsoup to sidestep that
12:03callenTimMc: now I can't get data.zip.xml/xml-> to return anything from the parsed and zipped document.
12:03callenwhich 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:05callenusing 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:07TimMcI'm not sure why you're using zippers to access it.
12:08TimMcMy first inclination would be XPath.
12:29callenTimMc: this is how I saw everybody else doing it.
12:29callenTimMc: everybody that talks about accessing parsed XML uses the zip-xml approach.
12:31callenTimMc: more profoundly, I'd like to know why the goddamned code doesn't work.
12:31callenI don't want to just cargo-cult around, if something doesn't work, I want to know *why*
12:37duck11232zip-xml is great for parsing xml unless you need namespace support
12:37duck11232I've found XOM to be the easiest to use from clojure
13:21rabblerHello 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:21rabblerwow, bad engish.
13:22rabblerhit 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:22jsabeaudryrabbler, perhaps you could be interested in nrepl
13:22rabblerBlurg, typing too fast.
13:22technomancyrabbler: a dumb socket repl is trivial to add, but nrepl will get you better interop and tooling.
13:23rabblertechonomancy, you gave up swank! :-)
13:23rabblerbut, I am no expert on Clojure. Though, I've been to two clojure-conj. heh.
13:23rabblerDoes nrepl require emacs?
13:23technomancyswank needed to die; the needs of the many outweigh the needs of the few, &c
13:24rabblerhahj.
13:24technomancyno, nrepl is client-agnostic
13:24technomancyyou can connect via `lein repl :connect host:port` or via emacs/IDEs
13:26rabblerI'll see if I can figure it out. Thanks. This is the correct site? :https://github.com/kingtim/nrepl.el
13:26technomancyno, that's the Emacs client
13:26rabblerthat's what I thought.
13:26technomancythe server is just "nrepl"
13:26rabblerheh. hence why I asked about emacs. heh.
13:27jsabeaudryrabbler, https://github.com/cemerick/nREPL
13:27jsabeaudryoops
13:27rabblerheh, not: https://github.com/clojure/tools.nrepl
13:27rabbler?
13:27jsabeaudryyes my bad
13:27jsabeaudryheheheh
13:27rabblerCool, cool.
13:27rabblerThanks everyone.
13:40yankovwhat 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:42augustlyankov: it's passed by reference
13:44augustlso, no copying
13:44yankovaugustl: thanks. now if I add an element to this list and pass it to another function, memory usage is still not doubled?
13:44augustlyankov: no, that's the "persistent" part of clojure's collections
13:45augustlyankov: tree structures are utilized internally, the new object shares most of it's structure with the original
13:45augustlyankov: 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:46yankovaugustl: awesome, thanks! reading that
13:47augustlyankov: 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:47augustlyou create a new list that has the item added to it
13:47augustlsomeone should make a "how to talk about clojure data structures" cheat sheet..
13:49yankovdo 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:49augustlit's very different from the typical mutable collections in other programming languages
13:51augustlthe 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:00scriptorthere are still some issues with having to copy the path to the node when, say, appending to a vector
14:01scriptorbut if that ever becomes a problem, there's always zippers
14:13oichdo 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:14nDuffoich: ...sure this is the channel you intended to be in?
14:14oichurggh... sorry. It is actually about ritz-nrepl. but wrong channel sorry.
14:14nDuffoich: I'd check whether a reverse DNS of the IP address used on your default route comes back to that, by the way.
14:36SgeoIf I install JDK6 or JRE6 after having installed JDK7, what will my default be?
14:37technomancySgeo: depends on your OS
14:37SgeoWindows 7.
14:37cemerickweavejester: Looks like :tag#id.class works in hiccup 1.0.1, but #tag.class#id doesn't. Intentional?
14:39nDuffSgeo: 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:40technomancychoosing between installed JVMs is typically done by adjusting your PATH
14:49amalloycemerick: 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:04cemerickamalloy: Noted. Interesting how my defaults are so often diametrically opposed to others'. :-P
15:04amalloyi think i tried it your way as well
15:04amalloyso never fear, you are not alone
15:20TimMccemerick: You mean :tag... not #tag..., right?
15:21cemerickTimMc: Yes, I meant :tag.class#id
15:26bhenryi 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:26bhenryany ideas?
15:28hiredmanbhenry: I don't think either of those are valid data formats for #inst, http://en.wikipedia.org/wiki/ISO_8601
15:29bhenrythey 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:29hiredmanerrors how? when?
15:31firesofmayHi, How can I run commands like whoami? inside of clojure and get output?
15:31augustlfiresofmay: https://github.com/Raynes/conch is a good library
15:31emezeskebhenry: Maybe post a code snippet?
15:31bhenryhiredman: 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:31augustlor you can just call the java stuffs yourself of course
15:31firesofmayaugustl, okay thanks.
15:32bhenryemezeske: i'll try to see what happens with a generic sample.
15:33emezeskebhenry: Yeah, step one with a problem like that should usually be "build the minimal reproduction"
15:55gtrak`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:56gtrak`or to completely inline stuff?
15:56nbeloglazovI'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:57nDuffnbeloglazov: Incanter, perhaps?
15:57emezeskenbeloglazov: Maybe "incanter"?
15:57nDuffHeh.
15:57emezeske:)
16:00nbeloglazovIncanter is grown and advanced project and I doubt I can really contribute much to it.
16:04Raynesnbeloglazov: You can contribute to refheap. It is scientifically proven to be awesome. :P
16:05scriptorwhat's it built on?
16:05nbeloglazovRaynes: :) The only thing left to do is to prove it to my teachers.
16:06Raynesscriptor: What is refheap built on?
16:06scriptorRaynes: yep, compojure?
16:06RaynesNoir, but I plan to move to Compojure. Just lazy.
16:10bsbutlerdrop-last seems to neatly subsume butlast. Is there any plan to deprecate/remove butlast?
16:10bsbutlerI assume no. Just curious if there's a rationale.
16:11Raynes&(doc drop-last)
16:11lazybot⇒ "([s] [n s]); Return a lazy sequence of all but the last n (default 1) items in coll"
16:11RaynesI didn't know that existed.
16:12bsbutlerbutlast is lifted directly from CL, it would seem
16:12bsbutlerhttp://www.lispworks.com/documentation/HyperSpec/Body/f_butlas.htm
16:14amalloybutlast is eager, amazingly
16:15bsbutlerheh. so it was *really* lifted from CL. ;)
16:15technomancyyou can always tell when something comes from CL because its name doesn't make sense
16:15technomancyluckily clojure didn't lift any functions ending in -p
16:15amalloywhat's wrong with butlast?
16:15technomancyit's not hyphenated
16:17amalloyneither 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:17bsbutlerhaha
16:18amalloywhoa, 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:18lazybot⇒ "([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:30augustlis 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:33chronnoaugustl: Check http://clojure.org/cheatsheet
16:33hiredmanaugustl: reduce
16:33TimMcaugustl: into/for with 2-element vectors, zipmap...
16:34augustlthe list of functions under "map" on the cheat sheet is sparse..
16:34augustls/"map"/"Maps"
16:35bsbutleralso in the category of "why is this here?": ##(doc ffirst)
16:35lazybot⇒ "([x]); Same as (first (first x))"
16:35bsbutlerwe have pervasive destructuring!!! gah ; though this does work if you don't know the type being passed.
16:35augustlhah
16:36augustla lot of the built-in map functions uses reduce, persistent! and transient. Seems I should learn what the last two does..
16:40dnolenaugustl: persistent! and transient are optimizations, they don't really change the overall approach.
16:41augustldnolen: are you aware of any blog posts describing this in more detail? :)
16:42augustlis the idea that you create a mutable map while building, then return a persistent one?
16:42SgeoReminds me of the ST monad
16:42SgeoWell, so does the fact that set! exists.
16:42SgeoAlthough set! is usable for larger impurities I think
16:44metellusaugustl: look into transient and persistent!
16:44amalloybsbutler: fnext, baby. in case you really miss your cadr, and second is just too wordy for you
16:44augustlpersistent! and transient seems to be the ultimate proof that Clojure is very pragmatic as far as immutability goes :)
16:44dnolenaugustl: you can't just bang on it - it still needs to be used in a functional way.
16:45scriptoraugustl: http://clojure.org/transients is a good read
16:45bsbutleramalloy: OMG *why* would second be too wordy? :P
16:45augustlscriptor: nice, thanks
16:46augustldnolen: I just did a very imperatice set of assoc! calls :)
16:46pjstadigamalloy: fnext and second are both "words", maybe you meant too charactery? :)
16:46amalloywell, you know common lispers are used to nice short names like multiple-value-bind
16:46technomancydelete-if-not
16:47amalloya classic
16:47bsbutlerremove-if-not is more common. but those are nothing compared to terpri and rplaca. ;)
16:47bsbutlerrplacd even.
16:48bsbutleryeah, the clojure core certainly feels more consistent. fnext, ffirst, butlast are just interesting exceptions.
16:48technomancyhttp://www.jwz.org/blog/2008/11/ejacs/
16:49bsbutlerha! hadn't read that. Everybody loves Miyazaki!
16:49bsbutlerAnd, of course, what kind of car does that make Clojure?
16:50hiredmanhttp://www.military-today.com/apc/stryker.jpg
16:50technomancyhttp://machinegestalt.posterous.com/if-programming-languages-were-cars
16:50scriptorhttp://en.wikipedia.org/wiki/Sidecar
16:51augustlI 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:52octagonin 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:53hiredmanoctagon: that will not work the way you want in clojure either
16:53augustlall I can think of is some kind of for loop
16:53hiredman,(apply (symbol "map") [identity '(1 2 3)])
16:53clojurebot(1 2 3)
16:53hiredman,(apply (symbol "map") [inc '(1 2 3)])
16:53clojurebot(1 2 3)
16:53augustlthen again, I want to end up with {"some_attr" "Some error message"}. But map doesn't take/return a map..
16:53octagonhiredman: it works in a clj repl, is that an artifact of the repl?
16:54hiredmanoctagon: but no, vars are not reifed in cljs, so no runtime resolution
16:54hiredmanoctagon: 'map is not the function map
16:55hiredman,(symbol "map")
16:55clojurebotmap
16:55hiredman,'map
16:55clojurebotmap
16:55hiredman,map
16:55clojurebot#<core$map clojure.core$map@2d1127ff>
16:55hiredman,#'map
16:55clojurebot#'clojure.core/map
16:56hiredmanhttp://clojure.org/data_structures#Data%20Structures-Symbols
16:56amalloyoctagon: it doesn't work in a clj repl. you just happened to pick a functon, identity, for which it works by coincidence
16:56octagonhiredman: 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:57octagonhiredman: oh wow
16:57octagonhahaha you're right
16:58bsbutlerholy crap. map-indexed is a thing. O_O
16:59octagonthanks, hiredman
17:18bsbutleropinions on which drop-nth is more readable/idiomatic/etc? https://www.refheap.com/paste/5119
17:18mmitchellanyone here use korma?
17:19Frozenlockbsbutler: I prefer the first, easier to read
17:19nDuff...well, not so much "hated it" as "spent much, much too much time trying to work around it"
17:20mmitchellyeah, 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:20scriptormmitchell: what's the query it generates?
17:20mmitchellscriptor: how can i get that?
17:21scriptorgood question
17:21bsbutlerFrozenlock: 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:21TimMcmmitchell: I remember there being a command to get the SQL isntead of running it.
17:22scriptormmitchell: looks like if you wrap the call to select in (sql/sql-only …) ?
17:22mmitchellTimMc: is it dry-run?
17:22mmitchellok i'll try that
17:23Frozenlockbsbutler: Perhaps. I don't really need to optimize speed over readability very often.
17:23bsbutlerTrue.
17:23FrozenlockMy time is more precious than machine time :P
17:24mmitchellthis is what I get: "SELECT "users".* FROM "users""
17:27amalloybsbutler: neither of those drop-indexed impls are any good
17:28amalloythe first has that awful n^2 behavior you mentioned, and the second doesn't work for seqs which contain false as an element
17:30amalloyinstead: (for [[i x] (map-indexed vector seq (range)) :when (pos? (mod (inc i) n))] x)
17:32Frozenlock$ (re-find "my" "hello my name is")
17:32FrozenlockWhat's the bot key again?
17:32antares_ClojureWerkz now has a blog: http://blog.clojurewerkz.org/
17:32Raynes&(+ 3 3)
17:32lazybot⇒ 6
17:32antares_plus, Quartzite 1.0 is out: http://blog.clojurewerkz.org/blog/2012/09/18/quartzite-1-dot-0/
17:32Frozenlock&(re-find "my" "hello my name is")
17:32lazybotjava.lang.ClassCastException: java.lang.String cannot be cast to java.util.regex.Pattern
17:32FrozenlockRaynes: thanks
17:32Frozenlock&(re-find #"my" "hello my name is")
17:32lazybot⇒ "my"
17:33FrozenlockWhat is '#' in this context?
17:34RaynesIt creates a regex.
17:34Raynes#" is a reader macro.
17:34RaynesSee http://clojure.org/reader
17:34bsbutleramalloy: I just found map-indexed and keep-indexed and was working on something similar. Thanks. :)
17:38octagonis 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:39FrozenlockHmmm.. How can I search a string in another string without '#'? (defn matching-string [string1 string2] (re-find string1 string2)) doesn't work.
17:39amalloy$javadoc String
17:39lazybothttp://docs.oracle.com/javase/6/docs/api/java/lang/String.html
17:40FrozenlockI'm in clojurescript
17:40mmitchelldang, i just can't get korma to work :/
17:41emezeskeoctagon: 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:41dnolenFrozenlock: JS has an indexOf String method.
17:42Frozenlockdnolen: Thanks. This means there's no clojure function to find a string?
17:42octagonemezeske: thanks, i just wanted to make sure
17:42emezeskeoctagon: 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:42emezeskeoctagon: Why do you need to call cljs from clj? Maybe there's some other approach?
17:43octagonemezeske: 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:44dnolenFrozenlock: I don't see why you can't just use re-find. (js/RegExp. some-string)
17:44emezeskeoctagon: You are aware that you can use macros in clojurescript? (albeit they are written in clojure)
17:45emezeskeoctagon: I guess that's where you're hitting trouble -- the clojure macro wants to use some handy clojurescript utility function?
17:45octagonemezeske: yes, but you can't use cljs things in your clj macro namespace
17:45emezeskeoctagon: I have done exactly what you're talking about
17:45octagonemezeske: i want to use cljs.reader/read-string :/
17:46emezeskeoctagon: Oh... nevermind!
17:46emezeskeoctagon: I've called meant-to-be-shared cljs code from clj, but not unmeant-to-be-shared cljs code :)
17:46octagonemezeske: well not exactly, i really wnat to call a function in cljs that calls read-string
17:46Frozenlockdnolen: 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:46octagonemezeske: i don't need to call read-string directly
17:46emezeskeoctagon: Are you sure you need to call that cljs function at compile-time?
17:47octagonemezeske: can i do some kind of "extern" declaration maybe to get the macro to compile?
17:47emezeskeoctagon: If you don't need to actually call the cljs read-string at compile time, you shouldn't have a problem
17:47emezeskeoctagon: If you really want to call cljs read-string at compile time, that's a little (lot) weird.
17:48octagonemezeske: oh wait, i think i can use the clj reader actually
17:48emezeskeoctagon: That would probably make your life a lot easier.
17:49octagonemezeske: the macro will run at compile time anyway, so that makes sense
17:49octagonemezeske: thanks for talking me off the ledge
17:51emezeskeoctagon: haha I think you talked yourself off the ledge :)
17:54mindbender1is anyone having success with piggieback in emacs?
17:55mindbender1It keeps throwing IllegalStateException at me
17:59mindbender1Here is the gist: https://gist.github.com/3740028
17:59xeqimindbender1: what does your project.clj look like?
18:00FrozenlockWhat's the advantage of piggieback vs inferior-lisp?
18:01mindbender1xeqi: here https://gist.github.com/3740038
18:04xeqiheh, is that a custom version of enlive?
18:04xeqilein deps :tree might be better here
18:05xeqicemerick: should there be a 0.0.1 tag for piggieback on github?
18:06cemerickxeqi: there is now
18:06xeqicemerick: thanks
18:08cemerickFrozenlock: if you don't use inferior-lisp, or Emacs even, lots :-P
18:08mindbender1xeqi: still need that deps :tree?
18:09xeqicould be helpful
18:09mindbender1xeqi: kk.. here : https://gist.github.com/3740062
18:10xeqithough I would have expected wrap-cljs-repl in that stacktrace somewhere...
18:12mindbender1xeqi: does tools.nrepl have a wrap-cljs-repl?
18:12cemerickmindbender1: what version of lein?
18:12mindbender1cemerick: leiningen 2.0.0-preview10
18:12xeqipiggieback does, its part of the middleware stack in injections
18:13cemerickmindbender1: :nrepl-handler needs to be in :repl-options https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L118
18:13cemerickmindbender1: but it'd be easier to just use :nrepl-middleware if adding piggieback is all you're doing nREPL-wise.
18:14mindbender1cemerick: it might also help to know that I'm trying to get it work from nrepl.el 0.1.4-preview
18:14cemerickThat should be irrelevant.
18:15mindbender1cemerick: ok
18:15cemerickI mostly don't know anything about nrepl.el though.
18:16xeqiit should start and eval fine w/ nrepl.el, though some things like loading files doesn't work yet
18:17xeqinrepl's :describe and :load-file are planned for 0.1.5 last I read; which would solve that
18:19whitakerLooks 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:19whitakerhttps://github.com/ztellman/aleph/blob/perf/src/aleph/http/websocket.clj
18:24whitakerDifferent 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:25whitakerSomething which doesn't require ginning up a .js test fixture and invoking it manually (ugh) in a browser?
18:29whitakerThe 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:31whitakerWhere routes is in (defroutes routes ……) in core.clj
18:40whitakerI'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:40whitakerAnyone?
18:40clojurebotJust 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:40whitakerNice.
18:41whitakerBot's on a 15-minute delay.
18:42lnostdalany sane way of doing stuff like this: http://cljbin.com/paste/5057a657e4b0c74e0067a3f8 ..? i.e., "forward" keyword args
18:43whitakerAs for "the question [for which I] really want the answer," it was asked in the context surrounding the line on which clojurebot reacted.
18:43amalloylnostdal: don't do it, man
18:43lnostdalamalloy: i guess pass a map directly instead?
18:43amalloyyes
18:44lnostdalok, right .. this stuff seems broken
18:44lnostdalso yes .. ok .. thanks
18:44amalloykwargs are a very mild syntactic convenience for the outermost layer of your API
18:45amalloypersonally i'd rather type the two {} characters than deal with kwargs
18:47hyPiRionWow, I never knew programming could be so exhausting.
19:02emezeskehyPiRion: Based on your comment, I guess that you are dealing with XML
19:03casionobviously using regex to deal with xml no less
19:04whitaker<- waiting for clojurebot to make a snarky comment about regex ("…now you have two problems…")
19:04hiredman~regex
19:04clojurebotSometimes people have a problem, and decide to solve it with regular expressions. Now they have two problems.
19:04whitakerAh, needed to be invoked
19:04hiredmanregex?
19:04clojurebotSometimes people have a problem, and decide to solve it with regular expressions. Now they have two problems.
19:04lnostdalperhaps he's doing CSS
19:04hiredmanclojurebot: what about xml?
19:04clojurebotXmL is case-sensitive
19:07mattmossbefunge?
19:32whitakerBTW, in case anyone didn't already know: ztellman rocks. For the record. Helped me elsewhere. He is "helpful" personified.
19:32ztellmanhaha
19:33gfredericks(inc ztellman)
19:33lazybot⇒ 1
19:33ztellmanyou shamed me into actually logging onto IRC
19:53gjcourthey guys, i have a ?
19:53gjcourthttp://pastie.org/4743548 is a macro im trying to define
19:53hiredman:(
19:54gjcourti can use macroexpand and it looks like it works, but passed as an argument to a function i get
19:54hiredmanyou want reify
19:54gjcourthiredman instead of new?
19:55hiredmaninstead of defrecord
19:55amalloyinstead of the whole thing
19:55hiredmanyes that
19:56gjcourtso something like (reify Handler (process ...
19:58gjcourtsweet, thanks hiredman amalloy
20:04akhudekFYI to anyone using ring + https + IE clients: https://github.com/ring-clojure/ring/issues/17
20:10lnostdalwhy not let the front-end HTTP server handle static content, akhudek?
20:11lnostdalkind of on the side, but still
20:11akhudeklnostdal: that's a good idea too, though people might still run into this like I did
20:25weavejesterakhudek: I'll fix that tomorrow and release a patch
20:25akhudekweavejester: thanks!
20:27muhooi'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:31jlewishi, anyone know why PersistentArrayMap doesn't use a binary search algorithm for its indexOf if keys are sortable?
20:31amalloybecause keys aren't sortable
20:31jlewisnot in general, but what if they happen to be?
20:31TimMcarray-map is just for small collections, right?
20:32jlewisyep
20:32TimMcso... why optimize?
20:32jlewisbut log(n) is a lot better than n even for small collections
20:32amalloyjlewis: not if the constant factor is large, which it probably will be. plus there are related issues
20:33amalloyeg, the fact that it's impossible to tell if they're all sortable
20:33jlewisyeah that's a good point
20:33jlewis:)
20:34leafwWould 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:38mpanhm, I feel weird switching between writing different languages
20:39casionyou get used to it
20:39emezeskempan: Keep it up! It makes you a much better programmer IMHO.
20:39casionI have projects that have 5 languages in the same file
20:39casionit's confusing for a while… then you get used to it and you get annoyed when you're stuck in one language
20:40mpanwell it's definitely a learning experience
20:40amalloyleafw: that is like a thousand pages. if you want comments on something in particular i recommend linking to a smaller sample
20:43leafwamalloy: it's a complete program that works. Got tired of finding only trivial examples of usage of monads in clojure.
20:44hamzaaaHi 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:45leafwamalloy: on macros inside domonad, it is likely that my assessment (that macros don't work inside a domonad block) is wrong
20:45amalloyyes, that assessment sounds pretty nuts since basically everything is a macro (eg, let)
20:45leafwright
20:46amalloyleafw: 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:46leafwamalloy: makes sense. Will try to write a minimal example.
20:49mpanhow do I pass the function representing a java static method?
20:49mpane.g. I can call Integer/parseInt, but how do I pass a fn representing it?
20:49mpanor just create the fn?
20:49xeqi#(Integer/parseInt %)
20:49mpanso create it? ok thanks!
20:57mpanis there a better way to get the max of a seq than passing identity fn to max-key?
20:58hiredman,(doc max)
20:58clojurebot"([x] [x y] [x y & more]); Returns the greatest of the nums."
20:58mpanthing is I have a seq, and I'm afraid to use apply because it might be large
20:58mpanI mean, what happens if you apply with too many args?
20:58amalloyapply works fine with infinite seqs
20:59amalloy&(apply (fn [& args] (take 10 args)) (range))
20:59lazybot⇒ (0 1 2 3 4 5 6 7 8 9)
20:59mpan,(doc range)
20:59clojurebot"([] [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:59mpanoh
21:00mpancool
21:00mpanthanks
21:00mpanI thought I heard something about a max of some # of args
21:03gjcourtany ideas why destructuring would fail here? https://www.refheap.com/paste/5126
21:03mpanperformance-wise, is having lots of args an issue? (for use w/ apply)
21:08gjcourtalso, from the repl is there a good way to do (ns :reload NS) on your current namespace?
21:08emezeskempan: No.
21:14emezeskegjcourt: I think *ns* refers to the current namespace, if that's helpful
21:16muhoompan: 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:17mpanmuhoo: not just languages, but styles
21:17mpanlike, this assignment uses functional style, previous 2 assignments used imperative style, because some classes do require a language and some don't
21:19mpanah it's this error again: CompilerException java.lang.RuntimeException: Unable to resolve symbol: defn in this context, compiling:(NO_SOURCE_PATH:2)
21:19mpanI'm really wondering what's breaking the repl so I can avoid it in the future
21:20amalloympan: you probably have an in-ns form somewhere without a refer-clojure or an ns
21:21mpanI'm not currently using in-ns
21:21mpanlike I'll get that from compiling all manner of unrelated but wrong things
21:21mpanthe actual root cause this time seems to be using a symbol that wasn't bound to anything
21:22mpanbut idk why it manifests as that error
21:23jimdueyleafw: 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:23jimdueyleafw: https://github.com/jduey/protocol-monads
21:24amalloympan: nobody else will ever know either, if you only provide an error message with no stacktrace or source
21:25mpanoh!
21:25mpanthe exception is caused by a different one that can't resolve something different
21:25mpanbut that something different is actually in my code
21:25mpanthank you!
21:25mpandidn't realize there was more than one exception happening
21:26hamzaaaHow 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:27gfrederickshamzaaa: it should
21:29gfredericksI believe it worked for me
21:30hamzaaagfredericks: this (dom/element [:div {:asd :asd} [:li "as"]]) returns <div><li>as</li></div> for me?
21:31gfrederickswhat is dom/element? is that from domina?
21:32gfredericksI've never heard that you can do hiccup-style things with domina; crate is the cljs hiccup library
21:32hamzaaagfredericks: nope it is from, https://github.com/clojure/clojurescript/blob/master/src/cljs/clojure/browser/dom.cljs
21:32hamzaaagfredericks: how did you generate it?
21:32gfredericksah; well same comment but for cljs.clojure.browser instead of domina :)
21:33hamzaaagfredericks: then let me rephares how would you generate it? without using strings
21:36gfrederickshamzaaa: using the crate library; that's how you do hiccup in cljs
21:37hamzaaagfredericks: thanks.
21:44casiondoes anyone use ac-nrepl? I'm constantly getting "java.lang.ClassNotFoundException: complete.core"
21:47casionoh, ok, I see a discussion about it now
22:05mpanis clojure doing implicit int-coercions for me in java interop?
22:08casionmpan: it seems to
22:08casionI had a lot of trouble with that recently
22:34luxbockdo I need to install clojure.contrib separately, or is it a part of the clojure package?
22:35luxbockwhen I try to do (require 'clojure.contrib.math) in repl I get a FileNotFoundException
22:36xeqi~contrib
22:36clojurebotMonolithic 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:37luxbockhmm I see
22:40luxbockso I see that clojure.contrib.math has moved to clojure.math.numeric-tower
22:41luxbockhow do I go about installing that?
22:43leonardoborgesluxbock: something like [org.clojure/math.numeric-tower "0.0.1"] in your project.clj
22:43leonardoborgesor whatever version you need.
22:45luxbockI'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:45luxbockhow would I enable myself to play around with things from clojure.contrib in REPL?
22:46luxbockI'm using the nREPL in Emacs to be more specific
22:48mpanuh, so are you using any sort of dependency management?
22:49mpan(I'm sorry in advance if this isn't right, because I'm also new)
22:49leonardoborgesluxbock: 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:49luxbockI'm just trying to play around with things in REPL
22:49mpanso 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:49mpanBUT
22:49leonardoborgesafk
22:50mpanthe preferred way is to use a tool such as leiningen to manage dependency requirements for you
22:50luxbockgot it
22:50xeqiluxbock: 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:50xeqi* add to the :dependencies vector
22:50mpanso if you put the clojure jar and that jar on your classpath and run the repl, you will have it, but
22:51mpanas 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:52mpanif you want to use lein, its project readme has setup instructions: https://github.com/technomancy/leiningen/blob/master/README.md
22:52luxbockhow 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:52xeqiyep
22:52luxbockah great
22:52luxbockthanks
22:57arrdem,(System/currentTimeMillis)
22:57clojurebot1347936741435
22:57gfredericksthe first half of that number is starting to feel familiar
22:58arrdemhum.... any ideas why for some atom foo I can't just (swap! foo System/currentTimeMillis)?
22:58gfredericksbecause that's not a function
22:58arrdemI'm getting a 'no such static member' from lein
22:58gfredericksI expect what you want is (reset! foo (System/currentTimeMillis))
22:59arrdem,(doc reset!)
22:59clojurebot"([atom newval]); Sets the value of atom to newval without regard for the current value. Returns newval."
22:59gfredericksbut java calls (both instance methods and static methods) can't be used directly as functions
22:59gfredericksyou could also do (swap! foo (fn [_] (System/currentTimeMillis)))
22:59gfredericksif you prefer it with swap!
23:01luxbockhow 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:02luxbocknot sure if I'm using the wrong command or or there's something wrong with the setup
23:02arrdemcheers gfredericks
23:31arrdem,(doc nth)
23:31clojurebot"([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:59mpan,(doc get)
23:59clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."