#clojure log - May 20 2010

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

0:12 defn: how would one go about integrating ruby on rails and clojure?

0:12 jruby probably, id guess

0:13 lancepantz: we use clojure for a backend rest api

0:13 defn: lancepantz: do you have any public code floating about?

0:13 lancepantz: using ring i presume?

0:13 lancepantz: rails just makes rest calls

0:13 yeah, with compojure

0:13 defn: k

0:14 lancepantz: and unfortunately we haven't open sourced any of that yet

0:14 defn: bummer

0:14 * defn wishes there was more documentation for compojure

0:14 lancepantz: very much so

0:14 even worse of a problem with the 0.4 release

0:15 defn: yeah it's kind of unnerving

0:15 what's the point of a framework with no documentation

0:15 lancepantz: agree

0:15 ring does a pretty good job w/ docs

0:15 defn: yeah, it's not very big and most of it is self-explanatory

0:15 lancepantz: i found the most helpful resource for compojure was the mailing list

0:16 defn: but compojure has made me want to rage on multiple occasions

0:18 lancepantz: so you have two server instances?

0:18 lancepantz: also, are you just running the clojure side of things in a REPL?

0:19 lancepantz: yes wrt instances, but we deploy a war

0:19 defn: bleh -- no clue what to do there

0:20 lancepantz: most people talk about deploying in a repl, which surprised me

0:20 defn: yeah it seems like a terrible way to do production stuff

0:20 it just seems...impermanent

0:20 lancepantz: yeah, i just assumed they weren't working on production stuff

0:21 defn: i mean, im using it for getclojure.org:8080/examples/concat

0:21 but that's staging -- i dont consider that a permanent solution

0:21 lancepantz: w/screen?

0:21 defn: yes

0:22 lancepantz: http://github.com/lancepantz/lein-war-example if you want something to work from

0:23 it's simple once you get it setup

0:23 defn: cool thanks

0:23 lancepantz: have you noticed any pain with managed dependencies from 1.1.0 to 1.2.0

0:23 it 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

0:24 lancepantz: not yet, but i haven't finished updating everything

0:30 defn: lancepantz: if/when you get something online id love to see a rails + clojure thingamajig working

0:31 lancepantz: will do, we should have it in production next week or so

0:32 gotta run for now, take care

1:32 slyrus: ack! 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)

1:40 timmorgan: I'm a Ruby dude, a Clojure noob, and cannot figure out how to do the equiv of ruby_arr.include?(item) in Clojure

1:41 (some #(= item %) items) ?

1:41 or ((set items) item)

1:41 is there a more idiomatic way?

1:42 mmarczyk: timmorgan: if item is not nil or false, (some #{item} items)

1:42 timmorgan: though #(= item %) is perfectly alright too

1:43 timmorgan: so, when treating a single-item set as a predicate, it tests to see whether its contents are present in the vector?

1:43 mmarczyk: it's not really a predicate

1:44 timmorgan: ok, a function

1:44 mmarczyk: it returns nil if it does not contain the given item, otherwise it returns the item itself

1:44 replaca: timmorgan: it can be an any-item predicate

1:44 mmarczyk: not a predicate in the sense of "a function which returns a Boolean", I mean

1:44 timmorgan: ok that makes sense

1:45 off to the repl I go

1:45 thanks guys

1:45 mmarczyk: yw :-)

1:45 replaca: for example (some #{:dog :cat} aseq) will tell me if dog or cat is in aseq

1:46 maxhodak: 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

1:46 I meant mmarczyk :)

1:56 mmarczyk: replaca: :-)

1:56 coming from Scheme, I'm used to the convention whereby anything with a name ending in ? returns Booleans only

1:57 remleduff: That's the convention in clojure too, that's why it's "some" and not "some?"

1:57 mmarczyk: yup, I know

1:59 but 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 ;-)

2:01 incidentally, "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

2:06 TheBusby: Is there a clojure function for handling a queue between threads similiar to promise/deliver?

2:07 just conj a ref maybe?

2:08 wdouglas: Hey 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.

2:09 chouser: TheBusby: you might like java.util.concurrent.BlockingQueue

2:10 mmarczyk: TheBusby: have a look at seque and clojure.contrib.seq/fill-queue

2:10 chouser: mmarczyk: it's not (comp first filter), it's more like (first (filter identity (map ...)))

2:10 'some', that is.

2:10 mmarczyk: though, yeah, LinkedBlockingQueue works just fine... except apparently it doesn't handle nils

2:11 TheBusby: looking in Java's concurrent section now, but producer cannot block, ConcurrentLinkedQueue maybe?

2:11 mmarczyk: ,(some #{:foo} [:foo :bar :quux])

2:11 clojurebot: :foo

2:11 mmarczyk: ,((comp first filter) #{:foo} [:foo :bar :quux])

2:11 clojurebot: :foo

2:11 mmarczyk: ,((comp first filter) #{:wibble} [:foo :bar :quux])

2:11 clojurebot: nil

2:12 chouser: ,(some :a [{:a nil} {:a false} {:a :b}])

2:12 clojurebot: :b

2:12 chouser: ,((comp first filter) :a [{:a nil} {:a false} {:a :b}])

2:12 clojurebot: {:a :b}

2:13 chouser: but the real question is

2:13 mmarczyk: oh.

2:13 thanks!

2:13 chouser: why the heck am I still up

2:13 * chouser goes to bed

2:13 mmarczyk: that goes for me as well

2:13 8:12 am here

2:13 TheBusby: chouser: thanks for the input

2:13 chouser: np

2:13 TheBusby: mmarczyk: thanks!

2:13 mmarczyk: yw

2:14 defn: does anyone here have cuke4duke working?

2:14 I can't seem to get it running

2:14 mmarczyk: LinkedBlockingQueue has an .offer method

2:14 or some such thing

2:14 for putting things on the queue if possible, getting an indication of success and never blocking

2:15 cuke4duke, wow 8-O

2:15 defn: ??

2:15 mmarczyk: is this something to do with testing?

2:15 defn: yes.

2:15 mmarczyk: I mean the project name

2:15 defn: cucumber

2:15 mmarczyk: and duke?

2:15 defn: no clue

2:15 mmarczyk: right.

2:16 defn: lol oh god -- maven2 needs...113 packages for ubuntu

2:17 Chousuke: are you sure it's not installing recommended packages?

2:18 TheBusby: likely install an alternate version of Java too...

2:19 * defn shrugs

2:19 defn: i just let apt do its thing

2:20 wait..maven2 is installing groovy?

2:24 tgk: I'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.

2:24 LauJensen: Morning all

2:25 tgk: Here's a usage example: (text-copy (defn f [x] (* 2 x))) => #'user/f

2:25 I'm pretty sure it's possible, but I have no idea how to get started.

2:27 defn: tgk: read the form in as a string, add it to a ref, vector, map, whatever

2:27 and then read-string

2:27 tgk: defn: how do I read the form in as a string?

2:35 defn: (read-string "(+ 1 2)")

2:39 tgk: Hmmm 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))"

2:46 tomoj: ,(str '(def f [x] (+ 3 x)))

2:46 clojurebot: DENIED

2:46 tomoj: bah

2:46 ,(str '(df f [x] (+ 3 x)))

2:46 clojurebot: "(df f [x] (+ 3 x))"

2:50 tgk: But that requires that I put the ' there... Hmmm I guess that can be solved by using macros

2:53 tomoj: uhh

2:53 what were you hoping to use? a function?

2:55 tgk: Oh no, not at all. I think I'll go tinker with it.

2:55 tomoj: if 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

2:56 well, it would be if (def f [x] (+ 3 x)) were fixed

2:56 tgk: I know, I was sure I needed to write a macro.

2:57 tomoj: oh

2:57 do you want to figure the macro out on your own, then?

2:58 tgk: I'll try, I'll get back when I fail.

2:58 tomoj: good luck :)

2:58 tgk: Thanks :)

3:02 TheBusby: anyone have any experience using processBuilder?

3:03 arbscht: TheBusby: ask your real question and someone might answer

3:06 TheBusby: arbscht: thanks

3:06 Then, any idea how to turn the stdout out of a process created with processBuilder into a lazy-seq accessible by other threads?

3:07 evidently if the stdout isn't consumed quickly by clojure the process will freeze

3:10 duck-stream/copy works, reader + line-seq not so well...

3:10 * defn tears his hair out trying to cuke4duke to work

3:25 stilkov: tgk: maybe you're looking or pprint

3:26 s/or/for/

3:26 sexpbot: tgk: maybe you're looking for pprint

3:28 stilkov: I use it to print code this way: (with-pprint-dispatch *code-dispatch* (pprint form))

3:28 form is something I read with read-string

3:36 tomoj: stilkov: what does that do differently than ugly printing?

3:37 actually, hmm

3:38 ,(require clojure.contrib.pprint)

3:38 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.pprint

3:38 tomoj: darn

3:38 (let [form '(fn [x] (+ x 2))] (= form (pprint/with-pprint-dispatch pprint/*code-dispatch* form)))

3:38 that is true for me

3:38 i.e. (partial with-pprint-dispatch *code-dispatch*) seems to be the identity

3:39 LauJensen: For those interested, we've picked a venue: http://conj-labs.eu/course.html#misc ! :)

3:39 sexpbot: "conjLabs - About Clojure"

3:39 stilkov: pprint prints to *out*

3:39 tomoj: nothing is printed for me

3:39 it just returns the form

3:39 strange..

3:39 stilkov: if you want to get the string value, you need to use a stringwriter

3:39 (binding [*out* (java.io.StringWriter.)]

3:39 (with-pprint-dispatch *code-dispatch* (pprint code))

3:39 (.toString *out*)

3:40 tomoj: oh, whoops

3:40 my problem was that I never called pprint

3:40 ok, but still, looks just like ugly printing

3:40 is it supposed to do something special?

3:40 stilkov: but what tgk seems to want is to get the string value and the eval'd result

3:41 and the original form …

3:41 tomoj: I mean, (with-pprint-dispatch *code-dispatch* (pprint form)) and (println form) seem to have the same output

3:41 tgk: That is true, I think I have it solved.

3:41 stilkov: depends on the complexity of the form :-)

3:41 tomoj: ah, if it gets bigger it starts adding newlines etc?

3:41 stilkov: yep

3:41 tomoj: nice

3:44 eevar2: LauJensen: the blog link on http://conj-labs.eu/instructors.html doesn't work

3:44 sexpbot: "conjLabs - Instructors"

3:44 LauJensen: eevar2: thanks!

3:45 eevar2: fixed

3:45 tomoj: brussels is disturbingly far away

3:45 eevar2: what's with the rdbms hate btw? just stick a caching proxy in front if you're worried about efficiency ;)

3:46 LauJensen: tomoj: from where?

3:46 eevar2: you talking about my baking skills?

3:46 eevar2: ^^

3:46 tomoj: LauJensen: texas

3:47 LauJensen: tomoj: 9 hour flight? Thats the time it takes to write a fun 3d shooter in Penumbra, whats the problem ?

3:47 tomoj: heh

3:47 LauJensen: eevar2: There's so much more at stake than performance

3:47 There isn't a problem possible with my site, that I cant fix with scp, rsync or tramp

3:48 Wordpress has numerous vunerabilities, and new ones pop up - how are you going to crack a static file? :)

3:49 eevar2: the comment system is still interactive, no? i think you might be adding complexity for no good reason, but maybe that's just me

4:01 LauJensen: eevar2: adding complexity? where?

4:09 eevar2: a db would take care of the acid issues, for instance. even if a work queue + some file system operations isn't _that_ complex

4:09 esj: Morning Good People

4:10 stilkov: it seems something has changed in compojure's defroutes syntax recently - anybody able to point me to a working recent example?

4:13 LauJensen: eevar2: 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

4:14 esj: morning :)

4:41 hiredman: ping?

4:41 clojurebot: PONG!

4:49 LauJensen: pong?

4:49 clojurebot: Qinfengxiang!

5:30 esj: are there any examples out there of a java client consuming the interface generated by a protocol ?

5:30 _na_ka_na_: hi, how do i clear the cache of a memoize fn?

5:31 hiredman: _na_ka_na_: you don't

5: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

5:33 maybe i should include the filename in all the fns ..

5:33 clojurebot: the 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

5:34 esj: _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

5:34 sexpbot: "Kotka : About Clojure… What else?"

5:34 esj: sexpbot: botsnack

5:34 $botsnack

5:34 sexpbot: esj: Thanks! Om nom nom!!

5:35 _na_ka_na_: esj: thanx lemme take a look @ that

