#clojure logs

2010-05-20

00:12defnhow would one go about integrating ruby on rails and clojure?
00:12defnjruby probably, id guess
00:13lancepantzwe use clojure for a backend rest api
00:13defnlancepantz: do you have any public code floating about?
00:13defnlancepantz: using ring i presume?
00:13lancepantzrails just makes rest calls
00:13lancepantzyeah, with compojure
00:13defnk
00:14lancepantzand unfortunately we haven't open sourced any of that yet
00:14defnbummer
00:14lancepantzvery much so
00:14lancepantzeven worse of a problem with the 0.4 release
00:15defnyeah it's kind of unnerving
00:15defnwhat's the point of a framework with no documentation
00:15lancepantzagree
00:15lancepantzring does a pretty good job w/ docs
00:15defnyeah, it's not very big and most of it is self-explanatory
00:15lancepantzi found the most helpful resource for compojure was the mailing list
00:16defnbut compojure has made me want to rage on multiple occasions
00:18defnlancepantz: so you have two server instances?
00:18defnlancepantz: also, are you just running the clojure side of things in a REPL?
00:19lancepantzyes wrt instances, but we deploy a war
00:19defnbleh -- no clue what to do there
00:20lancepantzmost people talk about deploying in a repl, which surprised me
00:20defnyeah it seems like a terrible way to do production stuff
00:20defnit just seems...impermanent
00:20lancepantzyeah, i just assumed they weren't working on production stuff
00:21defni mean, im using it for getclojure.org:8080/examples/concat
00:21defnbut that's staging -- i dont consider that a permanent solution
00:21lancepantzw/screen?
00:21defnyes
00:22lancepantzhttp://github.com/lancepantz/lein-war-example if you want something to work from
00:23lancepantzit's simple once you get it setup
00:23defncool thanks
00:23defnlancepantz: have you noticed any pain with managed dependencies from 1.1.0 to 1.2.0
00:23defnit seems like so many of the things i was using havent been upgraded to 1.2.0, and while i could do it myself im just making a bigger mess
00:24lancepantznot yet, but i haven't finished updating everything
00:30defnlancepantz: if/when you get something online id love to see a rails + clojure thingamajig working
00:31lancepantzwill do, we should have it in production next week or so
00:32lancepantzgotta run for now, take care
01:32slyrusack! the only thing scarier than whatever maven seems to want to download is the list of dependencies required to install maven2 in the first place! (at least via apt-get)
01:40timmorganI'm a Ruby dude, a Clojure noob, and cannot figure out how to do the equiv of ruby_arr.include?(item) in Clojure
01:41timmorgan(some #(= item %) items) ?
01:41timmorganor ((set items) item)
01:41timmorganis there a more idiomatic way?
01:42mmarczyktimmorgan: if item is not nil or false, (some #{item} items)
01:42mmarczyktimmorgan: though #(= item %) is perfectly alright too
01:43timmorganso, when treating a single-item set as a predicate, it tests to see whether its contents are present in the vector?
01:43mmarczykit's not really a predicate
01:44timmorganok, a function
01:44mmarczykit returns nil if it does not contain the given item, otherwise it returns the item itself
01:44replacatimmorgan: it can be an any-item predicate
01:44mmarczyknot a predicate in the sense of "a function which returns a Boolean", I mean
01:44timmorganok that makes sense
01:45timmorganoff to the repl I go
01:45timmorganthanks guys
01:45mmarczykyw :-)
01:45replacafor example (some #{:dog :cat} aseq) will tell me if dog or cat is in aseq
01:46replacamaxhodak: yeah, that's a fuzzy line in clojure. I tend to think of things as predicates more based on how I use them than on their defs
01:46replacaI meant mmarczyk :)
01:56mmarczykreplaca: :-)
01:56mmarczykcoming from Scheme, I'm used to the convention whereby anything with a name ending in ? returns Booleans only
01:57remleduffThat's the convention in clojure too, that's why it's "some" and not "some?"
01:57mmarczykyup, I know
01:59mmarczykbut whether it makes sense to take issue with a foo? function which might return nil seems to be a matter not everybody agrees on... I'm on the "switch to false or drop the ?" side personally ;-)
02:01mmarczykincidentally, "some" as a name only makes sense to me as a predicate, "lookup" or sth would make more sense to me... or find-first, since it's just (comp first filter) anyway
02:06TheBusbyIs there a clojure function for handling a queue between threads similiar to promise/deliver?
02:07TheBusbyjust conj a ref maybe?
02:08wdouglasHey all, I'm having an odd to me problem of not being able to use the thrown?, thrown-with-msg? calls in clojure.test. I look at the source for 1.1 and I see the functions there but when I use clojure.test, not showing up. Probably something stupid but I can't seem to figure it out.
02:09chouserTheBusby: you might like java.util.concurrent.BlockingQueue
02:10mmarczykTheBusby: have a look at seque and clojure.contrib.seq/fill-queue
02:10chousermmarczyk: it's not (comp first filter), it's more like (first (filter identity (map ...)))
02:10chouser'some', that is.
02:10mmarczykthough, yeah, LinkedBlockingQueue works just fine... except apparently it doesn't handle nils
02:11TheBusbylooking in Java's concurrent section now, but producer cannot block, ConcurrentLinkedQueue maybe?
02:11mmarczyk,(some #{:foo} [:foo :bar :quux])
02:11clojurebot:foo
02:11mmarczyk,((comp first filter) #{:foo} [:foo :bar :quux])
02:11clojurebot:foo
02:11mmarczyk,((comp first filter) #{:wibble} [:foo :bar :quux])
02:11clojurebotnil
02:12chouser,(some :a [{:a nil} {:a false} {:a :b}])
02:12clojurebot:b
02:12chouser,((comp first filter) :a [{:a nil} {:a false} {:a :b}])
02:12clojurebot{:a :b}
02:13chouserbut the real question is
02:13mmarczykoh.
02:13mmarczykthanks!
02:13chouserwhy the heck am I still up
02:13mmarczykthat goes for me as well
02:13mmarczyk8:12 am here
02:13TheBusbychouser: thanks for the input
02:13chousernp
02:13TheBusbymmarczyk: thanks!
02:13mmarczykyw
02:14defndoes anyone here have cuke4duke working?
02:14defnI can't seem to get it running
02:14mmarczykLinkedBlockingQueue has an .offer method
02:14mmarczykor some such thing
02:14mmarczykfor putting things on the queue if possible, getting an indication of success and never blocking
02:15mmarczykcuke4duke, wow 8-O
02:15defn??
02:15mmarczykis this something to do with testing?
02:15defnyes.
02:15mmarczykI mean the project name
02:15defncucumber
02:15mmarczykand duke?
02:15defnno clue
02:15mmarczykright.
02:16defnlol oh god -- maven2 needs...113 packages for ubuntu
02:17Chousukeare you sure it's not installing recommended packages?
02:18TheBusbylikely install an alternate version of Java too...
02:19defni just let apt do its thing
02:20defnwait..maven2 is installing groovy?
02:24tgkI'm trying to think of a macro for getting a textual representation of a form while still evaluating it. Does anybody know if there is a way to do this? The textual representation should just be saved somewhere as a side effect.
02:24LauJensenMorning all
02:25tgkHere's a usage example: (text-copy (defn f [x] (* 2 x))) => #'user/f
02:25tgkI'm pretty sure it's possible, but I have no idea how to get started.
02:27defntgk: read the form in as a string, add it to a ref, vector, map, whatever
02:27defnand then read-string
02:27tgkdefn: how do I read the form in as a string?
02:35defn(read-string "(+ 1 2)")
02:39tgkHmmm okay, it will read it from a string. But I need the reverse; I want to create a string from a form. E.g.: (string-from-form (def f [x] (+ 3 x))) => "(def f [x] (+ 3 x))"
02:46tomoj,(str '(def f [x] (+ 3 x)))
02:46clojurebotDENIED
02:46tomojbah
02:46tomoj,(str '(df f [x] (+ 3 x)))
02:46clojurebot"(df f [x] (+ 3 x))"
02:50tgkBut that requires that I put the ' there... Hmmm I guess that can be solved by using macros
02:53tomojuhh
02:53tomojwhat were you hoping to use? a function?
02:55tgkOh no, not at all. I think I'll go tinker with it.
02:55tomojif string-from-form is a function and you call (string-from-form (def f [x] (+ 3 x))), the first arg of the function will be bound to #'f
02:56tomojwell, it would be if (def f [x] (+ 3 x)) were fixed
02:56tgkI know, I was sure I needed to write a macro.
02:57tomojoh
02:57tomojdo you want to figure the macro out on your own, then?
02:58tgkI'll try, I'll get back when I fail.
02:58tomojgood luck :)
02:58tgkThanks :)
03:02TheBusbyanyone have any experience using processBuilder?
03:03arbschtTheBusby: ask your real question and someone might answer
03:06TheBusbyarbscht: thanks
03:06TheBusbyThen, any idea how to turn the stdout out of a process created with processBuilder into a lazy-seq accessible by other threads?
03:07TheBusbyevidently if the stdout isn't consumed quickly by clojure the process will freeze
03:10TheBusbyduck-stream/copy works, reader + line-seq not so well...
03:25stilkovtgk: maybe you're looking or pprint
03:26stilkovs/or/for/
03:26sexpbottgk: maybe you're looking for pprint
03:28stilkovI use it to print code this way: (with-pprint-dispatch *code-dispatch* (pprint form))
03:28stilkovform is something I read with read-string
03:36tomojstilkov: what does that do differently than ugly printing?
03:37tomojactually, hmm
03:38tomoj,(require clojure.contrib.pprint)
03:38clojurebotjava.lang.ClassNotFoundException: clojure.contrib.pprint
03:38tomojdarn
03:38tomoj(let [form '(fn [x] (+ x 2))] (= form (pprint/with-pprint-dispatch pprint/*code-dispatch* form)))
03:38tomojthat is true for me
03:38tomoji.e. (partial with-pprint-dispatch *code-dispatch*) seems to be the identity
03:39LauJensenFor those interested, we've picked a venue: http://conj-labs.eu/course.html#misc ! :)
03:39sexpbot"conjLabs - About Clojure"
03:39stilkovpprint prints to *out*
03:39tomojnothing is printed for me
03:39tomojit just returns the form
03:39tomojstrange..
03:39stilkovif you want to get the string value, you need to use a stringwriter
03:39stilkov (binding [*out* (java.io.StringWriter.)]
03:39stilkov (with-pprint-dispatch *code-dispatch* (pprint code))
03:39stilkov(.toString *out*)
03:40tomojoh, whoops
03:40tomojmy problem was that I never called pprint
03:40tomojok, but still, looks just like ugly printing
03:40tomojis it supposed to do something special?
03:40stilkovbut what tgk seems to want is to get the string value and the eval'd result
03:41stilkovand the original form …
03:41tomojI mean, (with-pprint-dispatch *code-dispatch* (pprint form)) and (println form) seem to have the same output
03:41tgkThat is true, I think I have it solved.
03:41stilkovdepends on the complexity of the form :-)
03:41tomojah, if it gets bigger it starts adding newlines etc?
03:41stilkovyep
03:41tomojnice
03:44eevar2LauJensen: the blog link on http://conj-labs.eu/instructors.html doesn't work
03:44sexpbot"conjLabs - Instructors"
03:44LauJenseneevar2: thanks!
03:45LauJenseneevar2: fixed
03:45tomojbrussels is disturbingly far away
03:45eevar2what's with the rdbms hate btw? just stick a caching proxy in front if you're worried about efficiency ;)
03:46LauJensentomoj: from where?
03:46LauJenseneevar2: you talking about my baking skills?
03:46eevar2^^
03:46tomojLauJensen: texas
03:47LauJensentomoj: 9 hour flight? Thats the time it takes to write a fun 3d shooter in Penumbra, whats the problem ?
03:47tomojheh
03:47LauJenseneevar2: There's so much more at stake than performance
03:47LauJensenThere isn't a problem possible with my site, that I cant fix with scp, rsync or tramp
03:48LauJensenWordpress has numerous vunerabilities, and new ones pop up - how are you going to crack a static file? :)
03:49eevar2the comment system is still interactive, no? i think you might be adding complexity for no good reason, but maybe that's just me
04:01LauJenseneevar2: adding complexity? where?
04:09eevar2a db would take care of the acid issues, for instance. even if a work queue + some file system operations isn't _that_ complex
04:09esjMorning Good People
04:10stilkovit seems something has changed in compojure's defroutes syntax recently - anybody able to point me to a working recent example?
04:13LauJenseneevar2: ah yes. Its true that in the single instance which needs to be dynamic on the server-side, you can argue that my system isn't simpler than a db-based on, thats true
04:14LauJensenesj: morning :)
04:41hiredmanping?
04:41clojurebotPONG!
04:49LauJensenpong?
04:49clojurebotQinfengxiang!
05:30esjare there any examples out there of a java client consuming the interface generated by a protocol ?
05:30_na_ka_na_hi, how do i clear the cache of a memoize fn?
05:31hiredman_na_ka_na_: you don't
05:32_na_ka_na_hiredman: why?, i've a long running app, where the user loads a file, my app reads the file & caches the ds etc, ... then the user loads another file, in which case i want to clear the caches
05:33_na_ka_na_maybe i should include the filename in all the fns ..
05:33clojurebotthe unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation
05:34esj_na_ka_na_: to do this you need to reimplement memoize. Not hard. There is a great post on this here http://kotka.de/blog/2010/03/memoize_done_right.html
05:34sexpbot"Kotka : About Clojure… What else?"
05:34esjsexpbot: botsnack
05:34esj$botsnack
05:34sexpbotesj: Thanks! Om nom nom!!
05:35_na_ka_na_esj: thanx lemme take a look @ that
05:36esjOK, I guess my question is more; is the method described in this link still current http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java
05:36sexpbot"Clojure Programming/Tutorials and Tips - Wikibooks, collection of open-content textbooks"
05:40eintrautodoc and clj 1.2 seem unhappy together. sadness ensues. all is quiet. undocumented.
05:45LauJensenesj: I think its still possible, but checkout cemericks Maven screencast, you see him doing a much simpler interop
05:46stilkovI'm running into UniCode problems with Compojure; anybody run into this yet?
05:47esjLauJensen: Thanks. I'll check it out. It looks like deftype may be the right stuff, but I'm haven't seen examples.
05:55sparievstilkov: what kind of problems do you have ? All mine Unicode troubles were with swank-clojure encoding settings
05:55stilkovmy problem seems to be independent of swank, it happens if I start my webserver from the command line too
05:57stilkovin fact, if I get stuff from the backend with a remotely connected slime and write it to a file with UTF-8 encoding, everything's perfect
05:57stilkovit's as if compojure/ring didn't use UTF-8 encoding when writing
05:58sparievhaven't tried 0.4 compojure yet, no problems with old 0.3.2
05:59esjLauJensen: thanks, nice screencast. Not quite what I was after, but cool.
06:25LauJensenOk :|
06:41kasperlangerHi everyone. Is there a way to freeze the root-bindings of a namespace?
07:55_na_ka_na_hi, I have a question regarding protocols and datatypes,
07:56_na_ka_na_I'm defining a proto, as (defprotocol P (foo [this & args]))
07:56_na_ka_na_then a datatype as, (deftype PImpl [] P (foo [this & args] (println this args)))
07:56_na_ka_na_after that I eval, (foo (PImpl.) :x :y)
07:56_na_ka_na_this prints...
07:56_na_ka_na_#<PImpl iiit.PImpl@7c8865> :y
07:56_na_ka_na_where did the :x go?
07:57_na_ka_na_am I defining P, PImpl properly?
07:58_na_ka_na_or is destructuring not possible in protos?
07:58rhickeyfogus: yeah, read that earlier. The principle is correct, but the reality is that the declarative nature of Prolog is a somewhat a lie. Not that is didn't work for him, and the lesson is still a good one
07:59raek_na_ka_na_: are you running the latest version? previously the 'this' parameter has been handled in a different way
08:00_na_ka_na_raek: I'm using clojure-1.2.0-master-20100518.110252-71.pom
08:01_na_ka_na_its working if I do it w/o destructuring ...
08:02fogusrhickey: Intriguing. I used Prolog in school (who didn't) and most of the things we did seemed declarative. But at one point I worked with a guy who used it on a very large system, and his code didn't look anything like those school projects
08:03_na_ka_na_rhickey: is destructuring possible in proto method declarations?
08:03rhickeyfogus: three things rain on the parade in Prolog IMO: cut/fail, infinite evaluations, and clause order dependency
08:04rhickeytogether they truly prevent you from just thinking declaratively, and force you to consider the baked-in evaluation semantics
08:04LauJensen_na_ka_na_: http://bestinclass.dk/index.clj/2010/04/prototurtle-the-tale-of-the-bleeding-turtle.html
08:04sexpbot"Best In Class: ProtoTurtle - The tale of the bleeding turtle"
08:04rhickey_na_ka_na_: what would it mean to put destructuring in the declarations? destructuring is supported in the definitions
08:04fogusrhickey: I see what you mean now. For that angle I agree
08:05foguss/For/From/
08:05sexpbotrhickey: I see what you mean now. From that angle I agree
08:05foguswhoa!
08:05_na_ka_na_:)
08:07LauJensenrhickey: any clues as to how close 1.2 is ?
08:15_na_ka_na_rhickey: thanks! for the clue, got it - used a map to simulate, one more question: is it possible to declare methods with variable number of args in protos?
08:15clojurebotmap is *LAZY*
08:15_na_ka_na_clojurebot: not the fn, but the ds
08:15clojurebot|monads| is "yea, though I should walk in the valley of imperative code, I shall fear no evil, for your monad comforts me" - seen in #haskell
08:16_na_ka_na_:)
08:18rhickey_na_ka_na_: no variadics in protocols, you can write a variadic fn that calls a protocol fn. Remember, a protocol is not (necessarily) a consumer API, it is an abstraction implementor's API
08:19cemerickI was way too overenthusiastic in my first run at using prolog. It was a trail of tears in the end, as I'll bet it is for most.
08:20rhickeyLauJensen: close
08:21LauJensenGreat
08:21foguscemerick: More blood than tears for me
08:23rhickeyfor that subset of Prolog that it covers, Datalog is far superior IMO
08:23cemerickfogus: thankfully, I wasn't using it in conjunction with an active project, just research-y stuff. Lots of good lessons though. Prime among them being the declarative > imperative one.
08:24npoektop,(str "\/")
08:24clojurebotUnsupported escape character: \/
08:24rhickeyfogus: yes, Bratko is great, but I just recommended it to someone and it appears to be running out of print!?
08:25npoektopcan't write "\/", it says java.lang.Exception: Unsupported escape character: \/
08:25npoektop,(str "\/")
08:25clojurebotUnsupported escape character: \/
08:25gregh,(str "\\/")
08:25clojurebot"\\/"
08:26greghis that what you're looking for?
08:26npoektopgregh, i need "\/", not "\\/"
08:26fogusrhickey: But the Clocksin and Mellish book will continue forever... there's no justice.
08:27gregh,(print "\\/")
08:27clojurebot\/
08:27greghstr is showing you the escaped representation of the string "\/"
08:28npoektopgregh, cool. thank you
08:36fogusThere seems to be a steady flow of former Rubyists coming into Clojure. Maybe the Scala stream will start picking up soon. ;-)
08:37ryoko-shaNewbie apols in advance - (clojure.contrib.prxml/prxml [:p {:class "red"} "cat"]) => <p class="red">cat</p>nil where's nil coming from?
08:37chouserryoko-sha: that's the return value
08:38cemerickfogus: are you still solidly in scala for work?
08:38chouser<p ...through p> is what prxml is printing, but then it returns nil which the repl prints for you.
08:38ryoko-shachouser: thanks!
08:39foguscemerick: The projects that I used it for are mostly stable now. Working on the Clojure sell at the moment.
08:39rhickeyfogus: so, what is the Clojure sell to Scala folks?
08:40chouserI've recently begun starting my repl with non-default options so that I get a green ----- between prompts, and the return value prints in blue.
08:40cemerickClojure: it eliminates the need for psychotherapy!
08:40fogusI hate to say it, but I haven't been pushing for Scala lately.
08:40chouserryoko-sha: which helps point out the difference between printed and returned values.
08:41eintrchouser: that's neat, sort of like ipython's fanciful coloring. care to share?
08:41chouserhm, I suppose I should.
08:42fogusrhickey: The thing that I see coming up more and more is that people are blown away by the complexity of Scala (2.8 will only make that worse). Many people come into it thinking it's Java++ but find out that the ++ part is superficial
08:43bozhidarfogus: can you elaborate on the complexity part?
08:43fogusIMO, I think Scala should not try to sell itself as the "next Java" and just stand on its own merit and push an interop story instead.
08:43rcgchouser: how did you set these options?
08:43cemerickI thought the throwaway comment about the XML literals in that scala thread was a huge red flag. Not the kind of design work you want to see going into one's language.
08:44bozhidarI'll be doing a research for my company about modern alternatives to Java on the JVM that will be featuring Groovy, Clojure and Scala and of the three only Scala is a complete mystery to me at the this point
08:44fogusAlso I think going half-heartedly at the mutability problem is wrong. But I do not have an appreciation for the complexities of immutable FP/OOP
08:45cemerickbozhidar: this is a popular recent thread that touches on the complexity/"large language" topic: http://scala-programming-language.1934581.n4.nabble.com/The-right-tool-td2220305.html
08:46sexpbot"Nabble - Scala - The right tool"
08:46bozhidarcemerick: thanks, I'll have a look at it
08:46fogusrhickey: I guess the sell is simplicity. Simplicity beyond the initial "Clojure looks weird" hurdle.
08:47LauJensenfogus: the simplicity, and the immutability are what put Clojure miles and miles and a few lightyears ahead of Scala
08:47bozhidarif it were up to me I'd be researching only Clojure, but my boss is convinced that Scala is the future top language for the JVM for some reason
08:47rhickeyfogus: ok, thanks
08:47foguscemerick: The sad part about that comment was that I was (at one point) maintaining that stuff. I guess I am glad that I got out when I did
08:48bozhidarI've noticed that the Groovy creator is currently spending more time on Scala than on Groovy, so I thought that the language probably has some merits
08:48greghbozhidar: maybe because twitter uses it. :)
08:48fogusbozhidar: That thread (IMO) typifies Scala perfectly.
08:49cemericktypifies! Ha!
08:49fogusbozhidar: I think it has many merits.
08:49bozhidarI'm reading the thread right now :-)
08:50cemerickfogus: I just don't understand how it could have gotten in the first place. Perhaps part of it is that the language really is an academic experiment at its roots (i.e. trying to prove the applicability of FP in "practical" usage). Seeing XML literals in code like that is just *so* offensive.
08:50bozhidarfogus: I guess so, no language becomes that popular without merits
08:50bozhidarexcept maybe BASIC
08:50bozhidar:-)
08:50Hodapp*cough*C++*cough*
08:50greghbasic's merit was that it was the only choice :)
08:51cemerickbozhidar: don't hate on the BASIC. :-) RealBasic is pretty great for what it does.
08:51foguscemerick: Having spent (more time than I'd like to remeber) time in that code, I can say that it is poorly implemented, wrongheaded, bolted on, and other things that I should not write in a public forum.
08:51bozhidarcemerick: haven't even heard of it
08:51cemerickfogus: I'll do you the favor of letting someone else send that OH tweet :-)
08:51HodappBASIC is great for teaching the... uh... basics, but it's the sort of language that needs to be moved on from before awful habits set in
08:52bozhidarHodapp: I think Pascal better suits the learning bill
08:52cemerickbozhidar: it's a cross-platform RAD tool http://www.realsoftware.com/realbasic/
08:52sexpbot"REAL Software: REAL Studio, Best Development Tool for Mac, Windows and Linux"
08:52bozhidaror Lisp of course
08:52foguscemerick: ;-)
08:52chouserhttp://gist.github.com/407528
08:52cemerickdelivered my first paid consultant-ware with it
08:52Hodappbozhidar: When I say "basics", I mean the really basic basics, like the fact that a program is a pile of instructions and has variables and that loops and branches can exist.
08:53Hodappbozhidar: They man move into scoping and functions later. Like, a month or two later.
08:53Hodapps/man/can/
08:53sexpbotbozhidar: They can move into scoping and functions later. Like, a month or two later.
08:53Hodappo_O WHAT!?!?!
08:53ryoko-shachouser: thanks for that
08:53bozhidarHodapp: I know what you mean, but what I meant was that Pascal was created to serve mostly educational purposes
08:53bozhidarand makes stuff clearer than basic does
08:53Hodappbut I'm rather glad it's rarely used anymore
08:53bozhidarat least in bulgaria all introductory programming courses are in Pascal
08:54bozhidarsometimes in C
08:54Hodappit's mostly been replaced by Java here
08:54bozhidarbut very very rarely
08:55bozhidarsome mixture that was :-)
08:55rcgchouser: thanks :)
08:55rsynnottbozhidar: they were in the middle of transitioning to java
08:55bozhidarfogus: lucky bastard ;-)
08:55rsynnottif I'd been there a couple of years earlier it would have been scheme, as well
08:56rsynnottoh, we also did prolog as an introductory thing (though with a focus on AI-ish applications)
08:56bozhidarI'm not sure that Java is a good choice for a first programming language
08:56ryoko-shaAlgol-60 & BCPL - I'm a little ancient
08:56bozhidaralthough I have to admit that I've thought introductory programming courses in the university with Java
08:56rhickeyso, the current strategy for improving last-refer-wins is to preclude a referred var from overwriting an interned one
08:57bozhidarused to be perl before
08:57rhickeythoughts?
08:57bozhidarif I select some lisp dialect probably noone will come...
08:58Bendlashi folks
08:59cemerickrhickey: reviewing my notes
09:00chouserso last would still win when something has been copied from contrib to core, or when you define something yourself that gets added to core.
09:01rhickeychouser: yes, same as now, only say, in repl, you won't be able to trash you own ns vars with a refer/use
09:01rhickeySo, in reference to these problems: http://groups.google.com/group/clojure-dev/msg/fca78d8b00d3d6b7
09:01rhickey#1 I consider a non-problem
09:02rhickeyalso, #2 seems under-motivated
09:02rhickeythis fixes #3
09:03rhickeyand #4
09:03cemerickrhickey: I'm surprised that #1 isn't an issue for you.
09:04rhickeycemerick: why? This is a Lisp and load == run all expressions
09:05rhickey:use load-cannons fire-cannons
09:05rhickeynot that I'm recommending that :)
09:06cemerickRight, I think #1 not erroring on same-named vars being referred from 2 different ns' means that use is simply nuclear for any real code, unless you maintain the ns' being used.
09:06cemerickThe appeal to Lisp is fine and all, but sort of ignores the practical consequences of using libraries.
09:07rhickeycemerick: I don't see how, there's a warning. It's not a silent switcheroo
09:07cemerickthus my instinct to make all ns-effecting changes fundamentally transactional, though that's certainly out of scope, and probably not going to happen
09:08rhickeycemerick: you wouldn't like the performance implications of that
09:08cemerickWarnings are noise. No one pays attention to them.
09:08cemerickreally? That only impacts load-time, no?
09:09rhickeycemerick: no, how are you going to see any changes?
09:09rhickeycalls do no lookup now, so you can't simply put a ns-map in an atom
09:09rhickeyeach var would have to be a ref
09:10cemerickI think you'd only have to have refs in Namespace, but yeah, I see your point.
09:10rhickeyI considered it early on, but couldn't justify the overhead full-time on every call
09:10rhickeyrefs are not nothing
09:11cemerickThe results of an ns decl could be unpacked after each ns-effecting action so as to avoid the costs.
09:11rhickeynow, in a direct-linking world, that is very doable and fast
09:11rhickeycemerick: I don't see what you are saying re: unpacked
09:13cemerickrhickey: the contents of the mappings and aliases references could be lifted into refs (for all ns'es that are impacted by a load, etc), and then unpacked back into the AtomicReferences after the transaction has succeeded.
09:14cemerick...but all this is sorta straying from the topic, unless drastic changes under the covers are on the table as a possibility.
09:14rhickeycemerick: so, you are really more interested in all-only-if-nothing-fails ns load than truly transactional visibility
09:14cemerickright
09:15rhickeycemerick: these loads and warning aren't runtime things, they are things you'll encounter during dev and work out
09:15rhickeyI don't see the nuclear threat you do
09:15cemerickI think that's the common conception, and what I was referring to as the above potentially simplifiying the mental model people need to build to really understand namespaces, load, etc.
09:17cemericksay you have an ns that uses A and uses B. In a new version, B adds a fn that is similar to a fn found in A, and named the same. You get a warning, but ignore it because your tests pass.
09:17cemerickAnd we all know that all tests are entirely comprehensive in terms of prodding the full domain of the functions in question.... :-P
09:17rhickeycemerick: a big problem with 'transactional load', even if only for the all-succeed-or-no-effect, is that the vars truly need to be refs, and always, lest the loading code not see and use its own defs as it proceeds to load
09:18cemerickrhickey: bleh, good point.
09:19rhickeycemerick: so you'd be happ(y/ier) with a *treat-load-conflicts-as-errors* option?
09:20cemerickI doubt it. I'm hoping to see things get simpler, not add more options. :-)
09:21rhickeycemerick: then what is your version-to-version compatibility story "suck it up, and suffer until your lib vendors do the same"?
09:21rhickeyor cgrand's :as-of lockdown?
09:21cemerickheh
09:21cemerickI have a lot of sympathy for those hitting conflicts arising from core adding things.
09:22cemerickI have much, much less sympathy for those doing blanket use all over the place.
09:22rhickeyor core/this core/that everywhere?
09:22cemerickOf course, those doing that write a lot of useful libs people depend upon.
09:23rhickeycemerick: blanket use was never good, and still isn't. This isn't about enabling that
09:25rhickeyI haven't seen many viable alternatives, but am still open
09:29rhickeyno more additions to core?
09:30cemerickheh
09:30cemerickrhickey: why treat core refers the same as all other refers?
09:30cemerickI mean, beyond the appeal of simplicity.
09:30rhickeycemerick: vs what?
09:37cemerickPerhaps last-refer-wins should apply to core and nowhere else.
09:37rhickeycemerick: ah
09:38SynrGwin 2
09:38cemerickI think that's what chouser was driving at when we talked about this in the irc log I linked to in my post.
09:38SynrGbuh
09:38cemerickit's certainly a complication, but there's already a special :refer-clojure form in ns
09:42rhickeycemerick: it is kind of special-case-y, but mirrors implicit refer of core
09:42cemerickrhickey: it'd actually have to be, last-refer-wins for any var name that is in core, not just for actual core vars
09:42rhickey?
09:43cemericke.g. ns A defines a reduce fn. ns B uses A. Presumably, that use shouldn't error out.
09:44rhickeyI don't see the difference
09:44cemerickMaybe I'm overthinking it.
09:45rhickeyyou are never actually replacing something in core, only the slot in your ns
09:45rhickeywhich is re-filled with stuff from core
09:45rhickeypre-filled
09:46cemerickOK, say ns A defines a reduce fn, which takes precedence over core's reduce.
09:47rhickeyok
09:47rhickeythen B uses A
09:47cemerickns B then uses A. If last-refer-wins strictly applies only to core, then that use will fail, right?
09:48rhickeyno, since the reduce in B refers to core/reduce, this rule applies. It's not different from (def reduce ...) in your own ns
09:48rhickeybasically, you can't bump out references to core vars, by whatever means, with a warning
09:48rhickeycorry - can bump out
09:48rhickeysorry, can't type
09:48cemerickach, right, ok, I had things inverted
09:50cemerickrhickey: I think it's at least worth seeing how it plays, unless you dead-set against.
09:50rhickeyso, I am inclined towards this restriction of last-var-wins
09:50cemerickStellar. I think it's a big improvement on spec.
09:50rhickeywould obviate the no-overwriting-interns, so no more complex
09:50rhickeyand would still warn
09:51cemerickFalling back on warnings is such a red flag to me. Begs for a *strict*, which is yet another red flag.
09:51rhickeyI wonder if it covers all migration pain cases
09:52cemerickThat's what the beta/RC is for, I suppose. :-)
09:53rhickeycemerick: one problem is that te lib community is relatively responsive, so they will chase the changes. We won't find out about older/orphaned/in-house libs till later
09:54rhickeybut this will let us ship the contrib code in place as dprecated for one release, which will prevent breakage of :use a-contrib-lib :only some-name-now-in-core
09:54chouserjust flush them out -- find one important var from each major lib and add it to core.
09:54cemerickrhickey: I think that's going to be par for the course.
09:54chouser:-)
09:55rhickeychouser: http://github.com/stuarthalloway/argos
09:55chouserhuh!
09:55chousernice
09:56cemerickI suspect the rate of change isn't going to drop much for a long while, so stuff that languishes is going to have a rough time with each upgrade.
09:56chouserso I went to a meetup last night and found it energizing in roughly the way that writing a book is not.
09:57rhickeycemerick: need not with this mechanism, at least one release with libs in place, deprecated
09:57esjchouser: lol
09:57chouserrhickey: hm! interesting. why?
09:57rhickeychouser: :)
09:57rhickeyI missed my NYC Clojure meetup thinking it was tonight :(
09:57cemerickrhickey: no, but ^ and who-knows-what-else will do it this time around
09:58rhickeychouser: why remove them? because they are ugly
09:58chouserfogus: seriously. gimme a break! ;-)
09:58_na_ka_na_:rhickey IMO the focus should be the majority of noob/new developers (like myself)
09:58cemerickMakes for nicer interop, no? new my.clojure.function().invoke(foo, bar, baz)
09:58foguschouser: I know what you mean though.
09:58_na_ka_na_Not everyone (esp. newcomers), I figure read/care about the warnings, ref: app server warnings!
09:59_na_ka_na_The lib writers / experienced coders will get around I'm sure, no matter what the final solution.
09:59rhickeycemerick: ouch! who's doing that?
09:59_na_ka_na_Some people may blindly / unintentionally wrongly assume their code to be "1.2 complaint" when there are warnings..
09:59_na_ka_na_So I think overall *treat-load-conflicts-as-errors* would be better?
09:59cemerickrhickey: no one, but that would become possible given elimination of _1234, no?
09:59RaynesAin't that the pot calling the kettle black! I fixed at least 4 mistakes fogus made in the tryclojure tutorial. ;)
10:00rhickeycemerick: I hope not. I'm not promising that fns can be created that way. Calling through vars vastly preferred
10:00fogusRaynes: Writing a book and spelling/grammar ability are orthogonal. :p
10:00chouserone thing I thought was interesting: almost everyone there claimed to have dabbled with clojure some (no questions about basic syntax), but almost none seemed confident about reference types.
10:00cemerickrhickey: Sure. Just trying to make my UI programming easier. :-)
10:00rhickeycemerick: but stack traces etc should clean up a good bit
10:00cemerickthat's always good
10:01cemerick_na_ka_na_: more options are almost always bad, IMO. There should be a "right way", or at least an optimal compromise. Simpler is better.
10:01foguschouser: Slides?
10:01powr-tocI'm using c.c.sql with-query-results, and I need to dissoc a key from the result set, obviously as it's a struct I can't... so whats my best approach? (dissoc (merge {} rs) :key) ?
10:01rhickeyunfortunately the last step is a doozy, and I might back it out
10:01chouserfogus: http://github.com/Chouser/clojure-talk-conc
10:02_na_ka_na_cemerick: thats my point *treat-load-conflicts-as-errors* is simpler for the majority?
10:03cemerick_na_ka_na_: the majority won't even know about the option to begin with :-)
10:04_na_ka_na_cemerick: Of course I mean default *treat-load-conflicts-as-errors* to true :)
10:04cemerick_na_ka_na_: oh -- well, that was the default before :-) The aim is to cause a minimum of upgrade pain due to additions to core.
10:05rhickeythe remaining hurdle is the redefs in core itself, related to e.g. bootstrapping w/o destructuring, then adding it etc
10:05rhickeyI wonder how often other libs do similar things
10:06_na_ka_na_cemerick: but the point is correctness might go for a spin, unintentionally
10:17_na_ka_na_creating much up-gradation pain is preferable to shaky semantics?
10:20cemerickI think the hope is to satisfy both criteria.
10:23_na_ka_na_Any idea about the error - "Can't find matching method: foo, leave off hints for auto match." ?
10:24_na_ka_na_Proto: (defprotocol P (foo [this f])), Type: (deftype PImpl [] P (foo [this ^String f] (FileWriter. f)))
10:24jweisscemerick: i notice you contribute to the clutch couchdb lib. i'm having trouble getting the view server to work, currently it just quits after couchdb starts it. i am not quite sure which version of clojure it's expecting me to be using
10:25cemerickjweiss: the master branch is 1.2
10:25jweissthere's a 1.1 compatible branch, which oddly, when i run lein deps, installs clojure-1.2 snapshot jars
10:25cemerickhrm
10:25jweissi can use 1.2, that's no problem
10:26cemerickjweiss: we're merging the two branches today-ish, and dropping 1.1. entirely.
10:26cemerickThat's just FYI.
10:26jweisscemerick: meaning that it won't work with 1.1? or it will work with either
10:27cemerickMeaning that it will probably not work with 1.1. I don't use 1.1 at all, and I don't think Tunde does either, so maintaining the 1.1 branch is problematic for us.
10:28jweisscemerick: i see. isn't it unusual not to support the latest release of the language? :)
10:28cemerickDepending on my level of motivation, I may cut a final 1.1-compatible branch that will get no new features.
10:28cemerickjweiss: heh, perhaps. Clutch is decidedly scratch-my-itch territory though, and I haven't used anything on a 1.1 track since Novemberish I think.
10:29jweissi see, well, if clojure-1.2 works for people here, it should work for my newb self
10:29cemerickPerhaps I'll stand up a public hudson. That'll make supporting different versions of these libs a lot easier.
10:29cemerickUnderstand, I'm not *opposed* to having a 1.1-compatible clutch, it's just a workload issue.
10:30jweisscemerick: that's fine, i'm not constrained to a particular clojure version
10:31jweissalthough i haven't actually tried with 1.2 yet, i hope compojure works with it, i assume so
10:32cemerickI think HEAD is. There are branches here and there of 1.2-compatible 0.3.x-era compojure as well.
10:54Raynesfogus: <3 for the encouragement.
10:55RaynesExtremely helpful for a young, terrified padawan such as myself. <3
10:58texodusThere's no way to attach metadata to Classes, I assume?
10:59Chousukenope.
11:00texodusso documenting deftypes and defrecords is just plain out ...
11:01Chousuketexodus: hmm
11:06eintrchouser: modded your repl-init. added some flair to exceptions as well, and tuned colors for 256 color terms: http://gist.github.com/407622
11:06chousereintr: whew!
11:07remleduffWhy do you do clojure.main -e "(my-repl)" rather than just calling (my-repl) at the end of repl-init?
11:07chouserhm. I dunno.
11:08eintr:)
11:09sanityincI posted on the list about a sticky problem I'm having with protocols. Am I doing something obviously dumb? - http://groups.google.com/group/clojure/browse_thread/thread/e2e36ab8b7630e38
11:10rseniorsanityinc: do you have AOT compiling enabled?
11:10sanityincOnly if that's the default.
11:10jweisscemerick: i notice you also work on an ssh lib for clojure, that "with-ssh-agent" macro, is that using pre-decrypted private keys a la unix ssh-add?
11:11jweissi have been looking for a way to do that with java (not necessarily with a unix ssh-agent, which i doubt is possible) but with any agent
11:11cemerickjweiss: it also supports passphrase-protected keys :-)
11:11jweisscemerick: did you implement that or is it part of jsch
11:12cemerickthat's all jsch. It definitely works, but is a miserable API.
11:12rseniorI had that issue when I had old class files sitting out there that were taking precedence over my newly evaluated protocol definition
11:12cemerickjweiss: hugod is actually your point man for clj-ssh stuff
11:12jweisscemerick: so what ssh agent does it use? not compatible with linux's i assume
11:12cemerickno -- I'm pretty sure it's an in-memory impl provided by jsch
11:12sanityincrsenior: I can reproduce the problem with a completely empty project
11:13remleduffsanityinc: I'm not sure it would make a difference, but does it change if you do (require 'protoproblem.proto :reload-all) instead of "load"?
11:13jweisscemerick: oh, that's too bad. i was looking for a way to have my code not have to prompt my users (they could add their key via some other means and have it stay there even if the jvm goes away and comes back later)
11:14sanityincremleduff: Nope, I tried that too
11:14hugodjweiss: pallet adds some code to query the osx keychain - I need to move that into clj-ssh
11:14cemerickjweiss: pallet has OS X keychain support, which will probably make its way into clj-ssh eventually. A linux-flavored impl is conceptually possible, but I don't know what that would look like.
11:14hugodsnap
11:15jweisscemerick: to use unix ssh-agent would require unix sockets which java doesn'tdo
11:16jweisswhich is really irritating that basically java and ssh are incompatible
11:16sanityincIt's quite a surprising misbehaviour, and having to quit the JVM to fix it sucks.
11:17jweisscurrently there is no way in java for people to use their "real" ssh key and not get prompted to unlock it every time they run a jvm
11:17jweisswe are currently just using a throwaway key with a password that we don't care if it sits in a plaintext file
11:17jweissnot secure, of course
11:27sanityincNeedless to say, since it seems like a class loading / caching issue, it's pretty much impossible to see what's going wrong.
11:39hoecksanityinc: confirmed here, but after defining ArraySteps without a protocol (deftype ArraySteps []), and then redefinging the protcol-implementing ArraySteps type, it works :/
11:41sanityinchoeck: yikes. I've kinda assumed it's something to do with caching of protocol methods / classes. I'm going to try reify instead of deftype to see if the same thing happens.
11:44hoeckredefining the same ArraySteps over and over again doesn't change the Class
11:45sanityinchoeck: Ah, now, using reify solves the problem. So it looks like deftype is broken, or at least doing something unexpected.
11:46hoecksee http://gist.github.com/407710
11:46sanityinchoeck: so (defn arraysteps [a] (reify proto/Steps ...)) is fine
11:46hoeckseems like deftype does some weird kind of caching
11:48sanityincThe macroexpansion suggests that, yes. But I'm not smart enough to see exactly what's going wrong.
11:49hoeckwhen you load your file the third time, the deftype is evaluated but nothing has changed in the deftype implementation, so the "redefined Steps protocol is not implemented
11:50hoeckmaybe there is/was a reason to not create a new class for identical deftypes
11:52sanityincI can see how that would be desirable, but changes in the underlying protocols should also be taken into account, I guess.
11:52hoeckright
11:53sanityincSo... does this warrant an Assembla ticket?
11:53jweisscemerick: does clutch work with couchdb 0.10.2?
11:54cemerickjweiss: I'd hope. No?
11:54hoecksanityinc: I guess you have to ask rhickey about this :)
11:54jweisscemerick: i am still having the same problem with the view server after updating to clojure 1.2
11:54cemerickwhat's the issue?
11:55jweissit is exiting with return code 1 as soon as i try to load a view in futon
11:55jweissi didn't check yet to see if it's the same error, but last time it was a JSON error
11:55cemerickhrm
11:55jweisslet me check the couchdb log
11:58jweisscemerick: ah, trying to start the view server with the same cmd from the local.ini on the cmd line gives:
11:58rhickeysanityinc: yes, please create a ticket for this and set to milestone 1.2
11:58jweissCaused by: java.io.FileNotFoundException: Could not locate clojure/contrib/json/read__init.class or clojure/contrib/json/read.clj on classpath:
11:58sanityincrhickey: Thanks - will do.
11:58cemerickjweiss: ah, well, that's a lot simpler of an issue :-)
11:59jweissoh i fat fingered the classpath
12:04jweisscemerick: looks like the same problem still- it's looking for contrib/json/read.clj but that's not in contrib-1.2
12:04jweissi am using clutch 0.2 from leiningen
12:05jweissis there a newer jar i can point to in project.clj
12:06cemerickjweiss: if ashafa could talk, he'd say the jar in clojars is 1.1-only
12:06cemerick:-)
12:07cemerickI don't think any newer deployments have been done of it.
12:12jweisscemerick: the view server and the clutch lib don't need to be the same version do they?
12:12cemerickhrm, probably not
12:13cemerickcould get confusing though
12:14cemerickjweiss: ashafa says "if he uses clojure 1.1 in project.clj, he could just run lein superjar"
12:15cemerick(I guess he doesn't have voice here or something)
12:15mmarczykhe should register his nick with NickServ, then
12:16cemerickis that actually required to get voice? I haven't been anon in a long time, but I don't remember it being required.
12:17mmarczykwell, I've had connection problems a couple of times recently, reconnected with a temp nick (mmarczyk`) and couldn't talk here
12:17mmarczykthen reconnected in the usual way and all was fine...
12:18mmarczykI guess that's not enough to draw the conclusion that registering is required, but it's worth a shot
12:25esjwhen using :gen-class and :extends on a java class I'm not getting the protected methods of that class. Is this expected ?
12:29jfieldshow do you filter nil objects? (filter x? coll) what's x?
12:29remleduffidentity
12:29chouseresj: you need :exposes-methods
12:30esjchouser: I have em.
12:30remleduffThough identity will filter "false" too
12:30Raynes$(remove identity [1 2 3 nil 4 5 6 nil 7 nil 8])
12:30sexpbotresult: clojure.lang.LazySeq@745f
12:31Raynes$(remove nil? [1 2 3 nil 4 5 6 nil 7 nil 8])
12:31RaynesEh.
12:31sexpbotresult: clojure.lang.LazySeq@6b4b5785
12:31esjjfields: (complement nil?) might work too
12:31jfieldsremove does what I want. thanks
12:32esjchouser: using show from repl-utils lists all the superclass methods, even w/o :exposes-methods. But even with an explicit :exposes-methods I can't get the protected methods to join the party. Sulky.
12:36remleduffHmm, gen-class documentation claims that it exposes all "non-private" superclass methods, which I'd think would include protected methods
12:37esjindeed.... let me mock up a toy example and get back to you all
12:42remleduffesj: Are you including the prefix?
12:43esjin the call ? no. just doing (.methodSure this arg)
12:43esjs/Sure/Super/
12:43sexpbotin the call ? no. just doing (.methodSuper this arg)
12:46remleduffhm
12:46sanityincRe. the protocol/deftype issue discussed earlier - looks like I can't file an Assembla ticket after all, as a non team member. Can anyone file it on my behalf pls? Steps to reproduce: http://groups.google.com/group/clojure/browse_thread/thread/e2e36ab8b7630e38 . Problem not present with reify; just a deftype quirk.
12:48remleduffYou should be able to make a "support" ticket as a watcher
12:48sanityincAha, gotcha. Thanks.
12:56arohnercan someone test https://www.assembla.com/spaces/clojure/tickets/285-make-it-easier-to-discover-the-source-of-compiler-exceptions-when-two-files-have-the-same-name-in---#last_comment so we can get it in?
12:56sexpbot"#285 - Make it easier to discover the source of compiler exceptions when two files have the same name in different directories (Test) | Clojure | Assembla"
12:56sanityincOkay, support ticket filed, but perhaps a team member can move it to the 1.2 milestone as requested by rhickey? - https://www.assembla.com/spaces/clojure/support/tickets/353
13:00remleduffHa, I can't seem to do that for a support ticket
13:03remleduffThere we go
13:11esjrats - in the toy example protected methods do appear
13:11esjmore homework for me
13:15esjAHA ! its a protected FINAL method that won't come around. Should have read the FULL javadoc, not the summary line which didn't list the final.
13:18esjbut that does not explain why :exposes-methods won't let me see it
13:19sanityincremleduff: thanks
13:20remleduffWow, generate-class is a huge function
13:20esjremleduff: oh yeha
13:21esjremleduff: i'm guessing that :exposes-methods creates a new method that in fact overrides the superclass with a thin wrapper
13:21remleduffBut can't do that for final methods :\
13:22esjindeed
13:22esjbut now how do I get to the superclass method, which i don't want to override
13:27remleduffCan you paste your example code for me? I'm trying to follow along ;)
13:27esjsure: http://gist.github.com/407826
13:27esjsorry... 1 sec
13:28esjhttp://gist.github.com/407831
13:29esjI'm going to ask in the google group, I'm stumped
13:30jweisscan the stable release of leiningen be used to build projects that depend on clojure1.2? mine is failing all over the place
13:30jweisshttp://fpaste.org/zYiL/
13:31powr-tocDoes anyone know a way to do the following? (apply (partial struct-map foo) { :foo :bar})
13:31powr-tocI'd like to convert a map into a struct-map
13:32chouserwow, I just found my first use of :>> in condp
13:32chouserthat is one obscure feature.
13:35jweisscemerick: any idea why i get the error in that paste above trying to run lein install on clutch master branch?
13:37remleduffesj: Do you also get the message "java.lang.VerifyError: class foo.Foo overrides final method baz" that I'm seeing?
13:37esjthat's the one
13:38powr-tocHow can I do this? (struct-map foo {:foo :bar }) I need to convert a map into a struct map, as I want my keys to be in the order specified by struct-map
13:39powr-toc(well specified by the defstruct)
13:39cemerickjweiss: none off the top of my head -- I use maven though
13:39cemerickbbl
13:39savanniHey, brief question today. What is the naming convention for functions that have side effects? In this case, I am writing a function that updates a database and then returns data based on that update.
13:40esjsavanni: often they have a ! at the end of the name
13:41savannik, I thought about that. The coding standard I am reading says to use ! for an unsafe STM transaction, but I don't know what it means to be unsafe in STM.
13:41savanniAnd, this database update is not happening in STM.
13:42chousersavanni: is it safe to do the same call a couple extra times, or does each call make more or different observable changes to the database?
13:42savanniEach call makes observable changes.
13:42chouserok, that would not be safe to do in a transaction
13:43chouserso a ! suffix is appropriate
13:43chouseryou can even use io! in the body of the function itself so that attempts to use it in a transaction will throw an exception instead
13:44savanniWait, why is that unsafe? Is it because the database cannot be rolled back in the case of a failure?
13:45Hodappyikes, the assholishness of ##c++ is astounding...
13:50ataggartsavanni: it's because the STM transaction may be retried
13:51savanniAh, I had not tohught of that.
13:51savanniWhere is some good documentation on the subtlies of STM? Something that if I had read and thought about I would have realized that?
13:52chousersavanni: http://clojure.org/refs
13:52chouser"I/O and other activities with side-effects should be avoided in transactions, since transactions will be retried. The io! macro can be used to prevent the use of an impure function in a transaction."
13:52savanniOkay, awesome. Thank you!
13:55esjchouser: remleduff just pointed me to a post of yours http://osdir.com/ml/clojure/2009-09/msg00452.html which is exactly the problem I've just stubbed my toe on. Did you resolved it ?
13:55sexpbot"Re: Accessing a protected final method of the superclass - msg#00452 - clojure"
13:57chouserI don't recall that specific issue, and don't see any follow-up on the ggroup. So ... I guess not.
13:57chousergah! expired paste!?
13:57chouserthat really really sucks
13:58chousermakes my reply there alomst completely useless
13:58esjchouser: rats !
13:59remleduffgenerate-class still calls non-private-methods which filters out final methods as well, so I don't think it's been fixed
14:04jfieldsis there a function that takes [1 -1 2 -2] and returns [[-1 -2] [1 2]]?
14:07esjso, in this case, assuming I can't use gen-class to make .class files, what other options do I have ?
14:10esjthat many huh.... i feared so :)
14:15chouseresj: .java :-(
14:17Borkdudejava? :(
14:20BorkdudeIs there a way to find e.g. where partition-all is, without requiring its namespace (because I don't know it), with find-doc, or similar?
14:21fogusBorkdude: Google always works for me. ;-)
14:22remleduffesj: (def Hello-Forwarder (proxy [com.example.Hello] [] (yo [] (proxy-super yo))))
14:22remleduffthen (.yo Hello-Forwarder)
14:24remleduffBut, that may not work depending on what you need to do in gen-class
14:25esjit is a new and different object
14:26Borkdudefogus: Google, yes, brilliant ;)
14:27Borkdudeso, google is a function in what namespace exactly? ;)
14:31HodappBorkdude: ALL NAMESPACES!
14:35mmarczykBorkdude: you can always use clojure.contrib.find-namespaces to require every namespace you've got on the classpath
14:35mmarczykand then use find-doc
14:43LajlaHodapp, how do namespaces work in Clojure?
14:46Borkdudemmarczyk: I did (find-namespaces-on-classpath)
14:46Borkdudemmarczyk: but it doesn't find e.g. mexpand-all
14:46Borkdudeit=find-doc
14:50Borkdudemmarczyk: should I use map to require all of the namespaces returned by find-namespaces-on-classpath?
14:56Borkdudehmm, is clojure.walk/macroexpand-all a replacement for macro-utils/mexpand-all?
15:23Borkdudehttp://twitgoo.com/wjpd5
15:23sexpbot"Hanging out with #deadline #clojure #compojure #appengine at #io2010"
15:33chouserwhat's going on here? http://gist.github.com/407980
15:33chouserwhy doesn't (gettag x) return String ?
15:36chouserrhickey: any hints?
15:40ninjuddchouser: what does &env mean? i haven't seen that syntax
15:41Borkdudechouser: same question, it only works in 1.2 I just noticed
15:44chouserit's new macro magic
15:45ninjuddchouser: what does it mean?
15:47chouserif gives you the lexical scope at the point where the macro is expanding
15:47chouserit gives
15:47Borkdudehmm
15:47chouserwhich I'm abusing to do things that would otherwise require a code walker
15:48remleduffDoes a &prefix have some special meaning?
15:48chousernot generally. macros now have &env and &form
15:50Borkdudechouser: is (find &env sym) to equivalent to [sym (eval sym)]?
15:50mmarczykBorkdude: yeah, you'll have to use require on the namespaces
15:50mmarczykBorkdude: find-namespaces-on-classpath only finds out which namespaces are available
15:51Borkdudemmarczyk: ic
15:51Borkdudemmarczyk: I used (map require (find-namespaces...))
15:51Borkdudethen I got an exception along the way, but it used most of them....
15:51mmarczykwrap it in a dorun if it's in a source file
15:51mmarczykan exception? interesting
15:52mmarczykanyway, wait a sec, I think I have a link for you
15:52rhickeychouser: did you intend to use the same local name twice?
15:52mmarczykhttp://learnclojure.blogspot.com/2010/02/requiring-all-possible-namespaces.html
15:52sexpbot"Learning Clojure: Requiring all possible namespaces"
15:53chouseryes
15:53chouserthis is generated code, and I'm trying to attach meta data on the inner one and pick it up in the macro
15:54chouserthe compiler seems to do the right thing for :tag, but I can't seem to get at it using &env -- it finds the first local instead
15:56chouserBorkdude: no, not equivalent.
15:57chouserBorkdude: the values in the &env map are CompilerExpr objects (couldn't be runtime values as this is compile time)
15:57chouserBorkdude: the key returned by find should have the metadata attached to that local in the source, which may be different from the metadata on the sym I'm using to look it up.
15:58chouserwhich is the whole point. I know the name of the sym, but I want to know the metadata on the local of the same name.
15:59chouserI may be able to work around this, but it's bugging me.
16:06rhickeychouser: (map meta (keys (assoc {'^String x 11} '^Integer x 42)))
16:06rhickey,(map meta (keys (assoc {'^String x 11} '^Integer x 42)))
16:06clojurebot({:tag String})
16:07chouserah. so the compiler must be using something other than &env to figure out the :tag.
16:07rhickeychouser: the compiler is using the local binding info in the value, no longer the symbol after parsing
16:08chouserah, right. hmph.
16:09rhickey(defmacro gettag [sym] (.tag (val (find &env sym))))
16:10rhickeychouser: (defmacro gettag [sym] (.tag (get &env sym)))
16:10tcrayfordchouser: I gave up on getting locally bound vars using the compiler, was too icky when the form was using def. Cheers for your help though
16:16chousertcrayford: ok
16:18Borkdudemmarczyk: ah tnx, he catches Exceptions and wraps it in a doall, I see
16:18chouserrhickey: ok, I can get use .sym to get the metadata I really want.
16:18chousernot sure I want to do that though... hrm.
16:19BorkdudeI'm wondering if at this time it's better to post examples of 1.1 or 1.2 (namespace-wise) on my Twitter account
16:23chouseroh, actually I *have* to do that, or when someone writing the code shadows something without my knowledge, I'll pick up the wrong metadata. drat.
16:32riddochc(str "Good " (timezone-appropriate-greeting recipient) ", everyone.")
16:37Borkduderiddochc: (printf "%du%d" 2 2)
16:39The-KennyI read about a "irc standard greeting time" some time ago
16:40The-Kenny"If someone enters the channel, it's morning. Regardless of the actual local time. If someone leaves the channel, it's evening."
16:42The-Kennyhttp://www.total-knowledge.com/~ilya/mips/ugt.html "Universal Greeting Time"
16:42sexpbot"UGT"
16:46riddochcThe-Kenny: That's rather amusing.
16:47maxhodakis there anything already for doing rule-based systems in clojure (i.e., logic programming)?
16:48chouserdatalog?
16:48tcrayfordmaxhodak: I only know about http://github.com/jduey/mini-kanren
16:49tcrayfordmaxhodak: and the accomanying article: http://intensivesystems.net/tutorials/logic_prog.html
16:49sexpbot"Logic Programming for the Social Web"
16:49remleduffcascalog as well http://nathanmarz.com/blog/introducing-cascalog/
16:49sexpbot"Introducing Cascalog: a Clojure-based query language for Hadoop — thoughts from the red planet"
16:49riddochcmaxhodak: I'd heard of something not too long ago on clojure planet.
16:49tcrayfordhis monad articles are damn cool as well
16:51maxhodakriddochc: tcrayford: thanks guys
16:51maxhodakill check those out
18:57riddochcArgh. I can't remember the name of the function I'm looking for...
18:58riddochcI know there's more than one way to do this, too... I've got a function that produces key/value pairs, and I want to call it with something that collects them all together into a map, preferably without having to use 'apply hash-map', so it's lazy...
18:58Lajlariddochc, I think it's the factorial.
18:58LajlaOhh, not the factorial.
18:58tcrayfordriddochc: zipmap?
18:59tcrayford,(doc zipmap)
18:59clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."
18:59tcrayforddon't think its lazy though
18:59riddochctcrayford: That seems more appropriate for two separate seqs, one of keys, one of vals, right?
18:59tcrayfordconfirm
18:59tcrayfordyou can do that by breaking out your original seq into two things
19:00tcrayford(and can almost definitely do that lazily, but I can't remember the name of the function that does it)
19:01riddochcHm. Well, maybe I should step back a bit... I'm basically starting with something like (map #(let [[[all key val]] (re-pattern #"..." %)] {key val}) source)
19:02riddochcThere's probably a more idiomatic way to use the results of re-pattern, collecting parts of my matches as key/value pairs. I keep thinking assoc...
19:03riddochcHm. I could loop/recur over the source, and use assoc in the recursive step...
19:03tcrayfordthen wrap it with lazy-seq
19:03mmarczykhow would you go about constructing a map lazily?
19:03mmarczykI mean, in principle
19:03mmarczykwhat do you do if you attempt a lookup
19:04riddochctcrayford: Yeah, that would work. I could swear I saw something really similar in either clojure or -contrib, though...
19:05tcrayforddoes it need to be lazy?
19:05tcrayfordhow big is "source"
19:06riddochctcrayford: Not huge. Think email headers, for scale. (It's a git commit. So, rather short.)
19:07riddochcIt doesn't really need to be lazy.
19:07tcrayfordwell just use apply then?
19:07tcrayfordlazy maps don't really make much sense, as mmarczyk pointed out above
19:07riddochcYeah, yeah, I just keep thinking, "Functional! Generic! Perfectionism!" and such. *sigh*
19:07tcrayfordalternatively, you can use reduce
19:08riddochcReduce! Duh.
19:08riddochcReduce makes a *lot* of sense for this.
19:08tcrayfordsee http://www.tcrayford.net/2010/05/14/A-Tutorial-On-Reduce.html
19:08sexpbot"tcrayford"
19:08mmarczykyou could just use (comp reduce merge)
19:08mmarczykmeaning (reduce merge your-seq-of-single-binding-maps)
19:09tcrayfordnow we get point-free worked in as well
19:09tcrayfordjoy
19:09mmarczykor (reduce into {} your-seq-of-key-value-pairs)
19:09mmarczyk:-)
19:09riddochcYeah, I've used it before for other things, I think it didn't occur to me here because I'm still not used to thinking of my map as a reduceable. :)
19:09tcrayfordreduce is so damn powerful
19:09riddochcmmarczyk: Awesome.
19:09tcrayfordits crazy
19:10mmarczykfor breaking a seq into a seq of elements at odd positions and a seq of elements at even positions, (let [s input-seq p (partition 2 s) o (map first p) e (map second p)] [o e])
19:10mmarczyk;-)
19:10tcrayfordis there a complement to create-ns?
19:10tcrayfordthat deletes namespaces?
19:10mmarczyktcrayford: remove-ns, I think
19:10riddochctcrayford: Quite right, it is. Map and reduce, man. Not to be confused with google's mapreduce. Feh.
19:10mmarczyk(doc remove-ns)
19:10clojurebot"([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace."
19:10tcrayfordgotcha
19:10tcrayfordcheers
19:12riddochcmmarczyk: Thanks for the (reduce into {} ...) - that's beautiful, I'm using it.
19:12tcrayfordI think I prefer the comp one myself, but aye
19:13riddochcHmm. I don't have a seq of single binding maps, but I could arrange for that...
19:14riddochcWait, no, I suppose that's exactly what I have.
19:14mmarczyktcrayford: Clojure refactoring -> cool :-)
19:14mmarczykriddochc: happy to hear that :-)
19:15tcrayfordmocking out filesystems and such looks to be a right pain :/
19:15mmarczykriddochc: if you had doubleton vectors (representing map entries), you could use (reduce conj {} seq-of-entries)
19:17mmarczyktcrayford: I'd expect it to be :-(
19:17tcrayfordif I want to change to a new namespace, and refer clojure.core in it (which it isn't using in-ns), how do I do that?
19:18mmarczykthere's a function called refer-clojure
19:18mmarczykor is it a macro... hm
19:18mmarczyk(doc refer-clojure)
19:18clojurebot"([& filters]); Same as (refer 'clojure.core <filters>)"
19:18mmarczykwhatever. anyway, do (clojure.core/refer-clojure)
19:18tcrayfordaha
19:18tcrayfordcheers
19:19riddochcWell, re-seq gives a vector of results that I'm unpacking with a let...
19:22riddochcHm.
19:22mmarczykhm, maybe (reduce conj {} (map (partial subvec 1) (re-seq ...))) then?
19:23tcrayfordif you're getting into mutliple nested seq functions, I'd reccomend using ->>
19:23mmarczykyeah, good point
19:23tcrayfordor just breaking them up into smaller ones
19:23tcrayford(or both)
19:23mmarczyk(->> (re-seq ...) (map (partial subvec 1)) (reduce conj {}))
19:24riddochcI haven't actually used ->> much yet.
19:24tcrayfordits pretty useful for readability
19:24mmarczyktcrayford: best not touch it if it doesn't break on its own ;-)
19:25tcrayfordmmarczyk: that code is pretty much finished with for now anyway
19:25tcrayfordbesides, refactoring-mode can automatically thread stuff with ->> </blowing his own horn>
19:25mmarczykcool! :-)
19:26riddochcThere's certainly more than one way to do this. I'm not sure what I should do if the regex *doesn't* match...
19:27mmarczykyou could consider sth like 1.2's keep for throwing non-matches away
19:28riddochcThat looks rather appropriate. re-seq gives a nil on non-matches...
19:28tcrayfordheh
19:28tcrayford,(filter identity [nil nil 1])
19:28clojurebot(1)
19:29riddochcCool. I'm using 1.2 anyway...
19:29tcrayfordusing keywords as arguments to filter is nice if you want only maps with certain keys
19:29mmarczykthough that would be most natural with (keep (partial re-find #"...") ...)
19:30mmarczykfor re-seq, good old filter identity is probably just as good, yeah
19:30tcrayfordhow do I add metadata to a function whilst I'm defining it?
19:30tcrayfordis it (defn foo {:bar 1} [a] a) ?
19:30mmarczykyou could do that
19:31tcrayfordI get an error here
19:31mmarczykor add reader metadata to the symbol
19:31tcrayfordhow?
19:31clojurebotwith style and grace
19:31tcrayfordassuming 1.2
19:31mmarczykoh? I think you shouldn't get an error for that
19:31mmarczyksee if it works if you include a docstring before the map
19:31tcrayfordstill errors
19:31tcrayford(defn foo "" {:line 3 :file} "foo.clj" [a] a)
19:32tcrayfordoh
19:32tcrayfordfail
19:32tcrayfordyeah the map was messed up
19:32tcrayfordmy installation of paredit in my repl is somewhat borked
19:32mmarczykright
19:32mmarczykas for the reader metadata solution
19:33mmarczyk(defn ^{...} foo ...)
19:33mmarczyk(or the old #^)
19:33tcrayfordI should probably use old-style, as not all projects are using 1.2 atm
19:33mmarczykoh, but the new style is so *pretty*!
19:34mmarczyk*khem*
19:34mmarczykI guess you're right
19:35mmarczykas soon as you use a protocol, though... :-)
19:35tcrayfordnow I have to decide: does my refactoring tool make the changes on disk, or do I send the changes to emacs so it can make the changes?
19:36tcrayfordif my tool makes the changes then it has to handle undo, but I can test it better
19:37mmarczykor make it configurable
19:37mmarczykso it's somewhat usable with other editors too
19:37mmarczyk(hopefully)
19:37tcrayfordwell either route is pretty configurable
19:38tcrayfordthe emacs way of doing it would just send out s-expressions, which the other editors can parse and use
19:38mmarczykpersonally I'd prefer changes to happen in the Emacs buffer
19:38tcrayfordmmarczyk: the changes *will* happen in the buffer, I'll just call revert-buffer after making the change
19:38mmarczykwell that's not quite what I meant :-)
19:39tcrayfordI can't change multiple files from one buffer
19:39mmarczykI meant, "in the buffer first, w/o touching the file"
19:39mmarczykif you need to create a new file, sure, go ahead
19:39tcrayfordthat's what happens currently, but you have to touch the file to change across multiple namespaces
19:39tcrayford*touch the files
19:39mmarczykif you need to change a different, but already existing file, have find it in Emacs first
19:39tcrayfordhave the user, or the emacs mode?
19:40mmarczykouch... "have Emacs find it first"
19:40mmarczyksomehow ;-)
19:40tcrayfordoh I can do that, its not hard
19:40tcrayfordthe other downside of that method is that I have to learn about stubbing the filesystem in emacs :(
19:40tcrayfordoh
19:40tcrayfordactually not
19:40mmarczykthat downside is also an upside ;-)
19:41tcrayfordyeah I think I know where I'm going with this now
19:41tcrayfordcheers
19:41mmarczykcool
19:41mmarczykI think I've seen you doing a screencast with an early version of this...?
19:42tcrayfordthe katacast?
19:42mmarczykyup
19:42tcrayfordyeah, the current version isn't much changed from that
19:42mmarczyklooked pretty cool
19:42tcrayfordcurrently it just takes s-expressions (which you select in emacs), and then does stuff to them
19:43mmarczykdoes it preserve line breaks at this time?
19:43tcrayfordnope, that's still broken
19:43mmarczykright
19:44tcrayfordneed to talk to somebody who knows emacs better than me for that
19:46tcrayfordcan you spot any errors with this: http://gist.github.com/408283 ?
19:48tcrayfordbasically create a new namespace, defines a function in it, then tries to find that function from another namespace using find-var
19:48mmarczykactually in-ns creates the namespace if it doesn't exist already
19:48tcrayfordyep
19:48mmarczykthe other in-ns should use a - in the namespace name instead of _
19:49tcrayfordthat's me being bad, shouldn't break anything atm
19:49tcrayfordah
19:49tcrayfordneeded a call to require in the new namespace
19:49Licenserhmm I try to profile some clojure code with visual vm but oddly it does not seem to see any of the functions, the profile tree is more or less empty
19:49Licenserdoes anyone ever seen this?
19:50mmarczyktcrayford: you mean to pull in clojure.test/is ?
19:50tcrayfordmmarczyk: no, require the just-created namespace
19:50mmarczyktcrayford: that's the next thing I thought would probably break
19:50mmarczykum, right
19:50mmarczykbut I wonder if you need to pull in #'is
19:51tcrayfordits in the top of the file
19:51tcrayfordyeah, test works now
19:51mmarczykoh good :-)
19:52tcrayfordoh, maybe not, just throws an error that test-mode didn't highlight
19:53mmarczykLicenser: check that you're not filtering too much stuff out
19:53Licensermmarczyk: the filters are just set to sun and apple stuff
19:54Licensergrrr and now it stack overflows :(
19:54mmarczykLicenser: weird... I suppose you've checked that you're connecting to the right jvm...?
19:54Licenseryes I see the stuff in the text console
19:54mmarczyksuper weird. :-(
19:55Licenseryea eseically since it stack overflows now even it does not in the repl
19:56mmarczyktcrayford: and the file that code comes from defines the namespace clojure-refactoring.rename-fn-test ?
19:56mmarczyktcrayford: maybe check the _ -> - thing there too
19:57tcrayfordmmarczyk: yes
19:57mmarczykLicenser: is restarting the whole thing an option?
19:57Licenserit seems to entirely ignore my code
19:57mmarczykoh, and btw
19:57Licensermmarczyk: yes I cna reset everything I want
19:58mmarczykhmmm
19:58mmarczykmaybe try running something like
19:58mmarczykoh... um...
19:58Licenserrm -rf /
19:59Licenserfor i in `find / -name "*java*"`; do rm -rf $i; done
19:59mmarczyk(loop [k 12345143265143256124351234512435 l 5471843290518432758102435 m 12354143256] (recur (mod (* k l 2) m) (mod (* k l 3) m) m))
19:59mmarczykLicenser: yeah, that's another option ;-)
19:59Licenser^^
19:59Licensermmarczyk: what should that give me?
19:59mmarczyksome bignum arithmetic in an infinite loop might spin the whole thing up a bit
19:59mmarczykthen you'll see if visualvm picks it up
20:00Licenserah good plan!
20:00mmarczykI suppose you need bigger numbers, though
20:00clojurebot(pl reverse $ (↕reduce range $ 10 () λxy (↕conj inc $ y x)))
20:00mmarczykactually a bigger m
20:01mmarczykclojurebot: Clojukell? Hajure?
20:01clojurebotIt's greek to me.
20:02tcrayfordin theory you could write a clojure on top of haskell that uses the dot syntax for calling down to haskell
20:02mmarczykLicenser: hmmm :-)
20:02Licensermmarczyk: the CPU has fun, the profiler is calm and totally empty
20:02defnor you could just write haskell on clojure, right?
20:02tcrayfordand all the way around
20:02Licenserit also says something like 22 methods instrumented, that shoulds like it would missing something
20:02defnI want to write Haskell in Clojure in Haskell in Clojure
20:03Licenserdefn: you get an infinit implementation loop there :P
20:03mmarczyktcrayford: with Clojure in Clojure, it might be fun to try building on all sorts of host platforms :-)
20:03tcrayfordmmarczyk: when that's done I'm totally building clojure on top of javascript
20:03mmarczyktcrayford: :-D
20:03tcrayforddefn: spot the bug https://gist.github.com/408283/ee992633b8ddf64388d9f45b968b623e93ff8e1c
20:03Licensermmarczyk: nope nothing in the profilerr even for an infinit loop
20:03mmarczyktcrayford: I can't wait for that to happen
20:04mmarczyktcrayford: I'll be able to write useful scripts for Web pages, finally :-P
20:04tcrayfordeither that or clojurescript will be finished/work without patching clojure core
20:04Licenser*looks if there is a newer version*
20:04mmarczykLicenser: so, how are you doing things?
20:04Licensernope
20:04Licenserlein jar
20:04Licenserjava -cp clj-highlight.jar:lib/clojure-contrib-1.1.0.jar:lib/clojure-1.1.0.jar test
20:05defntcrayford: defn a?
20:05Licenserin there is a read-line where the process waits, when it waits I connect the visualvm to the process, start the profiler and wait untill it says it is ready
20:05mmarczykLicenser: and that process actually does stuff? as in, uses CPU time?
20:05tcrayforddefn: explain?
20:05defnive just never seen "defn a {} []"
20:06Licensermmarczyk: certenly yes aside the fact that I could hear my cooler go crazy I could watch the usage meter paint the rocky mountains
20:06tcrayforddefn: that works in the repl
20:06defntcrayford: oh...color me a noob
20:07mmarczyktcrayford: so, does the new version work? (sorry, I got confused)
20:07Licenserdefn: I could make clj-highlight color noobs for you
20:07tcrayfordmmarczyk: nope, still broken
20:07defnLicenser: you could rewrite it and then id be a happy man ;)
20:07defnLicenser: stupiddb (the new v) is pretty cool, i like that you added db-update-in
20:08tcrayfordthough actually clojure overwrites the :line and :file metadata when you define a function, so I can't really write this test anyway
20:08Licenserthanks mate :)
20:08Licenserit also uses gzip now to compress the DB
20:08defntcrayford: meta on that macro seems problematic i guess
20:08defntcrayford: just a hunch
20:09tcrayforddefn: even if I remove the metadata the test still fails
20:09LicenserIs there any clojure profiler save visua vm
20:09tcrayfordyou *can* use yourkit, but its not free (15 day trial was good enough for me though)
20:10tcrayfordthough iirc that goes through the same mechanisms as visualvm
20:10Licenser*nods*
20:10LicenserI thought a clojure specific one that gives usage data about fn's and stuff
20:10tcrayforddon't think it exists yet
20:13Licenser:(
20:20tcrayfordhah
20:20tcrayfordmy issue works fine from the repl
20:21tcrayforddebating posting to the mailing list now, this is getting annoying
20:30Licenserfrustrating :(
20:33mmarczyktcrayford: you could set your own :line and :file meta after the defn form returns
20:35mmarczykLicenser: have you tried connecting running your code at the repl
20:36mmarczykand connecting visualvm to that?
20:36mmarczykthat's what I've been doing usually
20:36defnvisualvm is...not very helpful
20:36defnto me, anyway
20:36Licensermmarczyk: that is an id
20:36mmarczykdefn: even with some filtering? like, no clojure.core functions?
20:39Licensermmarczyk: it works, I can benchmark jinline :P
20:39mmarczyktcrayford: you should really rename that namespace to use - and not _
20:39LajlaSo, Clojure is more of an implementation than a standard right?
20:40mmarczyk_ is not supposed to be used in namespace names at all
20:40mmarczyk(and - is not supposed to be used in Clojure source file names)
20:41tcrayfordmmarczyk: yep I know, but it all works atm, and hence is on the todo list
20:41alpheusHi. I'm just starting to learn Clojure. Just got connected to a REPL with SLIME. Is this the right channel for newbie questions?
20:41tcrayfordsure
20:42defnmmarczyk: could you be more specific about "no clojure.core functions"
20:42defnLajla: im not sure how you'd answer that -- it's...sort of...standard
20:42defni mean, it has the stuff that makes lisp, lisp
20:43Lajladefn, I mean, it has a reference implementation opposed to a formal specification, right?
20:43TimMcchouser: Does Joy of Clojure go into stuff like how best to set up a workspace with tests, how to organize code in large projects, and related topics?
20:43LajlaOr as it seems, only one implementation which is the reference.
20:43mmarczykdefn: you can tell visualvm to skip certain classes when instrumenting your code for profiling
20:44mmarczykdefn: java.*, I think, is on the list by default
20:44mmarczykdefn: you can add clojure.*
20:44LajlaAs in, it's a program that reads a programming language as opposed to a formal specification of a language.
20:45tcrayfordTimMc: not to answer for chouser, but most of that is covered by lein these days
20:46tcrayfordLajla: clojure is too young to have a formal spec
20:47defnmmarczyk: oh man, i have no idea
20:47TimMctcrayford: I suppose the workspace setup is, yes.
20:47defnhad*
20:47Licenserhmm interesting the memory profiler seems to work, I get clojure in there
20:47tcrayfordTimMc: otherwise for larger projects, listen to the tests/code, and look at swank-clojure for an example of organising stuff into namespaces
20:48TimMcYou're saying swank-clojure is a good example project to paw through?
20:48tcrayfordyeah
20:48TimMcOK, cool.
20:48tcrayfordits largish, has had a few people work on it, etc
20:49mmarczyktcrayford: wow, I actually had to type your code afresh to see what's going on
20:49mmarczykI feel rather silly for it
20:49mmarczykbut I've answered on SO
20:49Lajlatcrayford, well, some languages start with a formal spec I guess.
20:49Lajlatcrayford, how old is it?
20:49technomancyit's ancient code. most of it was written before atoms were implemented, and a lot of it is awkward because it's a pretty literal port of the CL code.
20:49mmarczykdefn: hm? :-)
20:49tcrayfordtechnomancy: I was just trying to find a largish project that was open source
20:50technomancytcrayford: yeah... maybe incanter would be a better choice?
20:50tcrayfordnever looked through the code there
20:50mmarczykdefn: I found visualvm's profiler completely useless when not filtering clojure.* out; with filtering, it's actually pretty useful
20:50technomancyleiningen is clean, but it's only 700 lines
20:50TimMctechnomancy: I learn best by absorbing code style and idioms.
20:50tcrayfordTimMc: also check out ring and hiccup
20:50TimMcOh, leiningen itself! Hadn't considered that. >_<
20:50technomancyit's not a large project by any means
20:51tcrayfordtechnomancy: is there a decent way to get an sexp out of slime and print it into a buffer?
20:51defntechnomancy: any chance you know the magic formula to get cuke4duke and lein-cuke working? :X
20:51technomancytcrayford: from elisp?
20:52tcrayfordtechnomancy: yeah
20:52tcrayfordactually, that has to be *multiple* sexprs, but I guess I can wrap them all in one larger one and pull them out of that
20:53technomancytcrayford: (insert (second (clojure-test-eval-sync "(and (:foo {:foo :bar}) 88)")))
20:53technomancydefn: no, never heard of it
20:53Licenserjava makes me sad :(
20:54Licensertcrayford: go go go!
20:54tcrayfordthat should fix my newlines problem completely
20:55technomancymore power to you
20:55tcrayfordbefore I was sending back a string and using read :(
20:56mmarczyktcrayford: does the test work for you now?
20:56tcrayfordmmarczyk: don't know. Stashed that stuff in a seperate git branch whilst I rewrite the elisp
20:57mmarczyktcrayford: well, it should, anyway
20:58tcrayfordIf it works for you, that's good to hear. That stuff is all a long way off though.
20:58mmarczyktcrayford: the ns name was wrong in the .../a symbol in find-var... no wonder it didn't work (but I'm blind and haven't noticed until I got to that while retyping :-/)
20:58tcrayfordreally?
20:58tcrayfordhahaha
20:58mmarczyk^hadn't
20:58mmarczykyup :-P
20:59tcrayfordit doesn't look wrong from here (referring to the stackoverflow q)
20:59mmarczyk(is (not= (find-var 'refactoring-test-fn-rename/a) nil))
21:00mmarczyknotice the symbol
21:00mmarczykah, sorry, I just realised how I'm totally off base here :-P
21:00mmarczykand also, I think, what might be wrong
21:00tcrayfordI thought that was the same
21:01mmarczyklet me go off and check
21:01mmarczykbecause the test does work with the modification
21:01mmarczykhm, just a sec
21:01defntechnomancy: lein-cuke + cuke4duke = cucumber + leiningen integration
21:02defnhttp://github.com/bgruber/lazytest-listen
21:02defnha! awesome.
21:03technomancydefn: I'm working on a lein hook to play the Final Fantasy victory theme when your tests pass
21:03defnhahaha!
21:04tcrayfordtechnomancy: are you interested in having the lein test output colored?
21:04technomancytcrayford: yeah, you could do that in a plugin now that we have hooks
21:04defntechnomancy: you're using lazytest
21:04defn?
21:04tcrayfordhooks make everything better
21:04technomancydefn: no, just clojure.test
21:05defni really wish people with stuff like lazytest and lazytest-listen would release
21:06technomancytcrayford: I'd eventually take it into lein proper, but I prefer doing it as a plugin first
21:06tcrayfordtechnomancy: cool. Might be a bit before I actually do it though
21:07Licenserhmm okay the problem seems to be that visualvm filtern the clojure classes
21:07tcrayfordmmarczyk: I'm fixing the filenames first now, cheers for the pointer
21:11mmarczyktcrayford: I've updated the SO answer
21:11mmarczykI think the current version works
21:12mmarczykthough I can't say I'm sure why the original doesn't
21:13defn [null] Unable to resolve artifact: The artifact has no valid ranges
21:13defnwhat's that mean?
21:13tcrayfordmmarczyk: thanks, I'll check it out in a bit
21:13mmarczyktcrayford: ok
21:13Licenserokay to get some more results I needed to set a starting class
21:14defnnvm, silly PEBKAC
21:14Licenseranother question for you people
21:15LicenserI do (set! *warn-on-reflections* true) in repl then load my code, no reflection warnings but when I finally managed to profile a lot of time was in reflectiosn
21:15mmarczykLicenser: I think you'll need to put this in your source file
21:15mmarczykor at the very least do the set! before require
21:15LicenserI did that
21:16mmarczykso that *warn-on-reflection* is true at compile time
21:16mmarczykoh, and yeah, it's *warn-on-reflection* (no 's')
21:16Licenser*just tries it again**
21:16tcrayfordI thought there was a lein option to set warn-on-reflection now?
21:17mmarczykright, :warn-on-reflection
21:17Licenseron heat
21:17tcrayfordmmarczyk: http://github.com/tcrayford/clojure-refactoring/commit/15cc3c0d56c151b6f5397d065528e838609aa39c
21:18Licensernope no warn on reflections
21:20remleduffWow tcrayford, that looks amazing
21:21mmarczykLicenser: http://clj-me.cgrand.net/2009/08/06/what-warn-on-reflection-doesnt-tell-you-about-arrays/
21:21sexpbot"Clojure and me » What *warn-on-reflection* doesn’t tell you about arrays"
21:21mmarczykjust sth of potential interest
21:22mmarczykthe thing which *really* should work is putting (set! *warn-on-reflection* true) in the source file before the namespace is required for the first time
21:22mmarczykif it doesn't work for you, maybe there's nothing to be done
21:23mmarczykto get rid of reflection, I mean
21:23mmarczykor maybe cgrand's post can help :-)
21:23mmarczyktcrayford: cool :-)
21:23Licensermmarczyk: then it tells me that it can't alter the root binding
21:23mmarczyktcrayford: I'd say that _ in function names is evil too :-P
21:24mmarczyktcrayford: but it definitely shouldn't cause any breakage, so...
21:24LicenserCaused by: java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set (test.clj:0)
21:24Licenser it says
21:24Licensermeeh
21:24tcrayfordmmarczyk: I use it occasionally in test names if I want to name a test exactly the same as a function name (but that's rare)
21:25mmarczyktcrayford: wouldn't work for a fn without a - :-)
21:25mmarczykI prefer adding -test, but ok
21:25mmarczykLicenser: oh bother :-(
21:25Licenserit's no fun
21:27mmarczykcould you gist that file?
21:28mmarczykor, I don't know, just a couple of forms from the top
21:31Licensermmarczyk: it's on github one second
21:32Licensermmarczyk: http://github.com/Licenser/clj-highlight
21:32Licenserhttp://github.com/Licenser/clj-highlight/blob/master/src/test.clj to be precise
21:33mmarczykthanks, I'll try to run it in a moment
21:33mmarczykto witness the ridiculous error with my own eyes, as it were
21:33mmarczykhopefully enlightenment follows ;-)
21:33Licenserheh thanks mmarczyk
21:33Licenserwhy do you know so much?
21:35mmarczyknot sure where that came from, I'm being totally unsuccessful at guessing what your profiling+testing woes are about just now :-)
21:35LicenserI am totally at a less here either
21:36Licenser*loss
21:37mmarczykLicenser: try (set! *warn-on-reflection* true)
21:38Lajlammarczyk, ah, so closure uses bangs?
21:38Licenser*runs that
21:38tcrayford,(= '((defn to-i [x] (Integer. x)) (defn add [s] (for [x (re-split #"," s)] (to-i x)))) '((defn to-i [x] (Integer. x)) (defn add [s] (for [x (re-split #"," s)] (to-i x)))))
21:38clojurebotDENIED
21:38tcrayfordhah, those are quoted lists
21:38Licensermmarczyk: gives me Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set (test.clj:0)
21:38tcrayfordclojurebot: you fail
21:38clojurebotPardon?
21:39mmarczykLicenser: you know, I think *warn-on-reflection* might be a binding established by the ns form
21:39mmarczykLicenser: try moving the set! below it maybe
21:39Licensertried that but I'll try it again
21:40mmarczykLajla: and ?s, conventions for use agree with those of Scheme
21:40Licensersadly same :(
21:40tcrayfordaha!
21:40tcrayford,(= #"," #",")
21:40clojurebotfalse
21:41mmarczyk,(.equals #"," #",")
21:41clojurebotfalse
21:41remleduff(class #",")
21:41Licenserhm hmmms
21:41remleduff,(class #",")
21:41clojurebotjava.util.regex.Pattern
21:42remleduffDid the prefix change?
21:42Licensermmarczyk: can you profile the test file?
21:42Licenserit runs with java -cp clj-highlight.jar:lib/clojure-contrib-1.1.0.jar:lib/clojure-1.1.0.jar test
21:42Licenser?
21:42remleduffI'm pretty sure there's a thread on clojure-dev about regex Patterns and the screwy equality semantics
21:42remleduff$(class #",")
21:42sexpbotresult: class java.util.regex.Pattern
21:43mmarczykLicenser: yup, I'll try in a moment
21:43tcrayfordyeah, it ain't a bother, I'll just change the tests so they change different functions
21:43Licensermmarczyk: thank you a lot!
21:43mmarczyknp :-)
21:45mmarczykLicenser: I'm seeing totally weird breakage for now
21:46Licensermmarczyk: yes that is something I know :P
21:47mmarczykthere's a double "fn" in clojure-keywords
21:47mmarczykI mean it occurs twice in the literal
21:47mmarczykClojure 1.2 complains
21:48Licenseroh
21:48mmarczyk(I might restart with 1.1 though)
21:49Licenserwehn I set the stack size to 100M I can run bigger files
21:49Lajlammarczyk, I take it the [ ... ] is optional and can be freely exchanged with ( ... )?
21:49mmarczykLicenser: same goes for let and loop
21:49Licenser^^
21:49mmarczykLajla: you mean in Clojure syntax?
21:50Lajlammarczyk, quite.
21:50mmarczykLajla: not at all, [...] is a vector, whereas (...) is a list
21:50Licensermmarczyk: thanks all removed
21:50Lajlammarczyk, ahhh
21:51Lajlammarczyk, and vectors also are encounted in code I see?
21:51mmarczykLajla: note [...] is not like #(...) in Scheme
21:51Lajlammarczyk, do go on.
21:51mmarczykLajla: Scheme's vector literals provide implicit quoting, while Clojure's don't
21:51LajlaI am imagining you speak with a French accent as to facilitate my attention span.
21:51Lajlammarczyk, this means that vectors evaluate to things?
21:52tcrayford,([1 2 3] 1)
21:52clojurebot2
21:52mmarczykLajla: so [(+ 1 2)] gives [3], whereas #((+ 1 2)) evaluates to a vector whose only element is '(+ 1 2) (the list of symbol +, numbers 1, 2)
21:52LajlaAhh, they evaluate all arguments.
21:52LajlaAnd vector-ref does not exist
21:52LajlaRather a vector is a procedure?
21:52mmarczykLajla: just a quick question on the side
21:53Lajla,([1 2 3 4] 0)
21:53clojurebot1
21:53LajlaCool
21:53mmarczykLajla: or actually, never mind
21:53Lajlammarczyk, ask.
21:53LajlaNahh, Now I want to know.
21:53mmarczykLajla: [ ] is just literal syntax for vectors
21:53mmarczyklike ( ) is for lists
21:53Lajla,(+ 1 ([2 3] 0))
21:53clojurebot3
21:53LajlaCool
21:53mmarczykin Scheme, ( ) is literal syntax for proper lists, or with the dot, improper lists
21:54mmarczykand of course (1 . 2) is a pair (cons)
21:54Lajla(([+ *] 1) 1 2 3 4)
21:54Lajla,(([+ *] 1) 1 2 3 4)
21:54clojurebot24
21:54mmarczykthe fact that those lists are evaluated the way they are is a different matter entirely
21:54LajlaVeeery cool
21:54Lajlammarczyk, I understand
21:54Lajlabut what did you want to ask?
21:54mmarczykanyway, I'm off to bang on Licenser's code until it regrets it's been written :-P
21:54LajlaNoo, you wanted to ask something.
21:54LajlaI want to know what it is.
21:55mmarczykthat *warn-on-reflection* thing is annoying
21:55LajlaIt's like a splinter in my mind.
21:56mmarczykLicenser: funnily enough, when I removed duplicate keys from clojure-keywords and moved (set! *warn-on-reflection* true) inside the ns form
21:56mmarczykLicenser: things started to work
21:56mmarczykLicenser: actually, scratch that
21:56Licenserinside the ns form?
21:56mmarczykLicenser: yes, but also
21:56mmarczykI moved renamed the namespace to clj-highlight.test
21:56mmarczykand moved the file to match the ns name
21:56Licenser*nods*
21:56mmarczykgoing off to move it back and see if it breaks again
21:57LicenserI had a problem with that when I did that that lein was acting up with the -
21:57mmarczykoh?
21:58mmarczykhm, apparently it doesn't break if it's just src/test.clj, ns test
21:58mmarczykI mean that's supposedly broken for different reasons ;-)
21:58Licenseryea if I added :main clj-highlight.test java was trying to call the class wiht - if I added clj_highlight lein was trying to compile the _ file
21:58mmarczykbut still, I can require it and *warn-on-reflection* gets set to true
21:58Licensererm namespace
21:59mmarczykLicenser: oh, I see
21:59mmarczykLicenser: which version of lein are you using? I'm under the impression that this was fixed, but I might well be imagining things
22:00Licenserhmm *looks*
22:00mmarczykLicenser: if it's an actual bug, I'd love to fix it :-)
22:00Licenserlein 1.1.0
22:00Licensernot working either, says it can't find set!
22:00tcrayfordreader macros really break the whole code is data thing sometimes :(
22:01Licensertcrayford: yap
22:01Licenserthen again if you use the reader, no:P
22:01Lajla,[1 2 3]
22:01clojurebot[1 2 3]
22:02tcrayford(= #(identity %) #(identity %))
22:02tcrayford,(= #(identity %) #(identity %))
22:02clojurebotfalse
22:02mmarczykLicenser: :-(
22:02Lajla,([1 2 3 5] +)
22:02clojurebotjava.lang.IllegalArgumentException: Key must be integer
22:02mmarczykit all runs fine here, with clj 1.2
22:02Licensermmarczyk: but I am way closer
22:02mmarczyklet's see with 1.1
22:02tcrayfordI kinda have to use the reader for this, seeing as I return sexps to emacs now :/
22:02Lajla,([1 2 3 4] -1)
22:02clojurebotjava.lang.IndexOutOfBoundsException
22:02LajlaHmm, no 4? =(
22:02mmarczykincidentally, got any test data?
22:03Licensermmarczyk: I get some kindof useful results when I use 100M stack space and then run a bigger file
22:03mmarczykI'm running it with (with-in-str "some-clojure-form\nanother-one\nyet-another-one\n" (test/-main))
22:03mmarczykfor now :-)
22:03Licenserheh
22:03mmarczykLajla: like your Python, do you ;-)
22:04LicenserLajla: ,(last [1 2 3 4])
22:04Licenseralso last is evil :P
22:04Lajlammarczyk, I don't, that rumour was formed while I was drunk!
22:04mmarczyk,(peek [1 2 3 4])
22:04clojurebot4
22:04LajlaI did not have a sexual relationship with that programming language.
22:04Lajlalicenser, how to get the second-last?
22:05mmarczyk,(peek (pop [1 2 3 4]))
22:05clojurebot3
22:05LajlaJust (- length 1) or some similar construct?
22:05mmarczykLajla: 'count' actually, but yeah
22:05Licensersee mmarczyk knows all
22:05LicenserLajla: also idally you don't need last
22:05Lajlalicenser, maybe mmarczyk is the third best progammer after me and the Chief Software Architect of Microsoft.
22:06Licenserwait that are odd standrds
22:06Lajlalicenser, ahhh, do elaborate here.
22:06Lajlalicenser, if I was normal I'd be programming in python rather in some bracketlang.
22:06mmarczykLicenser: there's one thing I'm not very clear on
22:06LicenserI'd buy that you are the best but a microsoft guy the second best?
22:06mmarczykLicenser: it's *the* Microsoft guy, actually ;-)
22:06Lajlalicenser, well, he did come up with the original DOS filename system.
22:06Lajla8 character limit, brilliant idea.
22:07LajlaWhy didn't I think of that.
22:07mmarczykLicenser: anyway, why do you use read-line and not read
22:07LicenserLajla: from what I understood about functional programming it is all about consuming seq's (lists) and not peacking at specific points
22:07LajlaHe also pioneered the concept of having to restart your computer either because it crashed or for trivial updates you have to do every six hours as some systray popup tells you.
22:07Lajlammarczyk, explain?
22:07Licensermmarczyk: because I was sure what read-line does :P and read is the reader isn't it?
22:07mmarczykLicenser: ahhhhh, right, of course
22:07mmarczyksorry :-P
22:08Lajlalicenser, well, in lists, not in vectors.
22:08mmarczykmakes sense you'd want a string for a syntax highlighter :-)
22:08LicenserLajla: you can treat vectors as lists ;)
22:08mmarczykoh, oh! cookies are good :-)
22:08Licenser^^
22:08Lajlalicenser, then I would use lists rather than vectors.
22:08LajlaVectors are for peaking at a random index.
22:09mmarczykLajla: in Clojure, not at all
22:09tcrayfordLajla: most clojure programmers use vectors most of the time
22:09mmarczyk,(conj [1 2 3] 4)
22:09clojurebot[1 2 3 4]
22:09Lajlain lieu of lists?
22:09LajlaFr what advantage?
22:09tcrayfordpersonally, I prefer the syntax
22:10Licenseralso vectors add to the end, lists to the front, sometimes it makes a difference
22:10LajlaI see.
22:10mmarczykLajla: actually, if you're genuinely interested in Clojure, would you like to read a really good -- yet reasonably short -- intro?
22:10LajlaYou have intruiged me with your unorthodox language, I might turn to the dark side.
22:10Lajlammarczyk, sure.
22:10mmarczykLajla: not that I mind answering here, on the contrary, just to be clear
22:10mmarczykbut I think it's a great article
22:11mmarczykand for a person coming from Scheme
22:11LajlaComing from is the right word.
22:11mmarczykmight be enough to get a pretty good idea of what the language is about
22:11Lajlammarczyk, sure, give me.
22:11mmarczykLajla: oh, I didn't see that coming :-)
22:11mmarczykyup, just a sec
22:12mmarczykhttp://java.ociweb.com/mark/clojure/ -- link to the current revision at the top, plus loads of other resources
22:12sexpbot"Mark Volkmann's Clojure Page"
22:13Licenser__oh yes that one was good, I started with it!
22:13mmarczykme too :-)
22:13Licenser__^^
22:13mmarczykand he's got another one on Clojure's STM, which is absolutely one of a kind
22:14mmarczykhttp://java.ociweb.com/mark/stm/
22:14sexpbot"Mark Volkmann's STM Page"
22:14alpheusIs "lein install" the right thing to use to put a jar file somewhere that "lein deps" can find it?
22:15tcrayfordyes
22:16mmarczykwell I think lein install works on the current project
22:16mmarczykfor now
22:16mmarczykand not an arbitrary jar
22:16mmarczykfor the latter case, you'd need mvn install (google for the correct command line options first)
22:17Licensermmarczyk: even if not the reflection the big stack thing did the trick
22:17alpheusthanks
22:18mmarczykLicenser: ok
22:18alpheusmvn manipulates maven repositories?
22:18mmarczykLicenser: I'm still not clear on how you test it
22:18mmarczyk(read-line) reads one line
22:18Licensermmarczyk: me neither
22:19remleduffIsn't it mvn deploy-file for an arbitrary jar?
22:19mmarczykso you're colouring just three lines, which probably isn't a lot of work
22:19mmarczykheh
22:19Licensermmarczyk: the read-line is just so that I've time to fire up the visualvm
22:19Licenserotherwise the tests are over before the profiler has connected
22:19mmarczykremleduff: tbh, it could very well be :-)
22:20Licenserwhat did the trick fir me: -Xss100M and add the clj_highlight.** to the classes that trigger profiling
22:20mmarczykmvn install worked for me once or twice, but these days I mostly put stuff in lib/ by hand (I'm not saying it's pretty)
22:20Licenserhttp://grab.by/4uz9 is what I got
22:21Licenserso actually the regexps are sloow :P
22:21mmarczykoh man, you've got your project.clj all on one line!!!
22:22Licensermmarczyk: yea it's from lein-search
22:22Lajlammarczyk, omg man, that sound when you start it.
22:23Licenser~defn re-find
22:23clojurebotHuh?
22:24Licensersorry clojurebot I enver can remember how you do that
22:24mmarczykLicenser: so, the idea is that you want to run test as the main class
22:24mmarczykLicenser: and it's supposed to do some work which you want to profile, right?
22:25LajlaI never really got what people find so difficult about switching to another paradigm though, but maybe that's just because I'm young.
22:25Licensermmarczyk: exactly
22:25mmarczykLicenser: well, the test.clj I pulled from your repo a short while ago
22:25mmarczykLajla: I've no idea what's difficult in switching from OOP to FP, but the other way around sure is hell
22:26mmarczyk;-)
22:26mmarczykLicenser: but why would you expect that test.clj to do anything?
22:26mmarczykas far as I can tell, it's almost empty
22:26mmarczykI mean in, devoid of computational challenge ;-)
22:26mmarczykor do you have a fuller version you're actually using, not yet pushed to the repo?
22:26bmasonare the javax packages a separate library from the main java spec?
22:26Lajlammarczyk, ahaha, could be that the other way around is more difficult yes.
22:26Licensermmarczyk: it grabs a file, and tokenizes it
22:27LajlaI don't like OOP though, I think it cripples the mind.
22:27bmasone.g. I'm trying to import javax.mail.internet.MimeMultipart
22:27bmason
22:27Licenserit does not look too much but there is a entire scanner for clojure code in the back
22:27Licenserand worst thing is, it is horribly slow
22:27mmarczykLicenser: grabs a file?
22:27clojurebotamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
22:28LicenserI only get ~20k Tokens a second from the scanner
22:28mmarczykLicenser: in the test.clj that I pulled there's no code for that
22:28mmarczykLicenser: that's what I meant by "devoid of computational challenge", the scanner looks impressive
22:28Licenserline 9
22:28Licensera hidden slurp there
22:28mmarczykoh wait, have I actually deleted a line
22:28Licenser:P silly
22:29mmarczyklol, no, I've simply missed it
22:29Licenserremove the content and it is of cause missing any kind of challange
22:29mmarczykI wonder if I should sleep more often :-)
22:29Licenserline 9 reads the file to a string line 13, 14, 15 and 18 parse the string into tokens and count them (to force the lazy seq)
22:30mmarczykright, now I tried to restart VisualVM and started IntelliJ instead... :-(
22:31Licenserheh
22:31Licenserstill you were good help mmarczyk thanks a lot!
22:32rshdo most people develop new clojure programs on v1.2?
22:32mmarczykLicenser: :-)
22:32alpheusI asked the wrong question. I'd like to require a .clj file, not a .jar. It seems as if having the path to the .clj file on CLASSPATH is sufficient. Is that about right?
22:32mmarczykLicenser: ok, so I'm running the test
22:32mmarczykfrom the REPL
22:32Licensernow I just have to figure out why the java regexp does not only suck but is also slow like hell
22:32mmarczykand the whole thing takes under 150 ms
22:33Licenserit seems close to impossible to write a good scanner in java
22:33mmarczykis that really slow, or does it become slow with a significantly larger input...?
22:33Licensermmarczyk: it is really slow
22:34Licensercoderay, a ruby highlighter is about 10x faster then this
22:34remleduffI think most people use a parser generator for something like that in Java
22:34Licenserand while I expected my crazy implementation with tons of functions would be the bottle nack the regexp is it
22:34Licenserremleduff: but that is so complicated
22:35remleduffWell, you're talking about java...
22:35mmarczykLicenser: somewhat importantly, I can see it working in VisualVM
22:35Licensermmarczyk: wow!
22:37Licenserbut i get the feelings that some kind of other function is slow or a regexp is bad
22:40mmarczykLicenser: ah, I think I might be on to the reason why the profiler doesn't pick things up
22:40Licenseroh?
22:41LicenserI had to add stuff to the class thing to the right
22:43mmarczykyeah! got it
22:43mmarczyk(I think)
22:43remleduffLicenser: Might want to look at http://www.javaworld.com/javaworld/jw-09-2007/jw-09-optimizingregex.html as well
22:43mmarczykit would seem to me that you need to move the test ns to clj-highlight.test
22:44Licenserreally oi
22:44mmarczykLicenser: because otherwise it ends up in the "default package" (is that the Java name?), which is a special situation which is wrong
22:44mmarczyk:-P
22:44Licenseryuck
22:44LajlaYou know, this cojure actually has a lot in common in a language I once made wich treated vectors like functions that took in natural numbers and sets as praedicates.
22:45LicenserLajla: then you'll feel right at home :D
22:45Lajlalicenser, I do actually, I'm considering turning to the dark side here.
22:46LajlaLooks well thought off.
22:46Licensermmarczyk: but how do I explain lein to do things right :(
22:46mmarczykLicenser: I wouldn't bother
22:46Licenserhmm true I don't need to unless I do the executable jar stuff
22:46mmarczykwhat I'm doing now is start it all in a repl
22:46mmarczykwrap the test in a dotimes with some large number of iterations
22:47mmarczykoh, and that's after telling VisualVM to skip clojure.*, swank.* and sun.rmi.* classes when profiling
22:47mmarczykin addition to those which it skips anyway
22:47mmarczykand start with clj_highlight.** (though that's probably optional)
22:48Licenser=)
22:48mmarczykor should it be sun.rmi.transport.*
22:50mmarczyket voila, 22% of the time spent in sth called re-token
22:50Licenser:D
22:50Licensermmarczyk: you good sir are briliant!
22:52mmarczykhttp://gist.github.com/408392
22:53Licensermmarczyk: only sad point is that the re-token just tells me that it is 'a' regular expression not which one :P
22:53remleduffLicenser: In your regex, basic-identifier has (?i) in it, and that ends up occurring several times in the final basic-identifier. Can you make that flag get turned on only once?
22:53Licenseryes I could
22:56mmarczykLicenser: I guess so :-(
22:56Licenser*looks into it again*
22:56riddochcSo, I know a suffix of 'M' on a number indicates that a literal should be treated as a bigdecimal. Is there something similar for a long?
22:57mmarczykLicenser: I suppose it should be possible to wrap that function in sth to keep track of which regexp took how much time on average
22:57mmarczykplus the number of times they were used
22:58mmarczykinterested?
22:58Licensermmarczyk: I just did that
22:58mmarczykoh :-)
22:58mmarczykgreat
22:58Licenserat least the wrapping
22:58LicenserI want to see if it works
22:58Licenserkilld the thing so with a slurp :P
22:58mmarczyk:-)
22:59mmarczykI'll be back very shortly, need to go off for a moment
23:00Licenserthanks mmarczyk and take care
23:02remleduff$*clojure-version*
23:02sexpbotCommand not found. No entiendo lo que estás diciendo.
23:02remleduff$(str *clojure-version*)
23:02sexpbotDENIED!
23:02RaynesUse $eval for stuff that isn't wrapped in parans.
23:03Raynes$eval *clojure-version* ; this still wont work though.
23:03sexpbotDENIED!
23:03RaynesI haven't whitelisted that. I need to.
23:03RaynesIt's running 1.2, for the record though.
23:04remleduffHmm, isn't *clojure-version* kind of a bad example of using earmuffs
23:04remleduff?
23:04remleduff$(+ 100L 1)
23:04sexpbotInvalid number: 100L
23:04remleduff$(+ (long 100) 1)
23:04sexpbotresult: 101
23:05remleduffWonder why the reader doesn't support the L suffix
23:07riddochcWow, something's quite wrong. I'm using clj-time, which uses joda-time, and (time-coerce/from-long (long 1274244710)) evaluates to #<DateTime 1970-01-15T17:57:24.710Z>
23:08remleduff$(long 1274244710)
23:08sexpbotresult: 1274244710
23:08remleduff$(class (long 1274244710))
23:08sexpbotresult: class java.lang.Long
23:09riddochcI've got a :require clause, [clj-time [core :as time-core] [coerce :as time-coerce] [format :as time-format]
23:09riddochc(time-core/now) evaluates to #<DateTime 2010-05-21T03:06:33.674Z>
23:10riddochcNow, aside from the fact that I need to fix my NTP setup, something seems a bit screwy, don't you think?
23:12remleduffWhat does (time-coerce/to-long (time-core/now)) give you?
23:12riddochcLet's find out...
23:12Licenser*sigh*
23:13riddochc1274411403008
23:13ravaGreetings programs :)
23:14mmarczykLicenser: how are you doing?
23:14Licenserwell trying things now but the repl crashes whenever I try to define the highlighter :P
23:14remleduffYou shouldn't need the call to long when calling from-long should you?
23:14mmarczykouch
23:15riddochcOh, I think I see. It expects *milliseconds*, not seconds.
23:15Licenseryea I've bad luck today :P
23:16riddochc(time-coerce/from-long (long (* 1000 1274244710))) -> #<DateTime 2010-05-19T04:51:50.000Z>
23:16riddochcNow that's more like it.
23:16remleduffCool
23:16remleduffI think calling "long" there is redundant though, from-long does the type-hint internally
23:18riddochcIt complained if I didn't and the time was closer to 1970... though for recent times, it should be fine.
23:19Licenserthis is so frustrating :(
23:19riddochcclj-time has a type hint, [#^Long millis] in its param-list, but that doesn't seem to be the same as a coercion. Hm.
23:19LicenserI think it hates me o.
23:19Licensero
23:20TimMctechnomancy|away: Leiningen totally works! Thank you. :-)
23:25Licenserhmm okay finally :D
23:27mmarczykoh good :-)
23:28Licensermmarczyk: the identifyer token is the evil one
23:29mmarczykum, shouldn't symbol* actually be called keyword* ?
23:29Licenseryes I guess so
23:29bmasonwhat's with all these warnings: WARNING: flatten already refers to: #'clojure.core/flatten in namespace: compojure.html.form-helpers, being replaced by: #'clojure.contrib.seq-utils/flatten
23:30bmasondoes that have something to do with compojure moving stuff to ring, or am I referencing inconsistent versions of something?
23:30mmarczykalso, ::foo/bar is not a valid keyword literal
23:30Licenserhmm okay learned something new :)
23:31mmarczykaaaahhhh, nope, wait
23:31mmarczykit is
23:31mmarczyksorry
23:31Licenserheh
23:31mmarczykand it even works with aliases then :-)
23:31Licenserproblem is this is a pretty ugly case :P
23:32LicenserI can't think of much to make this less ugly or faster
23:32mmarczykwhat does (?i) do?
23:33mmarczykhey, I just noticed sth
23:33mmarczykyou need to switch to regex literals!
23:34mmarczykwhere possible
23:34mmarczykmostly for prettiness' sake :-P
23:36remleduffLicenser: Would it help to change basic-identifier to lazy rather than eager by changing the * to *? ?
23:37remleduffYou'd need a token on the other side to match though
23:37Licenserhmm hmm I'm not an expert on regexps sadly :P
23:38Licensermmarczyk: (?i) makes it case insensitve
23:38Licensermmarczyk: yea but composing them isn't as nice
23:39remleduffWhat are you trying to match exactly?
23:39TimMcOoh, Clojure has sexp-based regexes available? (Or is it a lib?)
23:40Licenserremleduff: clojure symbols ^^
23:40remleduffSomething like #".*/.*" but with only clojure allowed characters?
23:41Licenserremleduff: well more or less yes
23:45remleduffI think you'd be better off just putting A-Z in your character classes rather than turning on and off case insensitivity like that
23:45remleduffBut I'm having a hard time figuring out exactly what you're matching :)
23:45Licenserremleduff: o.O Me to!
23:49Licenserremleduff: sadly didn't changed too much
23:51remleduffWhat are you matching at the end of identifier? It has to match any character or any two characters?
23:53Licenserremleduff: ny two?
23:53Licensernot sure what you mean
23:55remleduffI just am not sure what the "\\.\\.?" at the end of your regex is intended to do
23:55Licenserwell . and .. are both symbols
23:59remleduffYou want to avoid the | alternation as much as possible I think
23:59Licenser*nods* I just pulled the regexp apart and made 3 rules out of it