#clojure log - Feb 01 2010

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

0:14 abrooks: Next question: I see I can use :as with alias and require but I'd like to rename on an import. Can I do that?

0:18 kmurph79: what's the advised way of installing clojure (os x)? i have no intent of using emacs

0:19 * Raynes mumbles 'Emacs' under his breath.

0:19 Raynes: :>

0:20 abrooks: kmurph79: I think this is though I haven't tried it. http://github.com/citizen428/ClojureX

0:22 kmurph79: abrooks: thanks, ill give that a shot

0:22 abrooks: I suspect there's a prebuilt one here but the site is tooo slooooo and I'm not going to wait for it: http://citizen428.net/archives/390-Easy-setup-for-Clojure-on-Mac-OS-X-Leopard.html

0:22 That's linked off of the github project page for ClojureX at the top.

0:30 konr: Isn't it cool? http://55chan.org/prog/src/126500183321.jpg

0:48 DeusExPikachu: what is the difference between (load-file "pathname") and (load ["pathname"])?

1:01 Raynes: (doc load)

1:01 clojurebot: "([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise."

1:01 Raynes: (doc load-file)

1:01 clojurebot: "([name]); Sequentially read and evaluate the set of forms contained in the file."

2:57 Raynes: "procedural programming is also known as "Functional Programming.""

2:58 The guy who wrote that then proceeded to argue about how similar the paradigms are. I assume he actually had no clue what functional programming is.

2:59 tomoj: heh

2:59 I see you left a comment

3:00 I could see how he could be correct, maybe

3:01 as in, saying "X is also know as 'Y'" isn't the same as saying "X and Y are the same"

3:02 since one thing might be known by a name which typically refers to something else

3:02 but I don't think that's what he was going for

3:09 Raynes: tomoj: I know the guy.

3:09 tomoj: You must be a l33t google searcher, by the way.

3:12 tomoj: Scratch that. It's the first (and near only) result.

3:33 tomoj: yup :)

3:34 only result I found for "procedural programming is also known as"

4:43 LauJensen: I just got K-Lined?

4:43 eevar2: that or you got creative with your quit message ;)

4:44 LauJensen: == You are banned from this server- Temporary K-line 1440 min. - Joining #pines (2010/2/1 09.37)

4:47 cypher23: LauJensen, ask in #freenode?

4:49 LauJensen: What good would that do ?

4:53 cypher23: so the staff can tell you why you got klined?

4:55 LauJensen: But according to this webinterface, #freenode looks quite empty

4:57 cypher23: LauJensen, 563 nicks when I join it

4:57 LauJensen: Ok - Might be webchat.freenode.net thats messing with me

4:57 cypher23: maybe

4:57 I'm using irssi

4:58 hiredman: could be the webchat all got klined

4:59 clojurebot: the most horrible thing?

4:59 clojurebot: I don't understand.

4:59 hiredman: clojurebot: the most terrible thing?

4:59 clojurebot: Huh?

4:59 hiredman: gah

5:03 fnuction: Hello

5:04 Anyone able to help with failing clojure-test-mode installs?

5:05 esj: nope, tried it myself over the w/e and failed

5:06 fnuction: Well, means I'm not alone which helps my self esteem I guess.

5:15 zaphyr: How do I coax clojure into creating a class vec3f with float fields x, y, z?

5:16 must i use :gen-class?

5:18 Chousuke: on 1.1.0, yes

5:18 zaphyr: ah, okay. thanks

5:18 Chousuke: on 1.2.0-master you could use deftype.

5:18 zaphyr: goodie :)

5:18 hoeck: zaphyr: with the newest clojure build you can use (deftype vec3f [#^float x, #^float y, #^float z])

5:19 zaphyr: that's much nicer. i've only just started and spent ages seeing if i could somehow type defstruct for similar behaviour

5:21 hoeck: zaphyr: deftype creates a class with public final fields under the hood, so it is way more efficient than defstruct

5:21 Chousuke: before deftype the most idiomatic form of a three-float vector was [1.0 2.0 3.0] :P

5:21 hoeck: and prettier than gen-class :)

5:21 Chousuke: but that doesn't support primitives

5:21 which I suppose is one of the reasons behind creating deftype

5:22 zaphyr: hehehe, yeah. plus i'm porting from java, and already ran benchmarks on different representations, public field access is considerably faster than array references, which is why I have to take this route.

5:22 Chousuke: but hm, doesn't java already have a vector3d class somewhere?

5:23 hoeck: I have a small spacewar like game with clojure+jbox2d+processing laying around here, as soon as I have some time for it, I will port it to use deftyped vectors

5:24 zaphyr: Chousuke: I think Java3D might have, but i rolled my own library for jogl a few years back, and now want to do it over in clojure to see if I can implement it in a nice language

5:24 Chousuke: http://java.sun.com/javase/technologies/desktop/java3d/forDevelopers/J3D_1_3_API/j3dapi/javax/vecmath/Vector3d.html indeed

5:24 it's mutable though :-(

5:24 zaphyr: boo!

5:26 on an unrelated note- bizarrely creating a GLCanvas within the SLIME repl seems to cause the AWT to hang when it draws

5:26 that is- prior to registering anything such as a GLEventListener on it

5:27 Chousuke: you probably need to tell awt to do drawing in some special thread

5:28 zaphyr: I thought it was happening on the EDT? maybe not. I'll fight that battle another day

9:02 avarus: hi!

9:03 ohpauleez: hi avarus

9:04 avarus: I just tried the clojure-json lib from danlarkin

9:04 hi ohpauleez :)

