#clojure log - Apr 17 2010

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

0:00 technomancy: an excellent policy

0:00 slyphon: :D

0:00 technomancy: though unsustainable in the long term

0:00 slyphon: zeppo is our encoder client, groucho is our storage management system

0:00 true

0:00 technomancy: my policy is characters from literature

0:00 slyphon: then i have to switch to stooges, i guess...

0:00 technomancy: I just haven't thought of a project awesome enough to merit the name Orestes.

0:00 slyphon: haha

0:01 technomancy: nor Gabriel Syme, for that matter.

0:01 slyphon: the funny thing is harpo is going to be our encoding job dispatch service, and his main role is going to be talking to zeppo

0:01 you know, if you can't entertain yourself

0:02 * slyphon goes to look up Gabriel Syme

0:02 slyphon: ahh

0:02 how about "Harold Bloom"?

0:02 ajazz: hello! as i understand compojure is more about C controller. what do people usually use for M model and V view?

0:03 slyphon: dammit

0:03 i was just about to send him a link to something

0:04 bastard

0:04 technomancy: oh man, if you haven't read the Man who was Thursday... what a trip.

0:04 slyphon: technomancy: omg! "Yossarian"!

0:05 technomancy: yeah, i'll check it out

0:06 technomancy: characters from literature still under copyright is iffy

0:06 slyphon: ajazz: here's some stuff i collected: http://delicious.com/slyphon/compojure

0:06 sexpbot: "slyphon's compojure Bookmarks on Delicious"

0:07 slyphon: i think sexpbot is just trying to defend against goatse.cx

0:07 technomancy: yeah, true

0:07 technomancy: i still remember when the twisted python guys got a cease-and-desist for using "twisted.sister"

0:07 technomancy: hah

0:07 slyphon: i was like "really? shouldn't they be glad someone remembers who the fuck they are?"

0:08 ajazz: hi, I've had problem with internet connection and I think I missed ansver on my question

0:08 slyphon: ajazz: see above

0:08 ajazz: http://delicious.com/slyphon/compojure

0:08 sexpbot: "slyphon's compojure Bookmarks on Delicious"

0:08 slyphon: sexpbot: yes! thank you!

0:09 ajazz: thanks

0:11 slyphon: sure

0:12 did 1.2 get released?

0:12 or did someone just reformat stuff on clojure.org?

0:12 oh, nvm, i'm retarded

0:12 * slyphon whitelists clojure.org in noscript

0:12 technomancy: mmm... just ordered the Orson Welles production of the Man who was Thursday

0:13 confounds: heh

0:13 technomancy: should have done that years ago

0:13 slyphon: technomancy: is that the one that's set in germany

0:13 technomancy: the book is set in England and France

0:13 slyphon: ahh, right right

0:13 technomancy: I'd be surprised if the radio production changed that

0:13 slyphon: they make a movie out of it?

0:14 technomancy: oh man... gives me a thrill to think of the idea.

0:14 slyphon: :)

0:14 why is there no def- ?

0:14 technomancy: not yet, but I have a friend who says if his startup Makes it Big that he will fund one. =)

0:14 slyphon: hahaha!

0:14 nice :D

0:16 man, i forgot what a nice platform linux can be for hacking in

0:18 remleduff: slyphon: Any rhyme or reason to when you use () vs [] in your ns macro?

0:18 * slyphon sighs

0:19 slyphon: i started changing things over to using [] for the top level stuff, then () for the sub-names

0:19 just found it easier to read

0:19 but it's much less consistent than i'd like it to be

0:20 remleduff: I've been using () around :use/:require and [] everywhere else

0:20 slyphon: yeah, that's probably what i'll go back to doing

0:25 what's an efficient way of creating a string with 25 "-"s in it?

0:26 in ruby you just do "-" * 25

0:26 hiredman: ,(apply str (take 25 (repeat \-)))

0:26 clojurebot: "-------------------------"

0:26 slyphon: ah

0:26 hiredman: ,(apply str (repeat 25 \-))

0:26 clojurebot: "-------------------------"

0:26 slyphon: i had ,(apply str (take 25 (repeatedly (fn [] "-"))))

0:26 hiredman: (nth (iterate str -) 25)

0:27 slyphon: ,(apply str (take 25 (repeatedly (fn [] "-"))))

0:27 clojurebot: "-------------------------"

0:27 technomancy: heh

0:27 hiredman: hmmm

0:27 that iterate won't work

0:27 nuts

0:27 slyphon: :)

0:27 hiredman: ,reductions

0:27 clojurebot: #<seq_utils$reductions__730 clojure.contrib.seq_utils$reductions__730@193b8f>

0:27 hiredman: that won't work either

0:27 hmmm

0:28 ,(nth (reductions str (repeat \-)) 25)

0:28 clojurebot: "--------------------------"

0:33 hiredman: ,(int \-)

0:33 clojurebot: 45

0:33 lrenn: ,(apply str (replicate 25 "-"))

0:33 clojurebot: "-------------------------"

0:33 hiredman: repeat is shorter than replicate

0:35 arbscht: ,(clojure.contrib.str-utils2/repeat \- 25)

0:35 clojurebot: "-------------------------"

