#clojure logs

2010-08-27

00:00technomancyfielcabral: best bet is to use elpa
00:00fielcabralOK. Thanks!
00:00technomancyit may work from trunk, but not many people do that, so breakage there takes a while to get fixed.
00:18eshirahi, i'm trying to run a jar file that I made using "lein jar" I do: ava -classpath /Users/eshira/.clojure/clojure-contrib.jar:/Users/eshira/.clojure/clojure.jar -jar cljservice-1.0.0-SNAPSHOT.jar but I still get Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/IFn
00:18eshiraCaused by: java.lang.ClassNotFoundException: clojure.lang.IFn.
00:18eshiraany ideas?
00:19hiredmanyou can't use -cp or -classpath with -jar
00:20eshirareally, huh... oh java
00:22eshiraok, so I set up my classpath such that "echo $CLASSPATH" prints out:
00:22eshira:/Users/eshira/.clojure/clojure.jar:/Users/eshira/.clojure/clojure-contrib.jar. But "java -jar lein-compiled.jar" still gives me the error
00:23hiredmanCLASSPATH is ignored if you specify -cp -classpath or -jar
00:24technomancythe java command-line launcher is really terrible
00:24eshiraof course, that makes sense of course
00:24eshiraso my goal is to develop compojure apps faster w/o having to "lein uberjar" all the time
00:25technomancyit's pretty clear being able to launch CLI java was added as an afterthought in the 90s when everyone assumed java was all about running in web browsers, then nobody bothered to fix it once applets fell flat on their face.
00:27tomojeshira: don't you have a repl open while you're developing?
00:30eshiratomoj: yes. I guess I'll just do a :reload
00:31eshirai'm just used to the rails (and others) auto-reload when in dev mode
00:31tomojhmm
00:31tomojwhat dev environment do you use?
00:32eshiraright now, I do a "lein repl". I use vim as my editor.
00:32tomojah
00:33tomojmaybe vimclojure would help
00:33tomojif you have an editor that has decent support for clojure, you can just start the server in the repl there and reload function definitions or entire files in the editor
00:36eshirai have vimclojure set up, but it breaks when i'm using lein
00:37eshiraswhat do you mean by reloading? b/c when I run "(run-jetty {..} ...)", it blocks the REPL.
00:40dnoleneshira: you can start jetty w/o blocking the REPL
00:41eshirahow would I do that?
00:42dnoleneshira: in the options map to run-jetty, :join? false
00:43dnoleneshira: but as tomoj said with a decent environment (Enclojure, Emacs, VimClojure) you can just send new definitions to the REPL.
00:43dnoleneshira: but if you don't want to do that, Ring has a cool feature where you can automagically reload specific namespaces when you refresh your browser
00:44technomancy(future (run-jetty [...])) ;; is another option
01:01eshirathanks
01:46bortrebI think I found a bug
01:46bortreblet's say I define a function for making a sphere like so:
01:47bortreb(defn sphere [& {r :radius [x y z] :position :or {r 10 position [0 0 0]}}] (println x))
01:47bortrebnow, when I call (sphere) , nil is printed, but it should be 0
01:48hiredmanno
01:48hiredmanposition is [0 0 0] and x is nil
01:49bortrebah
01:49bortrebI see
01:49bortrebI thought it somehow called itself again with the new map but that doesn't make sense after all
01:49bortrebthanks, hiredman
02:30LauJensenGood morning all
02:37old_soundgood afternoon!
02:38LauJensen,UGT
02:38clojurebotjava.lang.Exception: Unable to resolve symbol: UGT in this context
02:38LauJensen:)
02:38LauJensentechnomancy: UGT is broken
02:39hiredmanclojurebot: please show us that ugt is not broken
02:39clojurebotAck. Ack.
02:39hiredmanugh
02:39hiredmanclojurebot: please show us that ugt \is not broken
02:39clojurebotx \is y is z
02:39hiredmanstupid bot
02:40hiredmanclojurebot: ugt now!
02:40clojurebotugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html
02:40LauJensenhiredman: I meant that the concept was broken :)
02:41old_soundmy local time, is useless now?
02:43LauJensenold_sound: it depends. technomancy suggested that we go with UGT, but to each his own
02:43LauJensenI though it was a good idea, because of the very repetitive "Good morning, Good evening, Hi its afternoon here, oh where are you from?" etc etc
02:49old_soundok, good morning then
02:57LauJensenhehe, sorry I hope I didn't kill the mood old_sound :)
02:57old_soundnp
02:58old_soundthe rules, abide them we must! :P
02:58LauJensenAlright, in that case I have a few suggestions more :)
02:58old_soundhoho
02:59old_sound"suggestions
02:59old_sound"
03:03incandenza44
03:25bartjhow do I avoid a reflection warning for this:
03:25bartj(.get hash "key")
03:25bartj(.get ^HashMap hash "key") doesn't seem to work
03:25bartjor even (.get ^java.util.HashMap hash "key")
03:27LauJensen(.get ^java.util.HashMap hash ^String "key") ?
03:31bartjLauJensen, that did it! thanks.
03:31LauJensennp, bartj What did the reflection warning say ?
03:32bartjgah, I actually gave #^java.util.HashMap
03:33bartjI am sorry I gave: ^#java.util.HashMap
03:33LauJensenk
03:34bartjand it gave: No dispatch macro for: j
03:34bartjjava.lang.ClassNotFoundException: ava.util.HashMap
03:34bartjI tend to use ^ here but not in my code for some strange reason sometimes
03:34bartjmay I ask why was #^ replaced with ^
03:35bartjor deprecated rather
03:35bartjit sure does remove the confusion as to which is first - either ^ or #
03:35bartjbut, is there any other reason ?
03:35LauJensenbartj: Yes I think #^ was needed for something else, but it slipped my mind
03:36LauJensenWhen you get a CNF exception, its typically a typo or an unqualified name
03:36LauJensenAnd I dont think you need the string hint, in which case it shouldn't be there
03:37bartjLauJensen, thank you for the tips
03:37LauJensennp
03:49sparievhi, can't figure out this reflection warning - http://gist.github.com/553005
03:50sparievoh, nevermind, problem solved with typehint on parameter
03:51LauJensenwhich parameter?
03:51BahmanHi all!
03:52sparievLauJensen: parameter to the whole fn, I've updated the gist
03:52LauJensenah right, otherwise you missed the 'or'
03:53LauJensenBadabing, Bada-bahman!
03:54sparievIt's amazing how some mistakes become clear seconds later you write about them :)
03:55LauJensenIts called the Rubber plant effect I think
03:55LauJensenSomebody discovered that developers could solve complex problems, if they just retold the problem, to anybody, even a plant
03:56sparievobviously we have too few plants in the office
03:58bobo_aint it rubber duck?
03:58sparievLau got it right - http://www.cb1.com/~john/computing/rubber-plant-effect.html
03:59LauJensenbobo_: Dont you feel silly for using a rubber duck all this time ?! :)
04:00bobo_http://en.wikipedia.org/wiki/Rubber_duck_debugging
04:00bobo_i used wikipedia, i win! :-)
04:02LauJensen:(((
04:02LauJensenMan you created that page and altered the timestamps fast!
04:02bobo_indeed!
04:02bobo_or i planed this al along
04:16edbondHi, how to use java iterators in clojure? .hasNext, .next etc. I want to have clojure sequence from it.
04:18LauJensenedbond: iterator-seq and enumerator-seq
04:19LauJensen,(doc iterator-seq)
04:19clojurebot"([iter]); Returns a seq on a java.util.Iterator. Note that most collections providing iterators implement Iterable and thus support seq directly."
04:22edbondLauJensen: thanks
04:36LauJensenHow do I run a task with cake in the context of my application? I need access to the entire classpath and all namespaces?
04:38notsonerdysunny(ns jrealityTutorial.core
04:38notsonerdysunny (:import [[de.jreality.plugin JRViewer]
04:38notsonerdysunny [de.jreality.geometry Primitives]
04:38notsonerdysunny [de.jreality.reader Readers]
04:38notsonerdysunny [de.jreality.ui.viewerapp ViewerApp]
04:38notsonerdysunny [de.jreality.scene.data AttributeEntityUtility]]))
04:39notsonerdysunnyHi everybody .. can you tell if above is the right way to import multiple classes? (sorry for flooding .. I was hoping it would appear on a single line)
04:39clojurebottrampoline is http://groups.google.com/group/clojure/browse_thread/thread/6257cbc4454bcb85/3addf875319c5c10?#3addf875319c5c10
04:40notsonerdysunnyIt is not compiling
04:40LauJensennotsonerdysunny: Its not a vector of vectors, its vectors
04:41hoeckor lists: (ns ... (:import (de.jreality.plugin JRViewer) ... ))
04:41notsonerdysunnyLauJensen: thanks
04:42LauJensennp
04:44bartjhmm, I thought :import were put in lists and :use were put in vectors ?
04:44bartjbased on the convention, I see in the Clojure code I read
04:45LauJensenbartj: if we had conventions for use/import/require etc, Clojure would simply be too easy
04:45bartjLauJensen, I am afraid, I don't understand
04:46bartjof course both lists and vectors are sequences, so they are interchangable ?
04:46LauJensenbartj: Im just making a joke. The whole import/use/require system has been a bit confusing since the beginning. (use .. is quoted, (:use is not, takes vecs and lists etc, huge overlap between require and use. Personally I use vectors for everything
04:46LauJensen,(seq? '(1 2 3))
04:46clojurebottrue
04:47LauJensen,(seq? [1 2 3])
04:47clojurebotfalse
04:47bartjscratches head
04:48LauJensenMaybe this makes more sense
04:48LauJensen,(filter seq? [[1 2] '(1 2) #{1 2} {1 2}])
04:48clojurebot((1 2))
04:48LauJensen,(filter coll? [[1 2] '(1 2) #{1 2} {1 2}])
04:48clojurebot([1 2] (1 2) #{1 2} {1 2})
04:48LauJensenUse collections where they make sense, and sequences (lists) where you need their special properties. lists and vectors arent totally interchangeable
04:48fliebelmorning
04:48LauJensenfliebel: morning
04:50bartjLauJensen, It would be wonderful, if you could provide an example - as to why, lists and vectors are not interchangeable
04:51LauJensen,(reduce conj [] [1 2 3])
04:51clojurebot[1 2 3]
04:51LauJensen,(reduce conj '() [1 2 3])
04:51clojurebot(3 2 1)
04:51LauJensenThats one thing, another is they have completely different performance characteristics
04:52LauJensenWhich tilkov and Chousuke actually put up a blogpost/table about ... wonder where that went
04:52LauJensenclojurebot: performance of datatypes?
04:52clojurebothttp://clojure.org/java_interop#toc46
04:52fliebellaujensen: That has always bothered me. Comming from Python with their "one way to do it", it feels wrong to have conj go in the other direction just because.
04:52LauJensenfliebel: Its a good thing. You want more datastructures. Everything in Clojure is data right? So we need to express ourselves in different ways
04:52LauJensenLike simulating a stack with a vector sucks, but not with a list
04:58bartjLauJensen, I think a vector sucks when you want to access data sequentially
04:58LauJensenIts the O(1) lookups thats bothering you? :)
04:58bartjand a list when you need random access
04:58bartjthat's about it, right ?
04:59LauJensenI fail to see how a vector isnt suited for sequential access. Its more performant than a list, so heavy lifting should be done in vectors
04:59bartjam sorry, I mean some operations have to be performed sequentially
04:59bartjlike insertion for example
05:00LauJensenIm with you so far, that if you need insertion at the front, a list is probably what you want
05:01bartjyes, you are right
05:02LauJensenAnother thing which is important, is that if you do start out with a list, and go through map/filter/remove etc, which are all made to work on collections, your sequence will be cast to collection, thus slowing the process down
05:06bartj, (list? (keys {:a 1 :b 2}))
05:06clojurebotfalse
05:07bartjwell, honestly I thought the keys function would give a list
05:07bartj, (type (keys {:a 1 :b 2}))
05:07clojurebotclojure.lang.APersistentMap$KeySeq
05:08bartjbecause a list is seq-able right ?
05:08bartjbut, it seems to be a collection !
05:10anars,(doc keys)
05:10clojurebot"([map]); Returns a sequence of the map's keys."
05:10anarsthere you go.
05:24BjeringI have the very first baby steps on my minimal clojure wrapping of NIO.2, would be great to hear some feedback on how it could be made better if anyone wants to look: https://gist.github.com/62014c28ba42f0c03b2b
05:29LauJensen`Bjering: No typehints?
05:30Bjeringnot yet, my thinking is any typehints should be motivated by profiling and its not enough in there to profile yet. Or is typehints acceptable "pre-mature" optimization? I do think they make things uglier.
05:31LauJensen`no no no
05:31LauJensen`Never prematurely optimize. A poorly placed typehint can slow your code down
05:31BjeringA question, can I get clojure to memoize the reflection? Seems to me that should really be enough in alot of cases.
05:31LauJensen`I think your lib looks quite well, though I havent thought about how I would model it so I cant comment on your abstraction level. Stylewise I would prefer to stay away from long names and instead choose short descriptive names with good docstrings.
05:32LauJensen`Bjering: I guess it could be done for static functions, but normally you wouldn't want that in case something changes somewhere.
05:32Bjeringits very little abstraction, I want to recognize the java lib below it. Any abstractions will be built on top of this thin clojure-layer
05:32LauJensen`Ok
05:33BjeringOne question, uis such super-thin wrapping really any point or just stupid, should I go with java-interop instead?
05:34LauJensen`Well, you seem to have an oppinion about bundling some state and keeping it in atoms, so if that works well I'd say thats enough justification for a wrapper lib in my mind. If people don't like it they'll likely roll their own or just interop
05:36BjeringI must say I dont have enough hybris to imagine anyone else to use this lib :) But what is good lib design is good lib design even if I am the only user. Only difference with a "private" lib I dont have to give as many extension-points/parameters. Ie I can be more opinionated and rely on convention-only, ie no configuration options. Which makes it alot easier to test.
05:38Bjeringthe tests, testing "behavior" such as that callbacks are called, call for state, I think its alittle clumsy, but a full mock seems an overkill atm, but eventually is there a good way to mock in clojure?
05:38LauJensen`Try searching for 'mock' on disclojure.org, I think I saw a realease of some lib for that not more than a couple of weeks ago
05:43BjeringIs there a streams lib for clojure that can do things like tokenizing based on arbitrary delimiters?
05:44LauJensenNot sure
05:44LauJensenWhat are those guys who are running cake called? And where are they !? :)
05:45bobo_im going to kill someone for creating php soon, how can anyone like this crap?
05:46bobo_bah wrong channel but anyway
05:51esjbobo_: you thought you were in #php ?
05:51esj;)
05:51bobo_:-p
05:52bobo_its okay for a language to be dynamic or static. but it can atleast decide
05:55fliebellaujensen: Do you mind me asking you some questions about the structure of bestinclass.dk? I mean the how and where of template+text=page
05:56LauJensenfliebel: http://github.com/LauJensen/bestinclass.dk/blob/master/src/bestinclass/templates.clj
05:56LauJensenSure, ask away
05:57fliebellet me read and think about this for a moment...
05:58fliebelSo you have a fixed and flat structure of templates?
05:58LauJensenits crazy, that last post I did it still on the frontpage of HN and have taken in over 20k hits in 2 days
05:59LauJensenthe templates could be
05:59LauJensen<body><div id="msg"/></body>
05:59LauJensenthe template could then do
05:59LauJensen[:div#msg] (content "Hi, this is the message")
05:59LauJensenor
05:59LauJensen[:div#msg] (clone-for [msg messages] (content msg))
05:59LauJensento make multiple div-tags
05:59fliebelI see, so where do you store the html files?
06:00LauJensentypically in resources/
06:00LauJensenI usually make 1 or 2 master html files, which have headers, footers, imports etc, and then smaller ones for specific pages
06:01fliebelBecasue you use enlive, are the templates the same files as the result, or do you copy them?
06:02LauJensenthe return of calling a template is a sequence of strings. You can write that to disk (like I do on bestinclass.dk) or serve them directly via Moustache, or basically whatever you want
06:02LauJensenBestinclass.dk codewise was primarily a way to convert a wordpress blog into a clojure blog, so it scraped the old blog, passed the data through templates, wrote them to disk
06:03fliebelIn my initial plan, I had a src and a dest folder, where the src folder contained templates and text, and was 'compiled' to the dest folder with the same structure.
06:04LauJensenyea thats certainly one way to do it
06:04fliebelBut with enlive I can imagine they are the same thing, and you only update them.
06:05fliebelSo how do you map source files to templates?
06:06LauJensenIf you look in templates.clj which I linked above, you'll see that deftemplates/defsnippet take first the name of your template/snippet and then the html file to base it on, then the selector, and the args
06:07fliebelyup, seen them. But say you have a blog post in a file, how does your app figure out which snippet to use?
06:09LauJensenI think the answer to that quetion is too specific to wordpress. Generally you don't pass the html to the snippet, you pass data. Make a template which has the general form of what you want as the result, then pass data in and the selectors will apply them where a match is found
06:10LauJensenThis is the file I executed to the deploy the site the first time: http://github.com/LauJensen/bestinclass.dk/blob/master/src/bestinclass.clj
06:10LauJensenBesides the conversion, it generates the static html pages, like the frontpage on bestinclass.dk etc
06:11alienscienceComrades. I am turning a gist into a git project and I don't know what to call it.
06:11alienscienceIt adds a bit of extra functionality to clojure.contrib.sql.
06:11alienscienceShould I call it: extra.contrib.sql?
06:11fliebellaujensen: And what do you run when you wrote a new post? Or updated a page?
06:11LauJensenalienscience: alien.science.sql might be better
06:12LauJensencontrib is not your domain
06:12zmilahow can I use (memoize) for recursive function (like factorial) ?
06:13LauJensenfliebel: admin.html contains a form which has action="/publish", that handler in admin.clj triggers http://github.com/LauJensen/bestinclass.dk/blob/master/src/bestinclass/admin.clj#L98
06:14LauJensenzmila: there's a memoized fibonnacci on one of the wikis
06:14zmilaok, i'll seorch
06:15LauJensenzmila: http://clojure.org/atoms
06:15LauJensenLook no further
06:15fliebellaujensen: ah, of course… You're running moustache, which directly parses it's stuff, while I'm thinking in terms of markdown files.
06:16LauJensenYea, Moustache is like Enlives speedy cousing, they go well together
06:16alienscienceLauJensen: There was a big discussion on the clojure group about library names. People didn't seem to like domain names too much.
06:16zmilaho, the trick is (def fib (memoize fib)) - redefine the same name
06:17LauJensenalienscience: Its not a matter of taste. We (I say we respectfully, I didn't start it) movement where we scrapped domain names, but as it turns out that can give you bad java interop problems down the line - Domain names are there for a reason
06:20alienscienceI also have the problem that I'm sharing the library with someone. I don't want to tie it to one of my domains in Clojars.
06:21fliebel~seen defn
06:21clojurebotdefn was last seen in #clojure, 2681 minutes ago saying: http://copperthoughts.com/p/the-golden-ratio-is-evil/
06:23zmilasadly, the trick with memoize of recursion function works only for direct calls, recursive calls are not memoized
06:24alienscienceAh, forget that - Clojars allows you to add people to groups. Its cool. I'll use a domain name. Thanks for your help.
06:24LauJensenzmila: No not unless you memoize the actual multipliction
06:25LauJensenlets try that again: multiplication
06:25zmilaLauJensen, if I do (fib 6) than (fib 6) is returned instantly, but (fib 4) is calculated again
06:26zmilacalling to (fib 6) creates only one memo, not all the 0 till 6
06:26serp_really?
06:26LauJensenmemoize in core is very simple. If you pass the same arg twice you get you a cached result
06:27serp_LauJensen: but (fib 6) will call (fib 5) etc... shouldn't they be cached then?
06:29zmilaserp_ (fib 6) will call old version of (fib), not memoized
06:36aliensciencezmila: Does this mean this example is wrong http://clojure.org/atoms
06:37Bjeringa no-op function that always return nil ant takes any number of arguments, do we have this?
06:37zmilaalienscience - it's not complete, and not fair
06:37tomojBjering: (constantly nil)
06:37Bjeringthanks
06:38tomoj-> (apply (constantly nil) (range))
06:38sexpbot=> nil
06:38tomoj:)
06:41joegalloGood morning. I'm getting a NullPointerException that comes from Var.java line 295. I'm flummoxed.
06:42joegalloClojure 1.2.0, the line is "Frame f = dvals.get();". It just doesn't seem like dvals could be null, though...
06:43LauJensenjoegallo: I think you got lost looking for ##java? :)
06:44LauJensen(that is, if youre hacking the clojure source)
06:46joegalloHeh, nope. I'm trying to run robocode from clojure. It's vanilla clojure-1.2.0.jar.
06:46LauJensenoh
06:47joegalloI suppose robocode might be doing some magic with classloaders, which might be the issue.
06:51fbru02hey guys , how do i do a map in clojure ? i always use reduce or filter but never map
06:51fbru02and i got this problem that didn't give me the output i expectedhttp://pastie.org/1120086
06:52fbru02anyone can help??
06:52LauJensenfbru02: map returns the result of applying your function, in this case (nil nil), your function prints, which is a side-effect that has no return
06:52LauJensen(doseq [i '(1 2)] (println i)) is what you want for side-effects
06:53fbru02LauJensen: cool, so for side effects should i use seqs ?
06:53LauJensenseq is an interface, which is particularily well suited for non-side-effectfull computations. Use doseq or dotimes for side-effects
06:54LauJensenuse map, filter, remove, etc on collections
06:54fbru02LauJensen: thank you , understood
06:54LauJensennp
07:09sid3kwhatever I try to do using mvn/ant fails... after switching to debian squeeze, lein started to not work
07:11zmilais there a function that does (divisible a b) = (zero? (rem a b)) ?
07:12LauJensensid3k: debian was all the rage in 1969, try Arch
07:12bobo_or mint?
07:13LauJensenbobo_: dont be vain :)
07:13bobo_i havent tried it. but it looks nice?
07:14LauJensenI tried it, was okay for a little while, then they got so popular that their servers drowned. Was some nasty package incompatabilities as well. But its not even in the same leageue as Arch though
07:17sid3kguess I need to reinstall maven but I don't know where it is
07:20LauJensensid3k: sudo apt-get purge maven && sudo apt-get install maven ?
07:21LauJensenor mvn, I forget what its called on debian
07:21sid3kLauJensen: tried both
07:22bobo_sid3k: rm -rf ~/.m2
07:22sid3kmaven is not installed but lein still uses anyhow
07:22bobo_thats where all the libraries are
07:22sid3kbobo_: yeah, this is the one thing I can do about maven :)
07:23bobo_:-)
07:29sid3kafter installing fresh version of lein
07:30sid3klein new foo & cd foo & lein deps commands gives this output: http://gist.github.com/553205
07:30sid3kany ideas are welcome, google doesn't return any good result for this trouble
07:36LauJensenits simply saying that it cant find an artifact, sure you got the name right?
07:39sid3kLauJensen: yeah, I've added content of the project.clj file to the gist
07:40sid3khttp://gist.github.com/553205
07:40sid3kvery mysterious problem
07:41aliensciencesid3k: whats lein --version say?
07:41alienscienceI just tried the same with 1.3.0 on Ubuntu and all is good
07:41sid3kLeiningen 1.3.0 on Java 1.6.0_20 Java HotSpot(TM) Client VM
07:41alienscienceI'm using maven 2.2.1
07:42LauJensenI just tried on Arch, works fine as well
07:42sparievmaybe you have network problems ... I can't reproduce the problem on fedora
07:42aliensciencesid3k: Oh, it probably worth asking if you're behind a firewall?
07:44LauJensenhmm, all distros seem to work except debian.. what could be the problem... hmm :)
07:44alienscienceMaven needs extra options if you access the internet through a proxy
07:45sid3kalienscience: no proxy, no firewall.. very strange
07:47sid3keven if I install and configure clojure without using lein, it will raise same exceptions when I try to use it to get dependencies of another clojure project
07:47raeksomething like this has happened to me before, but I could always solve it by removing the .m2 dir
07:47raeksid3k: you're not running lein as root, right?
07:47sid3kI removed it for many times
07:48raekreally strange
07:48LauJensensid3k: Perhaps you could try to install the super-pom dependency manually and retry
07:50sid3kBTW, I removed maven2 and ant packages from the system
07:51sid3kbut still lein launches maven anyhow
07:51raekwhat does "which mvn" return?
07:51sid3knothing
07:52alienscienceI thought Leiningen needed Maven to be installed?
07:52sid3kand debian offers to install lots of dependencies including openjdk if I try to install maven2 and ant
07:52sid3kalienscience: yeah, and I removed maven2
07:52sid3kbut still it can launch mvn
07:53bobo_locate mvn tell you anything usefull?
07:54raekas for the jvm, you can select which to use with "update-java-alternatives"
07:54joegalloLeiningen bundles the maven classes that it needs, they're inside leiningen-standalone.jar.
07:54joegalloIt doesn't need the maven executable.
07:54LauJensensid3k: You're on openjdk ?
07:55sid3kLauJensen: nope, it's not installed
07:55LauJensenok
07:55LauJensenDid you try installing super pom manually ?
07:56sid3knot yet, I don't know what it is
07:57LauJensenThen read the error dump from lein. It shows that it cannot get 2 dependencies for you, one is clojure and the other is super-pom, then shows you how to install them manually instead
07:58sid3kI've updated java alternatives and installed both ant and maven thing
07:58raekwhich program is not doing what it should? I mean, one should not normally have to do these things manually..
07:58sid3kno difference about problem
07:59sid3kraek: http://gist.github.com/553205
07:59raekyes, but is this a bug in leiningen or in maven?
08:00sid3kno idea
08:00sparievsid3k: can you download clojure jar from repo manually - wget http://build.clojure.org/releases/org/clojure/clojure/1.2.0/clojure-1.2.0.jar ?
08:01raek(this was an open question to everyone in #clojure)
08:01sid3karright :)
08:01naeuHow do I extract more useful information from a situation that generates an error message like this: java.lang.RuntimeException: java.lang.NullPointerException (NO_SOURCE_FILE:0)
08:02sid3kspariev: I'll try to install manually but after installation, lein continues to raise same problems
08:02raeknaeu: which editor/IDE?
08:02sparievhm, very strange
08:02naeuraek: emacs
08:02sparievno network problems, then
08:02raekthe original exception is wrapped as the cause of the RuntimeException
08:03naeualthought that particular cut and paste was from a lein repl session
08:03naeuraek: so how do I get to it to take a look?
08:04raeknaeu: you should be able to type 1 in the exception buffer that pops up
08:04naeuok, but if I'm on the terminal, there's no way to access it?
08:04raekor click the line that begins with [CAUSE1] under "Restarts"
08:05raekthe exception is stored in *e
08:05naeuraek: ahh, nice
08:05raekI think there is something in contrib for looking at stacktraces
08:05naeuraek: great, I'll take a look
08:05naeuthanks very much for your help
08:06raek(.printStackTrace *e) might do what you are looking for
08:06raekif you use slime, that will print in the swank terminal
08:07raeknot in the *slime-repl clojure* buffer
08:07naeuperfect. Yep, I normally use slime.
09:03jcromartieis there any kind of idiomatic approach to a data type with history?
09:04jcromartiefor instance, I'm working on a financial system, and I have invoices that I want to track
09:04jcromartieand I'd like to deal with them in terms of a sequence of changes
09:04jcromartiebasically a sequence of maps
09:06jcromartiemaybe this is where deftype comes in
09:06raekdo you need a new jvm type for it?
09:06jcromartieno
09:06jcromartieor a protocol for history
09:06pdkdo you mean the data type would be persistent or it'd store the differential between pre/post-change versions within itself
09:06pdkall of clojure's core data structures are immutable and persistent out of the box
09:07jcromartieright
09:07jcromartieI just mean I want to explicitly keep the history of the object
09:07jcromartiemaybe this is where protocols and records make sense
09:08pdkaside from refs/agents/atoms/vars the functions that work on a clojure data structure return new versions of those objects with the changes applied
09:08raekI think that could be done with plain old maps, vectors, lists and refs
09:08pdkso you could take the return value of a function that modifies an object and store it in any other structure you want
09:09pdkso if you wanted to maintain a linear history of the object
09:09jcromartieI understand Clojure's persistent data structures
09:09pdkyou could just append the newest version of it to a list as needed
09:10jcromartieyeah
09:10raekclojure's persistent data structures will share structure
09:10jcromartieyes
09:11jcromartieuntil you serialize and read them back in
09:11jcromartiethen you just have a big list
09:11jcromartiewhich is another tricky spot
09:11raekthen you might want to store them as deltas
09:11jcromartieright
09:11raekand build the maps from them by using assoc, etc
09:11pdkthats why hes trying to accomplish :p
09:13jcromartiealthough that might be more useful for serialization than runtime use
09:13jcromartiealthough it would be trivial to create a seq of values from the deltas
09:13jcromartiehmm
09:13pdkwould you be looking for storing the history of objects in terms of "x versions back" or "x amount of time back"
09:14raekI think it could be a good idea too separate the internal representation and the serialization representation
09:15jcromartiepdk: not really
09:15aliensciencejcromartie: If you don't minding reading scheme the following Chapter might be of interest to you
09:15aliensciencehttp://mitpress.mit.edu/sicp/full-text/book/book-Z-H-24.html
09:15jcromartiepdk: I just think it makes more sense to store these objects as the sequence of states
09:15jcromartiebecause we deal with lots of state changes
09:16aliensciencejcromartie: The section 'A functional-programming view of time' shows a bank account example
09:16jcromartieamount changed, approved by Jim, approved by Bob, put on hold by Sue, taken off of hold by Jim
09:16jcromartienice
09:16jcromartieI love what I've read of SICP but I never got this far :)
09:16jcromartietime to put it on my reader
09:17pdkdoes sicp have any more substantial example uses of closures/macros than you tend to see in introductory books
09:17pdklike beyond the counter example or quicksort with macros
09:18aliensciencepdk: No mention of macros. Some very cool use of higher order functions though.
09:18jcromartieit is the user's temporal existence that imposes state on the system... deep stuff
09:19pdkand that's why the machines want to rise against us
09:20pdkso they wont have to be coded in c
09:27jcromartiehttps://gist.github.com/f94f54d3801be0d7939a
09:27jcromartieb stands for bill :P
09:33jcromartiethe interesting thing is that the set of functions that will operate on this data will probably need to look at the whole history and not just the current map
09:33jcromartiethat's kind of messy, I think
09:37aliensciencejcromartie: why do the functions need to look at the history?
09:38jcromartiebecause certain attributes of an invoice are determined by history
09:38jcromartielike, how many days did it spend in a certain state
09:38jcromartieor when things happened
09:38jcromartieor the set of people that have operated on it
09:38jcromartieet.c
09:38jcromartieetc.
09:41fliebel(offtopic: anyone experience with how long it takes scribd to generate a html version of a document?)
09:43jcromartiehmm, destructuring makes this really easy
09:43jcromartie(defn do-something [[current & rest :as history]] ...)
09:45BahmanHi all!
09:46fliebelhi
09:46LauJensenlein question: How do I configure the classpath for custom tasks ?
09:51alienscienceLauJensen: I don't fully understand your question but I don't think you can change the classpath
09:52alienscienceIf you need something on the classpath its a dependency (as I understand it)
09:52LauJensenBut since its already a dependency of the project Im compiling, whats the problem?
10:18limux1972what's the realy meaning for the dorun of force side-effect?
10:19limux1972the api doc said that dorun used to force side-effect
10:21@chousercompare:
10:21@chouser,(let [a (map prn (range 5))] a :hi)
10:21clojurebot:hi
10:21@chouser,(let [a (map prn (range 5))] (dorun a) :hi)
10:21clojurebot:hi
10:21clojurebot0 1 2 3 4
10:22@chouserdorun forced the side effect of printing the values of a
10:22limux1972i see a blog that
10:23limux1972(def x (for [x (range 1 5)] (do (println i) i)))
10:23limux1972(dorun x)
10:23limux1972(dorun x)
10:23limux1972first it will print 1 2 3 4
10:23limux1972second it print nil
10:24raekyes, after the lazy sequence has been realized, it won't be recalculated
10:24limux1972i see
10:25limux1972i know it won't be recalulated
10:25raekand print always return nil
10:25raekeven in the first case
10:25limux1972then the side effect won't be appeared
10:28limux1972originally i understanding dorun and doall, but since i see that "dorun used to force side-effect", i were sightly confused
10:30raekhrm, sorry. (dorun x) returns nil because dorun always returns nil
10:30limux1972yes
10:31limux1972what i say is the second dorun not print 1 2 3 4
10:31limux1972the first print 1 2 3 4 and nil
10:34jlf`can anyone here comment on the maturity/stability of clj-record?
10:34limux1972as my understanding of "dorun used to force side-effect", it should also print 1 2 3 4 and nil when it eval second time exactly as the first
10:36raeka lazy sequence can only be forced once, that's the way they work
10:37edbondhow to enable/use clj-stacktrace in slime?
10:37raekif you want to delay some code, and be able to make it run multiple times, just use an ordinary function
10:37limux1972because x is a lazy seq and it already evaled, so at second time nothing happened except return it's vaule nil in this case
10:38neotykGuys how do I use (c.t/do-template [a] (defn a ..)) to also generate documentation?
10:38limux1972thanks, raek
10:38limux1972what's an ordinary function?
10:38raeka function :)
10:39raekthere's nothing special called "ordinary function"
10:40raek(defn x [] (doseq [i (range 1 5)] (println i)))
10:40raek(x)
10:40raek(x)
10:40jlf`technomancy|away: `lein new' also omits the final newline in .gitignore , so commands like 'echo newly-ignored-file >>.gitignore' weld two entries together
10:40raekor using dorun and map: (defn x [] (dorun (map println (range 1 5))))
10:43limux1972what's difference between your x and mine?
10:44raekmy x is a function, your x is a sequence
10:44limux1972lazy sequence
10:44raek(defn foo [args] body) is the same as (def foo (fn [args] body))
10:45edbond,(.?. "foo" .toUpperCase (.substring 1))
10:45clojurebotjava.lang.Exception: Unable to resolve symbol: .toUpperCase in this context
10:46raek,.?.
10:46clojurebotjava.lang.Exception: Unable to resolve symbol: .?. in this context
10:47limux1972a bit of clearness by you explanation
10:56slyrus,(.getRawOffset (java.util.TimeZone/getDefault))
10:56clojurebot-28800000
10:57raek,(/ -28800000 3600)
10:57clojurebot-8000
10:57raek->(/ (.getRawOffset (java.util.TimeZone/getDefault)) 3600)
10:57sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: ()
10:57limux1972bye, raek
11:03LauJensen$mail Raynes Whitelist: (/ (.getRawOffset (java.util.TimeZone/getDefault)) 3600)
11:03sexpbotMessage saved.
11:04akhudekit would be nice if clojure.walk supported record types when doing replacements
11:05akhudekI've hacked up a poor mans version of the library to do this
11:06raek17:05 [freenode] [ctcp(sexpbot)] TIME
11:06raek17:05 [freenode] CTCP TIME reply from sexpbot: Fri Aug 27 17:14:01 CEST 2010
11:06raek=> +2000
11:10fliebelhey
11:11akhudekhi fliebel
11:19slyruswhy is the http-agent contrib deprecated?
11:22slyrusor, to put it another way, if I'm used to using drakma in CL-land, where should I start in clojure-ville?
11:31dnolenslyrus: I use clj-apache-http and like it quite a bit.
11:49slyrusI guess I need to get over the clojure-all-the-way down instinct
11:50slyrusis there a reason you use that instead of clj-http?
11:51ssiderishello
11:51ssiderisI'm trying to make a lazy-seq of prime numbers
11:51ssiderisi've come up with this
11:51ssiderishttp://pastebin.ca/1926919
11:52ssiderisbut for bit values of top it runs out of stack
11:52ssideriscan anyone explain why?
11:54@chouseryes
11:54ssiderisbit=big
11:54pdktry making it (lazy-seq (cons (first xs) (euler ...
11:54chouserbut it's a bit tricky to describe
11:55pdkinstead of (cons (first xs) (lazy-seq (euler ...
11:55chouserthe problem is that 'remove' is lazy
11:56chouserthe lazy-seq returned by 'remove' is passed into euler again, and another 'remove' wrapped around it, and so on
11:56chouserso you end up with something logically like (remove f (remove f (remove f ...)))
11:57ssiderisah very deeply nested removes
11:57ssiderisso what would be a better way to write this?
11:58chouserthen when you force one of those, each remove has to force the next one down, each calling a function, adding to the stack...
11:58edbondhow to walk over map and apply func to vals?
12:00mefestoedbond: doall
12:00chouserssideris: that algorithm essentially iterates over 2 through n to determine if n is a prime or not
12:01ssiderischouser: i wasn't trying to write a test of whether n is a primer or not, I actually wanted the full sequence
12:01chouserssideris: so you could do that more explicitly
12:01chouserssideris: I understand, but what you've got there is doing the same work as (filter is-prime? (range 2 top))
12:02ssiderisagreed...
12:02chouserssideris: so if refactor to that, I doubt you'll have any problem writing 'is-prime?' that doesn't blow the stack.
12:03chouserhowever, it's also not very efficient. You can spend a lot of time working out efficient algorithms to produce lazy seqs of primes
12:03chouserthere's even a paper on the topic
12:03edbondmefesto: looks like doall doesnt what I need, I meant hash-map
12:03ssiderischouser: I could maybe memoize my is-prime?
12:04chouser,(let [m {:a 1, :b 2, :c 3}] (zipmap (keys m) (map inc (vals m)))
12:04clojurebotEOF while reading
12:04chouser,(let [m {:a 1, :b 2, :c 3}] (zipmap (keys m) (map inc (vals m))))
12:04clojurebot{:c 4, :b 3, :a 2}
12:05edbondchouser: cool, thanks
12:05chouser,(into {} (fn [[k v]] [(name k) (* v v)]) {:a 1, :b 2, :c 3})
12:05clojurebotjava.lang.IllegalArgumentException: Wrong number of args (3) passed to: core$into
12:05chousersheesh
12:05chouser,(into {} (map (fn [[k v]] [(name k) (* v v)]) {:a 1, :b 2, :c 3}))
12:05clojurebot{"a" 1, "b" 4, "c" 9}
12:05chouseredbond: take your pick. there are other ways too.
12:06pdkyknow i never looked into it enough to see what sort of cases -> and into are useful for
12:06pdk(doc into)
12:06clojurebot"([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
12:06chouserinto is very important. you need it in your toolbox.
12:06pdkyou could say...
12:06chouser(into toolbox 'into)
12:06pdki need to put it
12:06pdkGOD DAMN IT you stole my thunder
12:07chouser:-( sorry
12:07dnolenslyrus: I looked at the various options and clj-apache-http seemed the most comprehensive as well as being built upon something solid and well-tested. the other Clojure http libs are more minimal but that also means less malleable.
12:07pdkhm
12:07slyrusok, thanks dnolen
12:07pdkare there any blog posts or such outlining the cases where you'd want to use -> and into
12:07dnolenslyrus: it's also maintained by a Common Lisper :)
12:07ssiderisdnolen: no pressure, but did you get the chance to push native-deps 1.0.3?
12:08dnolenssideris: I could not push to clojars last night I don't know what's up.
12:08ssiderisah ok... your fans are waiting eagerly :-D
12:08dnolenssiderris: just clone the repo and run lein install inside of it.
12:08ssiderisyeah, I think i'll do that :-)
12:08dnolenssideris: sigh I know, the clojars issue is frustrating, hopefully it will suddenly start working.
12:11ssideriserm, I'm feeling a bit stupid for asking this, but where is the repo for native-deps?
12:11ssiderisok found it
12:11ssiderissorry
12:16ssiderisdnolen: hm, I get Exception in thread "main" java.lang.IllegalAccessError: make-dependency does not exist (native_deps.clj:1)
12:16ssideris(i'm on windows if that makes any difference)
12:17dnolenssideris: are you on lein 1.3.0 }
12:17dnolen?
12:19ssiderisi think i am...
12:20ssideris$ lein.bat version
12:20ssiderisLeiningen nil on Java 1.6.0_17 Java HotSpot(TM) Client VM
12:20ssiderishaha
12:20ssiderisgreat
12:20dnolenssideris: you might want to run lein upgrade
12:21ssideristhat's not available on windows...
12:21ssiderisbut it seems that lein.bat mentions 1.3.0
12:21ssiderisand it's pointing to leiningen-1.3.0-standalone.jar
12:21fliebelOh, Im starting to love leiningen for its clarity and reliability.
12:23ssiderisso I think I have the right thing...
12:25dnolenssideris: hmm ... I tested it so it should work (not on Windows). make-dependency seems to indicate that you're not on the right version of lein.
12:26ssiderisok, i'll investigate further....
12:28ssiderisdnolen: you're right, it was my fault... sorry!
12:29dnolenssideris: cool, good to hear
12:30ssideriswoohooo, at last running penumbra/pong :-)
12:31fliebelssideris: what's that?
12:31dnolenssideris: awesome!
12:31ssiderispenumbra is a wrapper for opengl
12:31dnolenand a very good one at that
12:31ssiderisand it includes a few examples
12:31RaynesI need to try that.
12:32RaynesI've never done OpenGL before.
12:32fliebelSo you could write games and stuff using penumbra?
12:32ssiderisdnolen, Raynes: my idea is to learn a bit about opengl using the repl... it should make it much easier/fun because of the interactive nature of the process
12:33RaynesIndeed.
12:33dnolenAsteroids is like > 400 lines of code in Penumbra
12:33dnolenoops < 400
12:33fliebelssideris: Assuming you can modify the thing after you have started it?
12:33dnolenssideris: yeah that's one of the great features about penumbra, be able to change to the running code on the fly.
12:33dnolenfliebel: you can
12:33ssiderispong is 130 lines and tha includes some "A.I."
12:34fliebeldnolen: Great! Most of the time this kind of things are of the setup-and-run kind.
12:35dnolenfliebel: the entire world is actually passed around to the core fns, so it's possible to modify the game state on the fly as well as modifying fns and whatnot.
12:35ssiderishave you guys heard of the livecoding scene? people doing graphics and/or music by coding live in front of an audience...
12:35dnolenssideris: yes. the other cool Clojure live-coding project is overtone
12:35dnolena wrapper around SuperCollider
12:35ssiderisdnolen: yeah I saw that... but I'm more of a visual guy
12:36ssiderisalthough overtone seems to include a graphical repl (which I haven't tried yet)
12:36dnolenssideris: you can work with it entirely from emacs, but they are working on a fairly fancy ui as well.
12:37dnolenemacs or whatever.
12:37ssiderisfancy in what way
12:38dnolenssideris: envelope manipulation via penumbra view, integrated text editor, integrated repl
12:39ssiderissounds like a fantastic way to show off in a livecoding event :-)
12:41dnolenssideris: I started porting the nehe tutorials a while ago, http://github.com/swannodette/clj-nehe to penumbra
12:42ssiderisoooh nice!
12:43ssiderisalthough nehe has a slightly dubious reputation
12:43ssiderisbecause of his coding styl
12:43ssiderisstyle
12:43ssiderisstill, very useful, thanks!
12:43jcromartiessideris: how about this...
12:44jcromartie,(iterate #(.nextProbablePrime %) (bigint 1))
12:44jcromartieclojurebot: (iterate #(.nextProbablePrime %) (bigint 1))
12:44clojurebotExecution Timed Out
12:44clojurebotprogramming clojure is http://www.pragprog.com/titles/shcloj/programming-clojure
12:44jcromartieoops
12:44jcromartie,(take 20 (iterate #(.nextProbablePrime %) (bigint 1)))
12:44clojurebot(1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67)
12:44jcromartiethere you go
12:46raekooh, new version of Joy of Clojure
12:46ssiderishehe, nice, didn't know about this, but my question was more about learning clojure and less about using the java standard lib to work around the problem
12:47dnolenraek: so who is the secret foreward written by? :)
12:48jcromartie:)
12:48jcromartiessideris: sometimes the best way to do something in Clojure is to use the Java method
12:48jcromartiebut I understand
12:49jcromartiefor instance there was this blog on doing bit counts (population) of integers
12:49jcromartiehttp://metaljoe.wordpress.com/2010/08/12/bit-counts-in-python-erlang-and-clojure/
12:49raekdnolen: the pdf does not contain any foreword
12:49jcromartiethe best clojure version is (.bitCount (bigint n))
12:49dnolenraek: argh!
12:51fliebelHuh? what is this? nextProbablePrime Especially the probable part...
12:53ssiderisjcromartie: yeah, that's probably the "best" in production code, but for educational purposes I need to know how to make lazy seqs without blowing the stack
12:54jcromartieyeah :) did you figure it out?
12:54jcromartiefliebel: Returns the first integer greater than this BigInteger that is probably prime. The probability that the number returned by this method is composite does not exceed 2-100. This method will never skip over a prime when searching: if it returns p, there is no prime q such that this < q < p.
12:54jcromartiethat's (Math/pow 2 -100)
12:55jcromartieso it's very primey
12:55jcromartie:)
12:55ssiderisjcromartie: nope, got distracted by the fact that I got penumbra working!
12:55jcromartiehah awesome, sounds like you're having fun
12:56jcromartielazy-seq is important to understand, but it's also good to be able to use the abstractions like iterate and repeatedly, etc.
12:56fliebelIs there any page explaining all the different ways of loading modules? There is a whole bunch of them, and they even work different when used in the ns declaration.
12:56fliebelI mean: load, use, require...
12:56ssiderisfliebel: afaik you should only use them with ns
12:57fliebels/load/import/
12:57fliebelssideris: Still, I'm screwing up the syntax for them every time.
12:58raekssideris: this is an example I tend to show pretty much anyone who's learning lazy sequences. I guess you aldready know the basics, so maybe this is totally superflous. but anyway, here it is: http://gist.github.com/480608
12:58ssiderishow about this: http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Using_the_.28ns.29_macro
12:58raekfliebel: this covers the basics: http://clojure.org/libs
12:58fliebelssideris: And how about the non-ns veriants for on the repl?
12:59ssiderisfliebel: i think you can still use ns in the repl with (ns user ...
12:59raekalso, all those forms except ns are functions and thus requires you to quote their arguments
12:59mrBlissfliebel: drop the : and add a quote
12:59mrBlissfliebel: (ns .. (:use [..])) -> (use '[..])
12:59raekmrBliss sums it up very well... :)
13:00raekalso, don't use ns to switch namespace, use in-ns for that
13:00raek(if you want to play around in a certain namespace with the repl)
13:00ssiderisraek: oh
13:00fliebelmrBliss: (:use clojure.contrib.lazy-seqs)) -> (use clojure.contrib.lazy-seqs) = java.lang.ClassNotFoundException
13:01mrBlissyou forgot the quote
13:02fliebelmrBliss: Nice… a class literal? or what would that be?
13:02raekexactly
13:02jcromartieI think the confusion comes from the fact that the ns macro uses unquoted symbols
13:02jcromartieand uses keywords for functions where they are usually symbols
13:02fliebeljcromartie: Yea… not so nice, combined with several different import statements.
13:03jcromartiethey have different uses
13:03jcromartieinclude loads Java packages
13:03jcromartieor classes
13:03jcromartierather
13:03raekdon't forget the empty prefix list! a very common mistake
13:03jcromartierequire just loads a clojure lib
13:03jcromartieempty prefix list?
13:04raek(import '(foo.bar)) imports nothing
13:04jcromartieah yes
13:04raek(import '(foo.bar a)) would import a from the foo.bar package
13:04jcromartieand 'use' is like require but imports everything in the current namespace
13:04raekbut the first one imports *nothing* from foo.bar and doesn't signal any errors
13:04jcromartieI wish I could do (import '(java.util *))
13:05fliebeldiner, bye
13:05jcromartiebut NO! it's like Clojure expects me to use Java classes sparingly and with precision or something!
13:06mrBlissjcromartie: it's even discouraged in Java land
13:06jcromartieyeah I know
13:06jcromartiethey expect you to know what you are doing, or something ridiculous like that
13:06jcromartiewhat if I just want to bog down the JVM with unused bytecode?
13:07jcromartiemaybe that's *exactly* what I want to do
13:07mrBlissfunny, because a clojure developer is more likely to know what he's doing than an average java developer :-)
13:08jcromartieI really want to move our company to clojure, because it basically means you can't hire idiots anymore
13:08mrBlissjcromartie: I agree :-)
13:08jcromartieas it is, we have some of the worst C# code I've seen
13:10jcromartiewe added search to our system; if you search for an item, click on it to view it in the standard page that we always use, editing the item fails for some unknown reason
13:10jcromartiebut if you reach the item's page from certain other pages, you can edit it fine
13:10jcromartieglobal (session) variables abound
13:12jcromartielike, how does that even happen? how does a programmer *do that*?
13:19ssiderisraek: the lazy-seq example with use interaction is very informative, well thought out :-)
13:20raekreally? neat... :)
13:21raekI'm glad you found it useful
13:22ssiderisit really drives the point of laziness
13:22ssideris"drives home"? is that the phrase?
13:28raekit's so lazy, it doesn't even care to make up the values itself... :)
13:28ssideriswe have truly enslaved ourselves to the machines!!! :-D
13:42fliebelHow can I make a lazy seq that returns a list of 2 items from 2 other seqs?
13:43jkkramer,(map vector [:a :b :c] [1 2 3])
13:43clojurebot([:a 1] [:b 2] [:c 3])
13:43jkkramerlike that?
13:43fliebeljkkramer: yea :)
13:45astoddardHas anyone here used the emacs org-mode, org-babel-clojure?
13:45ssiderisi've used babel but not for clojure
13:46astoddardAh, I ask because it seems the world of setting up clojure environments has moved on since org-babel-clojure was created.
13:47astoddardI was hoping someone had the mode working and could offer some pointers on configuring it.
13:47astoddardI would like to use it with something like cljr.
13:48astoddardBut its easier to modify something starting from where it is working...
13:48technomancyanyone else read that as cl junior?
13:52neotykJust submitted checkable promise proposal http://j.mp/at4dsH http://j.mp/9LgTRj WDYT?
13:56fliebelTrying to figure out when nextProbablePrime will fail :)
13:58alekxvery newbie question: a form is whatever is enclosed in paranthesis... is that correct?
13:58jcromartiefliebel: well you've got luck on your side...
13:58alekxthen having a list (values) is '(val1 v2 ... )
13:58jcromartie,(Math/pow 2 -100)
13:58clojurebot7.888609052210118E-31
13:58jcromartiethat's the probability of a non-prime being generated :)
13:59alekxso why is clojure called homoiconic as there's a difference between forms and values?
13:59fliebeljcromartie: Hmmm, so it might take a while before walking my lazy seq will stop and return the difference.
14:00fliebel(how do I interrupt a loop without killing the repl?)
14:01chouseralekx: quoting comes in during evaluation
14:01chouseralekx: the compiler consumes nothing but data structures which have a textual representation which is exactly the representation we use when we write clojure code
14:02alekxchouser: what I don't understand is that according to my probably wrong definition homoiconic would mean there's no diff between code and data and that is deduced based on the runtime context
14:02chouserthere is no diff
14:03chouser(v1 v2 v3) is a list of symbols
14:03chouser,(count (read-string "(v1 v2 v3)"))
14:03clojurebot3
14:04chousereval'ing a list doesn't just return a list, it does something else.
14:04alekxchouser: how is that different from say a = [1, 2, 3]?
14:04raekthis could be of interest: http://stackoverflow.com/questions/2877371/definition-of-lisp-form
14:04chouseralekx: what data structure is that?
14:04alekxthere's something subtle I'm missing
14:05alekxstring string list
14:05alekxraek: to me?
14:06chouseralekx: so what's the function like 'read' that consumes that text and returns string string list?
14:06alekxprobably my confusion comes from the fact that in my brain there's something saying: all list/clojure reads is lists
14:06alekxfirst is lisp*
14:06alekxbut then there are different kind of lists
14:07chouserno lisp reads only lists
14:07raekalekx: yes, regarding the odd word "form", but maybe that was already clear
14:07alekxraek: I'll read it as I'm not sure it is clear
14:07chousereven simple lisps can read at least lists and symbols, and most can also read other literals -- string, numbers, etc.
14:08alekxI mean... right now philosophically I do seem to be extremely confused
14:08chouserclojure can also read hashmaps, vectors, sets, etc.
14:08alekxchouser: very correct
14:08alekxso what exactly makes it homoiconic?
14:08raekin lisps, you are basically writing the AST directly
14:08chouseralekx: that the syntax of the language is built out of those things
14:09alekxbut all syntaxes are build out of this things
14:09alekxbuilt* these*
14:09raekclojure evaluation is not defined in terms of text strings, but in terms of nested data structures
14:09raekits like if the java compiler could read code from nested ArrayLists
14:09alekxI mean ... java has symbols, numbers, etc... so what's the difference?
14:10raekyou cannot do macros in java
14:10alekxraek: not sure I follow you
14:10raekmacros take code and return code
14:10alekx"java compiler would read code from nested ArrayLists"
14:10raekand the code can be processed as ordinary data structures
14:10mefestoalekx: if you generate code in java you are creating a string that is parsed and compiled
14:10mefestoalekx: in clojure you create data structures
14:11alekxit reads code from nested functions/etc
14:11fliebelMuhahahah! My first actual Clojure in months: http://gist.github.com/553870 I want to get started with the real work. Anyone seen defn? That script runs nearly forever by the way.
14:12alekxI think I'll have to pull out one of my old lisp books and re-read the intro parts
14:12alekxseems like my brain got old and tired and is missing subtle things :(
14:13alekxmefesto: that's true
14:13mefestoalekx: in java you don't have direct access to the representation of the code
14:13alekxso if I'm writing an AST program that would make it homoiconic
14:13alekxbecause I can create "structures" that will be later interpretted?
14:14alekxmefesto: how do you have it in clojure? are you referring to macros?
14:14raekif you make a programming language whose AST is build out of the data structures of the language, then it is homoiconic
14:14raek*built
14:15alekxhmmm... there might be a little light at the end of the tunnel
14:15raekin most non homoiconic languages, the AST is just a compiler internal thing
14:15mefestoalekx: yeah in macros you can manipulate the forms as simple data structures that represent expressions
14:15alekxso, I have a PL that natively supports some data structures
14:15raekin lisps, it's basically what you program in
14:15alekxif I write the AST to work only with these data structures then I get homoiconic
14:16alekxraek: is that what you are saying?
14:16raekyes
14:16alekxhas it been proved that it is impossible to right such a thing for Java for example?
14:16alekxI mean the current compiler definitely doesn't do that
14:17alekxbut is there proof that it cannot be done? (theoretically)
14:17raekI suspect it would be possible to make an alternative "syntax" for java which is build on java collections
14:17alekxbut why only collections?
14:18fliebelDoes anyone knows why nextProbablePrime is probable?
14:18alekxyou said data structures
14:18mefesto,(eval (list 'println "hello"))
14:18clojurebotDENIED
14:18mefesto:-\
14:18alekxa "keyword" can be an atom and so a data structure
14:18raekah, well any data structure written in java would do, I guess
14:18raekah
14:19raekyou need atoms too, of course...
14:19raeksorry for being unclear
14:19alekxI see some light... but I'll still go back to my books :D
14:19alekxor probably just ignore this theoretical part for now ... which might be a bit more productive
14:20raekso the surface syntax / textual representation is not important for a homoiconic PL
14:20alekxthis is the part that tends to make sense to me
14:20raekthe compiler or evaluator does not care about which format the code was stored in
14:20somniumDylan is an example of a language with syntax and macros
14:20alekxit is about how the program is represented by the interpretter/compiler
14:21raekyes
14:21alekxsomnium: not familiar w/ Dylan
14:21somniumI think some recent ones too, Boo and Nemerle
14:21technomancyfactor too, I think
14:21mefestoIoke
14:21somniumstill not as easy as lisp macros, but pretty expressive
14:21KirinDaveLisp macros are not easy.
14:21KirinDaveThe raw defmacro is actually the hardest way to do it.
14:22KirinDaveEsp if you want real error handling in your syntax generator. Which is sorta necessary when your macros reach a certain level of complexity.
14:22technomancybasically every language whose author is well-educated and decides to make a clean break from the algol family.
14:23KirinDaveI really need to see if I can sit down and copy PLT scheme's MBE.
14:23KirinDaveI really like that system, mostly because it gives automatic error handling for a lot of common cases.
14:23somniumscheme syntax-rules style macros are very easy
14:23KirinDaveRight.
14:23KirinDaveSometimes you need to write LOOP, then Defmacro is what you want.
14:24KirinDaveBut for example, Enlive's macro system would be vastly better if it had more error handling.
14:24KirinDaveAnd MBE would make writing enlive's syntax stuff trivial.
14:24raekmy gf jokingly when I mentioned homoiconic languages: "I think that most programming languages are indeed homosexual... they were made by men for men..."
14:25KirinDavedang
14:27nollidji've got a quick question about leiningen: is there a flag i can pass to it which says "don't try to look for updates to stuff online"?
14:30fliebelWhat is the simples way to print the classpath?
14:31mrBlissfliebel: if you're using leiningen: $ lein classpath
14:31fliebelmrBliss: Not lein this time, just the repl
14:31mrBlissfliebel: (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
14:32fliebelwtf, contrib just dissapeard!
14:32mrBlissfliebel: (. System (getProperty "java.class.path"))
14:33fliebelJust a moment ago, I wrote a script that utilized contrib, and how it freaks out and contrib is off the cp!
14:36fliebelmrBliss: http://gist.github.com/553920
14:37mrBlissfliebel: strange
14:37raeknollidj: it seems like mvn has a -o option (for offline), but I don't know how to make leiningen use it
14:38mrBlissfliebel: and running clj in the previous dir fixes it?
14:38clojurebotwith java6(jdk1.6) CLASSPATH can contain a "*" so /jar/dir/* will suck in all the jars in the /jar/dir directory, this also works with swank-clojure-extra-classpaths in emacs, alternatively you can use this shell snippet: find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"
14:38fliebelmrBliss: Yea...
14:39mrBlissfliebel: what's in your clj script?
14:41raeknollidj: I have also seen this: mvn dependency:go-offline
14:41fliebelmrBliss: http://gist.github.com/553920 9second file)
14:43raekI find it simpler to use cljr for one-off repl sessions (when I don't want to create a project) and leiningen for everything else
14:43mrBlissMe too
14:45mrBlissfliebel: it would be easier for ;-) and you (especially when you want to update or install some extra dependencies) to use cljr (supports swank)
14:45mrBlissfliebel: for got "me" before the smiley
14:46fliebelwhat is cljr?
14:46mrBlissfliebel: lein without the projects
14:46fliebelok
14:46mrBlissfliebel: with easy dependency management adding
14:46mrBlisss/adding/http://github.com/liebke/cljr/
14:46nollidjraek: yeah, i knew maven had an argument for it
14:46nollidjthanks
14:46raekbasically, "get me a repl where I can use all libraries I have installed"
14:47mrBlissfliebel: I'll help you if you encounter a problem
14:48fliebelokay, I'll have a look
14:50nollidjdoesn't seem like lein does, though
15:00technomancynollidj: nothing yet, would love to see a patch for it or at least an issue
15:10nollidjtechnomancy: thanks for the answer. i might look into the code, but i'm stuck on 1.2 because of issues with native-deps and penumbra, so any patch would be based off an older branch
15:11nollidji'll make an issue, though
15:14nollidji guess it's really two issues: 1) if dependencies are present but lein can't connect to the internet, it doesn't fail gracefully. 2) there's no offline mode which lets you specify not to look online at all
15:14nollidjwould you want two different issues in the github tracker?
15:15technomancysure, thanks
15:16dnolenman, a lot more people use native-deps than I thought :(
15:17dnolenwouldn't know it from my 8 watchers on github tho
15:17dnolenanybody else having trouble pushing to clojars today? yesterday?
15:31somniumanyone with admin access to clojars? Ive been wanting to add people to a group but seem to have forgotten my login info and ato seems to be mia :/
15:32technomancysomnium: ato is working on migrating to a new server where he won't be the only admin
15:32technomancybut ... it hasn't happened yet.
15:32nollidjdnolen: if it helps, you might want to look at how many people use penumbra. that's what i use native-deps for
15:34ssiderisyeah, penumbra seems to be the main use case right now :-)
15:44ninjuddtechnomancy: thanks for accepting my cake shebang highlighting patch to clojure-mode
16:04technomancysure; thing
16:04technomancyfeels good to have my patch backlog clear again. =)
16:06ninjuddtechnomancy: i noticed that highlighting/indenting doesn't work in clojure-mode for deftype/defprotocol/proxy/etc. is there some option i need to set to enable it?
16:08ninjuddor is that not supported yet?
16:09raekhighlighting should work, I think
16:10raekindenting works in the latest commits if you set the clojure-mode-use-backtracking-indent variable to t
16:14raekI made and pushed patches for this about a month ago
16:15raekoh, you are a contributor of clojure-mode too, I see...
16:15ninjuddraek: barely
16:16ninjuddraek: that fixed the indenting. thanks!
16:17raekI saw your pull request, but I thought it would better if technomancy would decide about it
16:17ninjuddhehe, yeah
16:17ninjuddhmm... still looks like highlighting is wrong, but i may have a different idea of what is "right"
16:18raekall the def* forms should have a special color for the name
16:18raekand docstrings should have another color too
16:18raek(not protocol method docstrings so far, I think)
16:18ninjuddseems like the function names in a deftype should be the same color and with standard (defn ...) calls
16:19ninjudds/and/as/
16:19raekhadn't thought about it in that way, but it makes sense
16:20ninjuddraek: does backtracking-indent support highlighting too?
16:21raekI have no idea :)
16:21ninjuddmaybe it should be called back-tracking-context...
16:21raekit is some experimental code that technomanchy inherited from the previous maintainer
16:22ninjuddwell, i'll submit a patch if i can figure out how to do it without too much trouble
16:23raekfor me the name of a def is yellow
16:23mefestodidn't the "Contrib Libraries" link on clojure.org used to point to the clojure-contrib docs and not it's github readme?
16:23ninjuddyeah, me too
16:24raekdo you want "method" in (deftype [] Foo (method ...)) to be yellow too?
16:24ninjuddyeah. that seems right to me
16:37technomancyI haven't actually used defrecord yet
16:37technomancyso I am fully reliant on contributors to get this right. =)
16:43ninjuddlooks like it is pretty complicated to do multi-line highlighting...
16:44ninjuddit would likely mean the entire deftype or defprotocol would have to be rehighlighted when it changes. which may be too slow
18:29hiredman,(=)
18:29clojurebotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$-EQ-
18:30hiredman,(= 1)
18:30clojurebottrue
18:34seangroveHey all, wondering how I actually use server-socket
18:34seangroveThe link on the library page here: http://clojure.org/libraries#Clojure%20Libraries-Category:%20xml-clojure.contrib.server-socket.clj points to http://github.com/richhickey/clojure-contrib/ ... so I think it's in clojure.contrib
18:34seangrove... but I don't see it anywhere :P
18:37seangroveAh, nevermind
18:37qbghttp://www.reddit.com/r/programming/
18:37seangroveHad a typo in my :use statement
18:37mrBlissseangrove: http://clojure.github.com/clojure-contrib/server-socket-api.html
18:37qbgErr, http://clojure.github.com/clojure-contrib/server-socket-api.htmcl
18:37seangroveHeh, thanks mrBliss, and you too qbg
18:39seangroveIs there a generally favored testing lib in clojure?
18:39hiredmanclojure.test?
18:39clojurebotclojure is cheating
18:40seangroveLooks good enough to start out with :)
18:45seangroveI'm moving over from the scheme world, and intereste to build up a few throw-away libraries as a way to get used to clojure
18:46seangroveI'd like to implement a quick twitter client from the socket level up - but not sure where I should look for clojure to provide the functionality, and where to rely on java interop
18:49wwmorganseangrove: java.net.Socket provides socket functionality. Is that what you're looking for?
19:14dnolenfinally native-deps 1.0.3 pushed
19:15ssideriswoohoo!
19:15ssideris:-)
19:15ssideristhanks
19:15ssiderisbtw, in your nehe ports, (:use [penumbra opengl geometry] ... doesn't work for me
19:15ssiderisit works fine if I leave the geometry part out
19:16dnolenssideris: penumbra changed, I need to make a 0.6.0 tag
19:16ssiderisah, ok you know about this
19:16ssiderisi guessed it was something like that, thought to let you know
19:17dnolenssideris: oh yeah, I created a 0.6.0 branch
19:18dnolenjust: git checkout 0.6.0
19:18dnolenssideris: ^
19:20ssideristhanks
19:21ssiderisbtw, this is completely off-topic, but it's so cool I have to share: http://devour.com/video/racer/
19:37darrenaustinHey folks, is there a way to read input from the repl's standard in from my own code?
19:45hiredman*in*
19:54darrenaustinI tried to just use either read or read-line from the REPL, but I just get EOF exceptions or nil.
19:54darrenaustinI am using swank to talk to the repl. I don't know if that makes any difference.
20:03ihodesdarrenaustin: text you enter into the REPL is read by the fn read, which parses the strings into Clojure forms, which are then passed to eval. if that gives you a better idea of what's going on.
20:03hiredmanyeah
20:03hiredmanswank is funky about threads
20:03hiredmanit can mess with *in*
20:05danlarkinmake sure to vocally blame technomancy
20:08ssiderisI was reading that swank has problems with swing too (persumably because of threads)
20:10slyrusyou sure it isn't swing that has problems with swank?
20:10slyruslike swing stuff wanting to be run off of the initial thread?
20:12slyrusdoes swank-clojure support fd-handler SWANK:*COMMUNICATION-STYLE*?
20:44ihodesif you want to run a Swing app from the repl (i've been doing it a lot the past few months for testing…) just make sure you call it with SwingUtilities/invokeLater
20:45seangrove(str symbol) returns ":symbol" - how would I get it to return just "symbol" ?
20:45seangroveWell, (str :symbol)
20:46seangrovethis works, but probably isn't quite right: ;; Post with clj-apache-http...
20:46seangrove(http/post "http://twitter.com/statuses/update.json&quot;
20:46seangrove :query (merge credentials
20:46seangrove {:status "posting from #clojure with #oauth"})
20:46seangrovehaha
20:46seangroveSorry
20:46ihodes,(name :k)
20:46clojurebot"k"
20:46seangroveThanks ihodes
20:46ihodesno problem
20:46seangroveI had (str-join "" (rest (str :symbol)))
20:47hiredman:symbol is not a symbol
20:47ihodesit's a keyword seangrove
20:48ihodeswhich is a glorified string
20:48seangroveAh, sorry
20:48ihodeswhich has some nice attributes
20:48ihodesno need to be sorry!
20:48seangrove'symbol ?
20:48wwmorgan'symbol is a symbol
20:48seangroveHeh, got it
20:48ihodeswell, not quite, right? ' is a symbol
20:49ihodesand so is symbol
20:49wwmorgan,[(class 'symbol) (class symbol)]
20:49clojurebot[clojure.lang.Symbol clojure.core$symbol]
20:49ihodesyeah true just check in my repl
20:50fsmunozihodes: I'm doing swing stuff, cold you perhaps explain the invokeLater comment above?
20:50seangroveThanks guys, appreciate it
20:50fsmunozI'm not using the contrib stuff for now, still getting a hold of it first without any macros.
20:51ihodesfsmunoz: sure thing. it calls the swing app in its own thread, the EDT (event dispatch thread), which is where swing needs to run to run properly, basically
20:52ssiderisfsmunoz: you pass a runnable object to invokeLater
20:52fsmunozihodes: thanks. Wasn't there something called "do-swing" that did something similar?
20:52ssiderisand it makes sure it's invoked in the EDT
20:53ihodesfsmunoz: i'm not sure! if so, that wouldn've been nice. i wrote my own little macro instead to wrap my main swing fn
20:53fsmunozihodes: yeah,I think I saw that one in the contrib section. Probably something most people end up doing.
20:53fsmunozI still haven't though
20:54fsmunozssideris: something like (invokeLater (mytest)), instead of (mytest) - in which mytest returns a JFrame?
20:54fsmunozI'll read the docs instead of pestering you though
20:55ssiderisfsmunoz: hm, not exaclty... in java at least, *any* changes to GUI objects have to be performed in the EDT
20:55ssiderisso if you add data to tables
20:55fsmunozouch
20:55ssiderischange the strings in textboxes etc
20:55ssiderisnot sure what facilities clojure has for making this easier
20:56fsmunozssideris: I see.
20:56fsmunozPerhaps this: http://richhickey.github.com/clojure-contrib/swing-utils-api.html#clojure.contrib.swing-utils/do-swing
20:56fsmunozI think it is meant to wrap any swing code.
20:57ssiderisfsmunoz: yes, it sounds like it does exactly what i described
20:57ssideristhe equivalent java code is *much* more verbose
20:57fsmunozI can imagine
20:57ihodesyeah that's essentially my macro there
20:58ihodesfsmunoz: check out stuartsierra's series on swing in clojure
20:58ihodeshttp://stuartsierra.com/2010/01/06/heating-up-clojure-swing
20:58fsmunozOh, right, I've read that
20:58ihodesthat should help
20:58fsmunozihodes: it did (and does)
20:58ssiderisfsmunoz: I also liked this: http://blog.licenser.net/2010/05/11/the-ease-of-guis
20:59fsmunozI'm perhaps spreading a bit to thin, as it were, since I'm learning Clojure, new to functional programming, don't really know Java or Swing.
20:59ihodesnah, you should be okay.
20:59ihodeswhat kind of stuff are you trying to do?
20:59fsmunozWhich makes it all an exercise in searching. But in a nice way
21:00fsmunozihodes: oh, hobbyist stuff, experiments, etc. The final goal is theoretically to make a small game I have in mind, purely for personal entertainment
21:00fsmunozihodes: but at least I'm getting results, which is nice and motivating.
21:01ihodesi'd recommend trying out the examples stuart has in his posts, and using the macros he supplies. then you can expand, and look into the J-classes, like JTextField, JLabel etc, and add them into your projects. look into refs and add-watch, so you can create a responsive and manageable GUI with sort-of state
21:01ssiderisihodes: do you know what the documentation means when it says that add-watch is "subject to change"?
21:01fsmunozPlus, I've found that using the JVM has some hidden beneficts I hadn't thought about, like being able to put my experiments in an applet or via webstart for friends to see. Rather nice.
21:02dnolenfsmunoz: what do you language do you normally code in?
21:02ssideriswrite once erm... run anywhere!
21:02ihodesyou can also make things easier on yourself by wrapping some common things, like (swing-button "The Name" true) and (set-text c) etc
21:02ihodesssideris: yes? what do you mean?
21:02fsmunozdnolen: Common Lisp, mostly
21:03fsmunozdnolen: but never GUI stuff, in any event
21:03ssiderisihodes: have you heard what the plan is? will the interface change, or will it be removed as a feature or what
21:03fsmunozOh, and some Objective-C, that made the Java documentation much easier to swallow
21:03dnolenfsmunoz: CL, then not *totally* new to fp :)
21:03ihodesssideris: i have no idea! i hope its not going anywhere, as i've used it extensively in the app i wrote this summer for the lab i was interning at
21:03fsmunozdnolen: no, true.
21:03ihodesit was very useful
21:04ssiderisyeah, i can imagine... it must be very valuable for swing programming too
21:04fsmunozdnolen: I meant it mostly regarding the imutable data structures, while in CL I would make "pure" functions I would still let* variables, including changing them, etc.
21:05ihodesit really was. if i'd had the time, i probably could've made the swing program look almost functional. though the EDT would've been a bit difficult to manage, i guess.
21:08ssiderisfsmunoz: another common pattern in swing is that you'd like to run something in a new thread and then have the gui do something when this background job finishes (like display a message). For this, you can use SwingWorker
21:08ssideris(not sure what the idiomatic clojure is for those cases)
21:09ihodesyou could treat it like a future
21:11fsmunozssideris: I still haven't reached that stage, but I will shortly. Thanks for the pointer, will investigate SwingWorker. IIRC in Objective.C I do something involving -detachingNewThreadSelector and notifications. Mayve something similar happens in Swing - or mayve it's completely different.
21:12slyruscan one :use multiple packages :as the same name, getting the union of the packages symbols?
21:13hiredmanI sure hope not
21:13ihodesslyrus: you cannot
21:14ihodesthough if you really wanted to, you could make that happen with your own macro and the ns family of functions
21:14ihodesi *think*
21:16slyrushiredman: why not? It's equivalent to :use'ing multiple packages, but just putting them behind some sort of alias to the packages
21:17slyrusI'm still struggling with the best way to export my libraries API after refactoring things into multiple files. my core.clj has the protocols and their methods, but it isn't until the implementation defrecords get defined that their "constructors" (e.g. make-foo) get defined. I'd like to "export" those from the core ns, but I'm not quite sure how/if to do that
21:21tomojwhat do you mean "export"?
21:28slyrusI have things in get defined in foo/moose and foo/bar that I would like to be made available to other folks by use'ing foo/core
21:28slyruss/things in/things that/
21:29tomojI don't think there's any good way to do that
21:29tomojcompojure used to use an immigrate thingy but it turned out to be evil
21:29ihodestomoj: slyrus: haskell makes that easy, but it also makes it easy to pollute your namespace
21:29slyrusI guess the first question is "is that a good thing to want to do?"
21:30slyrusright, and CL's package system lets you do this too
21:30ihodesslyrus: i don't think so: it's gnerally better to say EXACTLY what you're getting, when you "use" something
21:30ihodesand for the people using your API, it might be surprising to get things from other namespaces when they just want to ue X namespace
21:30ihodesuse*
21:30slyrusI'd rather say EXACTLY what the provider of foo/core wants me to use and not have to know what that actually is
21:31tomojaren't you the provider of foo.core?
21:31slyrusyes
21:31ihodesyeah, i'm confused now
21:31tomojso just tell people to use foo.mouse and foo.bar instead of telling them to use foo.core...?
21:31ihodescould you describe a situation where this might be problematic? tomoj: that's what i'm thinking
21:32tomojhttp://groups.google.com/group/compojure/browse_thread/thread/400aac94e536e633
21:32slyrusif folks just :use the packages, it's really not a problem. If the require :as ... the packages, it's still not _really_ a problem, it's just a little bit of an inconvience
21:32tomojoh, I see
21:32slyrusthe specific case is that i used to have make-atom and make-molecule, e.g. in chemiclj/core
21:33slyrusthen I refactored the tree, s.t. now one has to do atom/make-atom and molecule/make-atom
21:33slyrusmolecule/make-molecule, I mean
21:33tomojright, shucks
21:33slyrusI'd rather have both of these available as chem/make-atom and chem/make-molecule
21:34ihodesi suppose you could 1) alias the functions you want in core 2) :use xxx :only the things you want 3) implement something like what Vagif suggested at the end of the linked thread
21:34ihodes(would aliasing them work?)
21:34dnolenslyrus: I think the thing to do then is the to import the symbols by hand into a namespace you want people to actually use. penumbra does this.
21:35dnolenyour project may have many namespaces, many which are not intended for public consumption.
21:35slyrusihodes: I was just thinking about trying to ... turn defalias on its head
21:35slyrusdnolen: ok, thanks, I'll look at how penumbra does it.
21:35slyruslike I was starting to say earlier, there are two questions, 1) is this reasonable and 2) if so, how to do it?
21:35slyrusI'm still on question 1 :)
21:36ssiderishow about defn-
21:36ihodesfor your use case, it sounds reasonable, as long as you make sure the user can keep his namespace clean!
21:36ssideris,(doc defn-)
21:36clojurebot"([name & decls]); same as defn, yielding non-public def"
21:37ihodesssideris: i think defn- would defeat the purpose here: he's trying to make these functions available, not hide them
21:37ssiderissorry, I misread the above
21:37ihodesno problem! it's a bit confusing
21:39tomojaleph might have an example
21:39ihodesslyrus: would something like: (use-groups :particles) work, where it would intern the functions from their respective namespaces, depending on the group name. groups could be user-defined, and/or defined in your core.clj. you could also allow qualified uses e.g. (use-groups [:particles :as ps])
21:40tomojaleph.import has a macro that aleph.core uses to pull a bunch of stuff in
21:40hiredmaneww
21:40slyrusihodes: I'm not sure I follow that.
21:41slyrus (in-ns 'chemiclj.core) (d/defalias make-atom chemiclj.atom/make-atom)
21:41slyrusat the end of atom.clj seems to do what I want
21:41slyrusso maybe I just use defalias to "export" the "foreign" symbols I want from core and everyone's happy
21:41slyrusnobody needs to know that make-atom isn't in chemiclj/core
21:42dnolentomoj: no, it imports one definition, it doesn't pull a bunch of things in.
21:42tomojeh?
21:42dnolentomoj: http://github.com/ztellman/aleph/blob/master/src/aleph/import.clj
21:42tomojyes, and aleph.core calls it 16 times
21:43tomoj25 actually
21:43dnolentomoj: yes, but he's has to write out by hand which fns he's going to bring in, and it carries over the important info.
21:43hiredmanugh
21:43tomojindeed
21:43hiredmanthat is nasty
21:44hiredmanwhat is the point of that?
21:44ihodeshiredman: he explains above
21:44tomojso that you can (:require [aleph.core :as aleph])
21:44dnolenhiredman: so consumers don't have list a bunch of namespaces, while his stuff stays organized.
21:44hiredmanhe's calling eval inside a macro
21:44hiredmandnolen: well he failed
21:44tomojand not (:require [[aleph [core :as acore] [foo :as afoo] [bar :as abar]]]) or whatever
21:44slyrusinstead of (:require [aleph.foo :as aleph] [aleph.bar :as aleph])
21:44slyrusbah
21:45slyrus:)
21:45dnolenhiredman: yeah but eval is at compile time. big deal, I use that all the time.
21:45hiredmandnolen: just because you do it, doesn't make it good
21:45somnium'definline calls eval from a macro, and its in (ahem) clojure.core
21:46dnolenhiredman: just because you think it's bad, doesn't make it bad ;)
21:46slyrusthe obvious solution is that multiple :as foo's just accumulate the symbols in the packages their requiring :)
21:46ihodeshttp://gist.github.com/554539 just something like that?
21:46hiredmandnolen: yeah, it does
21:46slyruss/their/they're/
21:46dnolenhaha,
21:46tomojslyrus: then you have to go dig through all those namespaces to find the var
21:46tomojM-. will probably still work fine though :)
21:46ihodesslyrus: i think that's a doable macro.
21:46hiredman(:use [aleph.foo :only [what-i-need]] [aleph.bar :only [other-thing-i-need]])
21:47slyrushiredman: please stop presenting reasonable, logical solutions
21:47ihodeshiredman: we've done those. this is now bat country.
21:48dnolenhiredman: sure but that can get tedious, depending. my ring imports are always crazy. aleph provides a friendly interface, imho.
21:48slyruswhat dnolen said
21:48tomojmaybe new ns will help someday
21:49slyrusfor the time being, the in-ns core / defalias combo seems to do what I want
21:49ihodesslyrus: you can do your "union of all the ns's under the :as name" idea, but the way I'm envisioning it is a hellish nightmare. though, i could be useful for sure.
21:49hiredmandnolen: a friendly interface is by no means evidence of correctness, it is only evidence of a friendly interface
21:50dnolenhiredman: well what do you consider the problem? what is incorrect?
21:50tomojexactly, and the question is, can we have a correct friendly interface?
21:50slyrusfriendliness is easier to judge than correctness
21:50slyrusand probably much easier to achieve
21:50dnolena package macro would be nice, something that is official for collecting defns into a namespace for friendly interfacing.
21:51slyrusanyway, thanks y'all for helping me think this through
21:51hiredmandnolen: that is very possible without any migration of stuff across namespaces
21:52dnolenhiredman: I still haven't heard a good reason why migration is bad? I'm ok with taking your side, if you have some case where it causes trouble.
21:53hiredmanI don't have one at hand because I don't use code that does it, but I could manufacture a few
21:54dnolenhiredman: I'd like see something :)
21:54hiredmanok
21:54ihodeshiredman: me too, i'm rather curious
21:55tomojthere's the binding problem in the thread above
21:59hiredmanactually, I think tomoj is right, that thread explains it pretty well
22:00hiredmanclojure's compiler, the binding behaviour of Vars, etc all assume that def'ed vars (and the functions they hold) live where they live
22:02dnolenhireman: huh, I suppose that's why the ztellman only doesn't import fn
22:02dnolenrebinding a fn seems wack
22:02dnolenonly uses import-fn I mean
22:02hiredmanztellman?
22:03dnolenaleph author
22:04hiredmanthere are a lot of neet projects that are the authors first (and only) foray into clojure, they are rarely examples of good style
22:05slyrus(defmacro export [sym] `(d/defalias ~(symbol (name `~sym)) ~sym))
22:06dnolenheh, aleph is not a first foray, ztellman does penumbra, that's one of the larger clojure projects I've seen. his code is usually delightfully idiomatic.
22:06dnolenbut sure, migration of defs is something to be used sparingly or not all, I agree.
22:09somniumprobably the source of clojurebot is one of the few examples of good style in the wild
22:09ihodessomnium: could you link to that, please?
22:10ihodesah, nevermind
22:10hiredmansomnium: I doubt that
22:14slyrushrm... "Can't create defs outside of current ns"
22:14slyrusthat seems a little harsh
22:14slyrusI should be able to create a def wherever I want
22:14somniumslyrus: you can always intern
22:16slyrussomnium: that seems to work! thanks :)
22:16slyrusdunno why you can intern but not defn then.
22:17slyrusthat seems like a rather petty restriction
22:17hiredmandef is compile time, intern is runtime
22:17ihodesclojurebot: def alias
22:17somniumI tried to do something like ml-functors, like (mk-red-black-tree :as my-rbt my-comparator), then (my-rbt/empty) (my-rbt/create ...), but it was hard
22:17ihodes,(doc alias)
22:17clojurebot"([alias namespace-sym]); Add an alias in the current namespace to another namespace. Arguments are two symbols: the alias to be used, and the symbolic name of the target namespace. Use :as in the ns macro in preference to calling this directly."
22:18somniumwas able to do (create ns blah) (intern ...), then alias it, but something didn't work right
22:20slyrusok, thanks hiredman
22:23slyrus(defmacro defn* [fn-name body] `(intern 'chemiclj.core '~fn-name ~body))
22:24slyrusoh, wait, I forget to put the (fn ... in the macro.
22:25slyrus(defmacro defn* [fn-name args body] `(intern 'chemiclj.core '~fn-name (fn ~args ~body)))
22:28slyrusback to the drawing board
22:31wei_how can I check where my logs are being written to?
22:34slyrushiredman: still, compile or runtime, I don't see why Compiler.java can't just intern the sym in v.ns instead of currentNS
22:34slyrusthat's what intern does, might as well give folks the convenience of defn if you're going to give them the rope of intern
22:35slyrusor am I missing something about how ns'es work?
22:37somniumslyrus: you can do variable arity with `fn'
22:38ihodesi'm curious if anyone knows the reasoning behind not allowing multiple dispatch with reifty, defrecord etc? i'm assuming for performance reasons, as performance was a motivating factor behind reify?
22:38slyrussomnium: oh, right
22:41tomojihodes: reify makes java stuff, java stuff doesn't do multiple dispatch
22:44tomojand performance, yeah
22:44tomojhotspot is good at single dispatch
22:46slyrussomnium: but I don't get access to the name of the function I'm defining inside of fn :(
22:47wei_hello
22:47wei_i have a quick question: I'm using the functions in clojure.contrib.logging, but I don't know where the output is going?
22:48somnium,((fn dizzy ([] (dizzy))))
22:48clojurebotjava.lang.StackOverflowError
22:48wwmorgan,((fn this [x] (if (zero? x) 0 (this (dec x)))) 3) ; <- slyrus
22:48clojurebot0
22:49slyrusoh, ok, thanks
22:51slyrusI'll probably burn in hell for this, but this seems to work:
22:52slyrus(defmacro defn* [fn-name & rest] `(intern 'chemiclj.core '~fn-name (fn ~fn-name ~@rest)))
22:53somniumI don't think the almighty weighs the irc's opinion of clojure style quite that heavily
22:53somnium(but you never know ...)
22:54ihodestomoj: java can be made to do multiple-dispatchy stuff…but the performance reasons are a good enough argument for me–i was just wondering if there were other reasons. i could see it being useful
22:55tomojmaking reified classes do multiple dispatch would be a terrible hack
22:55tomojrich tries to avoid those :)
22:56ihodesit would totally be awful haha
22:56ihodesfair enough.
22:56ihodesif it was totally needed and performance wasn't important, it wouldn't be too bad to implement it in Clojure, i think
22:56ihodesbut i could do that myself if necesary
23:09tomojisn't it already, in multimethods? guess you'd have your reify functions call some multimethod on their args?
23:18ihodestomoj: didn't even think of that; that'd work haha