9:04 it seems to work but I have no idea how to get the values :)

9:04 the decoder returns something like this: {:domainrequest {:targetemail foo@bar.com}, :email {:pass myscrecretpass, :user websend@foobar.com}, :database {:name domains, :pass mysecretpass, :user postgres, :host 127.0.0.1}}

9:04 so how can I get the value of :host e.g.? :)

9:05 chouser: avarus: (-> rtn :database :host)

9:05 Raynes: Hey... I bet I could clean up my code using that pattern.

9:06 Yep. I totally can.

9:07 avarus: chouser: thanks. what's rtn in this context? :)

9:07 chouser: :-) ...the thing that the decoder returns

9:08 Raynes: I'm guessing the map.

9:08 avarus: ah lol :)

9:08 thanks :)

9:08 Raynes: He telepathically says "You're welcome."

9:13 avarus: indeed, that works :)

9:14 it looked similar before but I didn't have that ->

9:14 I also had a variant where :database and :host were in front of the json/decode-from-str function

9:14 Raynes: It could have been done like so: (:host (:database rtn))

9:14 But -> makes it prettier.

9:15 avarus: oh, that makes even sense to me

9:16 Raynes: chouser: I'm buying your book today. :>

9:16 avarus: me, too :>

9:16 40% discount is too good to be true though :P

9:16 Raynes: hi5

9:17 Indeed.

9:19 avarus: ah I do it now before I get lazy and fall asleep

9:20 so if I got it right I get the full ebook/book when it's done? :)

9:21 rsynnott: is this the pragmatic programmers book?

9:21 avarus: no

9:21 http://joyofclojure.com/

9:22 perhaps will be finished in fall 2010 if I read it right

9:22 rsynnott: ah :)

9:22 avarus: the programming clojure book from pragmatic* is already available

9:22 rsynnott: the front cover is deranged...

9:22 avarus: yep, I've got it

9:23 was wondering was there another one

9:23 avarus: yes, me, too :)

9:23 Chousuke: I already bought that but the discount was mostly obliterated by shipping costs ;P

9:23 tomoj: yeah, what the heck is that on the cover?

9:24 avarus: the book is ok...sometimes it makes me think "what?!" .. I think it's because I never did any lisp programming at all

9:24 * rsynnott quite likes this approach of releasing betas of books as part of the cost of buying it

9:25 avarus: yes, it's a good idea

9:29 esj: is there a magic incantation to make jline work under swank-

9:29 the default repl is 'orrrrrrible.

9:31 avarus: chouser: just curious. what if there is an update to the ebook; do I get an email to download the newer pdf? :)

9:35 lol, the pdf says licensed to andreas schipplock (my name actually :P)

9:35 Raynes: avarus: Do you know what sucks?

9:36 avarus: no

9:36 what?

9:36 clojurebot: what is wrong with you

9:36 Raynes: When I bought Programming Clojure, I signed up on pragprog and accidentally used an incorrect name. Now I have to stare at that fail everytime I read that book. :|

9:36 avarus: hehe

9:37 Raynes: clojurebot: Be quiet.

9:37 clojurebot: Gabh mo leithscéal?

9:37 Raynes: That's what she said.

10:04 chouser: avarus: I'm not sure, actually. I think you get email, but we'll tweet and/or blog about updates as well.

10:07 _fogus_: avarus: I believe you will receive update emails directly from Manning when they are available

10:11 avarus: k, thx

10:29 bye:)

11:24 freddy_d: clojure + compojure + enlive = excellent

11:24 what are people using for database access? clojure.contrib.sql or something else?

11:25 esj: clojureQL and congomongo here,

11:30 freddy_d: esj: never heard of MongoDB, looks interesting

11:30 esj: yeah, I'm still in the initial explorations too

11:31 freddy_d: what is your back-end db?

11:31 esj: mysql, not exciting

11:31 freddy_d: that's fine :)

11:31 everything is key-value in my app, so MongoDB looks like it'll fit right in

11:33 fholm: MongoDB <3

11:36 esj: its be much faster if you do

11:36 ok, i say that, i think it should be much faster....

11:39 freddy_d: thing is, i already have ddl and sql queries, so i'm just running them through clojure.contrib.sql, not sure value of adding more layers

11:39 maybe for another project that i start from scratch, will be easier to get started

11:41 esj: yeah, for sure.

11:54 cemerick: freddy_d: cluch, given a couchdb backend

13:20 stuartsierra: Just pushed the Big Contrib Lib Rename.

13:21 freddy_d: ?