5:36 esj: OK, 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

5:36 sexpbot: "Clojure Programming/Tutorials and Tips - Wikibooks, collection of open-content textbooks"

5:40 eintr: autodoc and clj 1.2 seem unhappy together. sadness ensues. all is quiet. undocumented.

5:45 LauJensen: esj: I think its still possible, but checkout cemericks Maven screencast, you see him doing a much simpler interop

5:46 stilkov: I'm running into UniCode problems with Compojure; anybody run into this yet?

5:47 esj: LauJensen: Thanks. I'll check it out. It looks like deftype may be the right stuff, but I'm haven't seen examples.

5:55 spariev: stilkov: what kind of problems do you have ? All mine Unicode troubles were with swank-clojure encoding settings

5:55 stilkov: my problem seems to be independent of swank, it happens if I start my webserver from the command line too

5:57 in 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

5:57 it's as if compojure/ring didn't use UTF-8 encoding when writing

5:58 spariev: haven't tried 0.4 compojure yet, no problems with old 0.3.2

5:59 esj: LauJensen: thanks, nice screencast. Not quite what I was after, but cool.

6:25 LauJensen: Ok :|

6:41 kasperlanger: Hi everyone. Is there a way to freeze the root-bindings of a namespace?

7:54 * fogus reading http://kylecordes.com/2010/the-prolog-story

7:55 _na_ka_na_: hi, I have a question regarding protocols and datatypes,

7:56 I'm defining a proto, as (defprotocol P (foo [this & args]))

7:56 then a datatype as, (deftype PImpl [] P (foo [this & args] (println this args)))

7:56 after that I eval, (foo (PImpl.) :x :y)

7:56 this prints...

7:56 #<PImpl iiit.PImpl@7c8865> :y

7:56 where did the :x go?

7:57 am I defining P, PImpl properly?

7:58 or is destructuring not possible in protos?

7:58 rhickey: fogus: 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

7:59 raek: _na_ka_na_: are you running the latest version? previously the 'this' parameter has been handled in a different way

8:00 _na_ka_na_: raek: I'm using clojure-1.2.0-master-20100518.110252-71.pom

8:01 its working if I do it w/o destructuring ...

8:02 fogus: rhickey: 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

8:03 _na_ka_na_: rhickey: is destructuring possible in proto method declarations?

8:03 rhickey: fogus: three things rain on the parade in Prolog IMO: cut/fail, infinite evaluations, and clause order dependency

8:04 together they truly prevent you from just thinking declaratively, and force you to consider the baked-in evaluation semantics

8:04 LauJensen: _na_ka_na_: http://bestinclass.dk/index.clj/2010/04/prototurtle-the-tale-of-the-bleeding-turtle.html

8:04 sexpbot: "Best In Class: ProtoTurtle - The tale of the bleeding turtle"

8:04 * fogus has been cut by cut many times

8:04 rhickey: _na_ka_na_: what would it mean to put destructuring in the declarations? destructuring is supported in the definitions

8:04 fogus: rhickey: I see what you mean now. For that angle I agree

8:05 s/For/From/

8:05 sexpbot: rhickey: I see what you mean now. From that angle I agree

8:05 fogus: whoa!

8:05 _na_ka_na_: :)

8:07 LauJensen: rhickey: any clues as to how close 1.2 is ?

8: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?

8:15 clojurebot: map is *LAZY*

8:15 _na_ka_na_: clojurebot: not the fn, but the ds

8:15 clojurebot: |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

8:16 _na_ka_na_: :)

8:18 rhickey: _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

8:19 cemerick: I 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.

8:20 rhickey: LauJensen: close

8:21 LauJensen: Great

8:21 fogus: cemerick: More blood than tears for me

8:23 * fogus Still loves the Bratko book

8:23 rhickey: for that subset of Prolog that it covers, Datalog is far superior IMO

8:23 cemerick: fogus: 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.

8:24 npoektop: ,(str "\/")

8:24 clojurebot: Unsupported escape character: \/

8:24 rhickey: fogus: yes, Bratko is great, but I just recommended it to someone and it appears to be running out of print!?

8:25 npoektop: can't write "\/", it says java.lang.Exception: Unsupported escape character: \/

8:25 ,(str "\/")

8:25 clojurebot: Unsupported escape character: \/

8:25 gregh: ,(str "\\/")

8:25 clojurebot: "\\/"

8:26 gregh: is that what you're looking for?

8:26 npoektop: gregh, i need "\/", not "\\/"

8:26 fogus: rhickey: But the Clocksin and Mellish book will continue forever... there's no justice.

8:27 gregh: ,(print "\\/")

8:27 clojurebot: \/

8:27 gregh: str is showing you the escaped representation of the string "\/"

8:28 npoektop: gregh, cool. thank you

8:36 fogus: There seems to be a steady flow of former Rubyists coming into Clojure. Maybe the Scala stream will start picking up soon. ;-)

8:37 ryoko-sha: Newbie apols in advance - (clojure.contrib.prxml/prxml [:p {:class "red"} "cat"]) => <p class="red">cat</p>nil where's nil coming from?

8:37 chouser: ryoko-sha: that's the return value

8:38 cemerick: fogus: are you still solidly in scala for work?

8:38 chouser: <p ...through p> is what prxml is printing, but then it returns nil which the repl prints for you.

8:38 ryoko-sha: chouser: thanks!

8:39 fogus: cemerick: The projects that I used it for are mostly stable now. Working on the Clojure sell at the moment.

8:39 rhickey: fogus: so, what is the Clojure sell to Scala folks?

8:40 chouser: I'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.

8:40 cemerick: Clojure: it eliminates the need for psychotherapy!

8:40 fogus: I hate to say it, but I haven't been pushing for Scala lately.

8:40 chouser: ryoko-sha: which helps point out the difference between printed and returned values.

8:40 * cemerick has seen some absolutely hare-brained scala lately

8:41 eintr: chouser: that's neat, sort of like ipython's fanciful coloring. care to share?

8:41 chouser: hm, I suppose I should.

8:42 fogus: rhickey: 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

8:43 bozhidar: fogus: can you elaborate on the complexity part?

8:43 fogus: IMO, 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.

8:43 rcg: chouser: how did you set these options?

8:43 cemerick: I 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.

8:44 bozhidar: I'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

8:44 fogus: Also 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

8:45 cemerick: bozhidar: 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

8:46 sexpbot: "Nabble - Scala - The right tool"

8:46 bozhidar: cemerick: thanks, I'll have a look at it

8:46 fogus: rhickey: I guess the sell is simplicity. Simplicity beyond the initial "Clojure looks weird" hurdle.

8:47 LauJensen: fogus: the simplicity, and the immutability are what put Clojure miles and miles and a few lightyears ahead of Scala

8:47 bozhidar: if 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

8:47 rhickey: fogus: ok, thanks

8:47 fogus: cemerick: 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

8:48 bozhidar: I'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

8:48 gregh: bozhidar: maybe because twitter uses it. :)

8:48 fogus: bozhidar: That thread (IMO) typifies Scala perfectly.

8:49 cemerick: typifies! Ha!

8:49 * cemerick looks around nervously

8:49 fogus: bozhidar: I think it has many merits.

8:49 bozhidar: I'm reading the thread right now :-)

8:50 cemerick: fogus: 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.

8:50 bozhidar: fogus: I guess so, no language becomes that popular without merits

8:50 except maybe BASIC

8:50 :-)

8:50 Hodapp: *cough*C++*cough*

8:50 gregh: basic's merit was that it was the only choice :)

8:51 cemerick: bozhidar: don't hate on the BASIC. :-) RealBasic is pretty great for what it does.

8:51 fogus: cemerick: 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.

8:51 bozhidar: cemerick: haven't even heard of it

8:51 cemerick: fogus: I'll do you the favor of letting someone else send that OH tweet :-)

8:51 Hodapp: BASIC 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

8:52 bozhidar: Hodapp: I think Pascal better suits the learning bill

8:52 cemerick: bozhidar: it's a cross-platform RAD tool http://www.realsoftware.com/realbasic/

8:52 sexpbot: "REAL Software: REAL Studio, Best Development Tool for Mac, Windows and Linux"

8:52 bozhidar: or Lisp of course

8:52 fogus: cemerick: ;-)

8:52 chouser: http://gist.github.com/407528

8:52 cemerick: delivered my first paid consultant-ware with it

8:52 Hodapp: bozhidar: 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.

8:53 bozhidar: They man move into scoping and functions later. Like, a month or two later.

8:53 s/man/can/

8:53 sexpbot: bozhidar: They can move into scoping and functions later. Like, a month or two later.

8:53 Hodapp: o_O WHAT!?!?!

8:53 ryoko-sha: chouser: thanks for that

8:53 bozhidar: Hodapp: I know what you mean, but what I meant was that Pascal was created to serve mostly educational purposes

8:53 and makes stuff clearer than basic does

8:53 Hodapp: but I'm rather glad it's rarely used anymore

8:53 bozhidar: at least in bulgaria all introductory programming courses are in Pascal

8:54 sometimes in C

8:54 Hodapp: it's mostly been replaced by Java here

8:54 bozhidar: but very very rarely

8:54 * rsynnott had introductory programming courses in a mixture of java, C, and Eiffel

8:55 bozhidar: some mixture that was :-)

8:55 rcg: chouser: thanks :)

8:55 * fogus went to a school where Common Lisp was the intro language.

8:55 rsynnott: bozhidar: they were in the middle of transitioning to java

8:55 bozhidar: fogus: lucky bastard ;-)

8:55 rsynnott: if I'd been there a couple of years earlier it would have been scheme, as well

8:56 oh, we also did prolog as an introductory thing (though with a focus on AI-ish applications)

8:56 bozhidar: I'm not sure that Java is a good choice for a first programming language

8:56 ryoko-sha: Algol-60 & BCPL - I'm a little ancient

8:56 bozhidar: although I have to admit that I've thought introductory programming courses in the university with Java

8:56 rhickey: so, the current strategy for improving last-refer-wins is to preclude a referred var from overwriting an interned one

8:57 bozhidar: used to be perl before

8:57 rhickey: thoughts?

8:57 bozhidar: if I select some lisp dialect probably noone will come...

8:58 Bendlas: hi folks

8:59 cemerick: rhickey: reviewing my notes

9:00 chouser: so last would still win when something has been copied from contrib to core, or when you define something yourself that gets added to core.

9:01 rhickey: chouser: yes, same as now, only say, in repl, you won't be able to trash you own ns vars with a refer/use

9:01 So, in reference to these problems: http://groups.google.com/group/clojure-dev/msg/fca78d8b00d3d6b7

9:01 #1 I consider a non-problem

9:02 also, #2 seems under-motivated

9:02 this fixes #3

9:03 and #4

9:03 cemerick: rhickey: I'm surprised that #1 isn't an issue for you.

9:04 rhickey: cemerick: why? This is a Lisp and load == run all expressions

9:05 :use load-cannons fire-cannons

9:05 not that I'm recommending that :)

9:06 cemerick: Right, 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.

9:06 The appeal to Lisp is fine and all, but sort of ignores the practical consequences of using libraries.

9:07 rhickey: cemerick: I don't see how, there's a warning. It's not a silent switcheroo

9:07 cemerick: thus my instinct to make all ns-effecting changes fundamentally transactional, though that's certainly out of scope, and probably not going to happen

9:08 rhickey: cemerick: you wouldn't like the performance implications of that

9:08 cemerick: Warnings are noise. No one pays attention to them.

9:08 really? That only impacts load-time, no?

9:09 rhickey: cemerick: no, how are you going to see any changes?

9:09 calls do no lookup now, so you can't simply put a ns-map in an atom

9:09 each var would have to be a ref

9:10 cemerick: I think you'd only have to have refs in Namespace, but yeah, I see your point.

9:10 rhickey: I considered it early on, but couldn't justify the overhead full-time on every call

9:10 refs are not nothing

9:11 cemerick: The results of an ns decl could be unpacked after each ns-effecting action so as to avoid the costs.

9:11 rhickey: now, in a direct-linking world, that is very doable and fast

9:11 cemerick: I don't see what you are saying re: unpacked

9:13 cemerick: rhickey: 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.

9:14 ...but all this is sorta straying from the topic, unless drastic changes under the covers are on the table as a possibility.

9:14 rhickey: cemerick: so, you are really more interested in all-only-if-nothing-fails ns load than truly transactional visibility

9:14 cemerick: right

9:15 rhickey: cemerick: these loads and warning aren't runtime things, they are things you'll encounter during dev and work out

