#clojure logs

2010-02-01

00:14abrooksNext question: I see I can use :as with alias and require but I'd like to rename on an import. Can I do that?
00:18kmurph79what's the advised way of installing clojure (os x)? i have no intent of using emacs
00:19Raynes:>
00:20abrookskmurph79: I think this is though I haven't tried it. http://github.com/citizen428/ClojureX
00:22kmurph79abrooks: thanks, ill give that a shot
00:22abrooksI 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
00:22abrooksThat's linked off of the github project page for ClojureX at the top.
00:30konrIsn't it cool? http://55chan.org/prog/src/126500183321.jpg
00:48DeusExPikachuwhat is the difference between (load-file "pathname") and (load ["pathname"])?
01:01Raynes(doc load)
01:01clojurebot"([& 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."
01:01Raynes(doc load-file)
01:01clojurebot"([name]); Sequentially read and evaluate the set of forms contained in the file."
02:57Raynes"procedural programming is also known as "Functional Programming.""
02:58RaynesThe 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.
02:59tomojheh
02:59tomojI see you left a comment
03:00tomojI could see how he could be correct, maybe
03:01tomojas in, saying "X is also know as 'Y'" isn't the same as saying "X and Y are the same"
03:02tomojsince one thing might be known by a name which typically refers to something else
03:02tomojbut I don't think that's what he was going for
03:09Raynestomoj: I know the guy.
03:09Raynestomoj: You must be a l33t google searcher, by the way.
03:12Raynestomoj: Scratch that. It's the first (and near only) result.
03:33tomojyup :)
03:34tomojonly result I found for "procedural programming is also known as"
04:43LauJensenI just got K-Lined?
04:43eevar2that or you got creative with your quit message ;)
04:44LauJensen== You are banned from this server- Temporary K-line 1440 min. - Joining #pines (2010/2/1 09.37)
04:47cypher23LauJensen, ask in #freenode?
04:49LauJensenWhat good would that do ?
04:53cypher23so the staff can tell you why you got klined?
04:55LauJensenBut according to this webinterface, #freenode looks quite empty
04:57cypher23LauJensen, 563 nicks when I join it
04:57LauJensenOk - Might be webchat.freenode.net thats messing with me
04:57cypher23maybe
04:57cypher23I'm using irssi
04:58hiredmancould be the webchat all got klined
04:59hiredmanclojurebot: the most horrible thing?
04:59clojurebotI don't understand.
04:59hiredmanclojurebot: the most terrible thing?
04:59clojurebotHuh?
04:59hiredmangah
05:03fnuctionHello
05:04fnuctionAnyone able to help with failing clojure-test-mode installs?
05:05esjnope, tried it myself over the w/e and failed
05:06fnuctionWell, means I'm not alone which helps my self esteem I guess.
05:15zaphyrHow do I coax clojure into creating a class vec3f with float fields x, y, z?
05:16zaphyrmust i use :gen-class?
05:18Chousukeon 1.1.0, yes
05:18zaphyrah, okay. thanks
05:18Chousukeon 1.2.0-master you could use deftype.
05:18zaphyrgoodie :)
05:18hoeckzaphyr: with the newest clojure build you can use (deftype vec3f [#^float x, #^float y, #^float z])
05:19zaphyrthat's much nicer. i've only just started and spent ages seeing if i could somehow type defstruct for similar behaviour
05:21hoeckzaphyr: deftype creates a class with public final fields under the hood, so it is way more efficient than defstruct
05:21Chousukebefore deftype the most idiomatic form of a three-float vector was [1.0 2.0 3.0] :P
05:21hoeckand prettier than gen-class :)
05:21Chousukebut that doesn't support primitives
05:21Chousukewhich I suppose is one of the reasons behind creating deftype
05:22zaphyrhehehe, 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.
05:22Chousukebut hm, doesn't java already have a vector3d class somewhere?
05:23hoeckI 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
05:24zaphyrChousuke: 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
05:24Chousukehttp://java.sun.com/javase/technologies/desktop/java3d/forDevelopers/J3D_1_3_API/j3dapi/javax/vecmath/Vector3d.html indeed
05:24Chousukeit's mutable though :-(
05:24zaphyrboo!
05:26zaphyron an unrelated note- bizarrely creating a GLCanvas within the SLIME repl seems to cause the AWT to hang when it draws
05:26zaphyrthat is- prior to registering anything such as a GLEventListener on it
05:27Chousukeyou probably need to tell awt to do drawing in some special thread
05:28zaphyrI thought it was happening on the EDT? maybe not. I'll fight that battle another day
09:02avarushi!
09:03ohpauleezhi avarus
09:04avarusI just tried the clojure-json lib from danlarkin
09:04avarushi ohpauleez :)
09:04avarusit seems to work but I have no idea how to get the values :)
09:04avarusthe 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}}
09:04avarusso how can I get the value of :host e.g.? :)
09:05chouseravarus: (-> rtn :database :host)
09:05RaynesHey... I bet I could clean up my code using that pattern.
09:06RaynesYep. I totally can.
09:07avaruschouser: thanks. what's rtn in this context? :)
09:07chouser:-) ...the thing that the decoder returns
09:08RaynesI'm guessing the map.
09:08avarusah lol :)
09:08avarusthanks :)
09:08RaynesHe telepathically says "You're welcome."
09:13avarusindeed, that works :)
09:14avarusit looked similar before but I didn't have that ->
09:14avarusI also had a variant where :database and :host were in front of the json/decode-from-str function
09:14RaynesIt could have been done like so: (:host (:database rtn))
09:14RaynesBut -> makes it prettier.
09:15avarusoh, that makes even sense to me
09:16Rayneschouser: I'm buying your book today. :>
09:16avarusme, too :>
09:16avarus40% discount is too good to be true though :P
09:16Rayneshi5
09:17RaynesIndeed.
09:19avarusah I do it now before I get lazy and fall asleep
09:20avarusso if I got it right I get the full ebook/book when it's done? :)
09:21rsynnottis this the pragmatic programmers book?
09:21avarusno
09:21avarushttp://joyofclojure.com/
09:22avarusperhaps will be finished in fall 2010 if I read it right
09:22rsynnottah :)
09:22avarusthe programming clojure book from pragmatic* is already available
09:22rsynnottthe front cover is deranged...
09:22rsynnottavarus: yep, I've got it
09:23rsynnottwas wondering was there another one
09:23avarusyes, me, too :)
09:23ChousukeI already bought that but the discount was mostly obliterated by shipping costs ;P
09:23tomojyeah, what the heck is that on the cover?
09:24avarusthe book is ok...sometimes it makes me think "what?!" .. I think it's because I never did any lisp programming at all
09:25avarusyes, it's a good idea
09:29esjis there a magic incantation to make jline work under swank-
09:29esjthe default repl is 'orrrrrrible.
09:31avaruschouser: just curious. what if there is an update to the ebook; do I get an email to download the newer pdf? :)
09:35avaruslol, the pdf says licensed to andreas schipplock (my name actually :P)
09:35Raynesavarus: Do you know what sucks?
09:36avarusno
09:36avaruswhat?
09:36clojurebotwhat is wrong with you
09:36RaynesWhen 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. :|
09:36avarushehe
09:37Raynesclojurebot: Be quiet.
09:37clojurebotGabh mo leithscéal?
09:37RaynesThat's what she said.
10:04chouseravarus: 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:11avarusk, thx
10:29avarusbye:)
11:24freddy_dclojure + compojure + enlive = excellent
11:24freddy_dwhat are people using for database access? clojure.contrib.sql or something else?
11:25esjclojureQL and congomongo here,
11:30freddy_desj: never heard of MongoDB, looks interesting
11:30esjyeah, I'm still in the initial explorations too
11:31freddy_dwhat is your back-end db?
11:31esjmysql, not exciting
11:31freddy_dthat's fine :)
11:31freddy_deverything is key-value in my app, so MongoDB looks like it'll fit right in
11:33fholmMongoDB <3
11:36esjits be much faster if you do
11:36esjok, i say that, i think it should be much faster....
11:39freddy_dthing 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:39freddy_dmaybe for another project that i start from scratch, will be easier to get started
11:41esjyeah, for sure.
11:54cemerickfreddy_d: cluch, given a couchdb backend
13:20stuartsierraJust pushed the Big Contrib Lib Rename.
13:21freddy_d?
13:21stuartsierrasee my announcement on the list
13:21freddy_dok
13:22freddy_daw, no more ducks?
13:26stuartsierrano more ducks
13:26stuartsierrait was a silly name; I never would have chosen it if I though it would get used so much
13:26freddy_d:)
13:27freddy_dstuartsierra: thank you (and rhickey et. al.) for Clojure and libraries
13:27stuartsierrayou're welcome
13:28freddy_dI haven't been this excited about a new language since 1996
13:28stuartsierrame neither, give or take a few years
13:28freddy_dI've always loved FP but Haskell, Scala just don't do it for me
13:34freddy_dthere's something about the rhythm of Clojure.... when I write code, it's almost like a melodious drum beat
13:47qedmelodious drum beats!
13:51jcromartiemelodious drum beats?
13:51jcromartieit's starting to sound like a Rails dev channel in here
13:51qedheh 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:51jcromartieyeah
13:56qedjcromartie: 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:56jcromartieyes I know :)
13:57qed"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:58qed(okay, now i'm making fun)
14:05stuartsierraThis calls for http://xkcd.com/224/
14:06qedstuartsierra: hahahahaha
14:13technomancystuartsierra: For my clojure.io proposal I also moved a few things from java-utils as well... file, delete-file, and delete-file-recursively
14:13technomancydunno if you want to make clojure.contrib.io match that or not, but just thought I'd mention it
14:17stuartsierratechnomancy: yes, I like the idea
14:17stuartsierraCan't decide if I like having file-related stuff in c.c..io or creating a new c.c.file
14:20technomancya file-related namespace might be a little bare
14:22stuartsierratrue
14:22stuartsierraActually, it'd be nice if we could drop c.c.java altogether, since the name isn't exactly informative.
14:23stuartsierraMove the file stuff to c.c.io, the string-related stuff to c.c.string. What else is there?
14:23technomancyyeah, I only use it for file and delete-file, and occasionally as-str
14:23technomancyclojure.io will probably land in clojure.lib soon, so it probably doesn't matter a great deal what contrib does
14:23stuartsierraok
14:24technomancyc.c.java also has properties-related stuff, but that's easy to do in straight java too
14:24technomancy*straight java interop
14:24stuartsierraMy intent with my recent work on contrib was to clean it up for clojure.lib.
14:24technomancygotcha
14:25stuartsierraSo if you have a patch for moving file stuff to .io, go for it.
14:26stuartsierraback in a bit
14:49technomancysrc/main/clojure/clojure/contrib/io.clj <= eww; that is a mouthful
14:51hiredmanverging on java levels of directory nesting
14:51technomancyhiredman: it's great if you're paid by the directory. for open source though... not so much.
14:52cemerickwhat would the alternative be?
14:52technomancycemerick: the way it used to be was much nicer.
14:52technomancywith the one change of moving the tests to a top-level test/ directory.
14:53cemerickisn't that only a diff of 2 directory segments?
14:54stuartsierradirectories are not a crime
14:54technomancyit's just more busy work
14:54cemerickwhere's the work, though?
14:54technomancyanyway, you can ignore me; I'm not hacking on contrib these days
14:55stuartsierraIt's a small price to pay for a simpler build process.
14:55technomancystuartsierra: it's like three lines to use src/ in the maven build; clojure-pom works that way
14:56technomancybut go with whatever works for you
14:58technomancysorry, shouldn't be so negative. it's certainly better than the old build.xml; thanks for cleaning it up.
14:59stuartsierraI 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:00cemerickit's an absolute no-brainer IMO
15:00cemerickthat much less cognitive overhead for newcomers
15:01technomancystuartsierra: in that case, it must come to a duel
15:02technomancyif you're encouraging that kind of stuff outside contrib, that is
15:02technomancy=)
15:03cemericktechnomancy: where do you stand vis á vis clojure polyglot maven?
15:03stuartsierratechnomancy: I used to be a rated competitive fencer. :)
15:03technomancycemerick: I think it's a terrible idea to develop something like that in secret.
15:03technomancybecause of that I haven't been following it much
15:03cemericksecret?
15:05technomancycemerick: maybe it's opened up more recently, but as of a while ago the repositories for maven 3 weren't public
15:05cemerickah
15:05technomancythere's so much wrong with that... I don't even know where to start
15:06cemerickit's a software business, so I can't fault them for doing what they need to
15:06stuartsierraThey've got alpha snapshots up: http://maven.apache.org/download.html
15:06technomancythat's an improvement
15:06stuartsierraand public SVN: http://maven.apache.org/source-repository.html
15:08technomancythe 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:08technomancythough I am glad they've opened up
15:10cemerickThey'd never actually close it up, maven's ubiquity is what drives interest in their tools/servers.
15:12technomancythey'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:13stuartsierraDoesn't Apache own Maven now anyway?
15:14cemerickit's certainly an apache project. Sonatype could take their newest toys home with them if they so chose, though.
15:16AWizzArdbtw, does Leiningen also use Maven?
15:16technomancyAWizzArd: it uses maven-ant-tasks, which provides access to Maven's dependency management (the good part) via the ant API
15:17technomancywhich means you can use it without a dependency injection (!) framework
15:17AWizzArdtechnomancy: from Maven I saw so far that it tries to download stuff from the internet when one uses it.
15:17AWizzArdIs this also true for Leiningen, or would it work also behind a firewall, for corporate users?
15:18AWizzArd(who don't have access to the net)
15:18technomancyAWizzArd: you can configure both Leiningen and Maven to pull from private repositories
15:18AWizzArdWhat would it like to pull?
15:18technomancybut if you don't have access to the Internet, your build system is the least of your worries
15:18AWizzArdNo :)
15:18stuartsierraAWizzArd: does this help: http://www.aviransplace.com/2006/08/20/tip-installing-maven-2-behind-a-proxy/
15:19AWizzArdI 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:19technomancyAWizzArd: oh, if you've got the deps on disk it doesn't
15:19AWizzArdok, sounds good then
15:19technomancyAWizzArd: maven will still try to connect to the Internet every time you do something if you have a "-SNAPSHOT" version in your deps
15:19chouserbut 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:19technomancybut Leiningen will only do it when you explicitly ask for it
15:19stuartsierraUnless you add the "-o" option
15:20technomancyright
15:20AWizzArdo an in 'omit'?
15:20stuartsierrashort for --offline
15:20AWizzArdgood
15:21cemerickchouser: maven is really only a stub -- everything it does is implemented as plugins, which are pulled on demand
15:21cemericke.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:22chouserit feels much more like a distro tool than a build tool to me.
15:22AWizzArdIn 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:22AWizzArdchouser: a resource hungry distro ;)
15:22cemerickchouser: yup, build + release + project mgmt/description + ....
15:22stuartsierraMaven's really aiming at larger projects with 100s of dependencies.
15:23AWizzArdI am sure it is useful and it went through some years of development.
15:23stuartsierraBut putting contrib in a Maven build will make it easier (hopefully) for people with those kinds of large projects to use it.
15:23AWizzArdI am just not used to the idea of needing 100 MB for such a build tool.
15:24stuartsierraThink of autoconf/automake.
15:24cemerickstuartsierra: 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:25stuartsierracemerick: yes, once you get over the lack of control, it's valuable to be forced into certain conventions
15:25AWizzArdmanaging 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:25chouserah, yes. once you learn to live without liberty, there are benefits to a communist state. ;-)
15:25cemerickstuartsierra: aside from that, there's piles of plugins that are immensely useful and make all sorts of build processes trivial to use.
15:26cemerickAnd the release automation has been a godsend for us.
15:27AWizzArdtechnomancy: 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:27stuartsierrayeah, that's the biggest reason I wanted to switch contrib. Doing the releases with Ant was a pain.
15:28AWizzArdtechnomancy: lein jar Project1 ==> compiles and jars the right files
15:28AWizzArdlein jar all ==> compiles all sources, something like that I mean
15:32stuartsierraAWizzArd: in the Maven model that would be accomplished with sub-modules.
15:32AWizzArdI see.
15:33AWizzArdWe 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:35stuartsierraIn Maven, that would be one "parent" project with dirs like ./modules/foo. Still one source code repository.
15:36stuartsierraLook at the examples from the Sonatype guys - they're big on this.
15:36AWizzArdyes, such a thing would be interesting
15:36AWizzArdThis could be emulated with lein maybe by having a shell script that manages several project.clj files and renames them ;)
16:21technomancyAWizzArd: flightcaster added multiple module support for leiningen, but I haven't had a chance to review it yet
16:21technomancycheck the mailing list
16:22technomancyAWizzArd: what I've done in the past with Ruby is just treat independent subcomponents as independent projects, and that works really well too.
16:47cschepI 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:49reifyOH at lunch today: clojure sucks because it doesn't support OOP and defaults to immutable data structures
16:49the-kennylol
16:50reifyi was thankful they didn't mention the JVM :)
16:50technomancyprogrammaring is hard
16:55cschepHey 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:58dnolencschep: this doesn't work for you? http://clojure.org/repl_and_main
17:04cschepdnolen: ack, sorry, I went straight to the wiki which looks a little different, that is definitely right. thank you.
17:05dnolencschep: np
17:06hiredmanthe wiki is old, and whoever started it seems to have moved on to other things
17:08cschephiredman: ah, that makes sense.
18:01AWizzArdWhat is fsync(2) or fsync(3) in Java?
18:01hiredmana jni call
18:03AWizzArdhiredman: 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:04hiredmanAWizzArd: I would not rely on it
18:07AWizzArdhiredman: 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:12hiredmanI just asked in ##java
18:12hiredmanno replies yet, but nio seems like a more promising place to get that kind of thing
18:12AWizzArdhiredman: thank you!
18:13hiredmanoh
18:13hiredman~jdoc java.io.FileDescriptor
18:13hiredmanhas a sync method
18:15AWizzArdokay, that looks also good
18:16arohner_AWizzArd: even if java promises that it has called write() and sync(), your OS and raid controller can still lie to you
18:17AWizzArdarohner: could this also happen to the Oracle DB?
18:17AWizzArdOr do they use other tricks to be sure that their transactional data indeed was written?
18:18AWizzArdor take a DB written in Java (i think one such db ships with the jdk)
18:18hiredmanderby
18:18arohnerthey *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:18arohnerof course, your raid controller can still lie
18:18AWizzArdhmm ok
18:19AWizzArdinteresting problem will be how/when to write transactional data to disk. In principle it should happen during a dosync
18:19hiredmanwhich is what you want to be able to plugin into the stm for
18:20AWizzArdfirst making a change to a snapshot in memory, then writing out to disk that the modification happened and then ref-setting everything
18:21AWizzArdhiredman: is there already such a mechanism in place in Clojure?
18:22AWizzArdOne 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:22hiredmanAWizzArd: nope
18:23arohneris there a cleaner way to make a map from a for loop than (into {} (for []...))?
18:26KruppeClojure 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:26arohnerKruppe: typically refs are used for that
18:26arohner,(doc ref)
18:26clojurebot"([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:26Kruppearohner: ah ok, ill look into that
18:27arohner(def count (ref 0))
18:27AWizzArdarohner: this into is good. You only may consider reduce for some cases, maybe.
18:29hiredmanKruppe: don't re-def
18:29Kruppehiredman: yeah I noticed clojure.core/count
18:30Kruppehiredman: thanks for the warning though :)
18:30AWizzArdmaybe hiredman meant that you said (def count 0) ... a bit later ... (def count something-else)
18:31KruppeAWizzArd: ah, I actually couldn't find any other way to update the def
18:31KruppeAWizzArd: what SHOULD be there instead?
18:32KruppeAWizzArd: or should I just not use it like that?
18:32AWizzArdyou can use atoms for counter
18:33AWizzArd,(let [my-counter (atom 100)] (println @my-counter) (swap! my-counter inc) (println @my-counter))
18:33clojurebot100 101
18:33AWizzArdthe “swap!” is the function which will update the contents of your counter
18:34arohnerKruppe: 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:34arohnerKruppe: one thing that helped me when learning clojure: coming from CL, you're familiar with boxes pointing to values
18:34Kruppearohner: yup
18:35AWizzArdKruppe: note that using Refs and Atoms are concurrency-ready.
18:35arohnerin Clojure, def creates a box, called a var. refs and atoms are additional kinds of boxes
18:35arohnervars, refs, and atoms each have different concurrency semantics
18:36arohnerif you want a global value to something that can change, typically you use a var pointing at an atom or ref
18:37arohnera 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:37arohnerit's possible to re-set the root value (i.e. by re-defing), but this is considered bad style
18:37Kruppearohner: yeah it seemed clumsy
18:38Kruppearohner: I knew there had to be another way
18:46Kruppearohner: AWizzArd: thanks for clearing that up, I think I get it now!
18:47AWizzArdenjoy
18:47maxhodaki keep getting a java.lang.ClassNotFoundException trying to access a java class and have just hit a wall
18:48maxhodaki'm trying to use the thrift (incubator.apache.org/thrift) java libs and it's generating a series of classes
18:48maxhodakand clojure can't seem to find one of the nested classes
18:48AWizzArdmaxhodak: (System/getProperty "java.class.path")
18:48hiredmanmaxhodak: you have to use the desugared name
18:48hiredmanwith $
18:49maxhodakhmm
18:49maxhodakso it can find the class file; it's on the classpath. i'm using lein and that's all fine
18:49maxhodaklike, i have class foo { class bar { } }
18:49maxhodakand i can basically see foo , but not foo.bar
18:49hiredmansome.package.someClass$innerClass
18:50maxhodakhiredman: sugared name?
18:50maxhodakoh
18:51maxhodakhiredman: that didn't fix it, either quoted or unquoted
18:52hiredmannot quote
18:52hiredmansome.package.someClass$innerClass instead of some.package.someClass.innerClass
18:53maxhodaknope
18:53hiredmanare you sure?
18:54maxhodakmy path basically looks like
18:54maxhodak/src/clj/file.clj, /src/java/foo/bar.java
18:54maxhodakinside file.clj i'm trying (new myproject.foo.bar$quuz)
18:55maxhodak(er, add a myproject into those paths as appropriate)
18:55maxhodakand i'm getting either unable to resolve class name or class not found
18:56hiredmanhow are you starting the repl
18:56maxhodaki'm getting the error on lein compile; i dont have a repl up
18:58hiredmanwhere are the class files?
18:59maxhodaksrc/java/myproject/foo/*
18:59hiredmanmaxhodak: uh, and how do you know that is on the class path
19:00maxhodakbecause :import (myproject.foo) doesn't generate an error
19:01hiredmanmaxhodak: it wouldn't, you are telling it to import nothing from a nonexistant package
19:01hiredman(:import (myproject foo)) is what you want
19:03maxhodakis (:import (myproject.foo *)) valid in clojure?
19:03hiredmannope
19:03maxhodakhmm ok
19:05hiredmanI think you will find your classes are not on your classpath
19:05maxhodakyeah, now it's dying on the import
19:05maxhodakreadreadread lein doc
19:05maxhodakthaanks
19:06hiredmanI would recommend, if this is your first project, to skip lein
19:06maxhodakit's not my first in clojure, just the first trying to get it to play along really nicely with java
19:07maxhodakand lein is *amazing* with dependencies
19:08hiredmanok
19:08cschepis there a "best place" to get SLIME on github?
19:09Chousukecschep: I think you should install slime using ELPA to ensure it works with clojure-mode
19:09Chousukecschep: There's some incompatibility issue with the latest CVS/git/whatever versions :/
19:09dnolencschep: 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:10cschepChousuke: 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:11dnolenmaxhodak: based on your description of your project dir layout your import statement will not work.
19:11cschepso get ELAP, install clojure-mode, then do clojure-install ?
19:11cschepELPA*
19:11hiredmanthere is a lein java plugin somewhere
19:11hiredman~google lein-java
19:11clojurebotFirst, out of 163000 results is:
19:11clojurebotBuilding Clojure Projects with Leiningen « I am Zef
19:11clojurebothttp://zef.me/2470/building-clojure-projects-with-leiningen
19:11hiredman:/
19:12technomancycschep: clojure-install is deprecated. if you install swank-clojure through elpa it will get the jars for you
19:12AWizzArdhiredman: 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:13maxhodakhmm. now im getting tons of ZipExceptions on lein
19:13cschepthis feels so fragmented, is there one place with a "right way"?
19:13hiredmanAWizzArd: no
19:13hiredmanAWizzArd: don't do that
19:13technomancycschep: 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:13raekhave anyone seen this something like this function before? http://gist.github.com/292210
19:13raekI don't want to reinvent what's already in clojure...
19:14AWizzArdhiredman: what is the problem with that approach?
19:14hiredmanAWizzArd: the tie in with the stm would mean you could have database transactions, for example, that rollback if the transaction is retried
19:14hiredmannot some kind of constant writing or something
19:14hiredmandon't throw your own locks in with the stm
19:15AWizzArdyeah, but you also said that there is no mechanism in Clojure which would support my "plugins"..
19:15hiredmanthere is no stm support for this
19:16hiredmanyou just need to come up with a mechanism, possibly sending side-effect stuff to an agent to be executed once the transaction completes
19:17AWizzArdThe 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:17Chousukeraek: hm, remember that maps are unordered. the behaviour of that function is not well-defined.
19:18Chousukearray-maps happen to be ordered but I don't think that's guaranteed. :/
19:18raekI know... but the assumption is that only one of the predicates will return true
19:18AWizzArdStep 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:18raekat least that's the case in my application
19:19hiredmanerm, why are you using ref-set?
19:19raekmaybe "mutually exclusive predicates" needs more explanation in the docstring
19:20Chousukeraek: ah, well, in that case I don't think there's anything like that in clojure
19:20AWizzArdhiredman: because i have a pointer to a snapshot that already has the correct state that i want
19:20hiredmanwhy?
19:20clojurebothttp://clojure.org/rationale
19:20Chousuke:P
19:21hiredmanwhy aren't you just using alter?
19:22AWizzArdhiredman: I could also use alter
19:23hiredman~alter
19:23clojurebotalter is always correct
19:23AWizzArd:-)
19:24AWizzArd~seen kotarak
19:24clojurebotkotarak was last seen quiting IRC, 3557 minutes ago
19:26AWizzArdn8 all, and thanks hiredman for finding FileDescriptor’s .sync
19:32cschepWhy doesn't swank-clojure just grab the latest clojure/clojure-contrib from github?
19:33dnolencschep: because they aren't always stable, not very a good user-experience :)
19:34cschepdnolen: ha, cool.
19:34cschepdnolen: is there a command to see if there is an update? must be..
19:35dnolencschep: 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:36dnolenthat's what I do.
19:38cschepoh, cool.
19:42dnolencschep: supposedly there's way to configure swank-clojure from your .emacs file but I couldn't figure it out :)
19:43cschepdnolen: 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:43cschepdnolne: 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:44dnolenit's a lot to handle. Did you look into Enclojure?
19:44cschepdnolen: 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:46dnolenwell you're already on your merry way. If you stop now you'll just forget everything ;)
19:50cschepha, truth.
20:05zaphyrHeh, 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:08zaphyroops, s/public static final/public final/ (duh)
20:10dnolenzaphyr: I don't think that you can really do that in Clojure 1.1, you can use deftype in clojure 1.2.
20:11zaphyrahh, that's probably why i couldn't find it. :)
20:11zaphyrall i found was :state, which was close, but no cigar
20:11zaphyrthanks!
20:11krumholt_zaphyr, do you need that class to feed it to a java function?
20:12zaphyractually 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:13zaphyrjava doesn't really need to see it, but since it's going to be used heavily a defstruct probably won't cut it
20:13zaphyr(and float[] will be significantly slower according to my benchmarks)
20:14krumholt_zaphyr, (deftype vec3f #^float x1 #^float x2 #^float x3)
20:14zaphyrwant :), is 1.2 stable enough given I'm still starting out do you think?
20:15krumholt_i don't know anything about 1.2 sorry. but deftype should be pretty fast
20:16dnolenzaphyr: pretty stable, tho it means you need to build your .jars of course. Though that isn't so hard.
20:16zaphyrkrumholt: oh, i was under the impression deftype was 1.2 only, so maybe i've just completely overlooked that
20:17krumholt_no protocols and deftype is usable in 1.1
20:17cschepis there a good way to parse HTML in clojure?
20:17cschepI'm looking at http://htmlparser.sourceforge.net/ ..
20:17krumholt_it says in the docs that it is alpha and subject to change if thats not a problem for you
20:18zaphyrah, well, not really at this stage, i'm happy to change as required.
20:18somniumkrumholt_: that's 1.2 (previously 1.1-new)
20:18dnolencschep: Enlive is good for HTML parsing
20:19ohpauleezenlive is awesome
20:19krumholt_somnium, oh ok. thanks for the info
20:20zaphyrhmm (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:20zaphyrusing clojure 1.1.0-new-snapshot
20:20zaphyr(downloaded a couple of days ago)
20:21cschepdnolen: ok cool i'll check it out
20:21dnolen,deftype
20:21clojurebotjava.lang.Exception: Unable to resolve symbol: deftype in this context
20:21dnolen,+
20:21clojurebot#<core$_PLUS___4518 clojure.core$_PLUS___4518@1b38815>
20:22dnolen(deftype vec3f [#^float x #^float y #^float z])
20:24zaphyryay! it worked! thanks everyone :)
20:42zaphyrfinal 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:45arohner{:pre [(disjoint? (set (keys A)) (set (keys B)))]}
20:46arohnerI'd like to see the haskell type for that...
20:50zaphyrah, nm i just found clojure.contrib.generic.arithmetic :)
21:01arohnerare there any library functions for generating selections / permutations?
21:04dnolenarohner: clojure.contrib.combinatorics
21:05arohnerlooks like I need to become familiar with incanter
21:05somniumarohner: a few things in clojure.set too
21:26arohneris there any way to easily make maven/lein build against the clojure checkout in my directory?
21:26arohnerI 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:48vu3rdddid anyone try the latest clojure-contrib from the master branch?
21:48vu3rddI am having trouble giving locally built clojure.jar to the -contrib build
21:48dnolenvu3rdd: you're using maven right?
21:48vu3rddI do mvn -Dclojure.jar=<absolute path to clojure.jar> package
21:49vu3rddbut it still downloads clojure-1.2.0-XXX.jar from the web
21:49vu3rddI tried passing the -o flag to mvn (offline mode), but it fails because it can't find the jar
21:50vu3rddis anyone else also facing this?
21:50dnolenvu3rdd: hmm, it seemed to work for me this morning, but I'm not on machine with that setup at the moment.
21:52vu3rddwould you mind trying by deleting the copy of clojure-XXX.jar from the ~/.m2 directory and try again?
21:52vu3rddwhen you get to the machine, I mean
21:52vu3rdddnolen: thanks a lot.
23:06qedforgive 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:06qedSo I I make a symlink from where to where? I have lein-stable in my ~/bin/ which is on my path
23:06dnolenqed: yes
23:07dnolenfrom path/to/lein-checkout/bin/lein to /usr/bin/local or whatever is appropiate for your system.
23:07dnolen/usr/bin/local/lein i mean
23:07dnolenin your case
23:07dnolen~/bin/lein then
23:07clojurebotI don't understand.
23:08dnolenln -s ~/bin/lein path/to/checkout/bin/lein
23:08dnolener
23:08dnolensorry
23:08qedis it reversed?
23:08dnolenyes
23:08qedyeah i always make that mistake
23:08qedokay that makes sense, i kept reading that link i should overwrite the lein binary in my checkout
23:08qedlike*
23:09qedln would make so much sense if there was a [to] somewhere in there
23:09dnolenheh well it does follow the convention of cp and mv: source -> target
23:36qeddnolen-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