13:21 stuartsierra: see my announcement on the list

13:21 freddy_d: ok

13:22 aw, no more ducks?

13:26 stuartsierra: no more ducks

13:26 it was a silly name; I never would have chosen it if I though it would get used so much

13:26 freddy_d: :)

13:27 stuartsierra: thank you (and rhickey et. al.) for Clojure and libraries

13:27 stuartsierra: you're welcome

13:28 freddy_d: I haven't been this excited about a new language since 1996

13:28 stuartsierra: me neither, give or take a few years

13:28 freddy_d: I've always loved FP but Haskell, Scala just don't do it for me

13:34 there's something about the rhythm of Clojure.... when I write code, it's almost like a melodious drum beat

13:47 qed: melodious drum beats!

13:51 jcromartie: melodious drum beats?

13:51 it's starting to sound like a Rails dev channel in here

13:51 qed: heh jcromartie: 12:34:19 < freddy_d> there's something about the rhythm of Clojure.... when I write code, it's almost like a melodious drum beat

13:51 jcromartie: yeah

13:56 qed: jcromartie: i just thought that was funny -- im not making fun or anything, i just thought that particular way of phrasing it was, well, you know, sort of funny

13:56 jcromartie: yes I know :)

13:57 qed: "the heavens split apart before my very eyes upon the writing of mine first function! melodious drum beats filled the air as angels rocked me gently to sleep in a carriage made of gold as I ascended toward the heavens."

13:58 (okay, now i'm making fun)

14:05 stuartsierra: This calls for http://xkcd.com/224/

14:06 qed: stuartsierra: hahahahaha

14:13 technomancy: stuartsierra: For my clojure.io proposal I also moved a few things from java-utils as well... file, delete-file, and delete-file-recursively

14:13 dunno if you want to make clojure.contrib.io match that or not, but just thought I'd mention it

14:17 stuartsierra: technomancy: yes, I like the idea

14:17 Can't decide if I like having file-related stuff in c.c..io or creating a new c.c.file

14:20 technomancy: a file-related namespace might be a little bare

14:22 stuartsierra: true

14:22 Actually, it'd be nice if we could drop c.c.java altogether, since the name isn't exactly informative.

14:23 Move the file stuff to c.c.io, the string-related stuff to c.c.string. What else is there?

14:23 technomancy: yeah, I only use it for file and delete-file, and occasionally as-str

14:23 clojure.io will probably land in clojure.lib soon, so it probably doesn't matter a great deal what contrib does

14:23 stuartsierra: ok

14:24 technomancy: c.c.java also has properties-related stuff, but that's easy to do in straight java too

14:24 *straight java interop

14:24 stuartsierra: My intent with my recent work on contrib was to clean it up for clojure.lib.

14:24 technomancy: gotcha

14:25 stuartsierra: So if you have a patch for moving file stuff to .io, go for it.

14:26 back in a bit

14:49 technomancy: src/main/clojure/clojure/contrib/io.clj <= eww; that is a mouthful

14:51 hiredman: verging on java levels of directory nesting

14:51 technomancy: hiredman: it's great if you're paid by the directory. for open source though... not so much.

14:52 cemerick: what would the alternative be?

14:52 technomancy: cemerick: the way it used to be was much nicer.

14:52 with the one change of moving the tests to a top-level test/ directory.

14:53 cemerick: isn't that only a diff of 2 directory segments?

14:54 stuartsierra: directories are not a crime

14:54 technomancy: it's just more busy work

14:54 cemerick: where's the work, though?

14:54 technomancy: anyway, you can ignore me; I'm not hacking on contrib these days

14:55 stuartsierra: It's a small price to pay for a simpler build process.

14:55 technomancy: stuartsierra: it's like three lines to use src/ in the maven build; clojure-pom works that way

14:56 but go with whatever works for you

14:58 sorry, shouldn't be so negative. it's certainly better than the old build.xml; thanks for cleaning it up.

14:59 stuartsierra: I kind of want to encourage following the Maven defaults. I know it could be fewer dirs, but then there's more non-standard configuration.

15:00 cemerick: it's an absolute no-brainer IMO

15:00 that much less cognitive overhead for newcomers

15:01 technomancy: stuartsierra: in that case, it must come to a duel

15:02 if you're encouraging that kind of stuff outside contrib, that is

15:02 =)

15:03 cemerick: technomancy: where do you stand vis á vis clojure polyglot maven?

15:03 stuartsierra: technomancy: I used to be a rated competitive fencer. :)

15:03 technomancy: cemerick: I think it's a terrible idea to develop something like that in secret.

15:03 because of that I haven't been following it much

15:03 cemerick: secret?

15:05 technomancy: cemerick: maybe it's opened up more recently, but as of a while ago the repositories for maven 3 weren't public

15:05 cemerick: ah

15:05 technomancy: there's so much wrong with that... I don't even know where to start

15:06 cemerick: it's a software business, so I can't fault them for doing what they need to

15:06 stuartsierra: They've got alpha snapshots up: http://maven.apache.org/download.html

15:06 technomancy: that's an improvement

