#clojure logs

2010-03-29

00:27Raynesalexyk: Sure. Reify, deftype, defprotocol, and most of all, optional keyword argument destructuring. :D
00:27alexykRaynes: I need a writeup for the dumb ones!
00:27alexykor, for those who like to read!
00:47brian__test
00:49brian__hi, is it possible to use a regex as a predicate to the "filter" function? I want to filter out things from text?
00:51joshua-choiWhat you should use is (partial re-matches your-re).
00:51brian__ok
00:51brian__thnks
00:52tomojre-matches has always seemed a bit strange t ome
00:52tomojoh, re-find is what I was looking for
00:54brian__ok, well, ill take notice of your comment, thanks
00:57tomoje.g.
00:57tomoj,(let [matcher (re-matcher #"foo (\S+)" "foo bar foo baz")] (take-while identity (repeatedly #(re-find matcher))))
00:57clojurebot(["foo bar" "bar"] ["foo baz" "baz"])
00:57tomojhow do we do that more simply?
00:57tomojoh, re-seq
00:57tomojof course
00:57noidicemerick, thanks again for the maven post! I converted my hobby project to maven last weekend and now it's simpler, has more features and the dependencies are handled better :)
00:58tomoj,(re-seq #"foo (\S+)" "foo bar foo baz")
00:58clojurebot(["foo bar" "bar"] ["foo baz" "baz"])
00:58cemericknoidi: nice, glad to hear it. Feel free to share the good news. ;-)
00:58cemerickThe polyglot maven stuff appears to be moving along at a faster clip again, which is even better news IMO.
00:59cemerickI might cut a quick demo of that shortly as well, just to provide a complete perspective on where things stand.
00:59tomojcemerick: awesome :)
01:01noidicemerick, it's a bit early to start singing maven's praises, but if a few months go by without problems I'll be a complete convert :)
01:01cemericknoidi: sure, that's why I included the ;-)
01:01cemerick:-D
01:01noidi:P
01:03noidiI think what scares people about maven is that it has a lot of new concepts, like the lifecycle, the local and remote repositories etc.
01:04noidibut they're actually very useful concepts once you learn them
01:07noidiactually make/etc. vs. maven reminds me a lot of word vs LaTeX... the latter looks incredibly dense and unflexible at first, but when you take the time to learn it, it automates a lot of tedious manual work
01:07tomojhmm
01:07tomojthat comparison is enough to make me try to learn this maven stuff
01:07tomojI became quite angry when a professor forced me to submit .doc files
01:10cemericknoidi: nice analogy
01:35AntonyBlakeyping
01:58talioswb tomoj
01:58tomojthanks
01:58tomojfinally got wifi after suspend/resume working
01:58tomoj:)
01:59taliosI only just got home/rejoined anyway :)
01:59tomojmy wifi has been flapping
01:59tomojand I habitually M-x freenode so I end up flapping on freenode too :/
02:00taliosdarn emacs user :)
02:01taliosI could never really get into emacs, I like it more than vi ho
02:01taliostho
02:05tomojwell, there's hope for you yet
02:05tomoj:P
02:05taliosYou can pry IntelliJ from my cold dead decaying remains.
02:07tomojI don't think emacs can replace intellij for java
02:08tomojI haven't tried any of the non-emacs clojure tools either :/
02:09AntonyBlakeyNetbeans/Encloure/PolyglotMaven is turning out to be quite cool.
02:09tomojt
02:09tomojoops
02:09tomojreally need to disable mouse focusing...
02:10tomojI plan to make some screencasts about emacs, with some about clojure
02:10tomojI wonder if anyone has made any for the other tools..
02:10AntonyBlakeyYes they have
02:11taliostomoj: did you see cemerick's recent video on maven/netbeans with clojure/
02:11talios?
02:11AntonyBlakeyA good emacs + clojure screencast would be one focusing on typical workflows, with supporting docs for the key binding
02:33tomojtalios: hadn't seen that
02:34tomojAntonyBlakey: I'd intended to focus on typical workflows, basically covering the stuff that I use alot
02:34tomojgood idea re the supporting docs
02:34tomojespecially important with emacs... :(
02:35AntonyBlakeyIt would be good to see a walkthrough of a typical dev session involving multiple source files, xref-ing, building, debugging, packaging etc. So that the view can place themselves in your position and see all the things they need to do to develop in that environment.
02:36AntonyBlakeys/view/viewer/
02:37AntonyBlakeyIf the supporting docs were a form an annotated transcript then it would be a great multi-modal learning resource
02:37AntonyBlakeys/form an/form of/
02:37tomojhadn't thought of that
02:38tomojcould make a blog-post style writeup mirroring the screencast
02:38tomojthen also provide a reference of all important functions/bindings
02:38taliosI wonder if there's too much focus on the REPL?
02:38taliosnot that the REPL is bad
02:38AntonyBlakeyMake the whole thing available as a PDF to go with the video. Easy to print and cogitate on offline, and to have next to you while trying your own stuff.
02:39tomojjust have to learn how to make pretty pdfs
02:39AntonyBlakeyIMO there is too much focus on the REPL as a development environment. Not all programming is exploratory.
02:39taliostomoj: I have clojure code for that ;-)
02:40tomojI'd probably try it in org-mode
02:40taliostomoj: http://www.talios.com/connecting_the_clouds__the_internet_in_new_zealand_in_pdf.htm <- using clojure + flying saucer to make PDFs
02:40taliostomoj: that post + pdf actually got me a 'cease and desist' letter from Internet NZ ;-)
02:41taliosthe actual PDF code is the last 4 lines. which just takes an HTML file with CSS and PDfs it
02:41tomojnice
02:42taliosmmm, must rewrite it to generate an .epub version of that book :)
02:42talioswe use flyingsaucer at work for all our report generation
02:44AntonyBlakeyI've used http://www.princexml.com/ commercially, which gives great results
02:44talioswe looked at prince, then looked at the price, then looked elsewhere :)
02:45AntonyBlakeyIt's written in Mercury, which appeals.
02:45AntonyBlakeyYes, it's expensive for commercial use, although I got a good deal 'cos I was working on an Aid project.
02:45taliosI don't think I know of Mercury? It rings a bell
02:45AntonyBlakeyIt's free for non-com
02:46tomojhttp://en.wikipedia.org/wiki/Mercury_(programming_language) interesting
02:46tomojI'd never heard of it either
02:46AntonyBlakeyMercury is like prolog, but with arg typing that makes it efficient
02:48taliosinteresting
02:49taliosbbl - making myself some dinner, getting hungry here ;)
03:03LauJensenMorning all
03:04RaynesI think I've heard of most languages at this point.
03:04RaynesMorning Lau.
03:50wooby'lein test' doesn't seem to be referring a certain macro from my tested code, anyone run into something like that before?
03:50woobythings work nicely in clojure-test-mode
03:58tomojwooby: you mean you get an error because the macro is missing?
03:59woobytomoj, right
04:00tomojhmm
04:00woobyi tried to 'lein compile' manually beforehand, didn't seem to make a difference
04:01woobyhttp://github.com/alandipert/clj-utils/blob/master/test/org/dipert/test/utils.clj is the code if you'd care to sanity check
04:01woobythe mystery macro is 'with-private-vars'
04:02tomojpuzzling
04:02tomojI expected you might have to explicitly use the package that defines it
04:02tomojbut you already have :(
04:08tomojwooby: I see the same error
04:08woobytomoj, thanks for checking, i'm going to look at lein now
04:08woobytomoj, are you using a recent lein?
04:09tomojwooby: 1.1.0
04:10tomojwooby: the problem appears to be that the ns declaration in org.dipert.test.utils is bad
04:11tomoj(:use clojure.test org.dipert.utils)
04:11tomojonly wrap in a list if it's actually a prefix list
04:11tomoje.g. in the src file, (:use (clojure.contrib math)) works because that's really a prefix list
04:11woobytomoj, you rule!
04:11woobythanks
04:12tomojgoing to confirm that this happens everywhere
04:12woobysweet that fixed it
04:12tomojyeah, when I try using (clojure.test), I get an error about deftest, even when using clojure-test-mode
04:13Raynes,(seq (.split "reege..wf2rewf." "."))
04:13clojurebotnil
04:13RaynesHuh? :o
04:14tomoj,(seq (.split "reege..wf2rewf." "\\."))
04:14clojurebot("reege" "" "wf2rewf")
04:14tomojit's a regex :/
04:14RaynesScrew those nasty things. :|
04:22woobythanks again tomoj, i'm headed out
05:45talios /join #java
05:45taliosbah
06:11talios'lo miclorb
06:11miclorbtalios: ola
06:12miclorbexcellent
06:12taliosnow if only tony and richard would get their edits done I could publish this :) I think 36/37 should go out BEFORE 38 :)
06:13taliosmaybe we should care less about removing ums and ars and silence more.. be good to get a more regular publishing going again
06:13taliosnot heard you on the asylum lately either?
06:14miclorbyeah - or just go for the biggest silences
06:14miclorbyeah hasn't been one recorded for a month (aim is only one a month)
06:14miclorbmax has been travelling, lots of eclipse activity this time of year etc
06:14taliostrue. looking forward to seeing some videos out of eclipsecon
06:15miclorbtalios: my eyes still glaze over when I hear osgi, so I gather eclipsecon would be a bit boring for me
06:16talios*nod* I still think we would have been more productive if we didn't go OSGi at work, but that decision was made before I started
06:17taliosmodularisation via maven + IoC would have served us just as well I think.
06:17miclorbyeah I assume it must be important to some, but I just don't care for the details - too removed from anything I care about
06:18miclorbtalios: BTW I retiring from red hat
06:18miclorbwill still do the podcast though
06:18taliosoh? leaving drools as well, or just RH?
06:18miclorbjust RH - will still contribute, but not that actively
06:19talioscool. So what are you doing? Going anywhere hip and c00l?
06:19miclorbworkign on a startup - hopefully more will be public soon
06:19miclorbbut has made me thinkg if we would use maven or not - kind of makes sense for open source projects etc...
06:20miclorbbut otherwise - is it worth it? what worries me is hermetically sealed builds
06:20taliosyeh, do you want to waste your time on builds and arguements on builds, or get your startup - started up.
06:21miclorbyeah - I find it easier if a lib is in maven just to slap in the dependency.. and whee... that bit I like
06:21miclorbanything that does that at least is good
06:22miclorbI have this fear though, which has been validated, I go on 3 week holiday, come back, and my code, in the same statae, no longer builds
06:22miclorbdue to some dep change... just kind of unpleasant ;)
06:22talioswell, if you lock down your version numbers that doesn't happen. and plugin versions have been locked by maven itself for awhile
06:23miclorbtrue
06:23miclorbthis was specifically with the jetty plugin (used for testing etc) about 6 months ago
06:23miclorbhad to go change my pom
06:23taliostho Richard pointed out that grails had a spring dep on [2.0,) - which pulled in 3.x and broke everything :)
06:23miclorbjust annoyed me
06:23miclorbhahahahah
06:23miclorbyeah version ranges scare me
06:24miclorbthe best build system to me is one someone else deals with ;)
06:27taliosso what sort of things are you doing with clojure? I didn't realise you were looking at it
06:28miclorbnothing at the moment, just curious
06:30talioscurious is a good place to be. One thing I love about clojure is its bringing some enjoyment back into coding small things again, in a way thats non-worky
06:30talioser, $worky even
06:30Licenser_hmm what is a good way to persistantly store data in clojure?
06:32_atoLicenser_: if it's small I just 'prn' stuff to a file and 'read' it back in. (well to be safer, prn to file.new, flush, then rename file.new to file)
06:32taliosLicenser_: as in database? sql? I've seen a few people using neo4j and db4o, theres some nice clojure wrappers for them
06:33Licenser_I want something that does not require any extra effort, prn'ing stuff seems as a way but how fast/secure is it?
06:33miclorbtalios: my only problem with clojure is that is painfully practical for me. With scheme I can keep it fun and at arms length ;)
06:33Licenser_I hoped that fleetdb works as an integrated database (without the need of a server) but it does not seem to do that
06:39_atoif you're worried about security (eg random people can mess with the stored file) then I guess spitting JSON out would be safer
06:39_atoalthough prn/read aren't bad you just need to remember to turn off the eval reader macro when reading
06:40Licenser_hmm eval reader macro?
06:40_ato,(read-string "#=(println \"hi\")")
06:40clojurebotjava.lang.RuntimeException: java.lang.Exception: EvalReader not allowed when *read-eval* is false.
06:40_atoheh
06:40_ato,(binding [*read-eval* true] (read-string "#=(println \"hi\")"))
06:40clojurebothi
06:41_ato*read-eval* normally defaults to true, I wonder if thats changed in git master or something
06:41Licenser_,(binding [*read-eval* true] (read-string "#=(def x 1)"))
06:41clojurebotjava.lang.RuntimeException: java.lang.Exception: Can't resolve def
06:42Licenser_ouch
06:42Licenser_ouch ouch
06:42Chousuke:P
06:42Licenser_my sandbox does not check that
06:43Licenser_,(binding [*read-eval* true] (read-string "#=(java.lang.Thread.)"))
06:43clojurebot#<Thread Thread[Thread-299,5,main]>
06:43Licenser_Ouch
06:43Licenser_clojure bot neither
06:43ChousukeI don't think it's even possible to guard against that :P
06:43Chousukeunless you can somehow make a var that doesn't support thread-local binding
06:43Licenser_Chousuke: I'll find a way
06:45_ato,(binding [*read-eval* true] (read-string "#=(.alterVarRoot #'inc (fn [x] dec) [])"))
06:45clojurebotjava.lang.RuntimeException: java.lang.Exception: Can't resolve .alterVarRoot
06:47_ato,(binding [*read-eval* true] (read-string "#=(println (.alterVarRoot #'inc (fn [x] dec) []))"))
06:47clojurebot(.alterVarRoot (var inc) (fn [x] dec) [])
06:48_atostrange
06:48Chousukeit doesn't actually evaluate things
06:49Chousuke,(binding [*read-eval* true] (read-string "#=(type foo)))
06:49clojurebotEOF while reading string
06:49Chousuke,(binding [*read-eval* true] (read-string "#=(type foo)"))
06:49clojurebotclojure.lang.Symbol
06:49_atooh right
06:49Chousuke,(binding [*read-eval* true] (read-string "#=(type (eval +))"))
06:49clojurebotclojure.lang.PersistentList
06:49Chousukeoops
06:49Chousuke,(binding [*read-eval* true] (read-string "#=(eval (type +))"))
06:49clojurebotclojure.core$_PLUS___4518
06:50_ato,(binding [*read-eval* true] (read-string "#=(eval (.alterVarRoot #'inc (fn [x] dec) []))"))
06:50clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: No matching method found: alterVarRoot for class clojure.lang.Var
06:50_ato,(binding [*read-eval* true] (read-string "#=(eval (.alterRoot #'inc (fn [x] dec) []))"))
06:50clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.ISeq
06:50_ato,(binding [*read-eval* true] (read-string "#=(eval (.alterRoot #'inc (fn [x] dec) (seqf [])))"))
06:50clojurebotjava.lang.RuntimeException: java.lang.Exception: Unable to resolve symbol: seqf in this context
06:50Chousuke:P
06:50_ato,(binding [*read-eval* true] (read-string "#=(eval (.alterRoot #'inc (fn [x] dec) (seq [])))"))
06:50clojurebot#<core$dec__4586 clojure.core$dec__4586@13a1b2>
06:50_ato,(inc 2)
06:50Chousuke,(inc 1)
06:50clojurebot3
06:50clojurebot2
06:50_atoaww
06:50_atooh right
06:50_atoinc is a bad example
06:50_atoit'll be inlined
06:51_ato,(apply inc [2])
06:51clojurebot1
06:51_atoha
06:51Chousukenow please fix it :P
06:51patrkrisdoes anyone here know which property to check to see if the JVM is started with the -server flag?
06:51_atowhats it normally bound to.. something in clojure.lang.Numbers isn't it? hmmm
06:51Licenser_ouch!
06:51tomojyou could just check the process?
06:52_atoyeah
06:52tomojunless you need to do this in a clojure program?
06:52Chousuke_ato: just (+ x 1) ought to be enough
06:52Licenser_okay thar'd not be possible with my sandbox I hope
06:52patrkristomoj: Yeah I'd like to do it from a clojure program
06:52_ato,(binding [*read-eval* true] (read-string "#=(eval (.alterRoot #'inc (fn [x] #(clojure.lang.Numbers/inc %)) (seq [])))"))
06:52clojurebot#<sandbox$eval__5403$fn__5405$fn__5407 sandbox$eval__5403$fn__5405$fn__5407@15ca0cc>
06:52_ato,(apply inc [2])
06:52clojurebot3
06:52tomoj_ato: !!
06:53tomojwhy did clojurebot let you do that?
06:53_atocause I just found a hole in its sandbox
06:53tomojthe #= read macro doesn't call eval?
06:53tomoj,(eval '(+ 2 3))
06:53clojurebotDENIED
06:54tomojI'm confused
06:54Licenser_hmm wait it should
06:54Licenser_narf
06:54Chousuketomoj: clojurebot actually checks for the symbol eval, not the string
06:54tomojplease blog this
06:54tomojoh, hmm, interesting
06:54Chousukeplease don't :P
06:54tomojblog it after it's fixed, I mean
06:54Chousukeis it worth a blog entry? :/
06:55_ato,(binding [*read-eval* true] (read-string "#=(eval (defn hiredman-should-fix-this [x] (+ x 5)))"))
06:55clojurebot#'sandbox/hiredman-should-fix-this
06:55tomojI think it leads to some deeper knowledge on the innards of clojure
06:55_ato,(hireman-should-fix-this 3)
06:55clojurebotjava.lang.Exception: Unable to resolve symbol: hireman-should-fix-this in this context
06:55Chousukeit's just a hole in clojurebot's sandbox.
06:55_ato,(hiredman-should-fix-this 3)
06:55clojurebot8
06:55_atoyeah, okay, I'll stop playing with that now
06:55tomojhehe
06:55tomojbut I still don't understand it, so I think I'm missing some background knowledge about clojure somewhere
06:56_atosimple enough to fix I guess, just add *read-eval* to the blacklist
06:56ChousukeI suppose hiredman will need to add a check for *read-eval* in the string to be read
06:56_atoyeah
06:56Chousuketomoj: #=() is normally read-time eval
06:56Chousuketomoj: *read-eval* bound to false disables that
06:56tomojright, so we would use that for printable and readable data structures?
06:56_atoyep
06:56tomojother than just the ones we've got
06:57tomojkind sucks that we can't demo that in clojurebot
06:57tomojhmm, how do datatypes fare for readably printing?
06:57Chousukewell, yes, but it's not very secure
06:57Chousukedatatypes have their own syntax
06:57Chousuke#:foo{:key val :key2 val2}
06:57tomojawesome, I need to investigate this
06:57tomojhadn't tried it yet
06:58Licenser_ah no does not work
06:58tomojcan't read it?
06:58Licenser_no I mean on my sandbox sinde you can't use bindings
06:59tomojoh
06:59tomojno bindings either?? why not?
06:59Licenser_I forgot them :(
06:59Licenser_I wonder if they are secure
06:59tomojmaybe there are some certain bindings you want to deny
06:59Licenser_also it'd not allow you to rebind *read-eval*
06:59Licenser_java.lang.SecurityException: Code did not pass sandbox guidelines: (#'clojure.core/push-thread-bindings #'clojure.core/*read-eval* #'clojure.core/read-string #'clojure.core/pop-thread-bindings)
07:00Licenser_that it what it says
07:00tomoj*print-level*
07:00tomojthough clojurebot deals with that outside the sandbox, I guess?
07:00Licenser_in the clj-sandbox you've to whitelist stuff
07:00tomojLicenser_: that's very interesting for certain kinds of applications :)
07:00Licenser_,(binding [*read-eval* true] (read-string "#=(eval (type +))"))
07:00clojurebotclojure.core$_PLUS___4518
07:01Licenser_,(binding [*read-eval* true] (read-string "#=(eval (java.lang.File. \"/tmp\"))"))
07:01clojurebotjava.lang.RuntimeException: java.lang.ClassNotFoundException: java.lang.File
07:01Licenser_,(binding [*read-eval* true] (read-string "#=(eval (java.io.File. \"/tmp\"))"))
07:01clojurebot#<File /tmp>
07:01Licenser_yuck, THAT is dangerous
07:01_ato,(java.io.File. "/tmp")
07:01clojurebot#<File /tmp>
07:01ChousukeThat's not dangerous yet
07:01tomojjava will block your reads, right?
07:01_atoyeah
07:02tomojcould you also run it in a chroot jail or something
07:02Licenser_,(java.io.File. "/etc/profile")
07:02clojurebot#<File /etc/profile>
07:02_ato,(binding [*read-eval* true] (read-string "#=(eval (.exists (java.io.File. \"/tmp\")))"))
07:02clojurebotjava.lang.RuntimeException: java.security.AccessControlException: access denied (java.io.FilePermission /tmp read)
07:02Licenser_ah good :)
07:02Licenser_hmm is /tmp is a directory, exists works on that?
07:03Chousuke(java.io.File. "foobarsdjfksdj")
07:03Chousuke,(java.io.File. "foobarsdjfksdj")
07:03clojurebot#<File foobarsdjfksdj>
07:03Licenser_,(binding [*read-eval* true] (read-string "#=(eval (.exists (java.io.File. \"/etc/profile\")))"))
07:03clojurebotjava.lang.RuntimeException: java.security.AccessControlException: access denied (java.io.FilePermission /etc/profile read)
07:03Chousukebasically, it doesn't matter to File whether the file exists or not
07:03Licenser_okay good news are you can't read them :)
07:04tomojare there people like engineyard in the jvm world?
07:04Licenser_as in they know how it works or as in they run it on solaris?
07:07_atogoogle appengine I suppose might kind of count
07:07tomojhmm, they have bad restrictions though, no?
07:07tomojI mean, you don't get as much control
07:07_atoyep
07:07tomojand limited choices
07:08tomojI imagine you point to the git repo of a clojure project and boom
07:08tomojand many options for data storage or whatever
07:12_atogoogling java servlets hosting returns a lot of results
07:12_atonever heard of any of them, so I dunno if they're any good
07:17Licenser_oh wrong channel sorry
07:17Licenser_argh
07:17Licenser_,(eval '(+ 1 1))
07:17clojurebotDENIED
07:17Licenser_ah good
07:23_ato,(@(resolve (symbol "eval")) (read-string "(def on-a-roll-tonight true)"))
07:23clojurebot#'sandbox/on-a-roll-tonight
07:23_ato,on-a-roll-tonight
07:23clojurebottrue
07:23_atoLicenser_: are you safe on that one?
07:26Licenser__ato: let me test
07:27Licenser_java.lang.SecurityException: Code did not pass sandbox guidelines: (#'clojure.core/deref #'clojure.core/resolve #'clojure.core/symbol)
07:27_atonice
07:27Licenser_while deref and symbol might want to work
07:27Licenser_resolve likely not
07:29Licenser__ato: the approach I took is entirely differnt (at least on the security model, not the code, I got a good bit from clojurebot there). I work on a 'if it is not allowed it is forbidden' base, clojurebot works with 'if it is not forbidden it is allowed'
07:31_atoaah right
07:32Licenser__ato: it's not entirely secure either, but it is quite OK)
07:34_atoah it won't even let you use symbol
07:34_atohmm tricky
07:35_atooh.. but you have read-string
07:35Licenser__ato: you can allow symbol, it will on the next version
07:35Licenser_yes just added it, not sure if it is good that I did :P
07:35Licenser_but you don't have eval
07:38Licenser__ato: if you find any hole I will gladly fix it
07:40_atofound one!
07:40_atoerr wait
07:40_atomaybe...
07:41_atokeep crashing my repl
07:41_atohehe
07:41Licenser_oi, within our outside the sandbox?
07:42_atooutside
07:43_atoI'm just trying to do the same read-eval trick but with push-thread-bindings
07:43Licenser_ah okay, protectig you against yourself will not be implemented in 0.* of clj-sandbox
07:43Licenser_ah sneaky I think I nknow where you're going
07:44Licenser_but you can't access *read-eval*
07:44_atoyeah, just realised that
07:44_atohmm
07:45_atoactually... (read-string "#'*read-eval*") works
07:45Licenser_yuck
07:45Licenser_that is sneaky
07:46Licenser_hmm hmm I wonder how to handle this
07:47Licenser__ato: can you give me the exact test case?
07:47_atooh
07:47_atono it doesn't
07:47Licenser_of cause I could forbid read-string
07:47_atocause its not evaled
07:47Licenser_great!
07:47_atohehe
07:48tomojyou don't forbid read-string, but the (read-string "#=(eval ...)") trick above won't work in your sandbox?
07:48Licenser_tomoj: the sandbox runs with *read-eval* false.
07:49Licenser_at least my newest version :P
07:49Licenser_the one I just pushed
07:50tomojoh, and you can't use binding, yeah, I get it
07:50Licenser_tomoj: you can
07:50Licenser_just can't bind *read-eval*
07:51Licenser_or any var that is prebound and not explictly allpowed
07:56tomojoh, nice
07:57tomojat what point does clojure block symbols?
07:57tomojor does it just refuse to look inside strings?
07:57Licenser_tomoj: if you want to see examples, there are by now 4 projects I know of using clj-sandbox all are linked at the github page
07:57Licenser_tomoj: after reading the data structure is examined for possible 'bad functions'
07:58Licenser_or actually examined to make sure everything in there is allowed
07:58tomojthis is in clojurebot?
07:58Licenser_tomoj: no
07:58tomojah, in clj-sandbox?
07:59tomojclojurebot has a problem clj-sandbox doesn't right?
07:59Licenser_clojurebot uses it's own sandbox, I just got many ideas from clojure bot :)
07:59tomojI see
07:59Licenser_tomoj: they use different approachs
07:59tomojI'm just wondering why clojurebot allows you to call eval when it's in a #= in a string
07:59tomojright
07:59tomojI think I understand yours
07:59tomojand it sounds great
07:59laynorhi, I just got clojure box working. I noticed that the repl hangs if I (read-line). Is there any solution for this?
07:59Licenser_clojurebot blacklists a few functions clj-sandbox (at least by default) whitlists a few functions
08:00Licenser_laynor: why would you want to read line on the repl?
08:00laynorLicenser_: because I'm new to Clojure, just learning the basics
08:00Licenser_tomoj: it does not allow it but as seen above you can rebind *read-eval* and then it allows it
08:00Licenser_ah :)
08:01_atonice job on clj-sandbox ;-)
08:01Licenser_laynor: well I think the problem is that read-linbe reads from STDIN and you can't access that from the repl
08:01Licenser__ato: thanks a lot!
08:01Licenser_Raynes did a lot of good testing killing a few evil bugs
08:02laynorLicenser_: what puzzles me is that it works flawlessly with slime/sbcl
08:02Licenser_laynor: read-lines or repl?
08:02laynorLicenser_: yeah
08:03Licenser_it is a or question, 'yeah' isn't a valid answer there :P
08:03laynoroh, i just read "on" not "or"
08:03Licenser_^^
08:03laynorlol
08:03Licenser_it's like 'do you want coke or fanta?', "YEs please."
08:04laynorso, I can (read-line) on the repl with slime/sbcl, I can't with slime/clojure, ergo must be a problem with swank-closure
08:04Licenser_laynor: sbcl is what?
08:04Licenser_some comon lisp thingy?
08:04laynorSteel Bank Common Lisp
08:04laynoryeah
08:04Licenser_I gues the reson is that the clojure repl is forwarded over TCP or at leaqst some other way
08:05Licenser_repl != repl ;)
08:07laynorI'd say it's the same for sbcl
08:07laynoruhmuhm
08:10laynorLicenser_: also, if I run (read-line) in the *inferior-lisp* buffer, it works. Problems arise only on the repl.
08:10Licenser_ah sneakyt
08:10Licenser_perhaps you can write a bug report, then again I'm not sure if slime is maintained :(
08:10laynoruhm, but it's not slime, it's swank-clojure i'd say, as the repl works flawlessly with sbcl
08:11Licenser_then that :P)_
08:11Licenser_sorry I never can keep them apart
08:11Licenser_for me it is one bug fluffy emacs thingy
08:11Licenser_*big
08:11laynorI see :) So you basically use emacs for the sake of clojure?
08:12Licenser_laynor: yes
08:12Licenser_never used it before I started with clojure
08:12laynoroh, I am a vi person
08:12Licenser_still am I guess
08:12laynorI use viper/vimpulse on emacs
08:12Licenser_hmm no clue what that is
08:13laynorso I get slime and swank and vim bindings
08:13Licenser_in the end I just want it to work :( sadly didn't found any editor that really does that
08:13laynorLicenser_: vim emulation for emacs
08:13Licenser_ah
08:13laynoryou should try it XD
08:14ChousukeI gave up viper because it didn't work so well with paredit
08:14Licenser_I fear I might get even more confused :(
08:14Licenser_I never understood this paredit thing, never got it to work, I guess I'm too stupid for emacs :P
08:14Chousukeif I used any of viper's deletion commands it would mess up the structure and throw off paredit:/
08:14laynoruhm, I don't really use paraedit, what can it do for me?
08:15Chousukeit's basically structural editing for lisp code
08:15laynorChousuke: you can di( and da( on vimpulse btw
08:15Licenser_I think it is for editing sexps
08:15_atoLicenser_: (my-sandbox "(.alterRoot #'inc (fn [str] dec) (list))")
08:15_atodoesn't get you eval, but lets you mess up builtin functions
08:15_atothat might not count as breaking it thoug
08:15Chousukeworks with non-lisp languages too.
08:15Licenser__ato: of cause it does
08:16Licenser_can you give me the code to create my-sandbox?
08:16Chousuke(though obviously not as well)
08:16_atoit's just the one from your example: (def my-sandbox (stringify-sandbox (new-sandbox)))
08:16Licenser_okay
08:16Licenser__ato: I just ask because I've had odd things already where people did strange things :P
08:16laynoruhm, I should give it a try and setup some bindings for viper ^^
08:18Licenser__ato: okay this gets tricky ^^
08:19Licenser_I should just forbid . :P
08:20_atogot eval
08:20_atobut using .
08:21Licenser_*nods*
08:21Licenser_user=> (fn-seq '(.alterRoot #'inc (fn [str] dec) (list)))
08:21Licenser_(. #'clojure.core/inc fn* #'clojure.core/str #'clojure.core/dec #'clojure.core/list)
08:21Licenser_That is how I filter stuff
08:21_ato((.get (.findInternedVar (:ns (meta #'inc)) (read-string "eval"))) '(+ 1 1))
08:21Licenser_since it can't resolve alterRoot it ignores it
08:21Licenser_this is very trucky
08:22Licenser_hrm
08:22Licenser_but cutting off . make things harder :(
08:22_ato:(
08:22Licenser_hmm tricky thing
08:22Licenser_java interop is evil
08:23_atosure is, clojure objects have too much stuff public ;-)
08:23Licenser_*nods*
08:23Licenser_I think the only way to work around this is either forbidding . or making very strage things
08:24Licenser_if you want people to use certainb java interop functions you could publish wrappers to the sandbox
08:25_atoyeah
08:25_atoprobably the best way to do it
08:26_ato'spose that works for clojurebot too
08:26_ato,((.get (.findInternedVar (:ns (meta #'inc)) (read-string "eval"))) '(+ 1 1))
08:26clojurebot2
08:26Licenser_most likely
08:26Licenser_hmm I wonder if I could override .
08:27Licenser_no can't bind it
08:27_atobut you could substitute it
08:27Licenser_*nods*
08:27Licenser_that might be a way
08:27_atowalk the entered forms and replace all . with something else
08:27Licenser_but the first fix will be remove it\
08:28SynrGwin 7
08:28Licenser__ato: yea but read would still le- no wait it won't
08:28Licenser_since you can't eval
08:28_atoyep
08:28Licenser_hmm yea that might be a good way
08:28Licenser_then agai I'd have to either white or blacklist stuff
08:28Licenser_or ... go a diferent way and allow to call stuff ON certan types
08:29Licenser_hmm that is a idea
08:29Licenser_I'll see into this
08:29Licenser_but for now I head home
08:29Licenser_see you all later!
08:30_atosee you
08:30laynorbye :)
08:31laynoruhm, (.. System out (println "asdf")) doesn't print the output on the repl, only on the *inferior-lisp* buffer
08:44raeklaynor: yes. the repl is connected to the swank server (*inferior-lisp*) with a socket
08:45raekand technically, you could have multiple repls connected to the same swank server
08:45raekslime seems to rebind clojure *out* to it's own repl buffer
08:46raekso (println "hello world") will print in the repl
08:46tomojhmm, that's interesting
08:46tomojis there support for multiple repls for one swank in other lisps?
08:46raekbut since *out* is a thread-local binding, other threads will still print in *inferior-lisp*
08:47tomojyeah
08:47tomojthat is awesome
08:47raekI have no experience with doing these sort of things in other lisps
08:48tomojoh well
08:48tomojwhat would be interesting is a way to provide a macro that causes all new threads spawned from something entered at the repl to use the repl *out* binding
08:49raekI think that's what bound-fn is for
08:49raekIIRC
08:49raek,(doc bound-fn)
08:49clojurebotExcuse me?
08:50raek"Returns a function defined by the given fntail, which will install the
08:50raeksame bindings in effect as in the thread at the time bound-fn was called.
08:50raekThis may be used to define a helper function which runs on a different
08:50raekthread, but needs the same bindings in place."
08:52tomojaha
08:52raekok, this is not a perfect match for the problem, but it is related, anyway
08:52tomojvery interesting
08:52tomojwhere is that located?
08:52raekclojure.core
08:52raekhttp://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/bound-fn
08:52tomojnever noticed it before
08:52chouserbound-fn is fairly new. 1.1 I think.
08:53raekhaven't used it myself, yet
08:53tomojbound-fn* is the real function
08:55tomojcan you optionally but unobtrusively add bound-fn's everywhere they need to go to make agents etc work with *out*?
08:57raekbound-fn would need to be added to all functions passed to the agent
08:58raekas the agent doesn't have to run the functions in the same thread
09:01zmilayour are a bit stuck in clojure if looking at http://poehali.net/attach/meri_96_4.jpg you misread the name
09:02raekhehe, true
09:02raek:)
09:16tomojraek: right, hmm
09:16Licenseraloa
09:17tomojit might be possible by thread-locally rebinding the agent fns, no?
09:17tomojwith an with-out-repl macro or something
09:32cburroughsMy recollection is that contrib 1.1.0 made it into maven central. But empirical evidence shows that this is clearly not the case. Does anyone know what the status of that is? The last message I could find on clojure-dev was by Stuart Sierra on Jan 4
09:35dnolencgrand: ping
09:35hugodcburroughs: I'm not sure about central, but you might want http://build.clojure.org/releases/
09:36cburroughshugod, yeah thanks. I'll probably just add that to the proxy list if our internal repo.
09:36cgranddnolen: pong
09:37cemerickcburroughs: yeah, that's what we do *shrug*
09:37cemerickalthough contrib really should be in central, too
09:37dnolencgrand: I've been looking at moustache :) so how do you do a redirect with moustache? Also app generates functions right? So it's easy to nest them.
09:41cgranddnolen: funny you ask since I'm planning to dust off moustache :-) yes, apps being function compose, you can "mount" an app
09:43dnolencgrand: I like the destructuring aspect of route definition in moustache, very idiomatic.
09:43cgranddnolen: there's no support for redirects, you have to send your body map with the correct :status code
09:44dnolencgrand: I see.
09:45cgrandI should add a middleware to handle relative redirections -- must check if compojure has one
09:45dnolencgrand: any specific plans you have for moustache?
09:49cburroughsNow if I swank-clojure was just in a nice repo.
09:49cgranddnolen: nothing specific except I'd like to dust it off since ring 0.2 makes moustache more useful
09:50cgranddnolen: lockstep selectors are in http://gist.github.com/335527
09:51dnolencgrand: nice :)
09:52cgrandand they are fast :-)
09:52dnolen:D
09:52tomojhmm, how did we do that before?
09:53cgranddnolen: are you planning a moustache tutorial? ;-)
09:55dnolencgrand: heh, why not? Honestly it was more about getting fed up with my dog slow WordPress setup. I'm thinking about moving stuff over to Clojure. Ring+Moustache+Enlive looks like a good combination.
09:57tomojmoustache looks interesting
09:57tomojbut is it dead?
09:57raekwhat is this moustache? a ring-based web framework similar to compojure?
09:57tomojlooks even smaller than compojure
09:57tomojperhaps something approaching compojure's features could be built out of it?
09:58hugodcburroughs: swank-clojure is in http://clojars.org/repo
09:58tomojdoes moustache benefit from the destructuring improvements?
09:58clojurebotdestructuring is http://clojure.org/special_forms#let
09:58dnolentomoj: compojure 0.4 will be pretty small. since Ring 0.2 implements many of features now.
09:58dnolenmany of its
09:58tomojcool
09:58tomojbut I like the looks of moustache
09:58tomojclojure's destructuring for routes is genious
09:58raekclojurebot: moustache?
09:58clojurebotNo entiendo
09:58tomojpure unadulterated genius
09:58tomojhttp://github.com/cgrand/moustache
09:59tomojsee also http://gist.github.com/109955 (linked there)
09:59tomojis anyone around who understands the change to destructuring?
09:59cburroughshugod I know, but clojars is very un-conventional as a maven repo.
10:00chousertomoj: I think so -- what do you want to know?
10:01raekah, moustache looks really neat!
10:01tomojchouser: umm.. can you just show something new that works?
10:01tomojI can't tell from the code what the heck it does
10:02tomojI'm wondering particularly if this opens up new routing possibilities for moustache
10:02tomojbut also just curious
10:02tomojwilling to blog about it if you get me started :)
10:02tomoj(or has someone already?)
10:02chouser,(let [f (fn [a b & {:keys [c d]}] [:my-args a b c d])] (f 1 2 :d 5))
10:02clojurebot[:my-args 1 2 nil nil]
10:02tomojmaybe I should search the logs
10:04chouser,(let [{a :a, b :b, c :c} (seq [:c 1 :b 2])] [a b c])
10:04clojurebot[nil nil nil]
10:04chouserheh. well, try those on a more recent clojure to see how they're useful. :-)
10:04tomojoh, thanks a lot
10:05tomojok, very interesting
10:06tomojthe :my-args tag was helpful, good way to illustrate things
10:07tomojso, hmm
10:07tomojis there ever a case like that in routing?
10:07tomojsomething like a PHP style /var1/value/var2/othervalue maybe
10:07tomojbut I'm not a big fan
10:08noidiis there a function that wraps its argument in a seq unless its one already?
10:08noidii.e. (ensure-seq 1) => (1), (ensure-seq [1 2 3]) => [1 2 3]
10:08chousera vector is not a seq
10:09noidiwell, a coll then :)
10:09chouserbut, probably not. rather few things in clojure core accept a collection or not and then treat them differently
10:10chousercollections are values too, so such usage would tend to be useful in more specific, rather than general, circumstances.
10:11noidiyeah, you're probably right
10:12noidiI'm writing swing code and would like to be able to say something like
10:12noidi(doto-named! widgets :foo enable, [:bar :baz] disable)
10:12noidiwhere widgets is a map
10:13tomojthat makes sense
10:13noidiand I was thinking that if there was something like ensure-coll, then I could deal with both the single names and colls of names with a doseq
10:13tomojwrite your own, I suppose
10:13tomojwould coll? be best to use?
10:14chouseractually, might be one of the few good uses of 'sequential?'
10:14tomojcoll? accepts maps as well
10:14chouser,(sequential? {:a :b})
10:14clojurebotfalse
10:14chouser,(sequential? [:a :b])
10:14clojurebottrue
10:15wooby,(sequential? #{:a :b})
10:15clojurebotfalse
10:15chouser,(sequential? (java.util.ArrayList. [:a :b]))
10:15clojurebotfalse
10:15chousereh. so maybe not. :-)
10:15tomojnoidi: are you going to release a swing clojure wrapper?
10:16cemericknoidi: this is what we use in a similar use-case, but chouser's right to note that it won't work with java collections: http://paste.lisp.org/display/97020
10:16noiditomoj, no, just getting rid of the boilerplate in my code :)
10:16bsteuberyeah, a swing wrapper would rock!
10:16tomojah
10:17tomojI kind of want a rewrite of ruby's shoes in clojure
10:17noidiand doto-named! will not be swing-specific either, since it could be used to execute any side-effecty functions on any things in maps
10:17noidiman, my abstractions became _so_ much more effecient when I bit the bullet and got rid of all encapsulation and started thinking in seqs and colls
10:18noidicemerick, thanks. I already have your let-map in my util.clj, btw. ;)
10:18tomojhow do I even build moustache?
10:18cemerickheh, good ol' let-map :-)
10:19chouseraren't they more often grown than built?
10:19cemerickthat was a little crazy
10:19chousersorry, nm.
10:20cemerickchouser: I wasn't referring your pun :-)
10:20dnolentomoj: build it? just include it in your own code as you do with any library.
10:20tomojhuh
10:20tomojjoke?
10:23fogustomoj: Chapter 9 of Joy of Clojure will be a good start for that Shoes port. ;-)
10:24tomojcool
10:24dnolenhttp://gist.github.com/347880, cgrand
10:24dnolen's moustache example updated for Ring 0.2
10:24tomojI personally want to be able to tinker with math stuff
10:24chousercemerick: heh, yeah I know.
10:24tomojbut if people could use interaction, sound, graphics, it would be awesome
10:24cp2oh cool
10:24tomojand I think java is capable
10:24ChousukeThat reminds me... when do we get more chapters? :P
10:25fogusChousuke: I wish I knew... they have been submitted are in review and should have been posted last week... but it seems chouser and I are the last to know the specifics. :-(
10:25Chousuke:/
10:26tomojthat's too bad, what is it they have to do?
10:28fogustomoj: Some highly involved process of posting them to the site. :-p
10:29tomojlame
10:29tomojautomate that shit
10:29noidiI'm glad to see that you have section about testing in "12. Clojure Will Change the Way You Program"
10:30fogusif it were in our hands you'd have updates every time we pushed to git
10:31noidinow that I've dropped the shackles of encapsulation, I've noticed that I don't feel the need to write unit tests anymore, wheras in Python I felt that TDD really helped me
10:31chouserfor more instantaneous typo feedback. :-)
10:32tomojgot rid of all encapsulation?
10:32tomojas in, just functions/values/macros, no classes/big deftypes/whatever?
10:33noidiyeah
10:33noiditomoj, I used to write almost OO code in Clojure, but it seemed that no one else did that and got along just fine, so I took the plunge and decided to give it a try
10:34tomojwhat clojure features did you use to emulate OO?
10:34noidiI'm not quite sure why, but for some reason Clojure code turns out just find with plain-old-data-objects
10:34tomoj:)
10:34noiditomoj, namespaces for "classes", treating objects as black boxes only accessed via the namespaces' functions
10:35tomojI see, and the objects are what?
10:35tomojI mean, internally
10:35noidiwhatever happened to be a natural fit, but mostly maps
10:36tomojI see
10:37noidiI thought that it was pretty nice actually, even better than writing OO code in a language with built-in support
10:39noidibut don't worry, I got over that phase now. now my code looks much more like "normal" Clojure :)
10:46raeknoidi: did this OO-like code invovle changes in state or was it persistent like clojure maps?
10:47raekbtw, when is it ideomatic to use "next"?
10:48raeklike this? (if (next some-lazy-seq) (there-is-a-rest) (no-rest))
10:49noidiraek, I tried to avoid side-effects and returned new "objects" from the "methods"
10:50Chousukeraek: that would be sensible
10:50dnolencgrand: is the following valid? http://gist.github.com/347905. Will those fns get the request map?
10:55slyphonis the difference between binding and with-bindings that one is global and one is thread-local?
10:57woobyanyone know a nice way to do something like (map :title (map :attr ...) without repetition?
10:58drewrwooby: (map (comp :title :attr) ...)
10:59raeknoidi: to me, that sounds like functional code with a lot of abstraction
10:59woobyyou are awesome, thanks drewr
11:00mattreplwooby: alternatively, (map #(-> % :attr :title) ...)
11:02woobyah yes, thanks mattrepl
11:02mattrepland there's also get-in
11:02slyphonheh
11:02slyphonwe really need a get-over-here!
11:04drewrand get-back which operates on jojo collections
11:04slyphondrewr: :D
11:04slyphonwinnar!
11:10cgranddnolen: all your *-post functions should get the request map as their only arg
11:11dnolencgrand: yeah just got it working :) moustache is _cool_.
11:12dnolencgrand: heh, ring has redirect
11:13cgranddnolen: you know that you merge your two ["new"] routes to dispatch to {:get new-post :post save-post}
11:13cgranddnolen: absolute redirect I guess
11:14dnolencgrand: yeah
11:14cgrandbtw, what did you update in the walkthrough? Only the ns form and the definition of server?
11:14dnolencgrand: yes
11:14dnolenring 0.2 support defining a server that doesn't join with the main thread.
11:15slyphonhey, what's the difference between with-bindings and binding? i looked at the code, but the subtlety escaped me
11:15tomojdnolen: how?
11:15tomojI can't figure it out
11:15dnolentomoj: http://gist.github.com/347880
11:15dnolenline 13
11:15tomojoh, ok :join false
11:16tomojhow do you start it up?
11:16tomoj(.start server) ?
11:16dnolenrun-jetty starts the server and returns it
11:16dnolenyou can stop it with (.stop server)
11:17tomojgreat
11:17tomojand this picks up changes to my-app?
11:17dnolentomoj: yeah
11:18tomojmaybe want a defonce for server?
11:21dnolentomoj: yeah that's what I did.
11:48technomancyhugod, LauJensen: hey guys
11:48technomancysorry; been offline for a while
11:48LauJensentechnomancy: Hey :)
11:48hugodtechnomancy: good morning
11:48technomancyI think swank-break is ready to merge
11:48tomojawesome
11:48LauJensenGreat !
11:49hugod:-)
11:49technomancyearlier when I tried it I was seeing some odd debug-ish (slime-rex) output in the repl buffer, but that was a while ago and I haven't been able to repro since
11:49lpetithi all
11:49LauJensenHi Laurent
11:49lpetita question to emacs users
11:50lpetitis there a paredit command which allows to wrap with parens a text selection ?
11:50technomancyhugod: and it looks like you fixed inspector hyperlinks as well; that wasn't working a while ago.
11:50technomancylpetit: if there's an active selection, pressing ( will do that
11:50technomancysame with [ and { iirc
11:50lpetitok
11:50lpetitwill the selection be lost at the end of the command ?
11:51hugodtechnomancy: yes - inspector should work fully now
11:51noidilpetit, M-( wraps the sexps on which the point is on
11:51technomancylpetit: no, it's preserved
11:51technomancylpetit: but you don't have to emulate every single detail. =)
11:54hugodtechnomancy: how about the other branches? any concerns?
11:54technomancyhugod: can you tell me a bit more about the other branches you mentioned?
11:54technomancyjinx?
11:55technomancyI haven't gotten a chance to look at them yet
11:55hugodautodoc fixes autodoc for slime head
11:55hugodcompile-file fixes compile-for-emacs in slime head
11:55technomancyoh, I was thinking that was related to Tom F's autodoc project, heh
11:56hugodexception-location does a better job of locating source code from stack trace and compile errors
11:56hugodhyperdoc links to clojure api docs
11:56technomancyawesome
11:56tomojhmm
11:57lpetitnodi, technomancy: ok, from reading the docs, I thought it was just wrapping the next form
11:57tomoj(app ["hi" & {:strs ["name" "age"]}] {:get (format "Hello %s, age %s." name age)})
11:57tomojthat look right?
11:57tomojdoesn't seem to be working
11:57lpetittechnomancy: /every single detail/ : agreed, I intend to improve it where it sucks :-p
11:57technomancyhehe
11:57technomancygood
11:57chousertomoj: try [name age] instead of string literals there
11:58tomojoh, I see
11:58lpetittechnomancy: does paredit have structural selection of text ? Or maybe it's provided outside paredit ?
11:58lpetits/have/provide/
11:59tomojI think the question is, what do you want to do with the selection?
11:59technomancyhugod: btw, you don't necessarily need to run these branches by me; review by anyone who uses and is somewhat familiar with swank is enough to get them merged to master.
11:59tomojchouser: hmm, more errors
12:00lpetittomoj: answering to me ? (too many concurrent discussions, I'm lost :-) )
12:00tomojlpetit: nope
12:00tomojlpetit: oh, yep
12:00tomojI mean, do you want to copy it?
12:00hugodtechnomancy: ok, I just discovered there's a ml for swank-clojure - I'll try and make use of it ...
12:01lpetittomoj: why answer my question with a question ? :-) I may want to wrap it with (, copy it, cut it, send it to the REPL, there are a lot of answers !
12:01tomojindeed
12:01tomojbut what I am saying is that you might not need some feature
12:01lpetittomoj: so again, my question :-)
12:01technomancyhugod: asking in here would probably get you some volunteers too
12:01tomojthree of those use cases don't need "selection" as such
12:01tomojwrap with ( - put the point before the sexp and hit M-(
12:02lpetittomoj: agree on the general case. Concerning the particular case, I'm pretty sure I need it (though you can try prove I'm wrong :-) )
12:02tomojcut - put the point before the sexp and hit C-M-k
12:02tomojsend to repl - put the point after the sexp and hit ... some key
12:02tomoj(depending on how exactly you want to send it to the repl)
12:03lpetitI don't want to put the point before the sexp, I want to discover what I want to wrap while I'm expanding to the left, to the right, or with the parent sexpr
12:03tomojI'm not sure how that makes sense
12:03tomojlike, a couple keys you can press over and over to expand the selection iteratively?
12:03lpetittomoj: First: I don't have to remember a new command for wrap with ( (I will then just hit ( ), etc.
12:04lpetittomoj: yes
12:04tomojok
12:04tomojI don't think there is anything for that
12:04tomojbut the wrapping keys aren't that hard to remember :) they're M plus whatever you want to wrap with
12:04tomojif you write something like that I'm sure people would be interested
12:04lpetittomoj: imagine you want to select 3 siblings (so not just a single form) from one point to another
12:05lpetittomoj: agreed, the particular examples were not that bad
12:05lpetits/from/and move them from/
12:05tomojC-SPC C-u 3 M-f
12:05tomojthen C-w to cut, C-y somewhere else to yank
12:05tomojs/cut/kill/
12:06lpetittomoj: wow, we don't have this in Eclipse. And I'm not sure I miss it either ;-)
12:06tomojof course you can just hit M-f multiple times instead :)
12:06tomojhehe
12:06tomojwell, maybe you have to be a bit insane
12:07lpetittomoj: I'm dead sure I'm insane, or I won't be on the clojure bandwagon :-)
12:07lpetits/won't/would'nt/
12:07tomojI meant, insane to like emacs
12:07lpetittomoj: oh :-)
12:08tomojI'm also sure I'm insane :)
12:08lpetittomoj: no, I'm quite sure it's a great environment for power users.
12:08tomojyep
12:08tomoja big investment I think, though
12:09lpetitwoops, was deconnected for a minute or two. Missed smth ?
12:09cgrandtomoj: I don't think you can make it work without modifying moustache
12:09tomojthat's what I had guessed
12:10tomojit seems to be using clojure.core/destructure
12:10tomojbut taking chouser suggestion, I get "java.lang.String cannot be cast to clojure.lang.IFn"
12:13tomoj,(let [[foo & {:strs [name age]}] ["hi" "name" "tom" "age" "22"]] (format "Hello %s, age %s." name age))
12:13clojurebot"Hello null, age null."
12:13tomojwell, yeah
12:14tomojbut, moustache must be doing something to allow literals in there
12:15tomojoh, whoops
12:16cgrandtomoj: try (app ["hi" & [& {:strs ["name" "age"]}]] {:get (format "Hello %s, age %s." name age)}) with url /hi/name/Lucy/age/23
12:16cgrandnot pretty but it should work
12:17tomojstill getting an error
12:18chouserunless you're doing something really unusual, the vector after :strs should contain symbols, not string literals
12:18tomojyes, made that change
12:18tomojstill no joy
12:19tomoj(app ["hi" & rest] {:get (str rest)}) doesn't even work
12:19cgrandchouser: true, I blindly copy-pasted
12:20tomojwhat the heck, now ["hi" name] doesn't even work
12:22tomojuhh
12:22tomojI am boggled
12:25tomojhttps://gist.github.com/c139721c1fdcda8ee34f
12:26tomojthe exception https://gist.github.com/037ed61415f0f7ce464f
12:28tomojI think I understand
12:29tomoj(app ["hi" & {:strs [name age]}] {:get ["" (format "Hello %s, age %s." name age)]})
12:30tomojneed a literal string there or the string will be called as a function
12:30chouserexception handling is so messy.
12:42tomojcgrand: thanks for leinifying
12:46cgrandtomoj: yw but I haven't been able to push it to clojars yet (it seems down)
12:46tomojno problem
12:46tomojI had already leinified myself anyway
12:54Crowb4rWhen is 1.2 being released?
12:54chouserwhen it stops changing
12:55chouseror myabe that's the other way around
13:12raekhow would you name functions for serializing/unserializing or interpreting/emitting data structures?
13:13raekas a part of a web server, I have functions to serialize and unserialize to various data formats
13:13raekI think "render" is a term that is used in some web frameworks, but what would the inverse be called?
13:14tomojhydrate?
13:14tomojI dunno
13:16raekanalyze/synthesize is a nice combo
13:16raekbut maybe too general
13:16raekfor (un-)serialization to strings I consider parse/format
13:17tomojsounds goo
13:17tomojgood
13:18dnolencgrand: are you going to push moustache to clojars?
13:22technomancyhugod: merged/pushed break to swank master
13:23technomancythanks a bunch!
13:23cgranddnolen: yeah as soon as clojars is back -- wait it is
13:23technomancyI'll try to take a look at the other branches later this week.
13:23hugodtechnomancy: yeah!
13:24technomancyof course if someone else reviews them first you're welcome to merge them without me
13:24technomancyjust be sure if you're using slime master also to check against elpa slime
13:25hugodI'll try and find time to do that - I'd rather find someone with elpa slime installed than checking elpa myself
13:26dnolentechnomancy: so does that mean swank-clojure will work with slime master again? :)
13:27technomancydnolen: maybe so... if you help hugo review his branches you can make it happen sooner. =)
13:27hugoddnolen: that requires the compile-file (and autodoc) branch
13:27technomancytbh I am not sure I know about all the details of the divergence in master that's causing breakage
13:27dnolenhugod: in your fork right? or techonmancy's ?
13:28hugodautodoc is only required if you are using slime-autodoc
13:28hugodin technomancy's
13:28hugodI should delete my fork
13:28dnolencgrand: cool. it also looks like ring 0.2 just got released.
13:30cgranddnolen: well it seems clojars still has problems so be patient
13:30dnolencgrand: oh gotcha.
13:37dnolenhugod: so how do you test your stuff? do you create an uberjar?
13:39hugoddnolen: I do a lein install locally. Maybe it would be easier if we created versions of swank-clojure in clojars for each of the branches?
13:40dnolenhugod: oh I see, never used lein install before. So that jars up the project and put's it into .m2 ? then you can add it as a dependency ?
13:43hugoddnolen: indeed - though I normally edit project.clj to give it a different name 1.2-xxx-SNAPSHOT
13:45hugodlein jar should work too - and then manually copy the jar into your project
13:46dnolenhugod: cool, I'll definitely give the compile-files branch a spin later today.
13:47tomojif you have lein jar might as well use lein install, eh?
13:48hugoddepends whether you want the modified jar in your local .m2, where it will be picked up by all your projects
13:48tomojoh, good point
13:48tomojguess you could tag your branch name in the version, but meh
13:49hugodI do locally, but commiting that would make merging the branch more painful
13:51tomojah yeah
13:54tomojhmm, gotta install jruby to get polyglot-maven working?
14:00stuartsierratomoj: probably a development thing
14:05tomojstuartsierra: as in, this problem should go away?
14:05tomojI can't get pmaven-cli to build because pmaven-jruby fails
14:05tomojpmaven-scala might as well, dunno
14:08stuartsierratomoj: I dunno, you'd have to ask talios.
14:12tomojok, thanks
14:18TakeVIs there a way to get keyboard input, without using the java libraries?
14:21The-KennyTakeV: (read-line)?
14:21The-Kenny,(read-line)
14:21clojurebotExecution Timed Out
14:21The-Kenny,(doc read-line)
14:21clojurebot"([]); Reads the next line from stream that is the current value of *in* ."
14:22TakeVHuh, didn't know about that. Thank you.
14:22The-KennyYou're welcome
14:38Borkdudehi
14:39raekhello
14:40BorkdudeI have posted a Clojure question on StackOverflow, maybe you guys want to take a look. http://stackoverflow.com/questions/2540237/are-the-square-brackets-in-clojures-defn-defmacro-and-binding-really-a-vector
14:43dcorbin_workIs the J in clojure pronounced as a J or an S?
14:43chouserI think rhickey has said it's pronounced exactly like "closure"
14:43lancepantzthats how i pronounce it
14:43chouserI tend to harden it toward a "J" just enough that it sounds different to me, but to nobody else. Kinda useless.
14:44Rayneschouser: Likewise.
14:44TakeVHuh, I've been pronouncing it "Clo-jer".
14:46Borkdudeah I had a conversation with someone from the Java community, I asked him if he ever heard of Clojure
14:46Borkdudethen he answered: a closure, yes I heared about it
14:46RaynesHehe.
14:46Borkdudethen I tried to explain him, no, not the programming language concept closure, but the language Clojure
14:47Borkdudeso now I still dont know what he meant... :)
14:48fogus,(eval (list (list 'fn (vector 'x) (list '* 'x 2)) 100))
14:48clojurebotDENIED
14:48fogus:(
14:48LauJensenI blogged about some high performance Clojure for Fluid Dynamics here: http://www.bestinclass.dk/index.php/2010/03/functional-fluid-dynamics-in-clojure/
14:48fogusfogusbot> 200
14:48TakeVNeat.
14:49drewrLauJensen: is that stuff related to your professional work?
14:49LauJensendrewr: Fluid Dynamics? No its for the kids :)
14:50drewrjust wondering how you have time to write these elaborate (and apparently esoteric) posts
14:50LauJensenhehe
14:50Borkdudefogus, thanks for explaining the vector question on SO
14:51hugodLauJensen: cool - I do fluid dynamics too
14:51LauJensendrewr: This was 1) Because Ive always wanted to do some kind of swirly smoke sim, because I didnt know how, and 2) I ran into a former Epic Games engine developer, so I figured I'd grab the opportunity and ask him a few questions
14:52drewrLauJensen: fair enough :-)
14:53cemerickLauJensen: Stellar stuff. :-)
14:53LauJensencemerick: Thanks :)
14:53fogusBorkdude: I hope it helps
14:53Borkdudeit sure does
14:58TakeVSo, is clojurebot hooked up to a REPL?
14:59cemerickLauJensen: How long should it take for a call to main to return? I'm pegged at 100%, but there's no jframe visible yet.
15:00cemerickhrm, seems like the frame should show up immediately
15:00LauJensencemerick: On my system it shows up straight away
15:00LauJensenOh, if youre on OSX I this setUndecorated and setLocation can trip you up
15:00Borkdude,(+ 1 2)
15:00clojurebot3
15:00LauJensencemerick: Try and remove those please, i it solves it, I'll remove them
15:00LauJensenif
15:01Borkdude,(println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
15:01clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
15:01Borkdude:)
15:01RaynesTakeV: Clojurebot simply evaluates code in a sandbox.
15:01TakeVAh, that makes sense.
15:01RaynesTakeV: I do the same thing in my bot using Licenser's clj-sandbox.
15:02TakeVClj-sandbox?
15:02Rayneshttp://github.com/Licenser/clj-sandbox
15:02RaynesIt's pretty stable at this point. At least, I've not found anymore bugs. The default whitelist is seriously lacking because I haven't yet had time to go through the API adding safe functions.
15:03Raynesany more*
15:03cemerickLauJensen: Yup, that fixed it.
15:03LauJensenThanks !
15:05TakeVNeat library.
15:10Licensergreetings Raynes
15:10RaynesGreetings.
15:11RaynesLicenser: I see you removed the . special form. What happened there? :o
15:28dakroneis there a way to get the REPL to allow me to type stuff like "せん" ?
15:29dakroneit shows up as "??" instead
15:29raekdakrone: clojure itself should not have any problems with unicode characters
15:29raekjust make sure the source is in UTF-8
15:30dakroneraek: from the REPL though, not a file
15:30raekand that your terminal running the repl also is set up for UTF-8
15:30TakeVIs there a way to get Ant to make Clojure project?
15:30dakronethe terminal is working fine I am assuming since I can type those chars in zsh
15:30dakronemaybe it's jline?
15:31raekcould be
15:31raekcoult you try to enter the characters with "java -jar /path/to/clojure.jar"?
15:32dakroneahhh yea, it's jline
15:32danielfmTakeV, Clojure uses Ant to build itself, which includes .clj files. Check out the source code
15:32dakroneremoving it allows me to type it fine
15:32raekjava sometimes uses the "system default encoding"
15:32raekyou should be able to set that with some environment variable
15:33raekexport LANG=en_US.UTF-8
15:33raek...in a sh-like shell (such as bash)
15:33dakroneraek: would that fix jline?
15:34raekmaybe I should try this myself first...
15:34danielfmTakeV: http://github.com/richhickey/clojure
15:34TakeVThanks.
15:37raekhrm, jline seems to ignore my LANG environment variable
15:37raekköttfärssås -> köttfärssÃ¥s :(
15:38dnolenraek: dakrone: I've been looking into it but I haven't found any good answers yet. And I think jRuby ran into the same issues.
15:38dakronehmm...I'm wondering what leiningen is doing to it too
15:38dnolenlein swank and lein repl both freeze if they receive unicode chars :(
15:39ska2342hi. feeling rather stupid right now, but how am I supposed to read 9 chars from a file? (apply (str (take 9 (repeatedly #(.read the-reader))))) ?
15:39dakroneif I do java -cp .:clojure.jar clojure.main, I can type "せん" fine, but "lein repl" and I get "??"
15:39ska2342uhm, forgot a char: #(char (.read the-reader)) ...
15:40dakronetechnomancy: is there a way to see leiningen's command for running the repl with 'lein repl'?
15:40raekdnolen: that can be fixed
15:40dnolenraek: what did you do?
15:40raekswank-server has latin1 as the default
15:40Raynesdakrone: It's in the lein file itself.
15:40raekposting in a sec
15:41dakroneRaynes: ahh, looks like leiningen itself is including the jline jar
15:41dakroneI'll file a bug report
15:41raekdnolen: http://gist.github.com/348309
15:42raekI use this to start a swank server
15:42raekand then in .emacs: (custom-set-variables '(slime-net-coding-system (quote utf-8-unix)))
15:44raekif you leave out the slime or the swank option (I don't remember which) the repl will hang
15:44raekif both are set to latin1 or utf-8, it works
15:45dnolenraek: thanks for the pointers will try that out.
15:50raek*sigh* sometimes I wish that the English alphabet utilized more füñňý ĉḥäřáçťêrš, so that encoding related issues would be detected alot quicker
15:50TakeVI always thought that Q was a pretty funny letter.
15:51RaynesNot nearly as hilarious as w
16:05BorkdudeRaynes: is there also such a clj-sandbox behind a Twitter account already?
16:05Borkdudeso you can tweet a Clojure sexp and it replies its evaluation?
16:06RaynesBorkdude: No idea. Not that I've heard of.
16:09KirinDavelein test is broken?
16:10LauJensenWee, Clojure on the frontpage of HackerNews :)
16:10nubacool
16:11fdaoudlink?
16:11clojurebotyour link is dead
16:13Rayneshttp://news.ycombinator.com/
16:13LauJensen#24 :|
16:13KirinDaveI dunno what I need to do to get lein test working. it's never worked for me. :(
16:13KirinDaveeternally bitching: java.lang.IllegalArgumentException: No matching field found: getCommandLine for class org.apache.tools.ant.taskdefs.Java
16:14fdaoudsilly me, I was looking at http://www.hackernews.com
16:14RaynesLol.
16:14KirinDaveWow. Wft is that.
16:14KirinDaveI dunno where to even begin with that site.
16:14BorkdudeThere's a nice interview with Rich in Linux Journal this month
16:14fdaoudyeah that's what i said
16:15fdaoudtried .net and .org before asking
16:15KirinDavefdaoud: Consider google.
16:16fdaoudhey how would you implement the observer pattern in Clojure? or any way of notifying listeners that something happened?
16:16LauJensen,(doc add-watcher)
16:16clojurebot"([reference send-type watcher-agent action-fn]); Experimental. Adds a watcher to an agent/atom/var/ref reference. The watcher must be an Agent, and the action a function of the agent's state and one additional arg, the reference. Whenever the reference's state changes, any registered watchers will have their actions sent. send-type must be one of :send or :send-off. The actions will be sent after the reference's state is
16:16KirinDaveThat's good for observables.
16:16fdaoudexcellent, thanks LauJensen
16:16KirinDaveLauJensen: The canonical lisp way is "hooks"
16:17KirinDaveLauJensen: If its' not a data thing.
16:25kotarak,(doc add-watch)
16:25clojurebot"([reference key fn]); Experimental. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any registered watches will have their functions called. The watch fn will be called synchronously, on the agent's thread if an agent, before any pending sends if agent or ref. Note that
16:26glogickotarak: where does the doc come from
16:26glogickotarak: doc string?
16:27kotarakyes
16:27glogickotarak: so doc is apropos
16:27glogictha'ts quite the doc string then
16:27kotarakdoc is doc
16:29glogicclojurebot should probably send long docstring via privmsg imho
16:29Raynesglogic: Bother hiredman about it.
16:30RaynesI doubt he would want to do that though.
16:30glogicRaynes: well
16:30glogicRaynes: that doc string
16:30RaynesBeing able to pull up a docstring for somebody would be useful.
16:30glogicRaynes: is clearly too long it's cut off
16:30glogicRaynes: ref. Note that
16:30glogicRaynes: not contextually useful
16:31glogictha'ts all i was saying
16:31RaynesIt's pretty useful. :\
16:31glogicrigh tup until it cust the rest off
16:31RaynesOr, you could just direct output to the person you have in mind.
16:32glogicthat would be ideal
16:32glogicif tha'ts possible already just ignore the suggestion then
16:32alexykis there a version of nth with swapped parameters?
16:32glogic,(doc nth)
16:32clojurebot"([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."
16:33alexykand?
16:33glogicoh no idea i just wanted to look something up
16:33glogicmostly because i don't know what nth looks like
16:33alexykok this one time
16:33alexyk:)
16:34glogicwhat do you mean by swapped parameters
16:34dakrone(defn nth2 [index coll] (nth coll index)) ?
16:34alexykin FP it's typical to curry, so if you want a partial with a fixed index instead of collection, you need swapped-nth n coll
16:35alexykdakrone: yeah, I can do it; was wondering why nth is swapped w.r.t. say take, and maybe there's a swap adaptor already or something in stdlib
16:35glogicalexyk: least surprise maybe
16:35glogicalexyk: that's my initial guess
16:35alexykto me it's most surprise, after take/drop
16:35glogici bet
16:36dakronealexyk: or (->> 1 (nth [1 2 3]))
16:36glogic,(doc ->>)
16:36clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."
16:36dakronewhich is *kinda* like what you want I think
16:36dakrone,(->> 1 (nth [1 2 3]))
16:36clojurebot2
16:36alexykdakrone: indeed
16:36glogicok wow
16:37Raynes,(nth 1 [1 2 3])
16:37clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
16:37Raynes,(nth [1 2 3] 1)
16:37clojurebot2
16:38alexyklet's all buy qlogic and Raynes a repl shall we
16:38RaynesWhy would you use ->> for such a simple form?
16:38timmcdHello!
16:38dakronejust to be able to have the index before the collection
16:39timmcdI was wondering if there was a way to import all classes from a group? Ie: (import '(java.net *) '(java.io *))
16:39timmcdor the like?
16:39RaynesNope.
16:40timmcd:( Have to by hand import all the classes? K
16:41TakeVHuh.
16:42TakeV,(nth {:x 5 :y 7 :z 12} 1)
16:42clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap
16:42TakeVAw.
16:42glogicsplendid exception handling though
16:42glogicpretty
16:43glogic,(nth (1 2 3 4))
16:43clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
16:43glogicaw
16:43glogic,(nth (1 2 3 4) 1)
16:43clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
16:43alexykwhen working with agents for N threads speedup, does it make sense to have N global agents and send them work, or create agents in defn's locally?
16:43glogic,(doc nth)
16:43clojurebot"([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."
16:43glogic:(
16:43fdaoud,(nth [1 2 3 4] 1)
16:43clojurebot2
16:43dakroneglogic: it's trying to call the function called "1"
16:43fdaoud([1 2 3 4] 1)
16:43glogicya i redid it though
16:43fdaoud,([1 2 3 4] 1)
16:43clojurebot2
16:43glogic,(nth (1 2 3 4) 1)
16:43clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
16:44glogicaw
16:44glogic,(nth [1 2 3 4] 1)
16:44clojurebot2
16:44fdaoud,(nth '(1 2 3 4) 1)
16:44clojurebot2
16:44fdaoud,('(1 2 3 4) 1)
16:44clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
16:44glogicyou guys are fun
16:44TakeVWait, you don't need the nth?
16:44fdaoudnot for vectors
16:44TakeV,([1 2 3 4 5] 2)
16:44clojurebot3
16:44fdaoudvectors are functions of their indexes
16:44TakeV,(count [1 2 3])
16:44clojurebot3
16:45TakeVAh, true.
16:46shalesHas anyone used a java.nio.ByteBuffer in clojure to pull apart or build some binary data like a packet?
16:52The-Kennyshales: Yeah, I've done this. But rather ugly and imperative
16:53The-Kennyshales: http://github.com/the-kenny/netwars-clj/blob/master/src/netwars/map_loader.clj#L123
16:53The-KennyIt's rather ugly, with much special cases
16:54shalesthanks. I've written some helper functions for working with ByteBuffers too http://github.com/geoffsalmon/bonjure/blob/master/src/bonjure/bytebuffer.clj
16:54shalesWanted to see how other people had approached it
16:56The-Kennyshales: Oh, they look very nice. Maybe I'll try them :)
16:57shalesmissing your read-n-string and read-null-string
16:59TakeVSo, with compile, it compiles the passed namespace into a class? Even namespaces that were created in REPL, without any source file?
17:05astoddardHas anyone out there been using the "map-invert" function in clojure.set? It ignores duplicated values (becoming keys), with the one picked being arbitrary.
17:06astoddardMaybe that behavior is considered obvious but I wonder if it should at least be documented.
17:13slyphonso, is there a difference between "with-bindings" and "binding"?
17:14slyphonbinding uses this "var-ize" fn, but i'm not really sure what that does...
17:17kotarakslyphon: with-bindings is more low-level. Normally you should use binding.
17:17slyphonok
17:17kotarakslyphon: (binding [a b] ...) <=> (with-bindings {(var a) b} ...)
17:17slyphoni was concerned at first that one was thread-local and the other wasn't, but it seems they both are
17:17slyphonahhh
17:18dnolennice: http://mmcgrana.github.com/2010/03/clojure-web-development-ring.html
17:18slyphonbefore you die, you see "the ring"
17:20raekI really like the idea of this standardized way of representing requests and responses
17:22TakeVIs Ring supposed to be to Clojure as what Rails is to Ruby?
17:22chouserno
17:22lancepantzit's rack
17:22slyphonyay rack!
17:23chouserwe don't have anything as big and frameworky as rails yet, I think.
17:23TakeVAh.
17:23TakeVRails is quite a nice system.
17:23slyphonrails is "ok"
17:23lancepantzi've seen a couple of project on github attempting, they are all pretty new still though
17:23chousercompojure may have been headed there at one point, but has fortunately been adjusting more toward being a comprehensive library
17:24lancepantzTakeV: compojure is similar to sinatra, if you've used it
17:24TakeVI have not.
17:24TakeVTo google!
17:27dnolenwell from the looks of it tho, Compojure 0.4 is now really just a routing library. Like Moustache.
17:28gstampQuick question... Say I have an array [1 2 3] and I want to repeat it indefinitely so that the output looks like (1 2 3 1 2 3 1 2 3...), how would I do it? I originally was thinking (repeat [1 2 3]) but that gives me ([1 2 3] [1 2 3] ...)
17:28dnolenRing 0.2 does all the heavy lifting that Compojure (and then some it seems) that Compojure 0.3.2 used to do.
17:28lancepantzdnolen: i think actually uses clout for the routing library
17:28chouser,(take 20 (cycle [1 2 3]))
17:28clojurebot(1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2)
17:28lancepantzit's pretty thin now, just a few macros
17:28gstampawesome, thank you
17:29dnolenlancepantz: oh yeah, yr right
17:29chousergstamp: note the input there is a vector (not an array) and the output is a seq
17:30gstampchouser: that's fine for my purposes. I actually remember reading about cycle but had forgotten it. :-)
17:40brian__Hi, Is there a better way to increment through two or more sequences than this: (doseq [line (map #(str %1 " (" %2 ")") w v)]) , pull the values from "line" ?
17:41raekbrian__: have you tried "for"?
17:42brian__no, i'll take a look, thanks
17:42chouser'map' is the way to walk two or more seqs in step
17:42raekbrian__: what is the desired input and output for your function?
17:42chouseror sometimes 'zipmap', but I don't think that applies here
17:43brian__it seems a little clunky to have to parse the values from a string
17:43brian__I mean sequence
17:44raekbrian__: can you give an example input and output?
17:44brian__ok
17:45brian__v - names , w - ages and I want to input to a database
17:45brian__for example
17:46brian__so in the above I have to figure out the exact index for each variable I want to input to the database, seems a little clinky
17:46brian__clunky
17:47raekso, you have two sequences, eg names = ["fred" "ethel"], ages = [30 40]
17:48raekwhat should the code output?
17:48raek("fred (30)" "ethel (40)") ?
17:48brian__db.input(:age 30)
17:48brian__db.input(:age 30 :name fred)
17:49brian__i mean
17:49raek,(interleave ["a" "b" "c"] [1 2 3])
17:49clojurebot("a" 1 "b" 2 "c" 3)
17:50raek,(partition 2 (interleave ["a" "b" "c"] [1 2 3]))
17:50clojurebot(("a" 1) ("b" 2) ("c" 3))
17:50kotarak(doseq [[name age] (map vector names ages)] (.input db :age age :name name))
17:50brian__ok , thats good
17:50raekah, (map vector name ages) accomplishes this better
17:50Chousukeor (doseq [name names age ages] ...)
17:51Chousukeor hm
17:51kotarakor (doseq [[name age] (zipmap names ages)] ...)
17:51ChousukeI think that does a cartesian product :P
17:51brian__ok because i didn't see ant example of multiple sequences for doseq online
17:52brian__thanks guys
17:56raekoh btw, has anyone thought about making a if-not-let macro?
17:56raekif-let is great for error handling
17:57raekbut I like having special cases and error handlig first
17:58raekI was thinking about something like this: (if-not-let [foo (might-yield-nil)] (report "foo is nil") (do-stuff foo))
17:58raeksimply if-let, but with the true and false branch swapped
18:14nteonis there a way to examine a function I've created in a slime session?
18:14nteonperhaps a way to dump the bytecode to disk, and use a disassembler?
18:16arohnernteon: the tools are all there, but undocumented
18:16arohnernteon: all clojure fns are classes
18:16arohnerand you can ask the classloader the class came from for its bytecode
18:20arohnernteon: hrm, maybe I was wrong about asking the classloader for its bytes. I can't find the method now
18:22arohnernteon: one thing I'm more sure about is if you precompile your clojure code, you'll get a directory full of .class files
18:22nteonarohner: yea, thgats what I'm going to resort to
18:23mattreplarohner: re: classloader and fetching compiled class' bytecode, sounds familiar
18:25mattreplmaybe it's just the other way bytes -> class
18:26arohnermattrepl: yeah, I found the method to define a class by passing a byte []. I thought the inverse existed. *shrug*
18:42glogic,(doc defn)
18:42clojurebot"([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata"
18:43glogicok wow i'm lost
18:46dakroneglogic: what are you trying to find?
18:48glogicdakrone: well
18:48glogicdakrone: i dont' expect all the docstrings to make perfect sense obviously but that one is kind of a dump of all the possible forms of defines i think
18:49glogicdakrone: so it takes some parsing, whcih is fine i just wans't expecting quite that much ifnromatin on that
18:49RaynesType a little slower. ;)
18:49glogicfor real bro
18:49glogiclol
18:49dakroneahh, okay, well luckily almost all the options are optional
18:50glogicya i kind of get the impression i can stumble a bit
18:50glogic,(defn [name "doc???" x] (+ x 1))
18:50clojurebotDENIED
18:50glogicoh right nvm
18:50glogicwell anyway would that work?
18:51glogicyou just really need a sandbox for clojurebot so you can define safely
18:51laynorHi, I'm not really experienced with the jvm. I'd like to play with clojure and swt, but I don't really get where to place the library and stuff
18:51Raynes(defn name docstring [args] body)
18:51glogicthen you can serialize evalution and build apps collbaoratively
18:51glogicalthought iw as suggested to me that the best way is to start sessions via irc if your'e going to do any serious editing
18:51Raynesglogic: There really isn't a way to define safely. Anything defined will pollute the namespace. clojurebot is there for showing people how to do stuff they're asking about.
18:51glogicRaynes: oh ok i parsed that really wrong lol
18:52dakrone(defn add-numbers "Adds two numbers together" [a b] (+ a b))
18:52dakronethere's a simple example
18:52glogicRaynes: oh ok, i had an eval bot i did up in chicken, i used the sandbox library it was reasonable never had any major issues tehre
18:52dakronethe docstring is optional
18:52dakrone,(defn add-numbers "Adds two numbers together" [a b] (+ a b))
18:52clojurebotDENIED
18:52glogicdakrone: right
18:52glogicdakrone: i wasn't sure where it went was all
18:52glogicdakrone: so right after name
18:52dakroneyep
18:53glogicis that where docstrings go
18:53glogici dont' remember
18:53nteonwhat java disassembler do people recommend?]
18:54glogicoh CL puts them after arguments i think
18:54laynorglogic: yeah
18:54laynor:)
18:54glogiclaynor: seems silly
18:54glogiclaynor: it actually makes more sense to me where it is in clojure
18:54laynorreally?
18:54glogickind of
18:54glogicname -> what i am
18:54dakronenteon: I like jad
18:54glogicalthough splitting up the function signature has some caveats on readability
18:55dakronebut it looks like it hasn't been updated in quite a while, and it's been a while since I've used it
18:56dakronenteon: wikipedia suggests http://java.decompiler.free.fr/
18:56laynorglogic: http://paste.lisp.org/display/97047 looks totally good to me, i think it wins in readability
18:57glogiclaynor: ya
18:57glogiclaynor: you know compared to the othr way
18:57glogiclaynor: i think yo'ue right
18:57laynorI guess clojure opted for documentation after the name because of overloads
18:57nteondakrone: thanks!
18:58glogiclaynor: having the argumentsa fter is a little wierd now that you showed methat
18:58glogic,(doc defn)
18:58clojurebot"([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata"
18:58glogichrrm
18:59laynorfor me it's also strange how in some clojure code they split the line after the function name
18:59glogicare arguments always []
18:59laynorin clojure? i think so
18:59laynorbut I'm no clojure expert
19:00laynori downloaded it yesterday
19:00laynorahah
19:00glogiclaynor: ya me too
19:00glogiclaynor: lol
19:00laynorI'd like to use swt, but i really don't get how to load the library
19:00glogicis the jvm somehow less dynamic with jruby?
19:00laynori always avoided the jvm like the plague
19:00laynoroh
19:01laynorno idea
19:01laynor:)
19:01glogici'm just readint eh topic
19:01laynor^^
19:07laynor-_-'
19:08laynoranyone that can help me loading swt ? ^^
19:31technomancywouldn't it be cool if calling a vector with two arguments called subvec?
19:31technomancyalso: wouldn't it be cool if calling a vector with a negative number counted from the end?
19:32technomancyalso: it would be great to have serializeable continuations.
19:32technomancythat is all.
19:36bsteuberlaynor: what's your exact problem?
19:46laynorbsteuber: I got it now :) But i got another problem...
19:46bsteuberic
19:46laynorwhen i use java from the command line it's by default the 64 bit server machine
19:47laynorand I can load the 64 bit swt library correctly
19:47laynorbut emacs for somewhat reason runs clojure with a 32 bit jwm
19:47laynorjvm
19:48laynorso, basically, I can't experiment with swt from the slime repl :/
19:48laynorand i can't run code from emacs
19:49laynorany idea how to solve this?
19:50laynoruhm, a clojure emacs clone would be nice :O
19:51technomancylaynor: just wait a while. Emacs now has threads, so as soon as clojure-in-clojure is done we can begin porting clojure to the Emacs VM.
19:51phren0logylaynor: why not start your repl then connect to it instead of starting it in emacs?
19:52_mstlaynor: perhaps (add-to-list 'swank-clojure-extra-vm-args "-d64") ?
19:54laynor_mst: Unrecognized option: -d64
19:54laynor:(
19:55_mstah, sorry. Turns out that only works on solaris :P
19:55laynorlol
19:55laynoruhm
19:56_mstah actually no, it works on an intel box here too
19:56laynorjava -version?
19:57_mstjava version "1.6.0_02"
19:58_mstbut it works on java 1.5.0_12 too...
19:58laynorwhat about the server vm? mine says Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)
19:58_mstJava HotSpot(TM) 64-Bit Server VM (build 1.6.0_02-b05, mixed mode)
19:58laynorno idea
19:58laynorlol
19:58_mst... it's not a path difference between emacs and your shell is it?
19:58_mstlike emacs picking a different java implementation or something?
19:58laynorno :)
19:59laynori ran emacs from cmd to be sure
19:59laynoralso, that doesn't explain why -d64 doesn't work
19:59laynoruhm
20:01laynoroh
20:02laynorif i wanted to run it manually, should i do something like java -d64 -jar clojure.jar?
20:02_mstyep, that should work
20:02laynorit doesn't work for me
20:02laynorjava doesn't recognize the -d64 option
20:04laynorcould it be it depends on emacs being 32 bits, and being unable to run 64 bit processes? (no idea if it makes sense at all)
20:05_msthm, mind you, your version string suggests that it's 64-bit anyway...
20:05laynoruhm
20:05_mstfrom emacs you could try M-x eshell then run 'java -version' from there--see if it matches what you get from the shell
20:06laynorwait, i try to Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing) :O
20:06laynors/wait, i try to//
20:06_msthm, how about: java -server -version
20:07laynorError: no `server' JVM at `C:\Program Files (x86)\Java\jre6\bin\server\jvm.dll'.
20:07laynorlol
20:09_msthm, yick. I must admit I'm fairly ignorant of java on windows :)
20:10laynoryou know more than me anyway ^^ I tried to avoid the jvm as long as I could
20:10laynorbut clojure is tasty
20:12laynorI'm looking forward to clojureclr
20:12laynorwhat's the status?
20:21licoresselooking forward to a clojureobj-c, or whatever the name should be
20:23lancepantzlicoresse: the book? did it get released?
20:23licoresselancepantz: no, only the MEAP early bird
20:24licoresseit's well written, I like it
20:24lancepantzah, yeah i had the first few chapters on there
20:42defnhttp://lbrandy.com/blog/2010/03/never-trust-a-programmer-who-says-he-knows-c/
20:42defnheh
20:43defnlicoresse: have they added some more chapters yet?
20:43defnonce i heard they were going to rearrange things i decided to hold off for awhile
20:43licoressenot yet, but saw a tweet that it could happen any day now
20:44defnyes me too -- hope it happens soon
20:44licoresseyes
20:47woobyhm, having some issues with this macro: http://gist.github.com/348620
20:47licoressedef: haha; “C++ is a language strongly optimized for liars and people who go by guesswork and ignorance.”
20:47woobyexperimenting with auto-gensym for the first time, and the second iota# isn't the same name as the first
20:48clojurebotmultimethods is what separates the boys from the men.
20:48woobythanks in advance for any tips
20:48licoresseisn't the ...# gensym shortcut?
20:49woobyindeed
20:50licoresseand this is in a macro
20:51woobyright
20:51joshua-choi...Why did clojurebot just talk?
20:52licoressegensym creates a symbol, whatever# refers to it
20:53licoressewhere is your gensym wooby
20:53woobyit's in the let
20:54woobyit gets referred to again in the line starting with ~@
20:54woobyunfortunately the second time it creates a new sym, when i would like it to expand to the first one
20:57technomancyjoshua-choi: he's practicing for an upcoming turing test
20:57licoressejust refer to it by deleting the #
20:58pschorfI am having an issue installing swank-clojure via ELPA
21:00pschorfWhenever i attempt to install the package, I receive the following error: Error: Cannot open load file: slime
21:01dnolenhugod: technomancy: I tried the compile-file branch and things seem OK with ELPA slime. One thing I notice that is weird tho is that lein-swank no longer starts on 4005, but on a random port.
21:01technomancypschorf: shouldn't be a problem; proceed as per the readme
21:03pschorftechnomancy: when i run M-x slime, i get the following http://pastebin.com/KKeSY1MW
21:03technomancypschorf: maybe try rm -rf ~/.swank-clojure and M-x slime again?
21:04technomancypschorf: also try some of the other ways of launching from the swank readme; lein swank or M-x swank-clojure-project
21:04technomancystandalone repls are not used very often
21:07pschorftechnomancy: no luck with the rm -rf... I was actually hoping for a standalone REPL to toy around with clojure a bit: I don't have any need to set up projects right now
21:17pschorftechnomancy: it appears I had a pre-existing .clojure directory, removing that fixed the problem
21:17pschorftechnomancy: thanks for the help
21:20hugoddnolen: Thanks for the testing. I think that has been that way for a while with the port
21:21dnolenhugod: so that's intentional?
21:23hugodI believe so, though technomancy would know better than I why it's that way - I guess to provent port collisions if you're already running other swank processes
21:23dnolenhmm. ok. hugod: so how does the new SLDB stuff work? I'm trying that out.
21:30hugoddnolen: there's a (swank.core/break) that should put you in sldb with locals available for inspection/available at the repl
21:35dnolenhugod: wow, that works! and you can even put in multiple breaks and continue :D
21:38hugoddnolen: glad you like it. You should also get nested exceptions all displayed in the same sldb buffer
21:39dnolenhugod: what do you mean by nested exceptions?
21:40hugoddnolen: exceptions that are caught and rethrown as a different exception
21:48licoressednolen: where?
21:48licoressehow do you use it?
21:51dnolenlicoresse: one sec
21:55hugoddnolen: compile-file is now merged
21:55hugodstill looking for volunteers to test or review the other swank-clojure branches...
21:59dnolenhugod: nice, any other branch you really want to see tested?
22:00dnolenlicoresse: basically you need to "lien install" the master branch of swank-clojure and use this instead in your project depedency list.
22:00laynoryay!
22:00dnolenlicoresse: then you can effectively put (swank.core/break) to breakpoint anywhere in your code.
22:00laynori got emacs to start the 64bit jvm :)
22:01hugoddnolen: it's in clojars 1.2-SNAPSHOT too
22:01laynorall working now, thank you all, good night
22:01laynor:)
22:01dnolenhugod: 1.2-SNAPSHOT of lein-swank? nice!
22:01dnoleneven better
22:02hugoddnolen: of swank-clojure - which I believe is used by lein-swank 1.2-SNAPSHOT
22:03hugoddnolen: the exception-location branch gets slime highlighting of compile errors to work
22:04hugodautodoc fixes for slime-autodoc in slime head - this one needs particular testing with elpa
22:04licoresse [null] An error has occurred while processing the Maven artifact tasks. WTF?
22:05dnolenhugod: I'm assuming if I test the branch I should create the jar from source and not pull from Clojars, right?
22:06hugodhyperdoc gets you links to the clojure api web page (C-c C-d h)
22:06hugoddnolen: yes
22:09dnolenlicoresse: you need to add dev dependency [leiningen/lein-swank "1.2.0-SNAPSHOT"], probably need to use the 1.2.0 master snapshots for clojure and clojure.contrib as well.
22:09licoressednolen: ah, ok, thanks
22:12hugoddnolen: swank-clojure doesn't require clojure 1.2
22:13dnolenhugod: yeah I just noticed that.
22:13dnolenI thought env stuff was 1.2.0
22:14hugodahh yes, you only get that with 1.2 - what was I thinking - but it still runs with 1.1
22:21arohnerI think I remember someone saying you have to specify the character encoding for swank or it gets fussy. Can someone point me to instructions?
22:22dnolenarohner: raek knew what to do, somebody needs to write this up somewhere.
22:22dnolenhugod: Ok I see that I'm getting the option to jump to the exception location but the line number is wrong.
22:22dnolenfor me it says line 1, when it's line 31
22:23arohnerright now, if I print say, an html page over swank, slime fails to parse the output from clojure, and then slime gives me exceptions on every action after that until I disconnect and reconnect
22:24dnolenarohner: yes it's very broken. you can't even input a unicode character, it will hang the REPL.
22:25hugoddnolen: so the stack trace in the sldb buffer gives a line number of 1 and it jumps to line 31?
22:25dnolenhugod: no line number 1 and jumps to 1. but the error is actually on line 31
22:26dnolenhugod: btw, these are some amazing changes. thank you.
22:28dnolenhugod: more detailed info.
22:29hugoddnolen: thanks for the appreciation
22:29dnolenif I have an undefined symbol, it jumps to the right place, however if I call a function with the wrong number of arguments I get line number at 1
22:30shalesI'm trying out (swank.core/break) too, with [leiningen/lein-swank "1.2.0-SNAPSHOT"] from clojars. It's working when I directly call the function containing the break from the slime repl, but I get an exception if break is called on the AWT thread in response to clicking a JButton. Is this expected?
22:31shalesjava.lang.IllegalStateException: Var swank.core.connection/*current-connection* is unbound.
22:31shales at clojure.lang.Var.deref(Var.java:142)
22:31shales at clojure.lang.Var.get(Var.java:133)
22:31shales at swank.core$send_to_emacs__334.invoke(core.clj:77)
22:31shales at swank.core$sldb_loop__403.invoke(core.clj:204)
22:31shales at swank.core$invoke_debugger__407.invoke(core.clj:215)
22:32hugodshales: thanks for the report - I hadn't tried it from AWT
22:32shalesNo prob
22:33shalesOh, and hi Hugo. This is Geoff from bonjure =)
22:33hugodHi Geoff!
22:34shalesI now see what you meant about how much better debugging in emacs could be
22:35hugodStill has a way to go
22:36hugoddnolen: I'll try and repro in a while
22:36shalesya, but shows plenty of promise
22:36dnolenhugod: cool I'll check out the other branches later.
22:42arohnerhow am I supposed to grab http://github.com/stuartsierra/lazytest via lein?
22:42arohnerI get [WARNING] repository metadata for: 'snapshot org.clojure:clojure:1.2.0-master-SNAPSHOT' could not be retrieved from repository: stuart sierra snapshots due to an error: Unsupported Protocol: 'ftp': Cannot find wagon which supports the requested protocol: ftp
22:49arohnerdnolen: this fixed my slime character encoding issues:
22:49arohner(setq slime-net-coding-system 'utf-8-unix)
22:49arohnermy emacs and JVM are already set on utf-8
22:53dnolenarohner: hmm, I'm still getting ? when I try to print é
22:53dnolenarohner: how did you set your JVM? -Dfile.encoding=UTF8
22:53dnolen?
22:54arohnerI was able to print 'é in my slime repl
22:54woobyanyone a gensym guru? stuck on this macro, thanks in advance for help: http://gist.github.com/348703
22:54arohnerdnolen: yeah, -Dfile.encoding=UTF-8
22:55arohnerdnolen: can you print it in the console?
22:56dnolenarohner: I'm giving up on the utf stuff, it looks like lein-swank does the wise thing and select the default encoding for the OS. that seems to work much better.
22:56dnolenlein-swank 1.2.0 that is.
22:56arohnerwooby: I would write that as `(let [~'iota (atom -1)] ~@body)
22:57arohnerwooby: ~'iota means insert the literal as-is, without ns-resolving the var
22:58woobyarohner, the effect i'm going for is (with-iota (let [a iota b iota] ;; a=1, b=2))
23:00arohnerwooby: you want iota to increment after every time it's evaluated?
23:00woobyarohner, right
23:00woobyand i'm stumped on this gensym business :)
23:00woobyi can syntax quote iota# a second time but then it expands to a different symbol :\
23:01arohnerfoo# expands to the same symbol inside the same `
23:01arohnerI'm not quite sure why that's breaking for you now
23:02arohnerbut if you want users to be able to refer to iota, instead of iota#, use ~'iota
23:03woobyarohner, thanks
23:45sramsayDear clojurians: I am so confused by the functional universe.
23:45sramsayTo wit: I have a list of number and a list of structs.
23:46sramsayWant to make successive numbers in the list keys to the corresponding structs in the hash.
23:47sramsayI know how to do this with loops. How to do it with clever sequence functions?
23:48woobysramsay, is your code somewhere? it sounds like you're looking for zipmap
23:48wooby,(zipmap [:a :b :c] [1 2 3])
23:48clojurebot{:c 3, :b 2, :a 1}
23:48sramsayNo! Really?
23:48sramsay(looking in docs)
23:49sramsayUnbelievable. That's it. Thanks.
23:50sramsaynamaste, wooby
23:50woobyno problem, have fun
23:51sramsayI'm sitting here thinking, "No functional programmer could possibly do it as stupidly and convolutedly as I'm doing it."
23:51sramsayAnd indeed . . . ;)