0:47 technomancy: remleduff: http://www.assembla.com/spaces/clojure/tickets/299-clojure-main--e-disables-stdin

0:47 sexpbot: "#299 - clojure.main -e disables stdin (Test) | Clojure | Assembla"

0:47 technomancy: cross your fingers

0:48 remleduff: Sweet~

0:48 technomancy: course sometimes it takes a while for simple patches like this to get applied. =(

0:49 but I'm optimistic now that Stuart H got commit access things might improve

0:50 hiredman: embrace the power of community

0:52 technomancy: so I'm realizing always putting the dev-deps in lib is a bad idea for leiningen

0:52 they sneak into the uberjar for one

0:52 but also: the system classpath needs to include the dev-deps but not the main deps

0:52 and the project classpath needs both

0:53 so I'm thinking of keeping dev-dep jars in lib/dev/

0:53 thoughts?

0:56 slyphon: not a bad idea

0:57 i used to do that with my scala code

0:57 lancepantz: i haven't really investigated, but how are they treated differently currently?

0:57 technomancy: lancepantz: they don't get pulled in by other projects that depend on your project

0:57 and they should get left out of the uberjar

0:58 lancepantz: ah

0:59 remleduff: What about .lib for dev libs?

1:00 slyphon: ick

1:00 hidden dirs ftl

1:00 technomancy: inclined against it

1:00 slyphon: so it works OK in scala-land?

1:00 slyphon: yeah, sure

1:01 well

1:01 i mean, as long as you recurse

1:01 i used to do all my startup stuff in rake

1:01 so building the classpaths was pretty easy

1:01 hell $(find lib -name '*.jar') would do the trick :)

1:02 technomancy: we recurse already when building the project classpath, when you want both

1:02 and the root classpath only wants the ones inside lib/dev

1:02 the downside (and this has been true all along) is that you can't override it in project.clj

1:02 since it must be known at JVM boot-time

1:02 * slyphon nods

1:02 slyphon: oh

1:02 lein repl should include ./test

1:03 imho

1:03 technomancy: slyphon: it will now

1:03 thanks to remleduff!

1:03 slyphon: nice!

1:04 technomancy: well, once this clojure patch gets applied

1:05 remleduff: Are you going to keep lein repl in the shell file or switch it to eval-in-project?

1:06 technomancy: eval-in-project, definitely

1:06 it's already coded in the repl-fix branch

1:06 just needs a little more work

1:06 been waiting for this bug to be fixed for quite some time now

1:07 remleduff: Excellent :)

1:07 technomancy: lots of people get confused by lein repl being a shell task

1:07 since it doesn't use the project classpath

1:10 slyphon: hah

1:10 pimpmyemacs.com is available

1:31 * defn buys that

1:31 defn: If only I could get xzibit to be the face of the site...

1:34 lancepantz: heh, if only there was an emac plugin for emacs

1:34 *s

1:35 defn: i want to do a television called "Pimp My Ride (with Emacs)"

1:35 Emacs in the headrests, customizable elisp steering wheel, etc.

1:35 lancepantz: haha

1:38 technomancy: mmm... feels good to get back to hacking lein again

2:06 defn: yay

4:15 lancepantz: considering anyone is here

4:15 anyone know how to get around this: Can't refer to qualified var that doesn't exist

4:20 defn: lancepantz: context would be helpful, although i dont know for sure if i can help, it might help someone else

4:21 lancepantz: good point

4:21 remleduff: ,(foo/bar)

4:21 clojurebot: java.lang.Exception: No such namespace: foo

4:23 lancepantz: i have a macro in ns foo that that has a defn inside of it, when i call it from another ns, where i want the function to be defined, i get that error

4:25 defn: and you're (use)'ing the foo namespace in your other ns?

4:26 either in the ns macro or via a (use 'foo)?

4:26 make sure you don't have circular dependencies: foo uses bar, and bar uses foo, for example

4:27 lancepantz: i don't think so, let me put it on a gist

4:27 defn: also know that (foo/bar), means you need to be requiring foo in bar, not using it

4:27 lancepantz: again, no guarantees -- im just thinking out loud here

4:27 lancepantz: yeah, appreciate it

4:29 remleduff: Can you gist a small example?

4:30 lancepantz: http://gist.github.com/369404

4:32 the macro in utils works if i put it in the profile ns

4:35 remleduff: Does it work if you unquote "update" (~update)

4:36 lancepantz: actual: clojure.lang.Compiler$CompilerException: java.lang.Exception: Unable to resolve symbol: update in this context

4:36 crap, i have to run

4:55 remleduff: lancepantz: My last guess, is that you need: ~'update

6:48 zmila: ,(doc amap)

6:48 clojurebot: "([a idx ret expr]); Maps an expression across an array a, using an index named idx, and return value named ret, initialized to a clone of a, then setting each element of ret to the evaluation of expr, returning the new array ret."

7:36 defn: morning all

7:37 djpowell: hi

7:39 lancepantz_: hi

7:40 well i think i got that ns stuff figured out

7:40 took me about 10 hours :)

7:44 defn: :)

7:44 lancepantz: what was the problem?

7:49 lancepantz_: the macro was expanding into the namespace of the project it was dined in