9:15 I don't see the nuclear threat you do

9:15 cemerick: I 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.

9:17 say 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.

9:17 And we all know that all tests are entirely comprehensive in terms of prodding the full domain of the functions in question.... :-P

9:17 rhickey: cemerick: 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

9:18 cemerick: rhickey: bleh, good point.

9:19 rhickey: cemerick: so you'd be happ(y/ier) with a *treat-load-conflicts-as-errors* option?

9:20 cemerick: I doubt it. I'm hoping to see things get simpler, not add more options. :-)

9:21 rhickey: cemerick: then what is your version-to-version compatibility story "suck it up, and suffer until your lib vendors do the same"?

9:21 or cgrand's :as-of lockdown?

9:21 cemerick: heh

9:21 I have a lot of sympathy for those hitting conflicts arising from core adding things.

9:22 I have much, much less sympathy for those doing blanket use all over the place.

9:22 rhickey: or core/this core/that everywhere?

9:22 cemerick: Of course, those doing that write a lot of useful libs people depend upon.

9:23 rhickey: cemerick: blanket use was never good, and still isn't. This isn't about enabling that

9:25 I haven't seen many viable alternatives, but am still open

9:29 no more additions to core?

9:30 cemerick: heh

9:30 rhickey: why treat core refers the same as all other refers?

9:30 I mean, beyond the appeal of simplicity.

9:30 rhickey: cemerick: vs what?

9:37 cemerick: Perhaps last-refer-wins should apply to core and nowhere else.

9:37 rhickey: cemerick: ah

9:38 SynrG: win 2

9:38 cemerick: I think that's what chouser was driving at when we talked about this in the irc log I linked to in my post.

9:38 SynrG: buh

9:38 cemerick: it's certainly a complication, but there's already a special :refer-clojure form in ns

9:42 rhickey: cemerick: it is kind of special-case-y, but mirrors implicit refer of core

9:42 cemerick: rhickey: it'd actually have to be, last-refer-wins for any var name that is in core, not just for actual core vars

9:42 rhickey: ?

9:43 cemerick: e.g. ns A defines a reduce fn. ns B uses A. Presumably, that use shouldn't error out.

9:44 rhickey: I don't see the difference

9:44 cemerick: Maybe I'm overthinking it.

9:45 rhickey: you are never actually replacing something in core, only the slot in your ns

9:45 which is re-filled with stuff from core

9:45 pre-filled

9:46 cemerick: OK, say ns A defines a reduce fn, which takes precedence over core's reduce.

9:47 rhickey: ok

9:47 then B uses A

9:47 cemerick: ns B then uses A. If last-refer-wins strictly applies only to core, then that use will fail, right?

9:48 rhickey: no, since the reduce in B refers to core/reduce, this rule applies. It's not different from (def reduce ...) in your own ns

9:48 basically, you can't bump out references to core vars, by whatever means, with a warning

9:48 corry - can bump out

9:48 sorry, can't type

9:48 cemerick: ach, right, ok, I had things inverted

9:50 rhickey: I think it's at least worth seeing how it plays, unless you dead-set against.

9:50 rhickey: so, I am inclined towards this restriction of last-var-wins

9:50 cemerick: Stellar. I think it's a big improvement on spec.

9:50 rhickey: would obviate the no-overwriting-interns, so no more complex

9:50 and would still warn

9:51 cemerick: Falling back on warnings is such a red flag to me. Begs for a *strict*, which is yet another red flag.

9:51 rhickey: I wonder if it covers all migration pain cases

9:52 cemerick: That's what the beta/RC is for, I suppose. :-)

9:53 rhickey: cemerick: 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

9:54 but 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

9:54 chouser: just flush them out -- find one important var from each major lib and add it to core.

9:54 cemerick: rhickey: I think that's going to be par for the course.

9:54 chouser: :-)

9:55 rhickey: chouser: http://github.com/stuarthalloway/argos

9:55 chouser: huh!

9:55 nice

9:56 cemerick: I 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.

9:56 * rhickey is so close to removing __1234 from named fn classnames

9:56 chouser: so I went to a meetup last night and found it energizing in roughly the way that writing a book is not.

9:57 rhickey: cemerick: need not with this mechanism, at least one release with libs in place, deprecated

9:57 esj: chouser: lol

9:57 chouser: rhickey: hm! interesting. why?

9:57 rhickey: chouser: :)

9:57 I missed my NYC Clojure meetup thinking it was tonight :(

9:57 cemerick: rhickey: no, but ^ and who-knows-what-else will do it this time around

9:57 * fogus thinks maybe he should stop beating chouser for grammar mistakes.

9:58 rhickey: chouser: why remove them? because they are ugly

9:58 chouser: fogus: seriously. gimme a break! ;-)

9:58 _na_ka_na_: :rhickey IMO the focus should be the majority of noob/new developers (like myself)

9:58 cemerick: Makes for nicer interop, no? new my.clojure.function().invoke(foo, bar, baz)

9:58 fogus: chouser: I know what you mean though.

9:58 _na_ka_na_: Not everyone (esp. newcomers), I figure read/care about the warnings, ref: app server warnings!

9:59 The lib writers / experienced coders will get around I'm sure, no matter what the final solution.

9:59 rhickey: cemerick: ouch! who's doing that?

9:59 _na_ka_na_: Some people may blindly / unintentionally wrongly assume their code to be "1.2 complaint" when there are warnings..

9:59 So I think overall *treat-load-conflicts-as-errors* would be better?

9:59 cemerick: rhickey: no one, but that would become possible given elimination of _1234, no?

9:59 Raynes: Ain't that the pot calling the kettle black! I fixed at least 4 mistakes fogus made in the tryclojure tutorial. ;)

10:00 rhickey: cemerick: I hope not. I'm not promising that fns can be created that way. Calling through vars vastly preferred

10:00 fogus: Raynes: Writing a book and spelling/grammar ability are orthogonal. :p

10:00 chouser: one 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:00 cemerick: rhickey: Sure. Just trying to make my UI programming easier. :-)

10:00 rhickey: cemerick: but stack traces etc should clean up a good bit

10:00 cemerick: that's always good

10:01 _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:01 fogus: chouser: Slides?

10:01 powr-toc: I'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:01 rhickey: unfortunately the last step is a doozy, and I might back it out

10:01 chouser: fogus: 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:03 cemerick: _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:04 cemerick: _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:05 rhickey: the remaining hurdle is the redefs in core itself, related to e.g. bootstrapping w/o destructuring, then adding it etc

10:05 I 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 creating much up-gradation pain is preferable to shaky semantics?

10:20 cemerick: I 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 Proto: (defprotocol P (foo [this f])), Type: (deftype PImpl [] P (foo [this ^String f] (FileWriter. f)))

10:24 jweiss: cemerick: 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:25 cemerick: jweiss: the master branch is 1.2

10:25 jweiss: there's a 1.1 compatible branch, which oddly, when i run lein deps, installs clojure-1.2 snapshot jars

10:25 cemerick: hrm

10:25 jweiss: i can use 1.2, that's no problem

10:26 cemerick: jweiss: we're merging the two branches today-ish, and dropping 1.1. entirely.

10:26 That's just FYI.

10:26 jweiss: cemerick: meaning that it won't work with 1.1? or it will work with either

10:27 cemerick: Meaning 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:28 jweiss: cemerick: i see. isn't it unusual not to support the latest release of the language? :)

10:28 cemerick: Depending on my level of motivation, I may cut a final 1.1-compatible branch that will get no new features.

10:28 * jweiss is ok with bleeding edge stuff

10:28 cemerick: jweiss: 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:29 jweiss: i see, well, if clojure-1.2 works for people here, it should work for my newb self

10:29 cemerick: Perhaps I'll stand up a public hudson. That'll make supporting different versions of these libs a lot easier.

10:29 Understand, I'm not *opposed* to having a 1.1-compatible clutch, it's just a workload issue.

10:30 jweiss: cemerick: that's fine, i'm not constrained to a particular clojure version

10:31 although i haven't actually tried with 1.2 yet, i hope compojure works with it, i assume so

10:32 cemerick: I think HEAD is. There are branches here and there of 1.2-compatible 0.3.x-era compojure as well.

10:54 Raynes: fogus: <3 for the encouragement.

10:55 Extremely helpful for a young, terrified padawan such as myself. <3

10:58 texodus: There's no way to attach metadata to Classes, I assume?

10:59 Chousuke: nope.

11:00 texodus: so documenting deftypes and defrecords is just plain out ...

11:01 Chousuke: texodus: hmm

11:06 eintr: chouser: modded your repl-init. added some flair to exceptions as well, and tuned colors for 256 color terms: http://gist.github.com/407622

11:06 chouser: eintr: whew!

11:07 remleduff: Why do you do clojure.main -e "(my-repl)" rather than just calling (my-repl) at the end of repl-init?

11:07 chouser: hm. I dunno.

11:08 * eintr points at chouser

11:08 eintr: :)

11:09 sanityinc: I 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:10 rsenior: sanityinc: do you have AOT compiling enabled?

11:10 sanityinc: Only if that's the default.

11:10 jweiss: cemerick: 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:11 i 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:11 cemerick: jweiss: it also supports passphrase-protected keys :-)

11:11 jweiss: cemerick: did you implement that or is it part of jsch

11:12 cemerick: that's all jsch. It definitely works, but is a miserable API.

11:12 rsenior: I had that issue when I had old class files sitting out there that were taking precedence over my newly evaluated protocol definition

11:12 cemerick: jweiss: hugod is actually your point man for clj-ssh stuff

11:12 jweiss: cemerick: so what ssh agent does it use? not compatible with linux's i assume

11:12 cemerick: no -- I'm pretty sure it's an in-memory impl provided by jsch

11:12 sanityinc: rsenior: I can reproduce the problem with a completely empty project

11:13 remleduff: sanityinc: 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:13 jweiss: cemerick: 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:14 sanityinc: remleduff: Nope, I tried that too

11:14 hugod: jweiss: pallet adds some code to query the osx keychain - I need to move that into clj-ssh

11:14 cemerick: jweiss: 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:14 hugod: snap

11:15 jweiss: cemerick: to use unix ssh-agent would require unix sockets which java doesn'tdo

11:16 which is really irritating that basically java and ssh are incompatible

11:16 sanityinc: It's quite a surprising misbehaviour, and having to quit the JVM to fix it sucks.

11:17 jweiss: currently 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:17 we are currently just using a throwaway key with a password that we don't care if it sits in a plaintext file

11:17 not secure, of course

11:27 sanityinc: Needless to say, since it seems like a class loading / caching issue, it's pretty much impossible to see what's going wrong.

11:39 hoeck: sanityinc: confirmed here, but after defining ArraySteps without a protocol (deftype ArraySteps []), and then redefinging the protcol-implementing ArraySteps type, it works :/

11:41 sanityinc: hoeck: 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:44 hoeck: redefining the same ArraySteps over and over again doesn't change the Class

11:45 sanityinc: hoeck: Ah, now, using reify solves the problem. So it looks like deftype is broken, or at least doing something unexpected.

11:46 hoeck: see http://gist.github.com/407710

11:46 sanityinc: hoeck: so (defn arraysteps [a] (reify proto/Steps ...)) is fine

11:46 hoeck: seems like deftype does some weird kind of caching

11:48 sanityinc: The macroexpansion suggests that, yes. But I'm not smart enough to see exactly what's going wrong.

11:49 hoeck: when 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:50 maybe there is/was a reason to not create a new class for identical deftypes

11:52 sanityinc: I can see how that would be desirable, but changes in the underlying protocols should also be taken into account, I guess.

11:52 hoeck: right

11:53 sanityinc: So... does this warrant an Assembla ticket?

11:53 jweiss: cemerick: does clutch work with couchdb 0.10.2?

11:54 cemerick: jweiss: I'd hope. No?

11:54 hoeck: sanityinc: I guess you have to ask rhickey about this :)

11:54 jweiss: cemerick: i am still having the same problem with the view server after updating to clojure 1.2

11:54 cemerick: what's the issue?

11:55 jweiss: it is exiting with return code 1 as soon as i try to load a view in futon

11:55 i didn't check yet to see if it's the same error, but last time it was a JSON error

11:55 cemerick: hrm

11:55 jweiss: let me check the couchdb log

11:58 cemerick: ah, trying to start the view server with the same cmd from the local.ini on the cmd line gives:

11:58 rhickey: sanityinc: yes, please create a ticket for this and set to milestone 1.2

11:58 jweiss: Caused by: java.io.FileNotFoundException: Could not locate clojure/contrib/json/read__init.class or clojure/contrib/json/read.clj on classpath:

11:58 sanityinc: rhickey: Thanks - will do.

11:58 cemerick: jweiss: ah, well, that's a lot simpler of an issue :-)

11:59 jweiss: oh i fat fingered the classpath

12:04 cemerick: looks like the same problem still- it's looking for contrib/json/read.clj but that's not in contrib-1.2

12:04 i am using clutch 0.2 from leiningen

12:05 is there a newer jar i can point to in project.clj

12:06 cemerick: jweiss: if ashafa could talk, he'd say the jar in clojars is 1.1-only

12:06 :-)

12:07 I don't think any newer deployments have been done of it.

12:12 jweiss: cemerick: the view server and the clutch lib don't need to be the same version do they?

12:12 cemerick: hrm, probably not

12:13 could get confusing though

12:14 jweiss: ashafa says "if he uses clojure 1.1 in project.clj, he could just run lein superjar"

12:15 (I guess he doesn't have voice here or something)

12:15 mmarczyk: he should register his nick with NickServ, then

12:16 cemerick: is that actually required to get voice? I haven't been anon in a long time, but I don't remember it being required.

12:17 mmarczyk: well, I've had connection problems a couple of times recently, reconnected with a temp nick (mmarczyk`) and couldn't talk here

12:17 then reconnected in the usual way and all was fine...

12:18 I guess that's not enough to draw the conclusion that registering is required, but it's worth a shot

12:25 esj: when using :gen-class and :extends on a java class I'm not getting the protected methods of that class. Is this expected ?

12:29 jfields: how do you filter nil objects? (filter x? coll) what's x?

12:29 remleduff: identity

12:29 chouser: esj: you need :exposes-methods

12:30 esj: chouser: I have em.

12:30 remleduff: Though identity will filter "false" too

12:30 Raynes: $(remove identity [1 2 3 nil 4 5 6 nil 7 nil 8])

12:30 sexpbot: result: clojure.lang.LazySeq@745f

12:31 Raynes: $(remove nil? [1 2 3 nil 4 5 6 nil 7 nil 8])

12:31 Eh.

12:31 sexpbot: result: clojure.lang.LazySeq@6b4b5785

12:31 esj: jfields: (complement nil?) might work too

12:31 * Raynes puts "unroll lazy seqs" on his todo list

12:31 jfields: remove does what I want. thanks

12:32 * Hodapp trolls ##c

12:32 esj: chouser: 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:36 remleduff: Hmm, gen-class documentation claims that it exposes all "non-private" superclass methods, which I'd think would include protected methods

12:37 esj: indeed.... let me mock up a toy example and get back to you all

12:42 remleduff: esj: Are you including the prefix?

12:43 esj: in the call ? no. just doing (.methodSure this arg)

12:43 s/Sure/Super/

12:43 sexpbot: in the call ? no. just doing (.methodSuper this arg)

12:46 remleduff: hm

12:46 sanityinc: Re. 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:48 remleduff: You should be able to make a "support" ticket as a watcher

12:48 sanityinc: Aha, gotcha. Thanks.

12:56 arohner: can 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:56 sexpbot: "#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:56 sanityinc: Okay, 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:00 remleduff: Ha, I can't seem to do that for a support ticket

13:03 There we go

13:11 esj: rats - in the toy example protected methods do appear

13:11 more homework for me

13:15 AHA ! 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:18 but that does not explain why :exposes-methods won't let me see it

13:19 sanityinc: remleduff: thanks

13:20 remleduff: Wow, generate-class is a huge function

13:20 esj: remleduff: oh yeha

13:21 remleduff: i'm guessing that :exposes-methods creates a new method that in fact overrides the superclass with a thin wrapper

13:21 remleduff: But can't do that for final methods :\

13:22 esj: indeed

13:22 but now how do I get to the superclass method, which i don't want to override

13:27 remleduff: Can you paste your example code for me? I'm trying to follow along ;)

13:27 esj: sure: http://gist.github.com/407826

13:27 sorry... 1 sec

13:28 http://gist.github.com/407831

13:29 I'm going to ask in the google group, I'm stumped

13:30 jweiss: can the stable release of leiningen be used to build projects that depend on clojure1.2? mine is failing all over the place

13:30 http://fpaste.org/zYiL/

13:31 powr-toc: Does anyone know a way to do the following? (apply (partial struct-map foo) { :foo :bar})

13:31 I'd like to convert a map into a struct-map

13:32 chouser: wow, I just found my first use of :>> in condp

13:32 that is one obscure feature.

13:35 jweiss: cemerick: any idea why i get the error in that paste above trying to run lein install on clutch master branch?

13:37 remleduff: esj: Do you also get the message "java.lang.VerifyError: class foo.Foo overrides final method baz" that I'm seeing?

13:37 esj: that's the one

13:38 powr-toc: How 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:39 (well specified by the defstruct)

13:39 cemerick: jweiss: none off the top of my head -- I use maven though

13:39 bbl

13:39 savanni: Hey, 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:40 esj: savanni: often they have a ! at the end of the name

13:41 savanni: k, 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:41 And, this database update is not happening in STM.

13:42 chouser: savanni: 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:42 savanni: Each call makes observable changes.

13:42 chouser: ok, that would not be safe to do in a transaction

13:43 so a ! suffix is appropriate

13:43 you 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:44 savanni: Wait, why is that unsafe? Is it because the database cannot be rolled back in the case of a failure?

13:45 Hodapp: yikes, the assholishness of ##c++ is astounding...

13:50 ataggart: savanni: it's because the STM transaction may be retried

13:51 savanni: Ah, I had not tohught of that.

13:51 Where is some good documentation on the subtlies of STM? Something that if I had read and thought about I would have realized that?

13:52 chouser: savanni: http://clojure.org/refs

13:52 "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:52 savanni: Okay, awesome. Thank you!

13:55 esj: chouser: 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:55 sexpbot: "Re: Accessing a protected final method of the superclass - msg#00452 - clojure"

13:57 chouser: I don't recall that specific issue, and don't see any follow-up on the ggroup. So ... I guess not.

13:57 gah! expired paste!?

13:57 that really really sucks

13:58 makes my reply there alomst completely useless

13:58 esj: chouser: rats !

13:59 remleduff: generate-class still calls non-private-methods which filters out final methods as well, so I don't think it's been fixed

14:04 jfields: is there a function that takes [1 -1 2 -2] and returns [[-1 -2] [1 2]]?

14:07 esj: so, in this case, assuming I can't use gen-class to make .class files, what other options do I have ?

14:10 that many huh.... i feared so :)

14:15 chouser: esj: .java :-(

14:17 Borkdude: java? :(

14:20 Is 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:21 fogus: Borkdude: Google always works for me. ;-)

14:22 remleduff: esj: (def Hello-Forwarder (proxy [com.example.Hello] [] (yo [] (proxy-super yo))))

14:22 then (.yo Hello-Forwarder)

14:23 * esj scurries to his repl

14:24 remleduff: But, that may not work depending on what you need to do in gen-class

14:25 esj: it is a new and different object

14:26 Borkdude: fogus: Google, yes, brilliant ;)

14:27 so, google is a function in what namespace exactly? ;)

14:31 Hodapp: Borkdude: ALL NAMESPACES!

14:31 * Hodapp plays dramatic, "oh shit" music

14:35 mmarczyk: Borkdude: you can always use clojure.contrib.find-namespaces to require every namespace you've got on the classpath

14:35 and then use find-doc

14:43 Lajla: Hodapp, how do namespaces work in Clojure?

14:46 Borkdude: mmarczyk: I did (find-namespaces-on-classpath)

14:46 mmarczyk: but it doesn't find e.g. mexpand-all

14:46 it=find-doc

14:50 mmarczyk: should I use map to require all of the namespaces returned by find-namespaces-on-classpath?

14:56 hmm, is clojure.walk/macroexpand-all a replacement for macro-utils/mexpand-all?

15:23 http://twitgoo.com/wjpd5

15:23 sexpbot: "Hanging out with #deadline #clojure #compojure #appengine at #io2010"

15:33 chouser: what's going on here? http://gist.github.com/407980

15:33 why doesn't (gettag x) return String ?

15:36 rhickey: any hints?

15:40 ninjudd: chouser: what does &env mean? i haven't seen that syntax

15:41 Borkdude: chouser: same question, it only works in 1.2 I just noticed

15:44 chouser: it's new macro magic

15:45 ninjudd: chouser: what does it mean?

15:47 chouser: if gives you the lexical scope at the point where the macro is expanding

15:47 it gives

15:47 Borkdude: hmm

15:47 chouser: which I'm abusing to do things that would otherwise require a code walker

15:48 remleduff: Does a &prefix have some special meaning?

15:48 chouser: not generally. macros now have &env and &form

15:50 Borkdude: chouser: is (find &env sym) to equivalent to [sym (eval sym)]?

15:50 mmarczyk: Borkdude: yeah, you'll have to use require on the namespaces

15:50 Borkdude: find-namespaces-on-classpath only finds out which namespaces are available

15:51 Borkdude: mmarczyk: ic

15:51 mmarczyk: I used (map require (find-namespaces...))

15:51 then I got an exception along the way, but it used most of them....

15:51 mmarczyk: wrap it in a dorun if it's in a source file

15:51 an exception? interesting

15:52 anyway, wait a sec, I think I have a link for you

15:52 rhickey: chouser: did you intend to use the same local name twice?

15:52 mmarczyk: http://learnclojure.blogspot.com/2010/02/requiring-all-possible-namespaces.html

15:52 sexpbot: "Learning Clojure: Requiring all possible namespaces"

15:53 chouser: yes

15:53 this is generated code, and I'm trying to attach meta data on the inner one and pick it up in the macro

15:54 the 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:56 Borkdude: no, not equivalent.