15:06 stuartsierra: and public SVN: http://maven.apache.org/source-repository.html

15:08 technomancy: the fact that they'd ever consider it reasonable to have it closed in the first place makes me want to avoid the whole scene

15:08 though I am glad they've opened up

15:10 cemerick: They'd never actually close it up, maven's ubiquity is what drives interest in their tools/servers.

15:12 technomancy: they'd never close up an actual release, but the fact that the public wasn't involved in the early transition from 2 to 3 signals something's very wrong with the community

15:13 stuartsierra: Doesn't Apache own Maven now anyway?

15:14 cemerick: it's certainly an apache project. Sonatype could take their newest toys home with them if they so chose, though.

15:16 AWizzArd: btw, does Leiningen also use Maven?

15:16 technomancy: AWizzArd: it uses maven-ant-tasks, which provides access to Maven's dependency management (the good part) via the ant API

15:17 which means you can use it without a dependency injection (!) framework

15:17 AWizzArd: technomancy: from Maven I saw so far that it tries to download stuff from the internet when one uses it.

15:17 Is this also true for Leiningen, or would it work also behind a firewall, for corporate users?

15:18 (who don't have access to the net)

15:18 technomancy: AWizzArd: you can configure both Leiningen and Maven to pull from private repositories

15:18 AWizzArd: What would it like to pull?

15:18 technomancy: but if you don't have access to the Internet, your build system is the least of your worries

15:18 AWizzArd: No :)

15:18 stuartsierra: AWizzArd: does this help: http://www.aviransplace.com/2006/08/20/tip-installing-maven-2-behind-a-proxy/

15:19 AWizzArd: I don't understand why a build system would need to have access to the net, if the dependencies are already present on the local disk.

15:19 technomancy: AWizzArd: oh, if you've got the deps on disk it doesn't

15:19 AWizzArd: ok, sounds good then

15:19 technomancy: AWizzArd: maven will still try to connect to the Internet every time you do something if you have a "-SNAPSHOT" version in your deps

15:19 chouser: but they aren't. when you install maven, you apparently only get a maven stub. each time I try a new command it fetch a half-dozen jars

15:19 technomancy: but Leiningen will only do it when you explicitly ask for it

15:19 stuartsierra: Unless you add the "-o" option

15:20 technomancy: right

15:20 AWizzArd: o an in 'omit'?

15:20 stuartsierra: short for --offline

15:20 AWizzArd: good

15:21 cemerick: chouser: maven is really only a stub -- everything it does is implemented as plugins, which are pulled on demand

15:21 e.g. if there's a 3rd-party plugin that has a goal you want to run, you can invoke it, and maven will go find the necessary artifact without any pom config, etc.

15:22 chouser: it feels much more like a distro tool than a build tool to me.

15:22 AWizzArd: In principle it's okay, our harddisks are big enough, we have enough ram and most users do have an internet connection. But still, seeing that Maven eats so very many resources sounds strange when I just want to compile a project and get a .jar file :)

15:22 chouser: a resource hungry distro ;)

15:22 cemerick: chouser: yup, build + release + project mgmt/description + ....

15:22 stuartsierra: Maven's really aiming at larger projects with 100s of dependencies.

15:23 AWizzArd: I am sure it is useful and it went through some years of development.

15:23 stuartsierra: But putting contrib in a Maven build will make it easier (hopefully) for people with those kinds of large projects to use it.

15:23 AWizzArd: I am just not used to the idea of needing 100 MB for such a build tool.

15:24 stuartsierra: Think of autoconf/automake.

15:24 cemerick: stuartsierra: now that I'm well past my former experiences/prejudices, I think using it if you have zero dependencies is worthwhile. The dependency mgmt is useful, but hardly the majority of its appeal, IMO.

15:25 stuartsierra: cemerick: yes, once you get over the lack of control, it's valuable to be forced into certain conventions

15:25 AWizzArd: managing complex software is a complex task itself, and I guess the maven devs did not write all that code to eat specifically my resources. It's just the psychological effect I think.

15:25 chouser: ah, yes. once you learn to live without liberty, there are benefits to a communist state. ;-)

15:25 cemerick: stuartsierra: aside from that, there's piles of plugins that are immensely useful and make all sorts of build processes trivial to use.

15:26 And the release automation has been a godsend for us.

15:27 AWizzArd: technomancy: i have a big code base, all rooted in a src/ folder. In that I find several components that can be combined with each other. What I would like to know is if I can use Leiningen to define several combinations of components out of which it can produce one .jar file.

15:27 stuartsierra: yeah, that's the biggest reason I wanted to switch contrib. Doing the releases with Ant was a pain.

15:28 AWizzArd: technomancy: lein jar Project1 ==> compiles and jars the right files

15:28 lein jar all ==> compiles all sources, something like that I mean

15:32 stuartsierra: AWizzArd: in the Maven model that would be accomplished with sub-modules.

15:32 AWizzArd: I see.

15:33 We just did not want to have 18 different repositories from which we have to pull. So most code sits in one repo. With a bigger portion of reusable code and some projects that are using that + specific code.