7:49 clojurebot: Barking spiders!

7:50 lancepantz_: instead of the one calling

7:50 so for now i'm going to have it use eval, which should work

7:50 but i might need to give further fault to what i'm trying to do

7:50 make sure its the right way

7:51 give further thought that is

7:51 that's 18 hours straight of clojure

7:51 i think i can call it a night with that

8:00 defn: lancepantz: oh right!

8:01 lancepantz: perhaps you don't want to use defn?

8:03 lancepantz: err maybe gensym (defn update#...) ? does am i crazy?

8:03 s/does//

8:06 lancepantz: actually, i think i may have an idea... would leveraging metadata (:namespace, for isntance) be useful?

8:06 lancepantz: er :ns

8:20 lancepantz_: that's good idea defn

8:20 i'll give it a shot in the morning

8:22 spent all night reading graph theory papers.... again

8:26 defn: lancepantz: fun :)

8:33 lancepantz: we'll have time to relax when we're dead

8:47 kzar: I'm trying to get my new project working. When I do (use 'controls.server) it tries to open controls/server.clj which isn't found because I've structured things like controls/src/server.clj . Should I put everything inside controls/ or is there a setting I should change?

8:52 djpowell: your folder structure needs to match everything up to the last component of the package name, and the filename has to match the last component of the package name.

8:52 and then you need to make sure that the root folder is on your classpath

8:54 cemerick: rhickey: ping

8:54 rhickey: cemerick: pong

8:56 cemerick: rhickey: morning :-) A simple case of compilation failure FYI: http://paste.lisp.org/display/97911

8:57 funny, I thought the duplicate key check was only on literals

8:58 hrm, nope, createWithCheck right there in hash-map

9:02 rhickey: cemerick: thanks, will fix

9:03 cemerick: rhickey: thanks :-)

9:05 so the alternative if you might have duplicate keys is (into {} (map vec (partition 2 [:a 5 :a 6]))))

9:05 ?

9:06 rhickey: cemerick: yup

9:34 defn: kzar: for your folder structure your project.clj should show the name of the project as "controls"

9:34 kzar: are you using leiningen?

9:36 kzar: defn: Yea I'm using Leiningen, arbscht in #compojure helped me a bit. I had structured things wrong. I had done controls/src/server.clj but I needed to do src/controls/server.clj . Although to me it seems counterintuitive way to lay things out

9:37 tcrayford: is there an easy way to find all parts of a tree that match a certain predicate?

9:37 kzar: defn: (I say that because then I've got something like controls/project.clj and controls/src/controls/server.clj, seems a bit redundant)

9:37 rhickey: how does one build contrib without running the tests?

9:38 when test fail no jar is produced

9:39 tcrayford: I'm currently using http://paste.lisp.org/display/97914 for finding all map lookups inside a tree, but it feels pretty inelegant

9:41 rhickey: is there a way to get maven to show you possible targets/tasks?

9:55 * rhickey is stuck on: how does one build contrib without running the tests?

9:55 Norrit: rhickey, you could use -Dmaven.test.skip=true to ignore the tests

9:55 rhickey: Norrit: thanks

9:56 Norrit: you're welcome

10:21 rfg: Does the latest version of slime work with clojure 1.2 yet?

10:21 YamNad: Yes.

10:24 cYmen: Bonjour.

10:24 I'm trying to get started on clojure but the installation instructions for vimclojure talk about clojars, leining, build environments or whatever and I can't figure out where to start.

10:26 What I have done: Download and unzip clojure and clojure-contrib and tried out the repl.

10:26 I also copied the usual vim plugin parts of vimclojure where they belong and that seems to work.

10:29 tcrayford: for lein, go to its github site and download/install it according to the instructions there

10:33 cYmen: tcrayford: well it doesn't really say lein it says leining/gradle/maven/ivy

10:33 so I don't know which to get..

10:36 tcrayford: go for lein

10:36 its the standard these days

10:36 cemerick: rhickey: maven doesn't have targets or tasks -- there's a default lifecycle, which has a fixed set of phases (clean, compile, package, install, deploy, verify, test, etc)

10:37 tcrayford: http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Vim might help you

10:37 sexpbot: "Getting Started with Vim | Clojure | Assembla"

10:37 cemerick: rhickey: 5 minute read on the above: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

10:37 sexpbot: "Maven - Introduction to the Build Lifecycle"

10:38 tcrayford: though it doesn't really cover using the advanced features of vimclojure

10:38 http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Leiningen covers lein

10:38 sexpbot: "Getting Started with Leiningen | Clojure | Assembla"

10:38 cYmen: sexpbot: Are you talking to me?

10:39 cemerick: cYmen: no, it parrots the titles of all pasted urls :-/

10:40 cYmen: ah, how pleasant :)

10:42 well..now I have leiningen

10:42 How do I add something to my "development dependencies" as the vimclojure readme wants it...

10:43 tcrayford: you have to create a project and put things in project.clj in the root of said project

10:43 * tcrayford thinks getting started with clojure is still way too hard

10:44 cYmen: I don't know. Getting to the repl is dead simple...

10:44 And setting up vim for any kind of lispy development has never been pretty..

10:45 But a standard build process would be nice

10:45 tcrayford: lein is that standard build process