15:57 Borkdude: the values in the &env map are CompilerExpr objects (couldn't be runtime values as this is compile time)

15:57 Borkdude: 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:58 which 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:59 I may be able to work around this, but it's bugging me.

16:06 rhickey: chouser: (map meta (keys (assoc {'^String x 11} '^Integer x 42)))

16:06 ,(map meta (keys (assoc {'^String x 11} '^Integer x 42)))

16:06 clojurebot: ({:tag String})

16:07 chouser: ah. so the compiler must be using something other than &env to figure out the :tag.

16:07 rhickey: chouser: the compiler is using the local binding info in the value, no longer the symbol after parsing

16:08 chouser: ah, right. hmph.

16:09 rhickey: (defmacro gettag [sym] (.tag (val (find &env sym))))

16:10 chouser: (defmacro gettag [sym] (.tag (get &env sym)))

16:10 tcrayford: chouser: 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:16 chouser: tcrayford: ok

16:18 Borkdude: mmarczyk: ah tnx, he catches Exceptions and wraps it in a doall, I see

16:18 chouser: rhickey: ok, I can get use .sym to get the metadata I really want.

16:18 not sure I want to do that though... hrm.

16:19 Borkdude: I'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:23 chouser: oh, 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:32 riddochc: (str "Good " (timezone-appropriate-greeting recipient) ", everyone.")

16:37 Borkdude: riddochc: (printf "%du%d" 2 2)

16:39 The-Kenny: I read about a "irc standard greeting time" some time ago

16:40 "If someone enters the channel, it's morning. Regardless of the actual local time. If someone leaves the channel, it's evening."

16:42 http://www.total-knowledge.com/~ilya/mips/ugt.html "Universal Greeting Time"

16:42 sexpbot: "UGT"

16:46 riddochc: The-Kenny: That's rather amusing.

16:47 maxhodak: is there anything already for doing rule-based systems in clojure (i.e., logic programming)?

16:48 chouser: datalog?

16:48 tcrayford: maxhodak: I only know about http://github.com/jduey/mini-kanren

16:49 maxhodak: and the accomanying article: http://intensivesystems.net/tutorials/logic_prog.html

16:49 sexpbot: "Logic Programming for the Social Web"

16:49 remleduff: cascalog as well http://nathanmarz.com/blog/introducing-cascalog/

16:49 sexpbot: "Introducing Cascalog: a Clojure-based query language for Hadoop — thoughts from the red planet"

16:49 riddochc: maxhodak: I'd heard of something not too long ago on clojure planet.

16:49 tcrayford: his monad articles are damn cool as well

16:51 maxhodak: riddochc: tcrayford: thanks guys

16:51 ill check those out

18:57 riddochc: Argh. I can't remember the name of the function I'm looking for...

18:58 I 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:58 Lajla: riddochc, I think it's the factorial.

18:58 Ohh, not the factorial.

18:58 tcrayford: riddochc: zipmap?

18:59 ,(doc zipmap)

18:59 clojurebot: "([keys vals]); Returns a map with the keys mapped to the corresponding vals."

18:59 tcrayford: don't think its lazy though

18:59 riddochc: tcrayford: That seems more appropriate for two separate seqs, one of keys, one of vals, right?

18:59 tcrayford: confirm

18:59 you can do that by breaking out your original seq into two things

19:00 (and can almost definitely do that lazily, but I can't remember the name of the function that does it)

19:01 riddochc: Hm. 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:02 There'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:03 Hm. I could loop/recur over the source, and use assoc in the recursive step...

19:03 tcrayford: then wrap it with lazy-seq

19:03 mmarczyk: how would you go about constructing a map lazily?

19:03 I mean, in principle

19:03 what do you do if you attempt a lookup

19:04 riddochc: tcrayford: Yeah, that would work. I could swear I saw something really similar in either clojure or -contrib, though...

19:05 tcrayford: does it need to be lazy?

19:05 how big is "source"

19:06 riddochc: tcrayford: Not huge. Think email headers, for scale. (It's a git commit. So, rather short.)

19:07 It doesn't really need to be lazy.

19:07 tcrayford: well just use apply then?

19:07 lazy maps don't really make much sense, as mmarczyk pointed out above

19:07 riddochc: Yeah, yeah, I just keep thinking, "Functional! Generic! Perfectionism!" and such. *sigh*

19:07 tcrayford: alternatively, you can use reduce

19:08 riddochc: Reduce! Duh.

19:08 * tcrayford is using reduce as his hammer for everything these days

19:08 riddochc: Reduce makes a *lot* of sense for this.

19:08 tcrayford: see http://www.tcrayford.net/2010/05/14/A-Tutorial-On-Reduce.html

19:08 sexpbot: "tcrayford"

19:08 mmarczyk: you could just use (comp reduce merge)

19:08 meaning (reduce merge your-seq-of-single-binding-maps)

19:09 tcrayford: now we get point-free worked in as well

19:09 joy

19:09 mmarczyk: or (reduce into {} your-seq-of-key-value-pairs)

19:09 :-)

19:09 riddochc: Yeah, 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:09 tcrayford: reduce is so damn powerful

19:09 riddochc: mmarczyk: Awesome.

19:09 tcrayford: its crazy

19:10 mmarczyk: for 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:10 ;-)

19:10 tcrayford: is there a complement to create-ns?

19:10 that deletes namespaces?

19:10 mmarczyk: tcrayford: remove-ns, I think

19:10 riddochc: tcrayford: Quite right, it is. Map and reduce, man. Not to be confused with google's mapreduce. Feh.

19:10 mmarczyk: (doc remove-ns)

19:10 clojurebot: "([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace."

19:10 tcrayford: gotcha

19:10 cheers

19:11 * tcrayford is mocking out tests for refactoring function names in his clojure refactoring tool

19:12 riddochc: mmarczyk: Thanks for the (reduce into {} ...) - that's beautiful, I'm using it.

19:12 tcrayford: I think I prefer the comp one myself, but aye

19:13 riddochc: Hmm. I don't have a seq of single binding maps, but I could arrange for that...

19:14 Wait, no, I suppose that's exactly what I have.

19:14 mmarczyk: tcrayford: Clojure refactoring -> cool :-)

19:14 riddochc: happy to hear that :-)

19:15 tcrayford: mocking out filesystems and such looks to be a right pain :/

19:15 mmarczyk: riddochc: if you had doubleton vectors (representing map entries), you could use (reduce conj {} seq-of-entries)

19:17 tcrayford: I'd expect it to be :-(

19:17 tcrayford: if 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:18 mmarczyk: there's a function called refer-clojure

19:18 or is it a macro... hm

19:18 (doc refer-clojure)

19:18 clojurebot: "([& filters]); Same as (refer 'clojure.core <filters>)"

19:18 mmarczyk: whatever. anyway, do (clojure.core/refer-clojure)

19:18 tcrayford: aha

19:18 cheers

19:19 riddochc: Well, re-seq gives a vector of results that I'm unpacking with a let...

19:22 Hm.

19:22 mmarczyk: hm, maybe (reduce conj {} (map (partial subvec 1) (re-seq ...))) then?

19:23 tcrayford: if you're getting into mutliple nested seq functions, I'd reccomend using ->>

19:23 mmarczyk: yeah, good point

19:23 tcrayford: or just breaking them up into smaller ones

19:23 (or both)

19:23 mmarczyk: (->> (re-seq ...) (map (partial subvec 1)) (reduce conj {}))

19:23 * tcrayford has a function somewhere in his code still that has something like 12 nestings of map, filter and reduce)

19:24 riddochc: I haven't actually used ->> much yet.

19:24 tcrayford: its pretty useful for readability

19:24 mmarczyk: tcrayford: best not touch it if it doesn't break on its own ;-)

19:25 tcrayford: mmarczyk: that code is pretty much finished with for now anyway

19:25 besides, refactoring-mode can automatically thread stuff with ->> </blowing his own horn>

19:25 mmarczyk: cool! :-)

19:26 riddochc: There's certainly more than one way to do this. I'm not sure what I should do if the regex *doesn't* match...

19:27 mmarczyk: you could consider sth like 1.2's keep for throwing non-matches away

19:27 * riddochc looks up 'keep'.

19:28 riddochc: That looks rather appropriate. re-seq gives a nil on non-matches...

19:28 tcrayford: heh

19:28 ,(filter identity [nil nil 1])

19:28 clojurebot: (1)

19:29 riddochc: Cool. I'm using 1.2 anyway...

19:29 tcrayford: using keywords as arguments to filter is nice if you want only maps with certain keys

19:29 mmarczyk: though that would be most natural with (keep (partial re-find #"...") ...)

19:30 for re-seq, good old filter identity is probably just as good, yeah

19:30 tcrayford: how do I add metadata to a function whilst I'm defining it?

19:30 is it (defn foo {:bar 1} [a] a) ?

19:30 mmarczyk: you could do that

19:31 tcrayford: I get an error here

19:31 mmarczyk: or add reader metadata to the symbol

19:31 tcrayford: how?

19:31 clojurebot: with style and grace

19:31 tcrayford: assuming 1.2

19:31 mmarczyk: oh? I think you shouldn't get an error for that

19:31 see if it works if you include a docstring before the map

19:31 tcrayford: still errors

19:31 (defn foo "" {:line 3 :file} "foo.clj" [a] a)

19:32 oh

19:32 fail

19:32 yeah the map was messed up

19:32 my installation of paredit in my repl is somewhat borked

19:32 mmarczyk: right

19:32 as for the reader metadata solution

19:33 (defn ^{...} foo ...)

19:33 (or the old #^)

19:33 tcrayford: I should probably use old-style, as not all projects are using 1.2 atm

19:33 mmarczyk: oh, but the new style is so *pretty*!

19:34 *khem*

19:34 I guess you're right

19:35 as soon as you use a protocol, though... :-)

19:35 tcrayford: now 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:36 if my tool makes the changes then it has to handle undo, but I can test it better

19:37 mmarczyk: or make it configurable

19:37 so it's somewhat usable with other editors too

19:37 (hopefully)

19:37 tcrayford: well either route is pretty configurable

19:38 the emacs way of doing it would just send out s-expressions, which the other editors can parse and use

19:38 mmarczyk: personally I'd prefer changes to happen in the Emacs buffer

19:38 tcrayford: mmarczyk: the changes *will* happen in the buffer, I'll just call revert-buffer after making the change

19:38 mmarczyk: well that's not quite what I meant :-)

19:39 tcrayford: I can't change multiple files from one buffer

19:39 mmarczyk: I meant, "in the buffer first, w/o touching the file"

19:39 if you need to create a new file, sure, go ahead

19:39 tcrayford: that's what happens currently, but you have to touch the file to change across multiple namespaces

19:39 *touch the files

19:39 mmarczyk: if you need to change a different, but already existing file, have find it in Emacs first

19:39 tcrayford: have the user, or the emacs mode?

19:40 mmarczyk: ouch... "have Emacs find it first"

19:40 somehow ;-)

19:40 tcrayford: oh I can do that, its not hard

19:40 the other downside of that method is that I have to learn about stubbing the filesystem in emacs :(

19:40 oh

19:40 actually not

19:40 mmarczyk: that downside is also an upside ;-)

19:41 tcrayford: yeah I think I know where I'm going with this now

19:41 cheers

19:41 mmarczyk: cool

19:41 I think I've seen you doing a screencast with an early version of this...?

19:42 tcrayford: the katacast?

19:42 mmarczyk: yup

19:42 tcrayford: yeah, the current version isn't much changed from that

19:42 mmarczyk: looked pretty cool

19:42 tcrayford: currently it just takes s-expressions (which you select in emacs), and then does stuff to them

19:43 mmarczyk: does it preserve line breaks at this time?

19:43 tcrayford: nope, that's still broken

19:43 mmarczyk: right

19:44 tcrayford: need to talk to somebody who knows emacs better than me for that

19:46 can you spot any errors with this: http://gist.github.com/408283 ?

19:48 basically create a new namespace, defines a function in it, then tries to find that function from another namespace using find-var

19:48 mmarczyk: actually in-ns creates the namespace if it doesn't exist already

19:48 tcrayford: yep

19:48 mmarczyk: the other in-ns should use a - in the namespace name instead of _

19:49 tcrayford: that's me being bad, shouldn't break anything atm

19:49 ah

19:49 needed a call to require in the new namespace

19:49 Licenser: hmm 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:49 does anyone ever seen this?

19:50 mmarczyk: tcrayford: you mean to pull in clojure.test/is ?

19:50 tcrayford: mmarczyk: no, require the just-created namespace

19:50 mmarczyk: tcrayford: that's the next thing I thought would probably break

19:50 um, right

19:50 but I wonder if you need to pull in #'is

19:51 tcrayford: its in the top of the file

19:51 yeah, test works now

19:51 mmarczyk: oh good :-)

19:52 tcrayford: oh, maybe not, just throws an error that test-mode didn't highlight

19:53 mmarczyk: Licenser: check that you're not filtering too much stuff out

19:53 Licenser: mmarczyk: the filters are just set to sun and apple stuff

19:54 grrr and now it stack overflows :(

19:54 mmarczyk: Licenser: weird... I suppose you've checked that you're connecting to the right jvm...?

19:54 Licenser: yes I see the stuff in the text console

19:54 mmarczyk: super weird. :-(

19:55 Licenser: yea eseically since it stack overflows now even it does not in the repl

19:56 mmarczyk: tcrayford: and the file that code comes from defines the namespace clojure-refactoring.rename-fn-test ?

19:56 tcrayford: maybe check the _ -> - thing there too

19:56 * Licenser tries some more stuff

19:57 tcrayford: mmarczyk: yes

19:57 mmarczyk: Licenser: is restarting the whole thing an option?

19:57 Licenser: it seems to entirely ignore my code

19:57 mmarczyk: oh, and btw

19:57 Licenser: mmarczyk: yes I cna reset everything I want

19:58 mmarczyk: hmmm

19:58 maybe try running something like

19:58 oh... um...

19:58 Licenser: rm -rf /

19:59 for i in `find / -name "*java*"`; do rm -rf $i; done

19:59 mmarczyk: (loop [k 12345143265143256124351234512435 l 5471843290518432758102435 m 12354143256] (recur (mod (* k l 2) m) (mod (* k l 3) m) m))

19:59 Licenser: yeah, that's another option ;-)

19:59 Licenser: ^^

19:59 mmarczyk: what should that give me?

19:59 mmarczyk: some bignum arithmetic in an infinite loop might spin the whole thing up a bit

19:59 then you'll see if visualvm picks it up

20:00 Licenser: ah good plan!

20:00 mmarczyk: I suppose you need bigger numbers, though

20:00 clojurebot: (pl reverse $ (↕reduce range $ 10 () λxy (↕conj inc $ y x)))

20:00 mmarczyk: actually a bigger m

20:01 * Licenser tests it w/o jar acutally

20:01 mmarczyk: clojurebot: Clojukell? Hajure?

20:01 clojurebot: It's greek to me.

20:02 tcrayford: in theory you could write a clojure on top of haskell that uses the dot syntax for calling down to haskell

20:02 mmarczyk: Licenser: hmmm :-)

20:02 Licenser: mmarczyk: the CPU has fun, the profiler is calm and totally empty

20:02 defn: or you could just write haskell on clojure, right?

20:02 tcrayford: and all the way around

20:02 Licenser: it also says something like 22 methods instrumented, that shoulds like it would missing something

20:02 defn: I want to write Haskell in Clojure in Haskell in Clojure

20:03 Licenser: defn: you get an infinit implementation loop there :P

20:03 mmarczyk: tcrayford: with Clojure in Clojure, it might be fun to try building on all sorts of host platforms :-)