15:35 stuartsierra: In Maven, that would be one "parent" project with dirs like ./modules/foo. Still one source code repository.

15:36 Look at the examples from the Sonatype guys - they're big on this.

15:36 AWizzArd: yes, such a thing would be interesting

15:36 This could be emulated with lein maybe by having a shell script that manages several project.clj files and renames them ;)

15:40 * stuartsierra cringes

16:21 technomancy: AWizzArd: flightcaster added multiple module support for leiningen, but I haven't had a chance to review it yet

16:21 check the mailing list

16:22 AWizzArd: what I've done in the past with Ruby is just treat independent subcomponents as independent projects, and that works really well too.

16:47 cschep: I have a file named foo.clj if I run a repl from the directory that it is in, should I be able to do (use 'foo) and run the function defined in the file? Or does it have to be on the class path? My java understanding is lacking here I think..

16:49 reify: OH at lunch today: clojure sucks because it doesn't support OOP and defaults to immutable data structures

16:49 the-kenny: lol

16:50 reify: i was thankful they didn't mention the JVM :)

16:50 technomancy: programmaring is hard

16:55 cschep: Hey guys, I'm trying to write a clj script so that I can say something like "clj foo.clj" and end up at a repl with foo.clj already ran/imported into the environment...the wiki's example seems outdated..does anyone have something like this setup?

16:58 dnolen: cschep: this doesn't work for you? http://clojure.org/repl_and_main

17:04 cschep: dnolen: ack, sorry, I went straight to the wiki which looks a little different, that is definitely right. thank you.

17:05 dnolen: cschep: np

17:06 hiredman: the wiki is old, and whoever started it seems to have moved on to other things

17:08 cschep: hiredman: ah, that makes sense.

18:01 AWizzArd: What is fsync(2) or fsync(3) in Java?

18:01 hiredman: a jni call

18:03 AWizzArd: hiredman: just calling .flush on my output stream won’t make sure that the writing action will block until the disk reports that my data was saved?

18:04 hiredman: AWizzArd: I would not rely on it

18:07 AWizzArd: hiredman: Do you think http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html#force%28boolean%29 is the right thing? Or also not trustworthy?

18:12 hiredman: I just asked in ##java

18:12 no replies yet, but nio seems like a more promising place to get that kind of thing

18:12 AWizzArd: hiredman: thank you!

18:13 hiredman: oh

18:13 ~jdoc java.io.FileDescriptor

18:13 has a sync method

18:15 AWizzArd: okay, that looks also good

18:16 arohner_: AWizzArd: even if java promises that it has called write() and sync(), your OS and raid controller can still lie to you

18:17 AWizzArd: arohner: could this also happen to the Oracle DB?

18:17 Or do they use other tricks to be sure that their transactional data indeed was written?

18:18 or take a DB written in Java (i think one such db ships with the jdk)

18:18 hiredman: derby

18:18 arohner: they *might* use tricks to say "I know that on linux versions x.y.z and above, calling sync();sync(); will really flush to disk"

18:18 of course, your raid controller can still lie

18:18 AWizzArd: hmm ok

18:19 interesting problem will be how/when to write transactional data to disk. In principle it should happen during a dosync

18:19 hiredman: which is what you want to be able to plugin into the stm for

18:20 AWizzArd: first making a change to a snapshot in memory, then writing out to disk that the modification happened and then ref-setting everything

18:21 hiredman: is there already such a mechanism in place in Clojure?

18:22 One other potential problem could be if many threads try to insert data, then maybe none of them could ever finish because they all compete with each other and no thread can win (because this syncing to disk just takes so long).

18:22 hiredman: AWizzArd: nope

18:23 arohner: is there a cleaner way to make a map from a for loop than (into {} (for []...))?

18:26 Kruppe: Clojure noob here, if i want some kind of global state variable should I be doing something like this: (def count 0) (defn update [] (def count (+ count 1))) or should I be doing something else? I'm looking for something analogous to defvar in cl.

18:26 arohner: Kruppe: typically refs are used for that

18:26 ,(doc ref)

18:26 clojurebot: "([x] [x & options]); Creates and returns a Ref with an initial value of x and zero or more options (in any order): :meta metadata-map :validator validate-fn :min-history (default 0) :max-history (default 10) If metadata-map is supplied, it will be come the metadata on the ref. validate-fn must be nil or a side-effect-free fn of one argument, which will be passed the intended new state on any state change. If the new state

18:26 Kruppe: arohner: ah ok, ill look into that

18:27 arohner: (def count (ref 0))

18:27 AWizzArd: arohner: this into is good. You only may consider reduce for some cases, maybe.

18:29 hiredman: Kruppe: don't re-def

18:29 Kruppe: hiredman: yeah I noticed clojure.core/count

18:30 hiredman: thanks for the warning though :)

18:30 AWizzArd: maybe hiredman meant that you said (def count 0) ... a bit later ... (def count something-else)

18:31 Kruppe: AWizzArd: ah, I actually couldn't find any other way to update the def