10:45 just about

10:45 cYmen: ok

10:46 * cYmen gets sidetracked and tries to install labrepl.

10:46 tcrayford: labrepl is pretty awesome if you're learning clojure

10:48 cemerick: There's a lot of tooling denominations in clojure-land. Each group has its own way.

10:49 cYmen: Yeah, but somebody needs to write an "Idiots guide to clojure development in vim."

10:49 Is there something like that somewhere?

10:50 cemerick: cYmen: this is the best there is, AFAIK: http://www.assembla.com/wiki/show/clojure/Getting_Started

10:50 sexpbot: "Getting Started | Clojure | Assembla"

10:50 tcrayford: the easy way is probably just to use a repl and plain old vim

10:51 lein only really comes into play when you're doing projects/want more functionality than repl/vim gets you

10:51 cemerick: I'm always astonished that anyone uses vim for lisp-related development.

10:51 tcrayford: I can understand it

10:51 when you're entrenched in vim, going to emacs feels very difficult

10:52 * tcrayford uses emacs & vim on a regular basis

10:52 cemerick: yeah, inertia is a big factor in any case

10:53 probably the biggest, actually

10:53 tcrayford: yeah

10:53 cemerick: the actual productivity differences for straight editing of code is probably effectively nil

10:53 tcrayford: I think I'm slightly faster in vim for straight text editing

10:54 but when you put paredit into play...

10:55 cemerick: well, I don't use emacs either :-)

10:55 tcrayford: what do you use?

10:55 cemerick: netbeans and enclojure

10:55 tcrayford: fair nuff

10:56 cemerick: though I've been eyeing the progress of other IDE plugins as well

10:56 tcrayford: I'd miss refactoring support :/

10:56 cemerick: refactoring support?

10:56 tcrayford: I wrote a refactoring tool for clojure/emacs/slime

10:57 cemerick: anything more than orchestrated grep? :-)

10:57 tcrayford: yeah

10:57 I can thread/unthread expressions (using both ->> and ->), add map destructuring to functions automatically

10:57 mefesto: hey everyone. noob here. just wondering what is meant behind putting an asterik at the end of a function's name?

10:58 cemerick: mefesto: that generally indicates a subordinate fn to the primary non-asterisk'ed fn

10:58 tcrayford: and extract method works well enough

10:58 cemerick: tcrayford: linky?

10:58 it all sounds great, and just a little scary

10:59 tcrayford: its not that sound yet

10:59 as in, you want to have tests on code you're running through it

10:59 mefesto: cemerick: so typically only used by the non-asterik'ed fn?

10:59 tcrayford: http://github.com/tcrayford/clojure-refactoring

10:59 cemerick: mefesto: generally, yeah. You also often see asterisk'ed fns backing up a non-asterisk'ed macro of the same name that adds some sugar, etc.

11:00 tcrayford: the backend is all in clojure, so you could probably write a frontend to it for anything else (assuming you have a running clojure connection) pretty easily

11:00 mefesto: cemerick: ok i understand, thanks :)

11:01 tcrayford: I've been meaning to play around with clojure's namespacing functions so I can do proper function renaming and inlining (neither of those are implemented at all yet)

11:02 cemerick: were there ever any successful refactoring systems for CL or scheme?

11:02 tcrayford: I don't know

11:02 not sure anybody ever tried it

11:02 its super easy with the whole code=data thing

11:03 cemerick: It'd take quite a bit of convincing for me to use a refactoring tool in a dynamically-typed lang.

11:03 tcrayford: aye

11:04 cemerick: *if* we could get everyone to use require and properly namespace their fn usage, then I might trust renames. :-)

11:04 tcrayford: smalltalk's one for example

11:04 yeah I'm still iffy about actually implementing renames

11:05 the current stuff is all local to one function

11:07 technomancy: refactoring in clojure is a *lot* easier than stuff like Ruby

11:07 tcrayford: c

11:07 *confirm

11:07 technomancy: since just loading a file can tell you all about what vars mean what

11:08 for top-level vars at least

11:08 tcrayford: yep

11:08 I need to get onto doing renames using the ns functions soon

11:08 technomancy: tcrayford: actually what we need to do is get slime xref working

11:08 that would make renames super-easy

11:08 tcrayford: technomancy: xref?

11:09 technomancy: cross references. "given this function, tell me everyone who calls it"

11:09 tcrayford: aye

11:09 * technomancy nominates tcrayford for that job =)

11:09 tcrayford: I was about to write something similar for refactoring-mode

11:10 can I use slime with slime?

11:10 technomancy: well all the elisp for it already exists

11:10 you'd just have to port the CL implementation to Clojure

11:10 tcrayford: right

11:10 technomancy: "just"

11:11 tcrayford: is there a common lisp implementation I should be looking at for that?

11:14 technomancy: http://github.com/nablaone/slime/blob/master/swank-backend.lisp#L907

11:15 tcrayford: cheers

11:17 technomancy: that would be super-slick to have

11:18 tcrayford: aye

11:21 cemerick: rhickey: defrecord/type names should be CamelCase, yes?

11:21 rhickey: cemerick: yes

11:22 tcrayford: technomancy:If I'm right, this should go under src/swank/commands/basic?