20:03 tcrayford: mmarczyk: when that's done I'm totally building clojure on top of javascript

20:03 mmarczyk: tcrayford: :-D

20:03 tcrayford: defn: spot the bug https://gist.github.com/408283/ee992633b8ddf64388d9f45b968b623e93ff8e1c

20:03 Licenser: mmarczyk: nope nothing in the profilerr even for an infinit loop

20:03 mmarczyk: tcrayford: I can't wait for that to happen

20:04 tcrayford: I'll be able to write useful scripts for Web pages, finally :-P

20:04 tcrayford: either that or clojurescript will be finished/work without patching clojure core

20:04 Licenser: *looks if there is a newer version*

20:04 mmarczyk: Licenser: so, how are you doing things?

20:04 Licenser: nope

20:04 lein jar

20:04 java -cp clj-highlight.jar:lib/clojure-contrib-1.1.0.jar:lib/clojure-1.1.0.jar test

20:05 defn: tcrayford: defn a?

20:05 Licenser: in 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:05 mmarczyk: Licenser: and that process actually does stuff? as in, uses CPU time?

20:05 tcrayford: defn: explain?

20:05 defn: ive just never seen "defn a {} []"

20:06 Licenser: mmarczyk: certenly yes aside the fact that I could hear my cooler go crazy I could watch the usage meter paint the rocky mountains

20:06 tcrayford: defn: that works in the repl

20:06 defn: tcrayford: oh...color me a noob

20:07 mmarczyk: tcrayford: so, does the new version work? (sorry, I got confused)

20:07 Licenser: defn: I could make clj-highlight color noobs for you

20:07 tcrayford: mmarczyk: nope, still broken

20:07 defn: Licenser: you could rewrite it and then id be a happy man ;)

20:07 Licenser: stupiddb (the new v) is pretty cool, i like that you added db-update-in

20:08 tcrayford: though actually clojure overwrites the :line and :file metadata when you define a function, so I can't really write this test anyway

20:08 Licenser: thanks mate :)

20:08 it also uses gzip now to compress the DB

20:08 defn: tcrayford: meta on that macro seems problematic i guess

20:08 tcrayford: just a hunch

20:09 tcrayford: defn: even if I remove the metadata the test still fails

20:09 Licenser: Is there any clojure profiler save visua vm

20:09 tcrayford: you *can* use yourkit, but its not free (15 day trial was good enough for me though)

20:10 though iirc that goes through the same mechanisms as visualvm

20:10 Licenser: *nods*

20:10 I thought a clojure specific one that gives usage data about fn's and stuff

20:10 tcrayford: don't think it exists yet