18:31 AWizzArd: what SHOULD be there instead?

18:32 AWizzArd: or should I just not use it like that?

18:32 AWizzArd: you can use atoms for counter

18:33 ,(let [my-counter (atom 100)] (println @my-counter) (swap! my-counter inc) (println @my-counter))

18:33 clojurebot: 100 101

18:33 AWizzArd: the “swap!” is the function which will update the contents of your counter

18:34 arohner: Kruppe: if you use a ref, you change it using dosync, alter, commute, ref-set. If you use an atom, you change it using swap!

18:34 Kruppe: one thing that helped me when learning clojure: coming from CL, you're familiar with boxes pointing to values

18:34 Kruppe: arohner: yup

18:35 AWizzArd: Kruppe: note that using Refs and Atoms are concurrency-ready.

18:35 arohner: in Clojure, def creates a box, called a var. refs and atoms are additional kinds of boxes

18:35 vars, refs, and atoms each have different concurrency semantics

18:36 if you want a global value to something that can change, typically you use a var pointing at an atom or ref

18:37 a var has a root value, that all threads see by default. You can also set a thread local value on the var, using binding

18:37 it's possible to re-set the root value (i.e. by re-defing), but this is considered bad style

18:37 Kruppe: arohner: yeah it seemed clumsy

18:38 arohner: I knew there had to be another way

18:46 arohner: AWizzArd: thanks for clearing that up, I think I get it now!

18:47 AWizzArd: enjoy

18:47 maxhodak: i keep getting a java.lang.ClassNotFoundException trying to access a java class and have just hit a wall

18:48 i'm trying to use the thrift (incubator.apache.org/thrift) java libs and it's generating a series of classes

18:48 and clojure can't seem to find one of the nested classes

18:48 AWizzArd: maxhodak: (System/getProperty "java.class.path")

18:48 hiredman: maxhodak: you have to use the desugared name

18:48 with $

18:49 maxhodak: hmm

18:49 so it can find the class file; it's on the classpath. i'm using lein and that's all fine

18:49 like, i have class foo { class bar { } }

18:49 and i can basically see foo , but not foo.bar

18:49 hiredman: some.package.someClass$innerClass

18:50 maxhodak: hiredman: sugared name?

18:50 oh

18:51 hiredman: that didn't fix it, either quoted or unquoted

18:52 hiredman: not quote

18:52 some.package.someClass$innerClass instead of some.package.someClass.innerClass

18:53 maxhodak: nope

18:53 hiredman: are you sure?

18:54 maxhodak: my path basically looks like

18:54 /src/clj/file.clj, /src/java/foo/bar.java

18:54 inside file.clj i'm trying (new myproject.foo.bar$quuz)

18:55 (er, add a myproject into those paths as appropriate)

18:55 and i'm getting either unable to resolve class name or class not found

18:56 hiredman: how are you starting the repl

18:56 maxhodak: i'm getting the error on lein compile; i dont have a repl up

18:58 hiredman: where are the class files?