11:22 cemerick: just checking

11:22 tcrayford: technomancy: seeing as there's already some basic xref (who specializes) stuff in there

11:22 cemerick: there'll be pitchforks raised for that ;-)

11:22 rhickey: cemerick: and not Camel-Case

11:22 cemerick: heh

11:23 * rhickey is cringing at c.c.json

11:23 cemerick: I'd hope not!

11:23 heh, Read-JSON-From

11:23 well, it's changeable. Surely no one's extended it elsewhere at this point. :-)

11:24 big improvement there since 1.1 contrib

11:26 djpowell: oops - I posted a patch to contrib' assemba space, rather than clojure - I guess I just have to close the issue, and raise a new one

11:26 technomancy: tcrayford: sure

11:31 tcrayford: technomancy: this might be a while, got to get to grips with how swank-clojure is organised first

11:38 technomancy: the real problem (as I see it), is that who-calls (etc) all take function names, where for clojure you want namespace qualified function names

11:39 otherwise you might be find all the calls to 'join' (for example), which might refer to somebody's string utils, somebody's sql lib etc etc etc

11:44 mefesto: i noticed that add-classpath is deprecated. is it meant to force users to call (clojure.lang.RT/addURL) instead?

11:48 rhickey: mefesto: dynamically modifying the classpath is not something that can be made to work portably in all execution environments, i.e. it shouldn't be in your code.

11:50 tcrayford: what does #'sym expand out into?

11:52 nvm, it's var

11:55 mefesto: rhickey: ok. i just wanted something that would support a quick write/reload cycle while in development mode but wouldn't be used when deployed.

11:58 tcrayford: anybody know why this won't evaluate?