20:13 Licenser: :(

20:20 tcrayford: hah

20:20 my issue works fine from the repl

20:21 debating posting to the mailing list now, this is getting annoying

20:30 Licenser: frustrating :(

20:33 mmarczyk: tcrayford: you could set your own :line and :file meta after the defn form returns

20:35 Licenser: have you tried connecting running your code at the repl

20:36 and connecting visualvm to that?

20:36 that's what I've been doing usually

20:36 defn: visualvm is...not very helpful

20:36 to me, anyway

20:36 Licenser: mmarczyk: that is an id

20:36 mmarczyk: defn: even with some filtering? like, no clojure.core functions?

20:39 Licenser: mmarczyk: it works, I can benchmark jinline :P

20:39 mmarczyk: tcrayford: you should really rename that namespace to use - and not _

20:39 Lajla: So, Clojure is more of an implementation than a standard right?

20:40 mmarczyk: _ is not supposed to be used in namespace names at all

20:40 (and - is not supposed to be used in Clojure source file names)

20:41 tcrayford: mmarczyk: yep I know, but it all works atm, and hence is on the todo list

20:41 alpheus: Hi. I'm just starting to learn Clojure. Just got connected to a REPL with SLIME. Is this the right channel for newbie questions?

20:41 tcrayford: sure

20:42 defn: mmarczyk: could you be more specific about "no clojure.core functions"

20:42 Lajla: im not sure how you'd answer that -- it's...sort of...standard

20:42 i mean, it has the stuff that makes lisp, lisp

20:43 Lajla: defn, I mean, it has a reference implementation opposed to a formal specification, right?

20:43 TimMc: chouser: 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:43 Lajla: Or as it seems, only one implementation which is the reference.

20:43 mmarczyk: defn: you can tell visualvm to skip certain classes when instrumenting your code for profiling

20:44 defn: java.*, I think, is on the list by default

20:44 defn: you can add clojure.*

20:44 Lajla: As in, it's a program that reads a programming language as opposed to a formal specification of a language.

20:45 tcrayford: TimMc: not to answer for chouser, but most of that is covered by lein these days

20:46 Lajla: clojure is too young to have a formal spec

20:47 defn: mmarczyk: oh man, i have no idea

20:47 TimMc: tcrayford: I suppose the workspace setup is, yes.

20:47 defn: had*

20:47 Licenser: hmm interesting the memory profiler seems to work, I get clojure in there

20:47 tcrayford: TimMc: otherwise for larger projects, listen to the tests/code, and look at swank-clojure for an example of organising stuff into namespaces

20:48 TimMc: You're saying swank-clojure is a good example project to paw through?

20:48 tcrayford: yeah

20:48 TimMc: OK, cool.

20:48 tcrayford: its largish, has had a few people work on it, etc

20:49 mmarczyk: tcrayford: wow, I actually had to type your code afresh to see what's going on

20:49 * technomancy would advise against treating swank-clojure as idiomatic

20:49 mmarczyk: I feel rather silly for it

20:49 but I've answered on SO

20:49 Lajla: tcrayford, well, some languages start with a formal spec I guess.

20:49 tcrayford, how old is it?

20:49 technomancy: it'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:49 mmarczyk: defn: hm? :-)

20:49 tcrayford: technomancy: I was just trying to find a largish project that was open source

20:50 technomancy: tcrayford: yeah... maybe incanter would be a better choice?

20:50 tcrayford: never looked through the code there

20:50 mmarczyk: defn: I found visualvm's profiler completely useless when not filtering clojure.* out; with filtering, it's actually pretty useful

20:50 technomancy: leiningen is clean, but it's only 700 lines

20:50 TimMc: technomancy: I learn best by absorbing code style and idioms.

20:50 tcrayford: TimMc: also check out ring and hiccup

20:50 TimMc: Oh, leiningen itself! Hadn't considered that. >_<

20:50 technomancy: it's not a large project by any means

20:51 tcrayford: technomancy: is there a decent way to get an sexp out of slime and print it into a buffer?

20:51 defn: technomancy: any chance you know the magic formula to get cuke4duke and lein-cuke working? :X

20:51 technomancy: tcrayford: from elisp?

20:52 tcrayford: technomancy: yeah

20:52 actually, 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:53 technomancy: tcrayford: (insert (second (clojure-test-eval-sync "(and (:foo {:foo :bar}) 88)")))

20:53 defn: no, never heard of it

20:53 Licenser: java makes me sad :(

20:53 * tcrayford goes and rewrites the elisp for refactoring mode

20:54 Licenser: tcrayford: go go go!

20:54 tcrayford: that should fix my newlines problem completely

20:55 technomancy: more power to you

20:55 tcrayford: before I was sending back a string and using read :(

20:56 mmarczyk: tcrayford: does the test work for you now?

20:56 tcrayford: mmarczyk: don't know. Stashed that stuff in a seperate git branch whilst I rewrite the elisp

20:57 mmarczyk: tcrayford: well, it should, anyway

20:58 tcrayford: If it works for you, that's good to hear. That stuff is all a long way off though.

20:58 mmarczyk: tcrayford: 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:58 tcrayford: really?

20:58 hahaha

20:58 mmarczyk: ^hadn't

20:58 yup :-P

20:59 tcrayford: it doesn't look wrong from here (referring to the stackoverflow q)

20:59 mmarczyk: (is (not= (find-var 'refactoring-test-fn-rename/a) nil))

21:00 notice the symbol

21:00 ah, sorry, I just realised how I'm totally off base here :-P

21:00 and also, I think, what might be wrong

21:00 tcrayford: I thought that was the same

21:01 mmarczyk: let me go off and check

21:01 because the test does work with the modification

21:01 hm, just a sec

21:01 defn: technomancy: lein-cuke + cuke4duke = cucumber + leiningen integration

21:02 http://github.com/bgruber/lazytest-listen

21:02 ha! awesome.

21:03 technomancy: defn: I'm working on a lein hook to play the Final Fantasy victory theme when your tests pass

21:03 defn: hahaha!

21:04 tcrayford: technomancy: are you interested in having the lein test output colored?

21:04 technomancy: tcrayford: yeah, you could do that in a plugin now that we have hooks

21:04 * technomancy needs to get that documented

21:04 defn: technomancy: you're using lazytest

21:04 ?

21:04 tcrayford: hooks make everything better

21:04 technomancy: defn: no, just clojure.test

21:05 defn: i really wish people with stuff like lazytest and lazytest-listen would release

21:06 technomancy: tcrayford: I'd eventually take it into lein proper, but I prefer doing it as a plugin first

21:06 tcrayford: technomancy: cool. Might be a bit before I actually do it though

21:07 Licenser: hmm okay the problem seems to be that visualvm filtern the clojure classes

21:07 tcrayford: mmarczyk: I'm fixing the filenames first now, cheers for the pointer

21:11 mmarczyk: tcrayford: I've updated the SO answer

21:11 I think the current version works

21:12 though I can't say I'm sure why the original doesn't

21:13 defn: [null] Unable to resolve artifact: The artifact has no valid ranges

21:13 what's that mean?

21:13 tcrayford: mmarczyk: thanks, I'll check it out in a bit

21:13 mmarczyk: tcrayford: ok

21:13 Licenser: okay to get some more results I needed to set a starting class

21:14 defn: nvm, silly PEBKAC

21:14 Licenser: another question for you people

21:15 I 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:15 mmarczyk: Licenser: I think you'll need to put this in your source file

21:15 or at the very least do the set! before require

21:15 Licenser: I did that

21:16 mmarczyk: so that *warn-on-reflection* is true at compile time

21:16 oh, and yeah, it's *warn-on-reflection* (no 's')

21:16 Licenser: *just tries it again**

21:16 tcrayford: I thought there was a lein option to set warn-on-reflection now?

21:17 mmarczyk: right, :warn-on-reflection

21:17 Licenser: on heat

21:17 tcrayford: mmarczyk: http://github.com/tcrayford/clojure-refactoring/commit/15cc3c0d56c151b6f5397d065528e838609aa39c

21:18 Licenser: nope no warn on reflections

21:20 remleduff: Wow tcrayford, that looks amazing

21:21 mmarczyk: Licenser: http://clj-me.cgrand.net/2009/08/06/what-warn-on-reflection-doesnt-tell-you-about-arrays/

21:21 sexpbot: "Clojure and me » What *warn-on-reflection* doesn’t tell you about arrays"

21:21 mmarczyk: just sth of potential interest

21:22 the 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:22 if it doesn't work for you, maybe there's nothing to be done

21:23 to get rid of reflection, I mean

21:23 or maybe cgrand's post can help :-)

21:23 tcrayford: cool :-)

21:23 Licenser: mmarczyk: then it tells me that it can't alter the root binding

21:23 mmarczyk: tcrayford: I'd say that _ in function names is evil too :-P

21:24 tcrayford: but it definitely shouldn't cause any breakage, so...

21:24 Licenser: Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set (test.clj:0)

21:24 it says

21:24 meeh

21:24 tcrayford: mmarczyk: 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:25 mmarczyk: tcrayford: wouldn't work for a fn without a - :-)

21:25 I prefer adding -test, but ok

21:25 Licenser: oh bother :-(

21:25 Licenser: it's no fun

21:27 mmarczyk: could you gist that file?

21:28 or, I don't know, just a couple of forms from the top

21:31 Licenser: mmarczyk: it's on github one second

21:32 mmarczyk: http://github.com/Licenser/clj-highlight

21:32 http://github.com/Licenser/clj-highlight/blob/master/src/test.clj to be precise

21:33 mmarczyk: thanks, I'll try to run it in a moment

21:33 to witness the ridiculous error with my own eyes, as it were

21:33 hopefully enlightenment follows ;-)

21:33 Licenser: heh thanks mmarczyk

21:33 why do you know so much?

21:35 mmarczyk: not sure where that came from, I'm being totally unsuccessful at guessing what your profiling+testing woes are about just now :-)

21:35 Licenser: I am totally at a less here either

21:36 *loss

21:37 mmarczyk: Licenser: try (set! *warn-on-reflection* true)

21:38 Lajla: mmarczyk, ah, so closure uses bangs?

21:38 Licenser: *runs that

21:38 tcrayford: ,(= '((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:38 clojurebot: DENIED

21:38 tcrayford: hah, those are quoted lists

21:38 Licenser: mmarczyk: gives me Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set (test.clj:0)

21:38 tcrayford: clojurebot: you fail

21:38 clojurebot: Pardon?

21:39 mmarczyk: Licenser: you know, I think *warn-on-reflection* might be a binding established by the ns form

21:39 Licenser: try moving the set! below it maybe

21:39 Licenser: tried that but I'll try it again

21:40 mmarczyk: Lajla: and ?s, conventions for use agree with those of Scheme

21:40 Licenser: sadly same :(

21:40 tcrayford: aha!

21:40 ,(= #"," #",")

21:40 clojurebot: false

21:41 mmarczyk: ,(.equals #"," #",")

21:41 clojurebot: false

21:41 remleduff: (class #",")

21:41 Licenser: hm hmmms

21:41 remleduff: ,(class #",")

21:41 clojurebot: java.util.regex.Pattern

21:42 remleduff: Did the prefix change?

21:42 Licenser: mmarczyk: can you profile the test file?

21:42 it runs with java -cp clj-highlight.jar:lib/clojure-contrib-1.1.0.jar:lib/clojure-1.1.0.jar test

21:42 ?

21:42 remleduff: I'm pretty sure there's a thread on clojure-dev about regex Patterns and the screwy equality semantics

21:42 $(class #",")

21:42 sexpbot: result: class java.util.regex.Pattern

21:43 mmarczyk: Licenser: yup, I'll try in a moment

21:43 tcrayford: yeah, it ain't a bother, I'll just change the tests so they change different functions

21:43 Licenser: mmarczyk: thank you a lot!

21:43 mmarczyk: np :-)

21:45 Licenser: I'm seeing totally weird breakage for now

21:46 Licenser: mmarczyk: yes that is something I know :P

21:47 mmarczyk: there's a double "fn" in clojure-keywords

21:47 I mean it occurs twice in the literal

21:47 Clojure 1.2 complains

21:48 Licenser: oh

21:48 mmarczyk: (I might restart with 1.1 though)

21:49 Licenser: wehn I set the stack size to 100M I can run bigger files

21:49 Lajla: mmarczyk, I take it the [ ... ] is optional and can be freely exchanged with ( ... )?

21:49 mmarczyk: Licenser: same goes for let and loop

21:49 Licenser: ^^

21:49 mmarczyk: Lajla: you mean in Clojure syntax?

21:50 Lajla: mmarczyk, quite.

21:50 mmarczyk: Lajla: not at all, [...] is a vector, whereas (...) is a list

21:50 Licenser: mmarczyk: thanks all removed

21:50 Lajla: mmarczyk, ahhh

21:51 mmarczyk, and vectors also are encounted in code I see?

21:51 mmarczyk: Lajla: note [...] is not like #(...) in Scheme

21:51 Lajla: mmarczyk, do go on.

21:51 mmarczyk: Lajla: Scheme's vector literals provide implicit quoting, while Clojure's don't

21:51 Lajla: I am imagining you speak with a French accent as to facilitate my attention span.

21:51 mmarczyk, this means that vectors evaluate to things?

21:52 tcrayford: ,([1 2 3] 1)

21:52 clojurebot: 2

21:52 mmarczyk: Lajla: 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:52 Lajla: Ahh, they evaluate all arguments.

21:52 And vector-ref does not exist

21:52 Rather a vector is a procedure?

21:52 mmarczyk: Lajla: just a quick question on the side

21:53 Lajla: ,([1 2 3 4] 0)

21:53 clojurebot: 1

21:53 Lajla: Cool

21:53 mmarczyk: Lajla: or actually, never mind

21:53 Lajla: mmarczyk, ask.

21:53 Nahh, Now I want to know.

21:53 mmarczyk: Lajla: [ ] is just literal syntax for vectors

21:53 like ( ) is for lists

21:53 Lajla: ,(+ 1 ([2 3] 0))

21:53 clojurebot: 3

21:53 Lajla: Cool

21:53 mmarczyk: in Scheme, ( ) is literal syntax for proper lists, or with the dot, improper lists

21:54 and of course (1 . 2) is a pair (cons)

21:54 Lajla: (([+ *] 1) 1 2 3 4)

21:54 ,(([+ *] 1) 1 2 3 4)

21:54 clojurebot: 24

21:54 mmarczyk: the fact that those lists are evaluated the way they are is a different matter entirely

21:54 Lajla: Veeery cool

21:54 mmarczyk, I understand

21:54 but what did you want to ask?

21:54 mmarczyk: anyway, I'm off to bang on Licenser's code until it regrets it's been written :-P

21:54 Lajla: Noo, you wanted to ask something.

21:54 I want to know what it is.

21:55 mmarczyk: that *warn-on-reflection* thing is annoying

21:55 Lajla: It's like a splinter in my mind.

21:56 mmarczyk: Licenser: funnily enough, when I removed duplicate keys from clojure-keywords and moved (set! *warn-on-reflection* true) inside the ns form

21:56 Licenser: things started to work

21:56 Licenser: actually, scratch that

21:56 Licenser: inside the ns form?

21:56 mmarczyk: Licenser: yes, but also

21:56 I moved renamed the namespace to clj-highlight.test

21:56 and moved the file to match the ns name

21:56 Licenser: *nods*

21:56 mmarczyk: going off to move it back and see if it breaks again

21:57 Licenser: I had a problem with that when I did that that lein was acting up with the -

21:57 mmarczyk: oh?

21:58 hm, apparently it doesn't break if it's just src/test.clj, ns test

21:58 I mean that's supposedly broken for different reasons ;-)

21:58 Licenser: yea 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:58 mmarczyk: but still, I can require it and *warn-on-reflection* gets set to true

21:58 Licenser: erm namespace

21:59 mmarczyk: Licenser: oh, I see

21:59 Licenser: which version of lein are you using? I'm under the impression that this was fixed, but I might well be imagining things

22:00 Licenser: hmm *looks*

22:00 mmarczyk: Licenser: if it's an actual bug, I'd love to fix it :-)

22:00 Licenser: lein 1.1.0

22:00 * Licenser Tries with the set in ns

22:00 Licenser: not working either, says it can't find set!

22:00 tcrayford: reader macros really break the whole code is data thing sometimes :(

22:01 Licenser: tcrayford: yap

22:01 then again if you use the reader, no:P

22:01 Lajla: ,[1 2 3]

22:01 clojurebot: [1 2 3]

22:02 tcrayford: (= #(identity %) #(identity %))

22:02 ,(= #(identity %) #(identity %))

22:02 clojurebot: false

22:02 mmarczyk: Licenser: :-(

22:02 Lajla: ,([1 2 3 5] +)

22:02 clojurebot: java.lang.IllegalArgumentException: Key must be integer

22:02 mmarczyk: it all runs fine here, with clj 1.2

22:02 Licenser: mmarczyk: but I am way closer

22:02 mmarczyk: let's see with 1.1

22:02 tcrayford: I kinda have to use the reader for this, seeing as I return sexps to emacs now :/

22:02 Lajla: ,([1 2 3 4] -1)

22:02 clojurebot: java.lang.IndexOutOfBoundsException

22:02 Lajla: Hmm, no 4? =(

22:02 mmarczyk: incidentally, got any test data?

22:03 Licenser: mmarczyk: I get some kindof useful results when I use 100M stack space and then run a bigger file

22:03 mmarczyk: I'm running it with (with-in-str "some-clojure-form\nanother-one\nyet-another-one\n" (test/-main))

22:03 for now :-)

22:03 Licenser: heh

22:03 mmarczyk: Lajla: like your Python, do you ;-)

22:04 Licenser: Lajla: ,(last [1 2 3 4])

22:04 also last is evil :P

22:04 Lajla: mmarczyk, I don't, that rumour was formed while I was drunk!

22:04 mmarczyk: ,(peek [1 2 3 4])

22:04 clojurebot: 4

22:04 Lajla: I did not have a sexual relationship with that programming language.

22:04 licenser, how to get the second-last?

22:05 mmarczyk: ,(peek (pop [1 2 3 4]))

22:05 clojurebot: 3

22:05 Lajla: Just (- length 1) or some similar construct?

22:05 mmarczyk: Lajla: 'count' actually, but yeah

22:05 Licenser: see mmarczyk knows all

22:05 Lajla: also idally you don't need last

22:05 Lajla: licenser, maybe mmarczyk is the third best progammer after me and the Chief Software Architect of Microsoft.

22:06 Licenser: wait that are odd standrds

22:06 Lajla: licenser, ahhh, do elaborate here.

22:06 licenser, if I was normal I'd be programming in python rather in some bracketlang.

22:06 mmarczyk: Licenser: there's one thing I'm not very clear on

22:06 Licenser: I'd buy that you are the best but a microsoft guy the second best?

22:06 mmarczyk: Licenser: it's *the* Microsoft guy, actually ;-)

22:06 Lajla: licenser, well, he did come up with the original DOS filename system.

22:06 8 character limit, brilliant idea.

22:07 Why didn't I think of that.

22:07 mmarczyk: Licenser: anyway, why do you use read-line and not read

22:07 Licenser: Lajla: from what I understood about functional programming it is all about consuming seq's (lists) and not peacking at specific points

22:07 Lajla: He 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:07 mmarczyk, explain?

22:07 Licenser: mmarczyk: because I was sure what read-line does :P and read is the reader isn't it?

22:07 mmarczyk: Licenser: ahhhhh, right, of course

22:07 sorry :-P

22:08 Lajla: licenser, well, in lists, not in vectors.

22:08 * Licenser gives mmarczyk a cookie for letting him feel smart at least once tonight!

22:08 mmarczyk: makes sense you'd want a string for a syntax highlighter :-)

22:08 Licenser: Lajla: you can treat vectors as lists ;)

22:08 mmarczyk: oh, oh! cookies are good :-)

22:08 Licenser: ^^

22:08 Lajla: licenser, then I would use lists rather than vectors.

22:08 Vectors are for peaking at a random index.

22:09 mmarczyk: Lajla: in Clojure, not at all

22:09 tcrayford: Lajla: most clojure programmers use vectors most of the time

22:09 mmarczyk: ,(conj [1 2 3] 4)

22:09 clojurebot: [1 2 3 4]

22:09 Lajla: in lieu of lists?

22:09 Fr what advantage?

22:09 tcrayford: personally, I prefer the syntax

22:10 Licenser: also vectors add to the end, lists to the front, sometimes it makes a difference

22:10 Lajla: I see.

22:10 mmarczyk: Lajla: actually, if you're genuinely interested in Clojure, would you like to read a really good -- yet reasonably short -- intro?

22:10 Lajla: You have intruiged me with your unorthodox language, I might turn to the dark side.

22:10 mmarczyk, sure.

22:10 mmarczyk: Lajla: not that I mind answering here, on the contrary, just to be clear

22:10 but I think it's a great article

22:11 and for a person coming from Scheme

22:11 Lajla: Coming from is the right word.

22:11 mmarczyk: might be enough to get a pretty good idea of what the language is about

22:11 Lajla: mmarczyk, sure, give me.

22:11 mmarczyk: Lajla: oh, I didn't see that coming :-)

22:11 yup, just a sec

22:12 http://java.ociweb.com/mark/clojure/ -- link to the current revision at the top, plus loads of other resources

22:12 sexpbot: "Mark Volkmann's Clojure Page"

22:13 Licenser__: oh yes that one was good, I started with it!

22:13 mmarczyk: me too :-)

22:13 Licenser__: ^^

22:13 mmarczyk: and he's got another one on Clojure's STM, which is absolutely one of a kind

22:14 http://java.ociweb.com/mark/stm/

22:14 sexpbot: "Mark Volkmann's STM Page"

22:14 alpheus: Is "lein install" the right thing to use to put a jar file somewhere that "lein deps" can find it?

22:15 tcrayford: yes

22:16 mmarczyk: well I think lein install works on the current project

22:16 for now

22:16 and not an arbitrary jar

22:16 for the latter case, you'd need mvn install (google for the correct command line options first)

22:17 Licenser: mmarczyk: even if not the reflection the big stack thing did the trick

22:17 alpheus: thanks

22:18 mmarczyk: Licenser: ok

22:18 alpheus: mvn manipulates maven repositories?

22:18 mmarczyk: Licenser: I'm still not clear on how you test it

22:18 (read-line) reads one line

22:18 Licenser: mmarczyk: me neither

22:19 remleduff: Isn't it mvn deploy-file for an arbitrary jar?

22:19 mmarczyk: so you're colouring just three lines, which probably isn't a lot of work

22:19 heh

22:19 Licenser: mmarczyk: the read-line is just so that I've time to fire up the visualvm

22:19 otherwise the tests are over before the profiler has connected

22:19 mmarczyk: remleduff: tbh, it could very well be :-)

22:20 Licenser: what did the trick fir me: -Xss100M and add the clj_highlight.** to the classes that trigger profiling

22:20 mmarczyk: mvn 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:20 Licenser: http://grab.by/4uz9 is what I got

22:21 so actually the regexps are sloow :P

22:21 mmarczyk: oh man, you've got your project.clj all on one line!!!

22:22 Licenser: mmarczyk: yea it's from lein-search

22:22 Lajla: mmarczyk, omg man, that sound when you start it.

22:23 Licenser: ~defn re-find

22:23 clojurebot: Huh?

22:24 Licenser: sorry clojurebot I enver can remember how you do that

22:24 mmarczyk: Licenser: so, the idea is that you want to run test as the main class

22:24 Licenser: and it's supposed to do some work which you want to profile, right?

22:25 Lajla: I never really got what people find so difficult about switching to another paradigm though, but maybe that's just because I'm young.

22:25 Licenser: mmarczyk: exactly

22:25 mmarczyk: Licenser: well, the test.clj I pulled from your repo a short while ago

22:25 Lajla: I've no idea what's difficult in switching from OOP to FP, but the other way around sure is hell

22:26 ;-)

22:26 Licenser: but why would you expect that test.clj to do anything?

22:26 as far as I can tell, it's almost empty

22:26 I mean in, devoid of computational challenge ;-)

22:26 or do you have a fuller version you're actually using, not yet pushed to the repo?

22:26 bmason: are the javax packages a separate library from the main java spec?

22:26 Lajla: mmarczyk, ahaha, could be that the other way around is more difficult yes.

22:26 Licenser: mmarczyk: it grabs a file, and tokenizes it

22:27 Lajla: I don't like OOP though, I think it cripples the mind.

22:27 bmason: e.g. I'm trying to import javax.mail.internet.MimeMultipart

22:27 

22:27 Licenser: it does not look too much but there is a entire scanner for clojure code in the back

22:27 and worst thing is, it is horribly slow

22:27 mmarczyk: Licenser: grabs a file?

22:27 clojurebot: amespaces 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:28 Licenser: I only get ~20k Tokens a second from the scanner

22:28 mmarczyk: Licenser: in the test.clj that I pulled there's no code for that

22:28 Licenser: that's what I meant by "devoid of computational challenge", the scanner looks impressive

22:28 Licenser: line 9

22:28 a hidden slurp there

22:28 mmarczyk: oh wait, have I actually deleted a line

22:28 Licenser: :P silly

22:29 mmarczyk: lol, no, I've simply missed it

22:29 Licenser: remove the content and it is of cause missing any kind of challange

22:29 mmarczyk: I wonder if I should sleep more often :-)

22:29 Licenser: line 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:30 mmarczyk: right, now I tried to restart VisualVM and started IntelliJ instead... :-(

22:31 Licenser: heh

22:31 still you were good help mmarczyk thanks a lot!

22:32 rsh: do most people develop new clojure programs on v1.2?

22:32 mmarczyk: Licenser: :-)

22:32 alpheus: I 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:32 mmarczyk: Licenser: ok, so I'm running the test

22:32 from the REPL

22:32 Licenser: now I just have to figure out why the java regexp does not only suck but is also slow like hell

22:32 mmarczyk: and the whole thing takes under 150 ms

22:33 Licenser: it seems close to impossible to write a good scanner in java

22:33 mmarczyk: is that really slow, or does it become slow with a significantly larger input...?

22:33 Licenser: mmarczyk: it is really slow

22:34 coderay, a ruby highlighter is about 10x faster then this

22:34 remleduff: I think most people use a parser generator for something like that in Java

22:34 Licenser: and while I expected my crazy implementation with tons of functions would be the bottle nack the regexp is it

22:34 remleduff: but that is so complicated

22:35 remleduff: Well, you're talking about java...

22:35 mmarczyk: Licenser: somewhat importantly, I can see it working in VisualVM

22:35 Licenser: mmarczyk: wow!

22:37 but i get the feelings that some kind of other function is slow or a regexp is bad

22:40 mmarczyk: Licenser: ah, I think I might be on to the reason why the profiler doesn't pick things up

22:40 Licenser: oh?

22:41 I had to add stuff to the class thing to the right

22:43 mmarczyk: yeah! got it

22:43 (I think)

22:43 remleduff: Licenser: Might want to look at http://www.javaworld.com/javaworld/jw-09-2007/jw-09-optimizingregex.html as well

22:43 mmarczyk: it would seem to me that you need to move the test ns to clj-highlight.test

22:44 Licenser: really oi

22:44 mmarczyk: Licenser: because otherwise it ends up in the "default package" (is that the Java name?), which is a special situation which is wrong

22:44 :-P

22:44 Licenser: yuck

22:44 Lajla: You 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:45 Licenser: Lajla: then you'll feel right at home :D

22:45 Lajla: licenser, I do actually, I'm considering turning to the dark side here.

22:46 Looks well thought off.

22:46 Licenser: mmarczyk: but how do I explain lein to do things right :(

22:46 mmarczyk: Licenser: I wouldn't bother

22:46 Licenser: hmm true I don't need to unless I do the executable jar stuff

22:46 mmarczyk: what I'm doing now is start it all in a repl

22:46 wrap the test in a dotimes with some large number of iterations

22:47 oh, and that's after telling VisualVM to skip clojure.*, swank.* and sun.rmi.* classes when profiling

22:47 in addition to those which it skips anyway

22:47 and start with clj_highlight.** (though that's probably optional)

22:48 Licenser: =)

22:48 mmarczyk: or should it be sun.rmi.transport.*

22:50 et voila, 22% of the time spent in sth called re-token

22:50 Licenser: :D

22:50 mmarczyk: you good sir are briliant!

22:52 mmarczyk: http://gist.github.com/408392

22:53 Licenser: mmarczyk: only sad point is that the re-token just tells me that it is 'a' regular expression not which one :P

22:53 remleduff: Licenser: 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:53 Licenser: yes I could

22:56 mmarczyk: Licenser: I guess so :-(

22:56 Licenser: *looks into it again*

22:56 riddochc: So, 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:57 mmarczyk: Licenser: 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:57 plus the number of times they were used

22:58 interested?

22:58 Licenser: mmarczyk: I just did that

22:58 mmarczyk: oh :-)

22:58 great

22:58 Licenser: at least the wrapping

22:58 I want to see if it works

22:58 killd the thing so with a slurp :P

22:58 mmarczyk: :-)

22:59 I'll be back very shortly, need to go off for a moment

23:00 Licenser: thanks mmarczyk and take care

23:02 remleduff: $*clojure-version*

23:02 sexpbot: Command not found. No entiendo lo que estás diciendo.

23:02 remleduff: $(str *clojure-version*)

23:02 sexpbot: DENIED!

23:02 Raynes: Use $eval for stuff that isn't wrapped in parans.

23:03 $eval *clojure-version* ; this still wont work though.

23:03 sexpbot: DENIED!

23:03 Raynes: I haven't whitelisted that. I need to.

23:03 It's running 1.2, for the record though.

23:04 remleduff: Hmm, isn't *clojure-version* kind of a bad example of using earmuffs

23:04 ?

23:04 * Raynes hugs sexpbot.

23:04 * Raynes goes to sleep.

23:04 remleduff: $(+ 100L 1)

23:04 sexpbot: Invalid number: 100L

23:04 remleduff: $(+ (long 100) 1)

23:04 sexpbot: result: 101

23:05 remleduff: Wonder why the reader doesn't support the L suffix

23:07 riddochc: Wow, 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:08 remleduff: $(long 1274244710)

23:08 sexpbot: result: 1274244710

23:08 remleduff: $(class (long 1274244710))

23:08 sexpbot: result: class java.lang.Long

23:09 riddochc: I've got a :require clause, [clj-time [core :as time-core] [coerce :as time-coerce] [format :as time-format]

23:09 (time-core/now) evaluates to #<DateTime 2010-05-21T03:06:33.674Z>

23:10 Now, aside from the fact that I need to fix my NTP setup, something seems a bit screwy, don't you think?

23:12 remleduff: What does (time-coerce/to-long (time-core/now)) give you?

23:12 riddochc: Let's find out...

23:12 Licenser: *sigh*

23:13 riddochc: 1274411403008

23:13 rava: Greetings programs :)

23:14 mmarczyk: Licenser: how are you doing?

23:14 Licenser: well trying things now but the repl crashes whenever I try to define the highlighter :P

23:14 remleduff: You shouldn't need the call to long when calling from-long should you?

23:14 mmarczyk: ouch

23:15 riddochc: Oh, I think I see. It expects *milliseconds*, not seconds.

23:15 Licenser: yea I've bad luck today :P

23:16 riddochc: (time-coerce/from-long (long (* 1000 1274244710))) -> #<DateTime 2010-05-19T04:51:50.000Z>

23:16 Now that's more like it.

23:16 remleduff: Cool

23:16 I think calling "long" there is redundant though, from-long does the type-hint internally

23:18 riddochc: It complained if I didn't and the time was closer to 1970... though for recent times, it should be fine.

23:19 Licenser: this is so frustrating :(

23:19 riddochc: clj-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:19 Licenser: I think it hates me o.

23:19 o

23:20 TimMc: technomancy|away: Leiningen totally works! Thank you. :-)

23:25 Licenser: hmm okay finally :D

23:27 mmarczyk: oh good :-)

23:28 Licenser: mmarczyk: the identifyer token is the evil one

23:29 mmarczyk: um, shouldn't symbol* actually be called keyword* ?

23:29 Licenser: yes I guess so

23:29 bmason: what'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:30 does that have something to do with compojure moving stuff to ring, or am I referencing inconsistent versions of something?

23:30 mmarczyk: also, ::foo/bar is not a valid keyword literal

23:30 Licenser: hmm okay learned something new :)

23:31 mmarczyk: aaaahhhh, nope, wait

23:31 it is

23:31 sorry

23:31 Licenser: heh

23:31 mmarczyk: and it even works with aliases then :-)

23:31 Licenser: problem is this is a pretty ugly case :P

23:32 I can't think of much to make this less ugly or faster

23:32 mmarczyk: what does (?i) do?

23:33 hey, I just noticed sth

23:33 you need to switch to regex literals!

23:34 where possible

23:34 mostly for prettiness' sake :-P

23:36 remleduff: Licenser: Would it help to change basic-identifier to lazy rather than eager by changing the * to *? ?

23:37 You'd need a token on the other side to match though

23:37 Licenser: hmm hmm I'm not an expert on regexps sadly :P

23:38 mmarczyk: (?i) makes it case insensitve

23:38 mmarczyk: yea but composing them isn't as nice

23:39 remleduff: What are you trying to match exactly?

23:39 TimMc: Ooh, Clojure has sexp-based regexes available? (Or is it a lib?)

23:40 Licenser: remleduff: clojure symbols ^^

23:40 remleduff: Something like #".*/.*" but with only clojure allowed characters?

23:41 Licenser: remleduff: well more or less yes

23:45 remleduff: I 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:45 But I'm having a hard time figuring out exactly what you're matching :)

23:45 Licenser: remleduff: o.O Me to!

23:49 remleduff: sadly didn't changed too much

23:51 remleduff: What are you matching at the end of identifier? It has to match any character or any two characters?

23:53 Licenser: remleduff: ny two?

23:53 not sure what you mean

23:55 remleduff: I just am not sure what the "\\.\\.?" at the end of your regex is intended to do

23:55 Licenser: well . and .. are both symbols

23:59 remleduff: You want to avoid the | alternation as much as possible I think

23:59 Licenser: *nods* I just pulled the regexp apart and made 3 rules out of it

Logging service provided by n01se.net