18:59 maxhodak: src/java/myproject/foo/*

18:59 hiredman: maxhodak: uh, and how do you know that is on the class path

19:00 maxhodak: because :import (myproject.foo) doesn't generate an error

19:01 hiredman: maxhodak: it wouldn't, you are telling it to import nothing from a nonexistant package

19:01 (:import (myproject foo)) is what you want

19:03 maxhodak: is (:import (myproject.foo *)) valid in clojure?

19:03 hiredman: nope

19:03 maxhodak: hmm ok

19:05 hiredman: I think you will find your classes are not on your classpath

19:05 maxhodak: yeah, now it's dying on the import

19:05 readreadread lein doc

19:05 thaanks

19:06 hiredman: I would recommend, if this is your first project, to skip lein

19:06 maxhodak: it's not my first in clojure, just the first trying to get it to play along really nicely with java

19:07 and lein is *amazing* with dependencies

19:08 hiredman: ok

19:08 cschep: is there a "best place" to get SLIME on github?

19:09 Chousuke: cschep: I think you should install slime using ELPA to ensure it works with clojure-mode

19:09 cschep: There's some incompatibility issue with the latest CVS/git/whatever versions :/

19:09 dnolen: cschep: I would get it from ELPA, but if you want to interoperate with other Lisps (SBCL, CMUCL, ClozureCL, MzScheme, etc) you should get technomancy's fork on github.

19:10 cschep: Chousuke: ahh.. I've been trying to avoid ELPA so I can learn better how everything fits together.. but if it's not going to work..

19:11 dnolen: maxhodak: based on your description of your project dir layout your import statement will not work.

19:11 cschep: so get ELAP, install clojure-mode, then do clojure-install ?

19:11 ELPA*

19:11 hiredman: there is a lein java plugin somewhere

19:11 ~google lein-java

19:11 clojurebot: First, out of 163000 results is:

19:11 Building Clojure Projects with Leiningen « I am Zef

19:11 http://zef.me/2470/building-clojure-projects-with-leiningen

19:11 hiredman: :/

19:12 technomancy: cschep: clojure-install is deprecated. if you install swank-clojure through elpa it will get the jars for you

19:12 AWizzArd: hiredman: about this in-memory transaction via dosync with additional persistence to disk: I would think that a (locking ...) around the dosync could help. In that case all threads that try to make a modification that requires disk-persistence would sit in the lock and won’t destroy each others transaction?!

19:13 maxhodak: hmm. now im getting tons of ZipExceptions on lein

19:13 cschep: this feels so fragmented, is there one place with a "right way"?

19:13 hiredman: AWizzArd: no

19:13 AWizzArd: don't do that

19:13 technomancy: cschep: there's a lot of outdated info on the web... that's how blogs work unfortunately. the swank-clojure readme is your best bet

19:13 raek: have anyone seen this something like this function before? http://gist.github.com/292210

19:13 I don't want to reinvent what's already in clojure...

19:14 AWizzArd: hiredman: what is the problem with that approach?

19:14 hiredman: AWizzArd: the tie in with the stm would mean you could have database transactions, for example, that rollback if the transaction is retried

19:14 not some kind of constant writing or something

19:14 don't throw your own locks in with the stm

19:15 AWizzArd: yeah, but you also said that there is no mechanism in Clojure which would support my "plugins"..

19:15 hiredman: there is no stm support for this

19:16 you just need to come up with a mechanism, possibly sending side-effect stuff to an agent to be executed once the transaction completes

19:17 AWizzArd: The challenge is that the order of the steps must be: writing data to the persistent data structure. This shows if there are contsraints or not. Then write to disk that the change happened. Then ref-set the ref to the new state.

19:17 Chousuke: raek: hm, remember that maps are unordered. the behaviour of that function is not well-defined.

19:18 array-maps happen to be ordered but I don't think that's guaranteed. :/

19:18 raek: I know... but the assumption is that only one of the predicates will return true

19:18 AWizzArd: Step 1 and 3 must be in the same dosync, so that I will know that I can ref-set the new state later. But that also implies that step 2 must be in the same transaction.

19:18 raek: at least that's the case in my application

19:19 hiredman: erm, why are you using ref-set?

19:19 raek: maybe "mutually exclusive predicates" needs more explanation in the docstring

19:20 Chousuke: raek: ah, well, in that case I don't think there's anything like that in clojure

19:20 AWizzArd: hiredman: because i have a pointer to a snapshot that already has the correct state that i want

19:20 hiredman: why?

19:20 clojurebot: http://clojure.org/rationale

19:20 Chousuke: :P

19:21 hiredman: why aren't you just using alter?

19:22 AWizzArd: hiredman: I could also use alter

19:23 hiredman: ~alter

19:23 clojurebot: alter is always correct

19:23 AWizzArd: :-)

19:24 ~seen kotarak

19:24 clojurebot: kotarak was last seen quiting IRC, 3557 minutes ago

19:26 AWizzArd: n8 all, and thanks hiredman for finding FileDescriptor’s .sync

19:32 cschep: Why doesn't swank-clojure just grab the latest clojure/clojure-contrib from github?

19:33 dnolen: cschep: because they aren't always stable, not very a good user-experience :)

19:34 cschep: dnolen: ha, cool.

19:34 dnolen: is there a command to see if there is an update? must be..

19:35 dnolen: cschep: if you want to work from the latest, clone them from github, build the jars, and symlink to them from your .swank-clojure dir

19:36 that's what I do.

19:38 cschep: oh, cool.

19:42 dnolen: cschep: supposedly there's way to configure swank-clojure from your .emacs file but I couldn't figure it out :)

19:43 cschep: dnolen: ha, yeah I was just reading about that, but i'm just learning clojure so i doubt that i'll even notice any difference in 1.1.0 and 1.2.0

19:43 dnolne: learning clojure as well as emacs, as well as being a bit newer to the java side of things has been a real hassle

19:44 dnolen: it's a lot to handle. Did you look into Enclojure?

19:44 cschep: dnolen: I didn't really, I'm hoping to start using emacs more and more for other code too, so I decided to just bite the bullet..maybe I should retreat for a bit though.. :) I dunno.

19:46 dnolen: well you're already on your merry way. If you stop now you'll just forget everything ;)

19:50 cschep: ha, truth.

20:05 zaphyr: Heh, I've been losing all day so I've been forced to ask this newbie question- I need to create a java class called 'vec3f', containing three public static final float fields x,y, and z, with a constructor taking those arguments (in clojure 1.1). Can anyone give a brief paste to demonstrate how I would go about this? Thanks in advance.

20:08 oops, s/public static final/public final/ (duh)

20:10 dnolen: zaphyr: I don't think that you can really do that in Clojure 1.1, you can use deftype in clojure 1.2.

20:11 zaphyr: ahh, that's probably why i couldn't find it. :)

20:11 all i found was :state, which was close, but no cigar

20:11 thanks!

20:11 krumholt_: zaphyr, do you need that class to feed it to a java function?

20:12 zaphyr: actually it's a performance thing- i need to be able to read unboxed floats from members as it's the quickest way to do it under the sun jvm

20:13 java doesn't really need to see it, but since it's going to be used heavily a defstruct probably won't cut it

20:13 (and float[] will be significantly slower according to my benchmarks)

20:14 krumholt_: zaphyr, (deftype vec3f #^float x1 #^float x2 #^float x3)

20:14 zaphyr: want :), is 1.2 stable enough given I'm still starting out do you think?

20:15 krumholt_: i don't know anything about 1.2 sorry. but deftype should be pretty fast

20:16 dnolen: zaphyr: pretty stable, tho it means you need to build your .jars of course. Though that isn't so hard.

20:16 zaphyr: krumholt: oh, i was under the impression deftype was 1.2 only, so maybe i've just completely overlooked that

20:17 krumholt_: no protocols and deftype is usable in 1.1

20:17 cschep: is there a good way to parse HTML in clojure?

20:17 I'm looking at http://htmlparser.sourceforge.net/ ..

20:17 krumholt_: it says in the docs that it is alpha and subject to change if thats not a problem for you

20:18 zaphyr: ah, well, not really at this stage, i'm happy to change as required.

20:18 somnium: krumholt_: that's 1.2 (previously 1.1-new)

20:18 dnolen: cschep: Enlive is good for HTML parsing

20:19 ohpauleez: enlive is awesome

20:19 krumholt_: somnium, oh ok. thanks for the info

20:20 zaphyr: hmm (deftype vec #^float x #^float y #^float z) gives me Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol?

20:20 using clojure 1.1.0-new-snapshot

20:20 (downloaded a couple of days ago)

20:21 cschep: dnolen: ok cool i'll check it out

20:21 dnolen: ,deftype

20:21 clojurebot: java.lang.Exception: Unable to resolve symbol: deftype in this context

20:21 dnolen: ,+

20:21 clojurebot: #<core$_PLUS___4518 clojure.core$_PLUS___4518@1b38815>

20:22 dnolen: (deftype vec3f [#^float x #^float y #^float z])

20:24 zaphyr: yay! it worked! thanks everyone :)

20:42 final stupid question of the night- can i implement multimethods for my new vec3f type to handle the numerical operators? looking at the source to clojure.lang.Numbers it seems i might win more if I just do this part in Java...

20:45 arohner: {:pre [(disjoint? (set (keys A)) (set (keys B)))]}

20:46 I'd like to see the haskell type for that...

20:50 zaphyr: ah, nm i just found clojure.contrib.generic.arithmetic :)

21:01 arohner: are there any library functions for generating selections / permutations?

21:04 dnolen: arohner: clojure.contrib.combinatorics

21:05 arohner: looks like I need to become familiar with incanter

21:05 somnium: arohner: a few things in clojure.set too

21:26 arohner: is there any way to easily make maven/lein build against the clojure checkout in my directory?

21:26 I dislike it that I have my own git branch, and then I download some library, and I run mvn install and then it goes and downloads some other clojure version than the one I'm using

21:48 vu3rdd: did anyone try the latest clojure-contrib from the master branch?

21:48 I am having trouble giving locally built clojure.jar to the -contrib build

21:48 dnolen: vu3rdd: you're using maven right?

21:48 vu3rdd: I do mvn -Dclojure.jar=<absolute path to clojure.jar> package

21:49 but it still downloads clojure-1.2.0-XXX.jar from the web

21:49 I tried passing the -o flag to mvn (offline mode), but it fails because it can't find the jar

21:50 is anyone else also facing this?

21:50 dnolen: vu3rdd: hmm, it seemed to work for me this morning, but I'm not on machine with that setup at the moment.

21:52 vu3rdd: would you mind trying by deleting the copy of clojure-XXX.jar from the ~/.m2 directory and try again?

21:52 when you get to the machine, I mean

21:52 dnolen: thanks a lot.

23:06 qed: forgive me if this is dense, but: When that finishes, symlink bin/lein from your checkout to your path. This will make "lein" run from your checkout while "lein-stable" uses the jar self-installed in ~/.m2.

23:06 So I I make a symlink from where to where? I have lein-stable in my ~/bin/ which is on my path

23:06 dnolen: qed: yes

23:07 from path/to/lein-checkout/bin/lein to /usr/bin/local or whatever is appropiate for your system.

23:07 /usr/bin/local/lein i mean

23:07 in your case

23:07 ~/bin/lein then

23:07 clojurebot: I don't understand.

23:08 dnolen: ln -s ~/bin/lein path/to/checkout/bin/lein

23:08 er

23:08 sorry

23:08 qed: is it reversed?

23:08 dnolen: yes

23:08 qed: yeah i always make that mistake

23:08 okay that makes sense, i kept reading that link i should overwrite the lein binary in my checkout

23:08 like*

23:09 ln would make so much sense if there was a [to] somewhere in there

23:09 dnolen: heh well it does follow the convention of cp and mv: source -> target

23:36 qed: dnolen-rec_: re: heh well it does follow the convention of cp and mv: source -> target --- Yes, but in a way the source is the target and vice versa

Logging service provided by n01se.net