11:58 (defn does-namespace-refer-to-var? [variable namespace]

11:58 (some #(= (second %) (var variable)) (ns-map namespace)))

11:58 error is: "Unable to resolve var: variable in this context"

12:02 Borkdude: When syntax-quoting something with locals, how do keep them from resolving to fully qualifying names

12:02 tcrayford: ~'

12:02 clojurebot: I don't understand.

12:03 tcrayford: ,`(~'defn [a] 1)

12:03 clojurebot: (defn [sandbox/a] 1)

12:03 Borkdude: ah tnx

12:03 tcrayford: ,`(~'defn [~'a] 1)

12:03 clojurebot: (defn [a] 1)

12:16 tcrayford: technomancy: also swank might have to add contrib as a dependancy (it doesn't have it atm)

12:19 technomancy: tcrayford: what for?

12:20 tcrayford: source

12:20 in repl-utils

12:20 technomancy: it's already able to find where a var is defined using M-.

12:20 could probably piggy-back off that mechanism

12:20 tcrayford: would be easier with source though

12:21 technomancy: well do whatever's easiest for a first run

12:21 then we can iterate on a more self-contained approach once it works

12:22 tcrayford: yep

12:44 bpsm: I'm seeing intermittent crashes when mvn runs test-complex-numbers.

12:45 Race condition in protocols?

12:45 http://groups.google.com/group/clojure/msg/7b667f653513b769

13:05 rfg: Yay, finally got 1.2 to work with slime.

13:23 And now it has stopped working again...

13:28 Symbol's function definition is void: swank-clojure-reset-implementation?

13:53 Raynes: (clojure.contrib.io/slurp* "http://groups.google.com/group/clojure/browse_thread/thread/5007718945a3046f") <- Any idea why this throws a "Server returned HTTP response code: 403 for URL:"?

13:53 The link works.

13:56 vegai: Raynes: also wget does the same

13:56 Raynes: That's odd.

13:56 * vegai shrugs

13:56 Raynes: Firefox says it's okay.

13:56 :(

13:56 vegai: perhaps it's some authentication scheme that the dumb clients can't do

13:56 Raynes: Maybe so.

13:57 It certainly takes away most of the point of having a title-scraping bot in here though. :|

13:57 It would be most useful against groups links.

13:59 vegai: have you tried setting your user-agent to look like a browser?

14:02 Raynes: I'm not sure how I would do that.

14:02 vegai: me neither ;) but that might work

14:02 Raynes: Hehe.

14:18 chouser: did direct binding show up in 1.1, or since then?

14:18 sorry, "direct linking"

14:20 looks like it was in 1.1

15:11 caljunior: I'm doing the Vladimir Konrad's tutorial on creating a GUI with Netbeans and using it with Clojure. But when I try to import the Java class (MainFrame.class in this case) I get a class not found exception. CLojure is looking for MainFrame__init.class.

15:11 The tutorial is here: http://www.dearm.co.uk/cgan/

15:11 sexpbot: "Clojure, GUI and NetBeans"

15:11 caljunior: Is excellent.

15:12 texodus: Has the api for deftype/defprotocol changed recently?

15:13 just updated clojure-1.2.0-master-SNAPSHOT from clojars and factory function for deftype doesnt seem to exist anymore ...

15:13 hoeck: texodus: yes, use the constructor instead

15:13 texodus: what constructor?

15:13 hoeck: texodus: (deftype Foo [a b] ...) -> (Foo. a b)

15:13 texodus: (deftype Foo [x y]) -> (Foo. 1 2) ?

15:14 ah

15:14 hoeck: Foo. is the constructor

15:14 caljunior: sexpbot: that's how I found the tutorial. I followed it to a tee.

15:14 hoeck: should be documented in deftypes docstring

15:16 texodus: 'tis

15:16 thanks

15:16 hoeck: caljunior: sexpbot is a bot and only prints the title of posted links :)

15:17 * joshua-choi has not been keeping up with deftype

15:17 joshua-choi: So you use (Foo. 1 2) instead of (Foo now)?

15:17 hoeck: yes

15:17 caljunior: hoeck: doh!

15:17 hoeck: and there is now deftype and defrecord

15:18 joshua-choi: defrecord is just deftype with IPersistentMap, right?

15:18 hoeck: right

15:18 caljunior: and you did (import 'gui.MainFrame) ??

15:18 texodus: ah

15:18 clever

15:18 * tcrayford is beavering away at getting proper xref support in slime

15:18 texodus: thats helpful

15:19 caljunior: hoeck: I did.

15:19 more familiar with clojure than java

15:19 tcrayford: is there any decent way to find out if a namespace actually USES another function it refers to?

15:20 caljunior: hoeck: correction. I didn't. Misread your suggestion.

15:21 hoeck: caljunior: you did use or require?

15:21 caljunior: hoeck: seems to make a difference. Now I get a different NoClassDefFoundError. This is progress.

15:21 tcrayford: Currently I've been looking up the source code of each var in the namespace to find if it calls said function, but that requires disk access, and is slow

15:23 caljunior: hoeck: with (use 'gui.MainFrame) and (require 'gui.MainFrame) I get java.io.FileNotFoundException: Could not locate gui/MainFrame__init.class

15:23 hoeck: caljunior: use and require are for clojure namespaces

15:23 caljunior: which is correct because i/MainFrame__init.class doesn't exist. just MainFrame.class

15:23 hoeck: caljunior: import is for java classes

15:24 so it should be (import 'gui.MainFrame)

15:25 when you do (use 'gui.MainFrame), clojure actually looks for a gui/MainFrame.clj or a gui/MainFrame__init.class (which resembles a compiled clojure namespace)

15:26 tcrayford: mhh, you could read the bytecode of each function and try to find calls to other functions, but that sounds not like "decent" to me :/

15:27 caljunior: in principle, can I use swank-clojure-project, set the project root to the directory of the Netbeans project add a lib directory with clojure.jar and swank-clojure.jar and (import 'gui.MainFrame) ?

15:27 I tried and failed.

15:27 tcrayford: yeah it sounds indecent

15:27 problem with the current method is "Elapsed time: 129922.729 msecs"

15:28 for a resolving of one var across all namespaces

15:29 and that's with an ssd

15:29 * tcrayford shudders to think of the time that would take on a rotational disk

15:32 hoeck: caljunior: where does netbeans keep the compiled classes?

15:32 caljunior: in classes/ ?

15:34 tcrayford: thats really long

15:34 tcrayford: hoeck: especially if its meant to be used in an ide/refactoring tool

15:35 hoeck: tcrayford: how do find out wether some code calls a function?

15:35 hiredman: you look for calls to IFn.invoke

15:35 tcrayford: that's roughly the question I'm trying to answer, yes

15:36 hiredman: how?

15:36 hiredman: whatever your prefered method of bytecode inspection

15:36 assuming compiled code

15:37 tcrayford: I don't think all of this is (not AOT compiled anyway)

15:37 hiredman: although, that will also find stuff like (:foo {:foo 1})

15:38 tcrayford: hiredman: not just any function, one particular function

15:38 hiredman: then you just look for the head of lists

15:38 Chousuke: so what, you need to find all references to a var?

15:38 tcrayford: that's the aim

15:38 caljunior: hoeck: I did ln -s build/classes/gui/ . as per the tutorial. This created MainFrame.class MainFrame$1.class and MainFrame$2.class.

15:38 hoeck: but what about (let [head first] (head [1 2])) ?

15:39 hiredman: there is a namspace walker in contrib

15:39 you might also like at my clojure-dependeny-grapher on github

15:39 look

15:40 there is a branch that uses the namespace walker stuff

15:40 Chousuke: tcrayford: It seems to me that to do this the right way you need a code analysis tool that is more advanced than the clojure compiler :P

15:40 hoeck: caljunior: but that tutorial says you should "." add the the classpath

15:40 caljunior: and it looks like swank-clojure-project puts only lib, src, test and classes onto the classpath

15:41 caljunior: so try to link or copy build/ to classes/

15:41 tcrayford: Chouske: its looking that way at the moment

15:42 caljunior: that's true. it was a separate track I was pursuing though.

15:42 "link or copy build/ to classes/" trying now

15:43 hiredman: I think it certainly is not trivial, but an 80% solution would not be that difficult

15:43 tcrayford: aye

15:43 hiredman: once it's usable you have all the time in the world for people to submit little bug fixes here and there as they use it

15:43 tcrayford: doing it from source code on disk is horribly slow though

15:44 caljunior: gui-project

15:44 doh!

15:44 Chousuke: or you could start working on the compiler for clojure-in-clojure with the explicit aim of making it useful for refactoring tools as well ;-)

15:44 hiredman: tcrayford: you are going to have to load the code from disk no matter what

15:45 tcrayford: aye

15:45 hiredman: Chousuke: !

15:45 tcrayford: what is the ns-walker in contrib called?

15:45 hiredman: I don't recall

15:46 http://github.com/hiredman/clojure-dependency-grapher/blob/find-namespaces/dep.clj

15:47 tcrayford: find-namespaces it is

15:49 hiredman: ♥ ->

15:50 tcrayford: I guess a point could be restricting it to namespaces outside of clojure core and contrib (for the moment)

15:52 hiredman: I think it would be restricted to namespaces in the directory tree you set it loose on

15:52 tcrayford: yep

15:52 which, given this is running from swank (and hopefully, lein), should be doable

15:54 caljunior: hoeck: no joy. but (import 'gui.MainFrame) in clojure instance booted from Netbeans project directory seems to be working now. Now I get another exception: java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group but that's my problem. Thanks.

15:55 companion_cube: hi there, i would like to write an irc bot in clojure (so original), and wondered if an irc lib was available...

15:56 hiredman: the are several java irc libs and maybe two clojure libs

15:56 the java libs tend to be well tested and mature, the clojure libs maybe less so

15:57 * companion_cube does not need a very complicated lib, only the basics

15:57 hiredman: the only lib I've used is the java pircbot

15:57 very simple

15:57 companion_cube: other question : is it easy in clojure to load/reload/unload code ? for example, if i want to have "plugins" to be loaded or unload dynamically ?

15:58 hiredman: but most (java) people seem to prefer jerklib

16:01 hoeck: caljunior: you can also use this to examine the current classpath: (->> (System/getProperty "java.class.path") (.split (re-pattern (System/getProperty "path.separator"))) (map println) dorun)

16:02 caljunior: hoeck: I usually do: (System/getProperty "java.class.path") but yours prints more nicely.

16:03 hoeck: caljunior: ah, okay, then nevermind :)

16:03 companion_cube: in fact, i should better read some existing code before :/

16:03 caljunior: the classpath contains the default swank-clojure stuff.

16:03 companion_cube: is sexpbot/clojurebot code available ?

16:05 tcrayford: oops

16:05 was using ns-map instead of ns-interns

16:05 now takes ~1s

16:05 7s if you include all namespaces

16:22 ordnungswidrig: hi

16:22 does anyone know of a comparision of clojure couchdb client libraries?

16:24 AWizzArd: ~seen rhickey

16:25 clojurebot: rhickey was last seen in #clojure, 276 minutes ago saying: mefesto: dynamically modifying the classpath is not something that can be made to work portably in all execution environments, i.e. it shouldn't be in your code.

16:26 tcrayford: ~seen technomancy

16:26 clojurebot: technomancy was last seen in #clojure, 245 minutes ago saying: then we can iterate on a more self-contained approach once it works

16:28 AWizzArd: hiredman: does clojurebot ignore his own comments? Or could it go into an endless loop if I ask if it has seen me, and it then says that the last thing I said was this seen command, which would then trigger it to do it over and over again?

16:30 hiredman: AWizzArd: how would that put it in an endless loop?

16:30 arohner: ~seen tcrayford

16:30 clojurebot: tcrayford was last seen in #clojure, 3 minutes ago saying: ~seen technomancy

16:30 hiredman: clojurebot's responses are not prefixed with a ~ or clojurebot, so they are obviously not addressed to clojurebot

16:30 arohner: empirical proof :-)

16:30 AWizzArd: k ;)

16:31 cp2: not to mention outgoing PRIVMSG commands arent sent back to your client

16:31 the client in this case being clojurebot

16:31 er, that is, clojurebot doesnt receive its own messages

16:32 hiredman: pircbot may actually loop it's own privmsgs back through the onMessage handler, I don't recall

16:32 cp2: last i knew it didnt, could be wrong though

16:33 ,(println "~seen foo")

16:33 clojurebot: ~seen foo

16:33 hiredman: I didn't actually answer AWizzArd's question

16:33 AWizzArd: it’s answered enough, thanks

16:34 hiredman: clojurebot may ignore things it says, I don't recall

16:41 _schulte_: seems like it'd be dangerous if it didn't ignore itself, e.g. ((fn [a] `(~a '~a)) '(fn [a] `(~a '~a)))

16:54 ordnungswidrig: if ns foo.bar has (ns (:use foo.bar.baz)) wont (ns (:require foo.bar :as x)) expose the var from foo.bar.baz in ns x ?

16:54 such that x/qux is foo.bar.baz/qux

17:00 cYmen: hm...I think running lein deps in the labrepl directory is installing a new version of clojure

17:00 tcrayford: it will be, yes

17:01 into that directory

17:01 cYmen: inside it?

17:01 tcrayford: yep

17:01 cYmen: not somewhere global?

17:01 tcrayford: inside the lib folder

17:01 cYmen: hmhm

17:01 tcrayford: in labrepl

17:03 that way your dependancies are separated for each project

17:28 cYmen: "Clojure is impure, in that it doesn't force your program to be referentially transparent, " what does this mean?

17:28 opqdonut: the value of a variable (or reference, rather) can change

17:29 mostly because of java

17:29 (let [a (HashMap.)] (.put a 1 2))

17:30 that actually mutates the structure that a points to

17:30 cYmen: ok

17:30 thanks

17:51 erikcw1: can anyone point me to an example somewhere that uses fixtures from the test-is lib? I'm having trouble figuring out setup/tear down...

17:51 hiredman: fixtures get passed the test as a function

17:52 so something like (defn my-fix [f] (binding [somevar false] (f)))

17:53 erikcw1: so where do I put use-fixtures?

17:53 hiredman: at the top of the file with all the tests

17:54 (use-fixtures :each my-fix)

17:54 ,(doc clojure.test/use-fixtures)

17:54 clojurebot: "; Wrap test runs in a fixture function to perform setup and teardown. Using a fixture-type of :each wraps every test individually, while:once wraps the whole run in a single function."

18:03 Raynes: Sorry about the abundance of joins and quits there. One of those bugs that you think you've fixed 5 times before you actually fix it, and by then you've already annoyed everyone.

18:16 unlink: Would anyone be interested in collaborating on an interface to Interactive Brokers' TWS API?

18:20 hiredman: whatever happened to reify's volatile fields?

18:36 cemerick: hiredman: that's all moved to deftype I think

18:37 hiredman: ,(macroexpand-1 '(fn [a] a))

18:37 clojurebot: (fn* ([a] a))

18:38 hiredman: that list in there is annoying

18:39 makes a naive approach of examining macroexpands for function calls difficult

18:39 tcrayford: I hadn't thought of checking macroexpands for function calls

18:39 :/

18:40 though my current way will just show up the original macro

18:40 cemerick: hiredman: that's just the way it is to support multiple arities, no?

18:40 hiredman: user> (desugar '(defn plus [a b] (+ a b)))

18:40 (def plus (fn* (. [a b] invoke (. + invoke a b))))

18:40 user>

18:40 right

18:40 I know why it is there, but that does not make it less annoying

18:41 licoresse: .

18:42 tcrayford: ~seen technomancy

18:42 clojurebot: technomancy was last seen in #clojure, 380 minutes ago saying: then we can iterate on a more self-contained approach once it works

19:00 cemerick: rhickey: thanks for that patch for 302; that's a good initial step

19:01 actually, might be enough for 95% of cases

19:10 hiredman: user> (deconstruct '(defn plus [a b] (+ a b)))

19:10 (. clojure.lang.Var intern (. clojure.lang.Namespace findOrCreate (. clojure.lang.Symbol create "user")) (. clojure.lang.Symbol create "plus") (fn* ([a b] (. + invoke a b))))

19:10 user>

19:12 tcrayford: user> (who-calls 'potential-ns)

19:12 (#'swank.commands.completion/potential-ns #'swank.commands.completion/potential-completions)

19:12 * hiredman just tried to (man def)

19:13 tcrayford: (alias man doc)

19:13 hiredman: doc is a macro, so that won't work

19:13 tcrayford: :(

19:13 hiredman: you need to be more subtle about it

19:13 you can still do it

19:14 tcrayford: (defmacro man [& args] `(doc ~@args))

19:14 user> (defmacro man [& args] `(doc ~@args))

19:14 #'user/man

19:14 user> (man defn)

19:14 -------------------------

19:14 clojure.core/defn

19:14 ([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?])

19:14 Macro

19:15 Same as (def name (fn [params* ] exprs*)) or (def

19:15 name (fn ([params* ] exprs*)+)) with any doc-string or attrs added

19:15 to the var metadata

19:15 nil

19:23 http://gist.github.com/369890

19:24 there's actually some bugs in there that I've just thought of :/

19:26 aside from the one I already noted

19:26 :/

20:10 defn: hello all

20:25 * Raynes pokes YamNad

20:25 Raynes: ohai

20:26 YamNad: Haha hi :)

20:46 gerryxiao: hello

20:46 what's definterface

20:47 ,(doc definterface)

20:47 clojurebot: Excuse me?

20:47 gerryxiao: ,(doc defprotocol)

20:47 clojurebot: Gabh mo leithscéal?

20:48 gerryxiao: ,*clojure-version*

20:48 clojurebot: {:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}

22:11 cemerick: anyone have a clue about this exception coming out of clojure.core.protocols?: http://gist.github.com/369953

22:13 hiredman: cemerick: there was a commit about InternalReduce yesterdayish, do you have the latest?

22:15 cemerick: hiredman: yeah, I just saw that. Digging now :-)

22:20 hiredman: yup, that was it -- was running clojure-1.2.0-master-20100416.220115-33.jar which broke, mvn -U got today's build (reverting the change, whatever it was), and all's green now :-)

23:09 cheezey: umm... when i do something like (take 2 "asdf"), it requires a lazyseq rather than a string..? how do i change it to a string :\

23:25 jomofo: ,(take 2 "asdf")

23:25 clojurebot: (\a \s)

23:26 jomofo: cheezey: what do you mean by "requires"?

23:28 cheezey: jomofo: i meant "it gives" sorry

23:30 wooby: hi everyone

23:34 nteon: evening wooby

Logging service provided by n01se.net