#clojure logs

2009-02-07

00:02gnuvince_I don't get why the type hint doesn't work with .get and .getShort
00:03gnuvince_Reflection warning, line: 16 - call to and can't be resolved.
00:03Chouseryeah, it's the bit-and that's complaining
00:04Chouseri'm working on that
00:04Chouserbut I just realized I'm using a patched clojure and it my be acting differently...
00:08gnuvince_Got it
00:09lisppaste8gnuvince pasted "avoiding reflection" at http://paste.lisp.org/display/75003
00:10Chouseryou found a pathalogical corner case there. :-)
00:12gnuvince_Is that what Rich means when he talks about wanting the JVM to support unboxing?
00:12gnuvince_I cannot recall the exact wording
00:15Chouserit does support unboxing. But he wants tagged numbers, I think it's called, where you'd get number "objects" that are as small and fast as primitives, but can be passed around and introspected like Object
00:16Chouserso you'd still need type hints of the #^ByteBuffer variety, but the mucking about with primitive locals and stuff I think would go away.
00:17gnuvince_OK
00:17gnuvince_That'd be cool.
00:17Chouserindeed!
00:17gnuvince_The profiling just finished
00:17gnuvince_the first mention of reflect is at position 460 (for my dump.clj script where I don't use a hint)
00:17Chousergood!
00:17gnuvince_Calling the unpack function from the REPL takes about 300 ms
00:18Chouseris the whole thing any faster?
00:18gnuvince_(down from 5-6 seconds)
00:18Chousernice
00:18gnuvince_Very much so, yes.
00:18gnuvince_Thanks for the help
00:18Chouseryou're welcome
00:18RaynesI wish I had a Clojurebot :|
00:18ChouserRaynes: ?
00:18Raynes,(doc flush)
00:18clojurebot"([]); Flushes the output stream that is the current value of *out*"
00:19gnuvince_The first two "performance takers" are Object.wait() and ReferenceQueue.remove
00:20Chouserhuh! you're multithreaded?
00:24gnuvince_no
00:25gnuvince_That shouldn't be there?
00:25Chouseroh, I don't know anything. That just sounds like waiting on a lock, but I really don't know.
00:26gnuvince_I see those two in every program I have.
00:26gnuvince_Even if they are purely functional (as starcraft.replay is)
00:26Chouserok Object.wait() is just blocking until a notify. looks harmless.
01:25RaynesO_O
01:26offby1clojurebot: help
01:26clojurebotmacro help is http://clojure-log.n01se.net/macro.html
01:26offby1clojurebot: source
01:26clojurebotI don't understand.
01:37hiredmanclojurebot: where are you?
01:37clojurebothttp://github.com/hiredman/clojurebot/tree/master
01:41offby1ah.
01:41offby1I guess one needs to speak the local dialect.
04:45flapanyone use Fiji?
04:45flapi dont get the scripting part, can i do it inside imageJ?
04:45flapi mean inside fiji?
04:45flapor just liek i normally do in emacs?
05:57leafwto flap, for the record: just open the prompt at "Plugins - Scripting - Clojure Interpreter". See http://pacific.mpi-cbg.de/wiki/index.php/Clojure_Scripting#Using_Clojure_inside_Fiji for how to create and run clojure scripts.
06:02bakkdoori have a problem with using (:use <namespace>) in a (ns ..) declaration within emacs & slime. it tells me that it cant find the specified name within my classpath. how can i tell it to add the current path of the opened file to the classpath?
08:33lpetitHello, all
08:33metaperllpetit: hi!
08:36lpetitI've tried the patch to clojure.lang.Compiler.writeClassFile() that ensures that the underlying OS is synchronized before leaving. Works like a charm for me.
08:57lpetitrhickey: is it time to speak about this ? Or do you prefer another time to consider it ? If you please just let me know, I won't bother you with that until the time you decide.
09:43rhickeylpetit: what does the call to lastModified do after close()?
09:44lpetitOh sorry, this call does nothing, it was from a previous attempt
09:44lpetitThe important part is just the call to sync()
09:45lpetitI should not have published the code with the line containing lastModified(), my apologizes
09:45rhickeylpetit: np
09:46lpetitBefore discovering the right way to force the sync, I was trying indirect ways by calling functions on the File instance ;-)
09:46lpetitI was just writing another e-mail (!), still concerning compilation. It'll be posted within seconds.
09:48rhickeylpetit: sync call in svn 1252
09:48lpetitOh thank you very much!
09:49lpetitI must quit in 5 minutes, any chance to quickly talk about the short e-mail I just sent to the ml ?
09:50clojurebotsvn rev 1252; added sync to writeClassFile
09:51lpetitOh! clojurebot is really up to date :-)
09:53rhickeylpetit: I think it's an ok idea, but it's not as simple as you might think
09:55lpetitArgh
09:55lpetitIf you give me some hints, maybe I can try, or is it really that 'touchy' ?
10:09lpetitrhickey: maybe the file path information should be added first in the source, that is as an additional metadata of the var ?
10:10lpetitrhickey: another option would be to have SOURCE modified to be fully qualified. But I suspect such a change would break a lot of things, even outside clojure's code base, since it would break a published contract with clojure client code ?
10:14lpetitI must quit now. I don't have an very powerful IRC client, so I won't be able to read further answers.
10:14lpetitSee you,
12:33ozy`,(first "pizza")
12:33clojurebot\p
12:34ozy`,(rest "cheese")
12:34clojurebot(\h \e \e \s \e)
12:36ozy`,(first map)
12:36clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: core$map__3634
12:36ozy`,(first 'map)
12:36clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol
12:36ayrnieu,(-> 'map name first)
12:36clojurebot\m
12:37ozy`... I need to look that up
12:38durka42,(-> map var .sym name first)
12:38clojurebot\m
12:39ozy`ahhh
12:39danlarkin(doto map name first)
12:39danlarkin,(doto map name first)
12:39clojurebotjava.lang.ClassCastException: clojure.core$map__3634 cannot be cast to clojure.lang.Named
12:39danlarkinbah
12:39ayrnieu,(macroexpand-1 '(doto map name first))
12:39clojurebot(clojure.core/let [G__1252 map] (name G__1252) (first G__1252) G__1252)
12:39durka42that won't do it
12:39durka42doto doesn't nest
12:40durka42,(macroexpand-1 '(-> map var .sym name first))
12:40clojurebot(clojure.core/-> (clojure.core/-> map var) .sym name first)
12:40durka42,(macroexpand '(-> map var .sym name first))
12:40clojurebot(first (clojure.core/-> (clojure.core/-> (clojure.core/-> map var) .sym) name))
12:40danlarkindurka42: oh duh you're right
12:41ayrnieumixed -> and doto: http://paste.lisp.org/display/74762
12:41ozy`,(macroexpand '(fn [f g] '(fn [xs] (f (g xs)))))
12:41clojurebot(fn* ([f g] (quote (fn [xs] (f (g xs))))))
12:42ozy`,(macroexpand '(let (a b) (c d)))
12:42clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: let requires a vector for its binding
12:43ozy`,(macroexpand '(let [a b] (c d)))
12:43clojurebot(let* [a b] (c d))
12:43ozy`ayrnieu: PLO seems to be down for me
12:43ayrnieuPLO?
12:43ozy`paste.lisp.org
12:43durka42as evidenced by the fact that lisppaste8 just died
12:43ayrnieustill responding to me.
12:44danlarkinthe Palestinian liberation organization?
12:44durka42but i don't think it's down
12:44ayrnieuPeople's Liberation Orchestra
13:03turbo24prgis there any function in the clojure namespace to check if a list contains an item?
13:04turbo24prgcontains? just works on maps
13:04danlarkinturbo24prg: and sets!
13:06turbo24prguh, strange
13:06turbo24prgdoc just tells the [map key] signature
13:08ayrnieu,(map #(.contains % 3) '(1 2 3 4) [1 2 3 4])
13:08clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--1266$fn
13:08ayrnieu,(map #(.contains % 3) ['(1 2 3 4) [1 2 3 4]])
13:08clojurebot(true true)
13:10turbo24prgah, .contains
13:10turbo24prgshould be documented, imho
13:10Chousukeit's probably documented in the javadoc.
13:11Chousukehttp://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html#contains(java.lang.Object)
13:13danlarkinok, how about terpsichore as the name for my framework
13:14danlarkingreek muse of dance and music
13:15ayrnieuyour what framework?
13:15turbo24prgi'd rather call clojure's api than java's
13:16ayrnieu(defn scared-of-java-contains [coll mem] (.contains coll mem)) ;; solved
13:17danlarkinayrnieu: port/rewrite/reimagining of django in clojure
13:19ayrnieu(defn clj-at-any-cost [coll mem] ((apply hash-map (interleave coll (repeat true))) mem))
13:22danlarkinturbo24prg: the "clojurish" way to solve this is (some #{:y} [:x :y :z])
13:22danlarkin(some #{50} [1 2 3 4 50])
13:22danlarkin,(some #{50} [1 2 3 4 50])
13:22clojurebot50
13:22danlarkinwhich will evaluate to true
13:24turbo24prgwhy does that work? i thought some takes a predicate, ie. a function?
13:25ayrnieu,(#{50} 50)
13:25clojurebot50
13:25danlarkin,(ifn? #{})
13:25clojurebottrue
13:28turbo24prgthought that works only on maps, cool
13:30ayrnieu,(filter ifn? ["" [] () {} #{} :k 'sym (ref 0) (atom 0) (agent 0) (var +) +])
13:30clojurebot([] {} #{} :k sym #<Ref@16f4ce0: 0> #'clojure.core/+ #<core$_PLUS___3183 clojure.core$_PLUS___3183@1735602>)
13:32ayrnieufreaky.
13:32ayrnieu,(let [x (ref inc)] (x 1))
13:32clojurebot2
13:33ayrnieu,('hi #{'hi 'there})
13:33clojurebothi
13:45Lau_of_DKGood evening gents
13:48danlarkinLau_of_DK: hiya!
13:48danlarkinLau_of_DK: terpsichore?
13:49durka42hey lau
13:53Lau_of_DKdanlarkin: terpischore? Is that some illness you have contracted? :(
13:54danlarkinit's the greek muse of song and dance :)
13:54Lau_of_DKoh
13:54Lau_of_DKHows Clabango coming along?
13:56danlarkinhaha well what do you think of terpsichore as a name
13:56Lau_of_DKIts pretty bad my friend
13:57danlarkinugh
13:57Lau_of_DK:(
13:57danlarkinI can't release anything until I come up with a name :)
13:58Lau_of_DKIsnt Clabango pretty fun ?
13:59danlarkinwell it's a step up from barkin' larkin I guess
13:59Lau_of_DKGood! Then we're getting somewhere
13:59Lau_of_DKBut as I understand it, youre delivering the worlds first complete web framework written in a purely functional lisp right? That screams: CLA BANGO!
14:00durka42purely?
14:00ayrnieuno, not purely.
14:00Lau_of_DKok, impurely
14:00Lau_of_DKYou kinda missed the point
14:01Lau_of_DKAre you specifically going for something greek/outlandish danlarkin?
14:02danlarkinLau_of_DK: no, not at all, just scrolling through wikipedia trying to think of a name
14:02Lau_of_DKk
14:05Lau_of_DKMan, I really like Clabango, if you dont use it I will :) It'll be my new brand, ClabangoSQL, ClabangoWeb, ClabangoEuler :)
14:05danlarkinhahah
14:05danlarkinclabango is *so* bad :)
14:06Lau_of_DKIts mine then! Muhahahaahah
14:09Lau_of_DKdanlarkin: Is the name seriously all thats standing between you and the Github ?
14:09danlarkinLau_of_DK: at this point yup
14:10Lau_of_DKHmm, you reject Barkin' Larkin', you mock Clabango...All thats left is: Funky Web
14:11danlarkinhaha
14:11offby1Poo. It seems that if I want to get anything done in Clojure, I have to learn Java first -- or at least, I have to be familiar with the built-in classes. Can someone recommend a terse cheat-sheet type overview that describes the classes? Specifically I don't know how to append two strings :)
14:12danlarkinoffby1: (str string1 string2)
14:12offby1I have NOT tried Google, since I assume I'll be overwhelmed with 1,000,000 not-quite-relevant hits.
14:12Chouser,(str "one" "two")
14:12clojurebot"onetwo"
14:12offby1danlarkin: thanks
14:12Chouserwe are your cheatsheet
14:12danlarkinoffby1: try reading core.clj or browsing http://clojure.org/api
14:12offby1but that's just giving me a fish, so my question still stands: any fairly terse how-to-fish web sites for the Java-ignorant?
14:13offby1danlarkin: hum, OK.
14:13offby1from what I've seen in http://clojure.org/api, though, that's all the stuff that _isn't_ already in java.
14:13zakwilsonThere's the Javadoc for the entire Java standard library.
14:13Wizardofwestmarcyeah sun's documentation is actually decent
14:13Lau_of_DKdanlarkin: we have to sort this out now, start here : http://gangstaname.com/mafia_name.php
14:13Wizardofwestmarcand it can even be downloaded for local browsing
14:13danlarkinoffby1: oh yes, that's not really an answer to your question, just an aside
14:13zakwilsonIt's not exactly a cheat sheet, but there's an index, and Sun has some tutorials that help you figure out where to start.
14:14durka42terpsichore -> Lightning Fingers Lou
14:14offby1danlarkin: and yet it does answer my immediate question, so it's indeed helpful. Thanks
14:14danlarkinDan Larkin -> Paolo the Greaser
14:15Lau_of_DKThere you go
14:15durka42clabango -> donato milano
14:15offby1zakwilson: that's probably what I need. I'll confess my fear, though, which is: say I want to read a file. I'll look up the relevant bits in the javadoc ... and I'll find 867 ways to read files, with nothing to help me decide which to choose. I'm probably just a whiner.
14:15danlarkinoffby1: (slurp "filename") :)
14:16Lau_of_DKdanlarkin: Youre American right?
14:16danlarkinLau_of_DK: yessir
14:17Lau_of_DKgreat, that makes it easier
14:17Lau_of_DKHow about "THE LIBERATOR 10.000 ! Get a free car with your first download and porkchops for life!!!"
14:17danlarkinhaha oh jeez
14:18ayrnieu,(> 10.000 10)
14:18clojurebotfalse
14:18danlarkinsilly europeans
14:18Lau_of_DKYou can laugh, but we practically own America now
14:18offby1danlarkin: I'm starting to get the sense that there's a lot more in the clojure API itself (as opposed to traditional java classes) than I thought; I'll read that API doc more carefully. Thanks.
14:18Chouser,(> 10,100 10)
14:18clojurebotfalse
14:18Lau_of_DKSince your little mishap at the stock exchange :)
14:19Chouser,(> 20,001 10)
14:19clojurebotfalse
14:19ayrnieu,(length '(10,000 10))
14:19clojurebotjava.lang.Exception: Unable to resolve symbol: length in this context
14:19durka42that is (> 20 001 10) isn't it?
14:19durka42,(count '(10,000 10))
14:19clojurebot3
14:19Chouser,(> 20,005 1)
14:19clojurebottrue
14:19Chouserther
14:19Chouserdurka42: yeah
14:20danlarkinLau_of_DK: I didn't realize you were chinese :)
14:20Lau_of_DKdanlarkin: Oh.. that must be because.. im not :)
14:20danlarkinwell you said you practically own america, that would make you chinese
14:21Lau_of_DKEBC gave 800 bill. EUR in loan to the US recently, I think the official letter said "pwned" at the top
14:21Lau_of_DKs/EBC/ECB
14:22zakwilsonAnd the US govenment is now going to spend it on wasteful projects.
14:22Lau_of_DKOf course :)
14:22zakwilsonBut none of that has much to do with Clojure or programming in general.
14:22zakwilsonUnless they want to pay us to program something cool and utterly useless in Clojure. I'd support that.
14:23danlarkin+1 for government funded clojure hacking
14:23Lau_of_DKIm just trying to understand the culture zakwilson
14:23Wizardofwestmarcjust tell them it's java <_<
14:23danlarkinis calliope any better than terpsichore?
14:24Lau_of_DKWhat does it mean ?
14:24danlarkinanother muse
14:24zakwilsonWhat culture?
14:24danlarkingreek
14:24Lau_of_DKThe American
14:24danlarkinoh, haha sorry
14:25Lau_of_DKdanlarkin: How about 'calligraphy' ? I means beautiful hand-writing
14:25zakwilsonYes, Lau_of_DK, as I was saying... what culture? (I actually mean that in a less insulting way than it may suggest - the thing is there's no single clearly-defined American culture)
14:26offby1In the one Java program I've ever written, I used a class called "java.io.FileReader". I thought I could access that in clojure by evaluating (java/io/BufferedReader "some-file-name"), but alas, I get an error: java.lang.Exception: No such namespace: java/io
14:26offby1What am I misunderstanding?
14:26Lau_of_DKzakwilson:
14:26Lau_of_DKYoure not american ?
14:26danlarkinzakwilson: oh there is too an American culture
14:27durka42offby1: use dots
14:27Lau_of_DKThe European view of Americans is generally that they're greedy, overweight lazy criminals, who crave big cars and mantions. Chouser being the only exception I know personally :)
14:27offby1durka42: huh, OK, I'll try that ...
14:27durka42and constructors in clojure end with a dot
14:27Lau_of_DKs/mantions/mansions
14:27durka42,(java.io.BufferedReader. "file/name")
14:27clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.io.Reader
14:27zakwilsonI am American. There are so many different subcultures that there are few, if any elements that can reasonably be said to be part of American culture as a whole.
14:27durka42java needs more red tape to make a BufferedReader but that's the syntax
14:28Arienswhy does every? return nil when false instead of false?
14:28offby1durka42: but I get the same error that you just got
14:28durka42well i guess bufferedreader's constructor needs a reader
14:28Ariens,(every #{\space} "dam")
14:28clojurebotjava.lang.Exception: Unable to resolve symbol: every in this context
14:28durka42,(-> "path/to/file" java.io.FileReader. java.io.BufferedReader.)
14:28zakwilsonThe overweight and big cars part is true. And we're a bit off-topic. I'd be happy to continue this discussion in private should anyone wish to.
14:28clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission path/to/file read)
14:28durka42also look at slurp
14:28durka42or its source
14:28offby1thanks
14:28Ariens,(every? #{\space} "dam")
14:28clojurebotnil
14:29Ariensis there a criteria
14:29Arienswhen to return nil and when to return false?
14:32durka42,(and nil false)
14:32clojurebotnil
14:32durka42,(and false nil)
14:32clojurebotfalse
14:32durka42,(and nil nil)
14:32clojurebotnil
14:32durka42,(and false false)
14:32clojurebotfalse
14:32durka42every? uses and internally
14:32durka42,(#{\space} "d")
14:32clojurebotnil
14:33durka42(doc and)
14:33clojurebotEvaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true.; arglists ([] [x] [x & rest])
14:33durka42(doc every?)
14:33clojurebotReturns true if (pred x) is logical true for every x in coll, else false.; arglists ([pred coll])
14:33durka42this could be a bug in every?
14:33ayrnieuor in its documentation.
14:34Ariensin the API it says it returns false
14:35Wizardofwestmarcwell, nil and false are interchangeable for boolean purposes, isn't the only time it matters for testing false?
14:35Wizardofwestmarc(false? nil)
14:35Wizardofwestmarc,(false? nil)
14:35clojurebotfalse
14:36Arienserm if the are interchageable why does (false? evaluate nil to false?
14:37durka42(doc false?)
14:37clojurebotReturns true if x is the value false, false otherwise.; arglists ([x])
14:37durka42(doc nil?)
14:37clojurebotReturns true if x is nil, false otherwise.; arglists ([x])
14:38durka42,(= (nil? false) (false? nil))
14:38clojurebottrue
14:38Ariensok so every? has a bug?
14:39ayrnieuor its documentation does.
14:39durka42well, the doc should say it returns nil or false, yes?
14:39ayrnieuor it should return false.
14:39durka42instead of just saying "false otherwise"
14:39durka42yeah
14:39Ariensdoc says it returns true or false
14:39durka42when does it matter
14:39ayrnieuyes, Ariens, we know.
14:39durka42,(boolean nil)
14:39clojurebotfalse
14:40ayrnieuevery?'s functionality differs from its documentation. This is not enough to say that it or its documentation is in error, it is only enough to say that one of them is.
14:40durka42yup
14:40BigTomoffby1: use duckstreams in clojure-contrib
14:40Ariensayrnieu: since it doesn't make much sence to me everty to return nil I think the error is in the implementation
15:11Lau_of_DKclojurebot: compojure?
15:11clojurebotcompojure is a concise web framework inspired by Sinatra
15:11Lau_of_DKLINK!?
15:12Lau_of_DKclojurebot: compojure is also http://github.com/weavejester/compojure/tree/master
15:12clojurebotRoger.
15:12Lau_of_DKclojurebot: compojure?
15:12clojurebotcompojure is http://github.com/weavejester/compojure/tree/master
15:12Lau_of_DKI said also...
15:12Lau_of_DKhiredman: Your sevant is disobediant
15:13danlarkinit's a random choice I believe
15:13danlarkinclojurebot: compojure
15:13clojurebotcompojure is a concise web framework inspired by Sinatra
15:13Lau_of_DKoh
15:14offby1``If it's random, teach it Russian Roulette!
15:18Chouser~roulette
15:18clojurebotroulette is click
15:19Chouser~roulette
15:19clojurebotclick
15:19Chouser~roulette
15:19clojurebotclick
15:21SuttoLclojurebot: ~roulette
15:21clojurebotbang
15:26turbo24prgwhich objects can hold meta informations? too bad strings itself can't
15:27Chouseranything than implements IMeta
15:28turbo24prgsay, i just want to store meta information for strings, what would be the best choice?
15:28turbo24prglist, set, ..?
15:29kotarakhttp://clojure.org/metadata
15:30ayrnieu,(filter #(try (do (with-meta % {:meta true}) true) (catch ClassCastException _ false)) [{} #{} [] () "" 1 1/0 'etc])
15:30clojurebotIt's greek to me.
15:30Chousera one-element list seems about right
15:30ayrnieusay what?
15:31ayrnieu,(filter #(try (do (with-meta % {:meta true}) true) (catch ClassCastException _ false)) [{} #{} [] () "" 1 1/2 'etc])
15:31clojurebotExcuse me?
15:31durka42no try
15:32ayrnieu,(filter #(try (do (with-meta % {:meta true}) true) (catch Exception _ false)) [{} #{} [] () "" 1 1/2 'etc])
15:32clojurebotexcusez-moi
15:32durka42i mean to say, clojurebot does not allow try/catch
15:32Chouser,^(with-meta '("hello") {:some :meta-data})
15:32clojurebot{:some :meta-data}
15:32ayrnieuhe should probably say something like "Oh, many apologies, I do not allow try/catch."
15:33ayrnieu,(with-meta () {:oops 1})
15:33clojurebot()
15:34ayrnieuhm, I get a NullPointerException.
15:34ayrnieuah, it's a feature of the lazy branch.
15:52mofmogIs programming clojure at a point where it'd be worth it to purchase it?
15:52technomancymofmog: yes
15:52technomancyhas been for some time
15:54Chousukemofmog: well, you get free upgrades
15:54mofmogit's mostly because there aren't that many comprehensive Clojure tutorials
15:54WizardofwestmarcConsidering you got all the later versions for free, it's always been worth it.
15:55mofmogas far as i can tell, it's either just reading through lots of code or watching the blip.tv videos
15:55Wizardofwestmarcor just asking questions here and in the google group. yeah
15:55technomancymofmog: the blip.tv is not very up-to-date IIRC.
15:55technomancyit's good to understand motivation, but not good for specifics
15:57Wizardofwestmarclast blip video was his talk to the boston lisp group, so yeah, bit out of date
15:58mofmoghow in depth is PC's STM section?
16:00Wizardofwestmarcthe concurrency tools (agents, refs, etc) is an entire chapter
16:01mofmogah cool
16:01Wizardofwestmarc~20 pages long as of beta 5
16:01clojurebotI don't understand.
16:01technomancyso I want to curry a function, but I want to provide the second arg. If I use partial, it only works if I provide the first arg.
16:01mofmogso if i had tomcat installed on an apache server, it should be a fairly easy task of deploying clojure stuff?
16:01technomancyis there another function I can use?
16:01mofmogswap?
16:02mofmogi dont know if clojure has a swap function but hey
16:02technomancydoesn't look like it
16:02mofmogso you just want to partially evaluate it? or curry curry it
16:02danlarkintechnomancy: use #()
16:03Lau_of_DKWhich webframeworks are actively being developer upon in Clojure atm ? We know danlarkin is almost RC ready with Clabango - Any others?
16:03Wizardofwestmarcmofmog: I'd think so but never used tomcat. I know one of the web frameworks already being written in clojure is using Jetty
16:03technomancydanlarkin: ok, so there's not a "more functional" approach?
16:03mofmogah, i'm also trying to get jetty installed
16:03technomancywhatever that means
16:03technomancymofmog: from what I've heard, it's easiest to deploy on jetty
16:03danlarkintechnomancy: well not that I can think of :)
16:03mofmogi plan on deploying on a university webserver and i might have to fight with the admins to get them to put jetty on
16:03technomancyLau_of_DK: compojure is active... perhaps webjure, but that may be stalled
16:03technomancymofmog: you can bundle jetty w/ your app
16:05mofmogoh right
16:05mofmogim not to experienced with java for web developing tbqh
16:05technomancydanlarkin: I'm looking at the definition of create-repl-server in server_socket.clj from contrib
16:05technomancydanlarkin: if create-server accepted a function first, *then* a port, it's be easier to curry
16:06technomancybut changing that seems like a bad idea
16:06technomancyinteresting how currying makes argument order matter a lot more
16:06mofmogtechnomancy: are you currying or partial evaluating?
16:07mofmogcurryin takes a function that accepts tuples and returns a function that sorta like a bunch of nested lambdas
16:07technomancymofmog: hrm; maybe my terms are messed up.
16:07mofmogpartial evaulating is one you "specialize" a function so to say
16:08mofmog*when
16:08mofmogsame sorta general idea nonetheless
16:08technomancymofmog: yeah, searching wikipedia for "partial application" redirects to the Currying page. =)
16:09mofmogoh yeah, mix it up in #haskell and they'll hunt you down and your family and your pets
16:09technomancyhah
16:10technomancybut partial evaluation is what I'm looking at. there's a function that calls create-socket by passing in all the arguments it recieved except one
16:11technomancysince there are three different arg lists to support (the same as create-socket) it'd be nice to be able to turn a seven-line function into one line. but the fixed arg is not the first one, so I don't know if you can do it.
16:12Lau_of_DKtechnomancy: compojure looks a little stalled as well
16:12skogshi all: do all collection implement ISeq interface?
16:12lpetithi
16:12technomancyLau_of_DK: the mailing list is extremely active
16:12technomancyI could use apply, but it's not quite as nice
16:12Lau_of_DKk
16:13lpetitCould someone explain me if there is a possibility to browser this channel's history (sorry, I'm a real IRC noob)
16:13mofmoghmm
16:13mofmogsay you have a function foo that takes in arguments x y z and you want to specialize it such that y is always 2
16:13lisppaste8technomancy pasted "two create-repl-socket implementations" at http://paste.lisp.org/display/75026
16:14technomancyare these two implementations equivalent?
16:14mofmog(define (special-foo y) (lambda (x z) (foox x y z)))
16:14ayrnieuclojurebot: google clojure irc log
16:14clojurebotFirst, out of 3580 results is:
16:14clojurebot#clojure - May 16 2008
16:14clojurebothttp://clojure-log.n01se.net/date/2008-05-16.html
16:14mofmogthat's scheme way at least
16:14mofmogthe you say, (define foo2 (special-foo 2))
16:15technomancymofmog: what do you think of the version I pasted?
16:15lpetitthx, I certainly didn't search with the right keywords (I didn't think to use the "log" keyword)
16:16mofmogtbqh i dont really know what's going on
16:16technomancyThe only disadvantage is that the older version is explicit about its argument list, whereas with the short one you have to refer to create-server's arg list to know what's going on
16:16mofmogso the conj operator does what?
16:16mofmogis it like cons?
16:16technomancymofmog: yeah, but it works for all sequences
16:17technomancynot just lists
16:17mofmogoh i see
16:17mofmoglike a general preappend
16:17mofmogor append i guess
16:17ayrnieualso, it has a more convenient argument order for some uses.
16:17Chouserno, conj adds to each collection in its own way
16:17mofmogah
16:17mofmogso the difference between defn and def?
16:17Chouserconj on a list is exactly like cons, but conj on a map takes a [key val] vector and adds that entry
16:18mofmogi've mostly just done scheme
16:18technomancyanyway, I think the explicitness of the argument list is enough to justify the verbosity of the original in this case
16:18technomancymofmog: defn is def + implicit fn
16:18mofmogah i see
16:18skogsHi all
16:18Chouser(defn foo [x] body) is essentially (def foo (fn [x] body))
16:18mofmogoh so it's like () around the name of something you're defining in scheme
16:18Chouser...plus extra optional args for docstring, etc.
16:19mofmog[port & args]?
16:19mofmogis that like .
16:19mofmog(define (dosomethin f . y) (map f y))
16:20technomancymofmog: yeah, it's "rest arguments"
16:20Chouser,(let [[x y & m] (range 9)] {:x x :y y :m m})
16:20clojurebot{:x 0, :y 1, :m (2 3 4 5 6 7 8)}
16:20technomancyI never got that far in my scheme impl, but I think it's the same idea.
16:20ayrnieu,((fn ([one] one) ([frst & rst] {:first frst :rest rst})) 1)
16:20clojurebot1
16:20ayrnieu,((fn ([one] one) ([frst & rst] {:first frst :rest rst})) 1 2 3)
16:20clojurebot{:first 1, :rest (2 3)}
16:20technomancyChouser: do you think it's a good idea for the server-sockets library to be defined in terms of duck-streams instead of calling Java classes directly?
16:21ayrnieutechnomancy - it provides the false convenience that a lot of people like -- for a while.
16:21mofmogoh i see why they chose to use defn, it lets you do the pattern matching deal
16:21technomancyor rather that the socket-repl sample function use it
16:21ayrnieuthat isn't pattern matching, mofmog; it only dispatches on the number of arguments
16:22ayrnieufor other dispatch, use defmulti/defmethod
16:22Chouserayrnieu: why is it false?
16:22Lau_of_DKAny good websites regarding compojure?
16:22technomancyLau_of_DK: docs are sketchy; need to ask on the mailing list for most things
16:23Chouserplain fn's can have arity overloading too. (fn ([] 1) ([x] x) ([x y] (+ x y)))
16:23technomancyayrnieu: if you're just looking to understand how the library works, the sample provided shouldn't bring in unnecessary baggage.
16:23skogsguys, i need some feedback on a switch statement macro
16:23technomancyyou can fall back to that if you want to, but if you end up needing it odds are you won't need to base your code off the sample
16:25ayrnieuskogs - ... OK?
16:25ChouserI haven't even figured out how to use all of condp's features yet.
16:26skogscan i paste code somewhere?
16:26Chouserlisppaste8: url
16:26lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
16:29lisppaste8skogs pasted "given" at http://paste.lisp.org/display/75027
16:31skogsChouser: did u see the paste
16:31Chouserskogs: yep
16:31skogsthats an example of the statement
16:31Chousercan't use it to see if x is a particular function or regex
16:32ayrnieuskogs - please ask a question.
16:32hiredmanskogs: do you know about condp?
16:32skogsno
16:33hiredman(doc condp)
16:33clojurebotTakes a binary predicate, an expression, and a set of clauses. Each clause can take the form of either: test-expr result-expr test-expr :>> result-fn Note :>> is an ordinary keyword. For each clause, (pred test-expr expr) is evaluated. If it returns logical true, the clause is a match. If a binary clause matches, the result-expr is returned, if a ternary clause matches, its result-fn, which must be a unary function, is ca
16:33skogsok
16:33skogsgiven is more generic switch than just predicate
16:34Chouserskogs: you've started trying to write the macro?
16:34hiredman,(let [a 1] (condp = a 1 "Hey" 2 "Yo"))
16:34clojurebot"Hey"
16:34skogsi wrote it
16:34hiredman,(let [a 2] (condp = a 1 "Hey" 2 "Yo"))
16:34clojurebot"Yo"
16:34skogslet me paste it
16:34ayrnieuskogs - OK. What is your question about it?
16:37lisppaste8skogs pasted "untitled" at http://paste.lisp.org/display/75028
16:38skogs(given x
16:38skogs 5 "a number"
16:38skogs #"c.*e" "matches regex"
16:38skogs even? "an even number"
16:38skogs :hashkey "key in map x exists"
16:38skogs)
16:39skogsin given, the case statements can be very generic
16:40ayrnieuChouser, -> is very convenient, and very limited, and the effect is that you can start out with an -> expression and then say, oh, wait, I can't do what I want to do with this. And then you have to rewrite the expression, turning it inside-out (outside-in), adding a lot of parentheses, etc.
16:41Chouserayrnieu: yes
16:41ayrnieuChouser - but I wouldn't call it 'false' because of the straightforwardness of this whole process. Even if you make a small change and then have to throw -> out, you still aren't doing a lot of work.
16:41Chouseroh!
16:41Chouseroh.
16:42ayrnieuChouser - but with socket-server you say, "aha, I can use this" -- and you're driven down completely the wrong path.
16:42Chouserayrnieu: because of socket-server, or because of duck-streams?
16:42hiredman,(-> "huh" (#(println % "?")))
16:42clojurebothuh ?
16:47ayrnieuChouser - *shrug*, I started doing something else as soon as I saw that the callback only received the duck-streams, because "let's pretend that sockets are files!" is a trap I'm familiar with, but server-socket's one-client-per-thread is also problematic.
16:48technomancyayrnieu: well both those assumptions fit great with the vast majority of the simple cases.
16:49technomancyif you've got a more complicated need you probably shouldn't be using server-socket to begin with
16:49technomancyit's not a lot of code
16:49ChouserI've only had positive experiences with duck-streams. I haven't look at server-socket at all yet.
16:50ayrnieuskogs, you never asked a question about this 'given' thing.
16:51skogsi guess i am not fully ready yet
16:51skogssince i have no doc, its hard to explain what it does
16:51Chouserwe might be able to figure out what it does enough to answer your question, if you ask one.
16:51skogsso started creating a github project to put the code and examples
16:52ayrnieuoh, do you just want comments on it?
16:52skogsyes
16:52skogshttp://paste.lisp.org/display/75028
16:53Chouserskogs: have you had use cases where you actually mix different types of values as conditions in the same 'given' form?
16:53skogsyes
16:54skogscould match a specific value or a regex
16:54Chouserhm, sure, that's plausible.
16:54skogs(given "dude" "sam" "its sam" #"rx" "its all these ppl")
16:54ayrnieuskogs, you can use a# b# etc in place of prepared gensyms. So (let [x (gensym)] `(let [~x ...] ...)) can just be `(let [x# ...] ...)
16:55ayrnieu,[a# b# a#]
16:55clojurebotjava.lang.Exception: Unable to resolve symbol: a# in this context
16:55ayrnieu,`[a# b# a#]
16:55clojurebot[a__1414__auto__ b__1415__auto__ a__1414__auto__]
16:55offby1technomancy: I didn't know about re-split, but was considering something like that ... it seems a little wrong, though, since it requires that I snarf the whole file into memory up front.
16:55Lau_of_DKtechnomancy: What am I not getting, I clone compojure, I run ant, I java -jar compojure.jar, and it boorks, they removed the old script/run, so hows it supposed to be launched?
16:55technomancyoffby1: oh sure, you'd want a lazy version?
16:56offby1ideally
16:56skogsayrnieu: i tried but needed to use symbol during macro expansion stage
16:57technomancyoffby1: I haven't done a much with constructing lazy sequences, but I suspect it would involve binding *in* to (reader "/path/to/file") and using lazy-cons
16:57technomancyor perhaps lazy-seq
16:57ayrnieuskogs - ifn? shadows map? in #'type; also, #'type could be replaced by dispatching on (class x) instead
16:58hiredmanthe whol thing could be a special predicate passed to condp
16:58hiredmanwhole
16:58skogsgotcha.. i will fix
16:59skogshiredman: i just learned condp, will change
16:59Chouseroffby1: re-split is lazy. you might try using mmap/slurp, which would allow the OS to load the file from disk as re-split demands it
16:59lisppaste8technomancy pasted "booting a compojure app for Lau" at http://paste.lisp.org/display/75030
16:59technomancyLau_of_DK: that's what I use
17:01technomancyChouser: slick.
17:01Chouserre-split is not lazy
17:01skogshow do i know if a value is a sequence without causing a runtime error
17:01hiredmanseq?
17:01hiredman(doc seq?)
17:01clojurebotReturn true if x implements ISeq; arglists ([x])
17:02Chousersorry, I had that wrong. re-partition *is* lazy and should work well with mmap/slurp
17:02skogsbut (seq? [3 4]) fails
17:02hiredman[] is a vector
17:02hiredman,(vector? [])
17:02clojurebottrue
17:02technomancybut /me suspects offby1 is prematurely optimizing
17:02offby1probably.
17:02hiredman,(seq? (seq []))
17:02clojurebotfalse
17:03offby1given that the slurpy way is simpler than the lazy way
17:03hiredmangrr
17:03hiredman,(seq? (seq [1]))
17:03clojurebottrue
17:03technomancyoffby1: plus slurp is fun to say
17:03skogsoh
17:03hiredman,(seq [])
17:03clojurebotnil
17:03skogs,(seq? 3)
17:03clojurebotfalse
17:03Lau_of_DK Seriosly, isnt there anything better than compojure out there? (ie., something that actually runs) Or am I just too dumb to use it?
17:04technomancyfunctions that are onomatopoeic are the best
17:04hiredmanLau_of_DK: ring is nice
17:04technomancyLau_of_DK: you can check out my lil app if you want more sample code
17:05Chouserskogs: I think you can replace your macro with (defmacro given [& r] `(condp match ~@r nil))
17:05technomancyring looks nice but really low-level
17:05hiredmanerm
17:05Lau_of_DKtechnomancy: link?
17:05hiredmanif anything I would say it is higher level
17:05technomancyhiredman: well it doesn't contain any functions for HTML generation or session abstractions, right?
17:06hiredmanlast time I used compojure you had to def a servlet then create a list of url mapings
17:06hiredmanring you just hand it a function
17:06skogsChouser: wow! I will try that
17:06hiredmantechnomancy: I believe that is correct
17:07hiredmanbut that is confusing featureful and abstraction level
17:07technomancyhiredman: compojure handles routing for you, ring hands off the path and lets you write your own routing mechanism
17:08technomancyLau_of_DK: I don't have it on github, but I can upload a tarball
17:08hiredmantechnomancy: have you used ring?
17:08Lau_of_DKThanks, appreciate it
17:09technomancyhiredman: I've used rack extensively, which ring is a port of.
17:09danlarkinmy <yet to be named web project> is based on ring
17:09technomancymaybe ring has been extended to be more than a port since I looked at it?
17:10hiredmanI dunno
17:10hiredmanI know nothing about rack
17:10Chouserskogs: you also might be interested in this thread: http://groups.google.com/group/clojure/browse_thread/thread/e750b045d8701f7/b93846216491e4e5
17:12technomancyLau_of_DK: there's some bitrot here; hold on
17:12technomancyanyway, what I mean about ring is that ring is designed to build frameworks or APIs on, whereas compojure is designed to build applications on.
17:13Lau_of_DKRing looks good
17:13Lau_of_DKI especally like that its not broken out of the box
17:14hiredmanthey could add that to the feature list
17:14skogschouser: there's already lot of thought here
17:15skogsi was just translating perl6's smart match and given control statement
17:16skogsthe tough part is the conditional part dispatch and what the sensible defaults
17:17Chouserright, I think condp is already doing what you want for the macro, it's just a matter of the matching function
17:17skogsyeah, the matching is where the smarts go i mean
17:18skogsand to be universably useful, it should be DWIMish as Perl6 ppl say
17:18technomancyLau_of_DK: http://p.hagelb.org/concourse.tar.gz <= ~5MB because it bundles all the jars
17:18Lau_of_DKThanks big guy
17:19danlarkinOooooo concourse
17:20Lau_of_DKdanlarkin: You seem to energetic, did you just drink a bottle of hansard?
17:20danlarkinLau_of_DK: hahaah
17:20danlarkinit's a good name, alright?!
17:21Lau_of_DKYea, I like my Budweiser and my Hansard, they go well together
17:21Lau_of_DKBut when you mix german sausages and Hansard.. then youre in for some stomach trouble
17:22danlarkinpahhh
17:22danlarkinI did just figure out how to implement conditionals in my templating language
17:22danlarkinmaybe that has made me cheery
17:23Lau_of_DK:)
17:23Lau_of_DKThats nice
17:24Lau_of_DKRing doesnt seem too big in the template department
17:25danlarkinring is just a layer between your app and the http spec
17:26danlarkin*gasp*!
17:26danlarkinit's sentient!
17:27Lau_of_DK(doc sentient)
17:27Lau_of_DKI really miss RSchulz, everytime he wrote something in the chan, I had to reach for my dictionary
17:27Lau_of_DKThat was nice
17:27durka42(defn sentient [] (/ 1 0)) ; singularity
17:30hiredman(doc test)
17:30clojurebottest [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception; arglists ([v])
17:34danlarkinyeah he was a character
17:40ayrnieualways with the NullPointerExceptions.
18:16technomancysets aren't ordered, are they?
18:17Wizardofwestmarcmaybe I'm insane but aren't there hashed AND ordered sets?
18:17Wizardofwestmarcjust like there's hash-map and sorted-map
18:18technomancythat sounds right
18:18technomancybut the one you get from #{"a" "b" "c"} is hashed?
18:19Wizardofwestmarcyeah
18:20Wizardofwestmarc,(sorted-set :a :b :c)
18:20clojurebot#{:a :b :c}
18:21technomancy,(= (sorted-set :a :b :c) #{:a :b :c})
18:21clojurebottrue
18:21technomancy,(= (hash-set :a :b :c) #{:a :b :c})
18:21clojurebottrue
18:21technomancyinteresting
18:22Wizardofwestmarcyeah, #{} is just the reader macro for hash-set
18:23forestthere are both PersistentHashSet and PersistentTreeSet in clojure sources, that is sorted and unsorted
18:23Wizardofwestmarchuh, I hadn't noticed treeset
19:24te'lo all
19:32durka42hi te
19:33ayrnieusince I criticized server-socket earlier: http://github.com/ayrnieu/clj-actors/tree/master
19:38bakkdoorhi
19:39teI'm trying to figure out Clojure. This is my first introduction to lisp, java, etc.
19:39teThis is a totally different way of programming.
19:40durka42having fun so far?
19:41forestclojure sources are so poorely documented
19:42ayrnieuthey aren't a work of Literate Java. What question do you have?
19:43tedurka42: Yes I suppose
19:43tedurka42: I must say I'm getting a little anxious
19:44durka42te, about what
19:45teI want to start /doing stuff/, but understanding the fundmanetal structure of how things fit together seems to be a large undertaking
19:45teI'd like to write a script to open a file, take the user input and add it to the file on a new line, and then close the file
19:45cemerickte: IMO, clojure is *very* well documented, though the delivery format and arrangement is very different from classic java project styles. I'll definitely grant that the style difference takes a little getting used ot
19:45tecemerick: forest was critiquing the docs, not me
19:46tecemerick: however, that is helpful advice, thanks
19:46cemerickte: oooh, sorry, my bad :-)
19:46durka42cemerick: mark volkmann would beg to differ
19:46forestjust noticed, probably we are not supposed to look into sources
19:46ayrnieute - so, what problems do you have with that?
19:47teayrnieu: truthfully i just dont know where to start -- im not very comfortable i guess
19:47ayrnieuforest - I often dig through them.
19:47cemerickdurka42: mark being who? I'm bad with names of people I don't talk with regularly :-|
19:48ayrnieuforest, don't confuse newbie source where every line is (add 1 2) ;; ADD TWO NUMBERS, RETURNING THE SUM with normal source that assumes a measure of language and system familiarity by the reader
19:48teayrnieu: do you think you could show me some code and then i could ask questions about it?
19:48durka42te: might want to look at clojure.contrib.duck-streams, with-open
19:48teayrnieu: or maybe you could walk me through it?
19:48tedurka42: i can look into that
19:48durka42cemerick: there was a big thread on the mailing list about clojure being poorly documented in general
19:49ayrnieute - well, can you do the 'write a script' part? Can you write a script that accepts a single argument and complains if it gets zero ore more than one arguments?
19:50teayrnieu: probably, but id need to look around a bit
19:50durka42SimonAdameit: have you downloaded clojure and contrib?
19:50ayrnieuSimon - I just use emacs and vim, a clj script, some ~/.zshrc stuff to populate CLASSPATH
19:50forestayrnieu: i mean the java sources, not clojure ones
19:50durka42are you trying to use emacs, vim, or neither?
19:51SimonAdameitexactly this CLASSPATH stuff is killing me..
19:51durka42whAT
19:51teayrnieu: (defn myfunc [myval])
19:51durka42oops
19:51cemerickdurka42: ah, that one, right. Eh, I just let stuff like that float by. I try not to convince people of things that they seem to have already made up their minds about.
19:51durka42what's your command to run java
19:51stimulihi
19:52SimonAdameitI tried to use netbeans + enclojure and the REPL wont work, because of some classpath or whatever issue. Now I am trying emacs and slime, and I dont have swank in my classpath it says
19:52ayrnieute - sorry, what about that myfunc ?
19:52SimonAdameitclojure works fine, just invoking java -jar clojure.jar
19:52teayrnieu: that takes an input value, thats the script part
19:52teayrnieu: no?
19:52durka42i installed enclojure and netbeans decided not to start anymore... haven't tried to fix it yet
19:53stimulihas anyone here seen pmap go wonky ?
19:53durka42wonky?
19:53ayrnieute - well, I was thinking of something with #! /usr/bin/env clj , *command-line-args* , etc.
19:53stimuliI have a prog w/ a bunch of pmaps and when I use maps is works, but blows up if I use pmap
19:53stimuliI'm not doing any other concurrent stuff
19:54teayrnieu: ah okay -- well i dont have the binary i dont thinkg
19:55ayrnieute - the binary?
19:55tei dont have a clj
19:55tein my PATH
19:55tei have a clojure.jar becase i compiled from source
19:56ayrnieute - get it from here: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started
19:56ayrnieuI especially recommend the rlwrap setup
19:57stimuliso anyway, I figure that other than the multiple cpu thing .. pmap should ahve the same semantics as map
19:57stimuliso I suppose there is a bug somewhere
19:58ayrnieustimuli - I suppose so. You could copy src/clj/clojure/core.clj:pmap into your program and add debugging hooks into it -- to track agents, for instance, and see if they get errors.
19:58stimulihmmm
19:59stimulisounds like a plan
19:59stimulithe only "debugging hooks" i've figured out so far are print statements, though :)
20:00ayrnieu(def pmap-agents (ref nil)) (defn rem [x] (dosync (commute pmap-agents conj x)))
20:00Rayneshttp://www.debloggers.de/wp-content/uploads/bilder/getstringfromobject.jpg
20:00ayrnieuwell, rem is already a function.
20:01durka42print statements are good :)
20:01durka42you can replace any x with (doto x prn)
20:01durka42,(+ 3 (doto 4 prn))
20:01clojurebot7
20:01clojurebot4
20:01ayrnieuooh, nice.
20:01stimuliah ... so add all the agents to a ref and watch them ?
20:02ayrnieuor you could just (filter agent-errors pmap-agents) afterwards
20:02stimulithen use the "get-agent-errors" thingy
20:04stimuliI'll try that and report back
20:04ayrnieu(def OMG-count (ref 0)) (defmacro OMG [expr] `(doto ~expr (println (dosync (alter OMG-count inc)))))
20:04ayrnieu(def OMG-count (ref 0)) (defmacro OMG [expr] `(doto ~expr (println ~(dosync (alter OMG-count inc))))) ;; rather
20:05durka42you want the dosync evaluated at compile time?
20:06ayrnieuyes. (def agent-hell [] ... (OMG x) ... (OMG y)) => (def agent-hell [] ... (doto x (println 1)) ... (doto y (println 2)))
20:06durka42ah good
20:06ayrnieuI feel that the name is the best part of this.
20:06durka42:p
20:17offby1So I'm in the REPL, and I'd like to use "re-split". Just typing "re-split RET" yields, not surprisingly, "java.lang.Exception: Unable to resolve symbol: re-split ...". However I can't figure out how to get it "imported". What should I do?
20:17offby1(import 'clojure.contrib.str-utils) ain't it ... tried various combinations ...
20:18durka42use, not import
20:18durka42or require
20:18durka42import is for java classes
20:22SimonAdameitIs anyone using enclojure here?
20:23SimonAdameitHow can I get anything into the repl? When I do (def foobar 234) in the file and compile, change REPL namespace to file namespace type foobar into the REPL, I get an error, symbol foobar not found.
20:29stimuliso I got this agent error: (def pmap-agents (ref nil)) (defn rem [x] (dosync (commute pmap-agents conj x)))
20:29stimulioops
20:30stimuliI mean this : java.lang.ClassCastException: clojure.lang.LazyCons cannot be cast to clojure.lang.Agent (NO_SOURCE_FILE:0)
20:30stimulifrom inside of pmap
20:31stimulioh wait ....
20:31stimuliI mean I got this: ava.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: nth not supported on this type: Keyword>)
20:31stimuliI'm learning as I got
20:31stimuligo
20:31Chouser,(nth :foo 5)
20:31clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: Keyword
20:31stimulibut everything works fine if I use a normal map
20:31stimuliand I get the correct results
20:49skogshow to get the class/interface hierarchy of a clojure type like vector
20:50skogs(class [3 4]) only tells me class but i'd like to all interfaces it defines as well
20:50stimuliI don't think you can nest pmaps safely
20:51stimuliwhich means I'll have to write my own parallization code
20:51stimulioh well
20:52ayrnieu,(-> [3 4] class ancestors)
20:52clojurebot#{java.util.Collection java.lang.Object clojure.lang.IObj java.lang.Iterable clojure.lang.AFn java.lang.Runnable clojure.lang.Streamable clojure.lang.IFn clojure.lang.IMeta java.util.List java.util.concurrent.Callable clojure.lang.Obj clojure.lang.Sequential clojure.lang.APersistentVector java.io.Serializable java.util.RandomAccess clojure.lang.Associative clojure.lang.IPersistentStack clojure.lang.IPersistentCollection c
20:53stimulidoes the bot let us run arbitrary code ?
20:53stimuliisn't that sort of ... dangerous
20:54skogsayrnieu: thanks! btw now i also know how to use -> op
20:54ayrnieustimuli - it's the point of having a bot.
20:56ayrnieuobviously there are measures you should take.
20:56offby1stimuli: I know a guy who specialized in crashing bots
20:57offby1s/specialized/specializes/
20:57offby1he sho' 'nuff crashed mine a lot
20:57ayrnieuare you talking about me?
20:57offby1nope
20:57offby1I'm talking about "eli" in #scheme
20:59stimuliI mean .. can I call out to java ?
21:00ayrnieustimuli - yes, although there's a security model in place.
21:00stimuli,(.. Runtime getRuntime availableProcessors)
21:00clojurebot1
21:00stimuliwow
21:01stimulithat requires a certain level of trust
21:01stimuliI hope he's running in a chroot or something
21:01ayrnieuhiredman isn't completely reckless. I wouldn't worry too much about a bot running under OpenBSD systrace and some quotas.
21:01stimulianywho ... my pmaps call a bunch of functions who themselves call a bunch of pmaps
21:02stimuliso that means I'm sending agent messages inside another agent
21:02stimuliI wonder if that is what is breaking things
21:02ayrnieuthe messages only get sent after the function on that agent returns.
21:02ayrnieuso that could very well be the problem.
21:03stimuliYES!
21:03ayrnieuwait, that's definitely true of dosync. Let me check.
21:03stimuliI see it now
21:03stimulirats !
21:03stimuliand pmap looked so easy
21:03stimuliI thought clojure was supposed to make concurrency utterly easy (j/k) :)
21:04stimulinow I have to think
21:04ayrnieu(pragma :sprinkle-on-parallelism) is always tricky :-)
21:04stimuliyes
21:04stimulion the other hand I figured out some really tricky graph algorithm code that seems to be working
21:05ayrnieutry using send-off instead.
21:05stimuliwell, I want to keep things in a thread pool
21:06ayrnieusend-off also uses a thread pool, just an expandable one.
21:06stimuliI'll figure something out .. but not tonight
21:06ayrnieu(better control over thread pools is an agent feature that I'd like, too)
21:06stimuliI think I'd still have the same "wait until the outer agent finishes before the inner agent returns" problem
21:07stimuliI mean ... I don't think the semantics changes w/ send-off
21:07stimuliregarding waiting
21:07ayrnieuI'm not sure that that's true, sorry.
21:07stimulihmmm
21:07ayrnieubut 'send' has a potentially very small thread pool (it's based on the number of processors) that does not expand
21:08ayrnieuso you could have this problem even if I'm wrong about delayed sends.
21:08stimulifrom the website: # If during the function execution any other dispatches are made (directly or indirectly), they will be held until after the state of the Agent has been changed.
21:08stimuliI think it is the same for send off
21:09stimuliof course ... it will take me 30 seconds to test .. be right back
21:09ayrnieuah, OK.
21:09ayrnieugeez, that's #5 on that list. It's too early for me to read this poorly :-/
21:09stimulisame behavior
21:10stimuliI can just create a java ModuleExecutor
21:10stimuliand do it myself
21:10stimuliClojure is still > Java
21:10stimuliI wonder though .. if that risks deadlock
21:11stimulithere is a reason the sends are delayed
21:11stimuliit could deadlock
21:11stimulihmmm
21:12stimuliI'm going to sleep for a while .. thanks for the help .. you guys saved me hours
21:40skogsis there a function that tells me if given item is in the collection?
21:41ayrnieu,(.contains "hello" "e")
21:41clojurebottrue
21:41skogswould this work on all collections?
21:41Chouserskogs: it's best to use a map or set if you're going to do this kind of lookup
21:42Chouser,(let [s '#{a b c d}] (s 'c))
21:42clojurebotc
21:42Chouser,(let [s '#{a b c d}] (s 'e))
21:42clojurebotnil
21:42skogsi'm doing a type based dispatch, hence a really general method
21:43ayrnieuuse defmulti, then
21:43Chouserother kinds of collections would require a linear search through the whole thing -- not recommended.
21:44ayrnieuhttp://paste.lisp.org/display/74647 - defmulti examples.
21:44skogsthis is in a defmulti dispatch, needed for resolving hierarchies
21:45skogschouser: given an item and a possible collection, need to find if item exists in the collection
21:45Chouser"possible collection"?
21:46Chouserif the collection is a map, you want to look up by key or by value?
21:46skogsisa? IPersistentCollection i mean
21:46skogsmap is a special case, dealt with it in earlier defmethod
21:48Chouser,(some #{'b} '[a b c d])
21:48clojurebotb
21:48Chouser,(some #{'e} '[a b c d])
21:48clojurebotnil
21:51skogschouser: is ur idiom more generic than using .contains
21:52ayrnieuit's different.
21:52ayrnieu,(some #{'a 'b} '[a x c d])
21:52clojurebota
21:52ayrnieu,[(.contains "hello" "el") (some #{\e} "hello")]
21:52clojurebot[true \e]
21:53skogsi just need the truth value
21:54skogs.contains seems cleaner, but uses java method
21:54ayrnieuugh.
21:54skogshow do i know which class/iface implemented .contains
21:57Chouserjava.util.Collection
21:59skogsis there a one-liner for method lookup
22:00ayrnieu,(sort (map #(-> % .getName symbol) (.getMethods (class ""))))
22:00clojurebot(charAt codePointAt codePointBefore codePointCount compareTo compareTo compareToIgnoreCase concat contains contentEquals contentEquals copyValueOf copyValueOf endsWith equals equalsIgnoreCase format format getBytes getBytes getBytes getBytes getChars getClass hashCode indexOf indexOf indexOf indexOf intern isEmpty lastIndexOf lastIndexOf lastIndexOf lastIndexOf length matches notify notifyAll offsetByCodePoints regionMatc
22:01ChouserI use clojure.contrib.repl-utils/show to do that sort of thing
22:01ayrnieu,(filter #(.contains % "in") (map #(.getName %) (.getMethods (class ""))))
22:01clojurebot("indexOf" "indexOf" "indexOf" "indexOf" "toString" "codePointAt" "codePointBefore" "codePointCount" "offsetByCodePoints" "substring" "substring" "contains" "intern")
22:01ayrnieuI still haven't explored clojure.contrib
22:02skogscool!
22:02ayrnieuthis is an example in Programming Clojure
22:02Chouserit's probably a bit intimidating at this point. could use a nice summary of the libs I suppose
22:05Raynes,(doc get)
22:05clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
22:05RaynesNeat.
22:06ChouserRaynes: clojurebot or get?
22:07RaynesChouser: get
22:07RaynesWell, both, but get was the source of the "Neat".
22:08Chouseryep. But 'get' is hardly every used.
22:08Chouser,(:a {:a 1 :b 2})
22:08clojurebot1
22:08RaynesI'm easily amused. I love functional programming.
22:08Chouser,(:c {:a 1 :b 2} :not-found)
22:08clojurebot:not-found
22:09Chouser,({:a 1 :b 2} :c :not-found)
22:09clojurebot:not-found
22:09Chouser,({:a 1 :b 2} :b :not-found)
22:09clojurebot2
22:09Chouserno need to use 'get'
22:10ayrnieu,(let [x (ref {1 2})] (dosync (alter x get 1)) @x)
22:10clojurebot2
22:10skogs,(.contains :a {:a 3})
22:10clojurebotjava.lang.IllegalArgumentException: No matching method found: contains for class clojure.lang.Keyword
22:10ayrnieu,(.contains {:a 3} :a)
22:10clojurebotjava.lang.IllegalArgumentException: No matching method found: contains for class clojure.lang.PersistentArrayMap
22:10ayrnieuthat's the right order, even if it doesn't work.
22:11skogs,(some #{:a} {:a 3})
22:11clojurebotnil
22:11ayrnieu,({:a 3} :a)
22:11clojurebot3
22:11ozy`(fetch-url "http://blog.fogus.me/2009/01/15/on-lisp-clojure-prolog-pt-1/&quot;) ;; hooray for literate programming
22:11Chouserskogs: you said maps were handled separatly/
22:12RaynesChouser: Stu used it in his book.
22:12skogsi'm wondering if i could cheat ;(
22:12skogswould keys function work on a java map?
22:13Chouserskogs: maps implement java.util.Map not java.util.Collection
22:13skogsic
22:14ayrnieuit's possible to be so general that your brains fall out.
22:14Chouserso you get .containsKey and .containsValue instead
22:15skogs,(.containsKey {:a 3} :a)
22:15clojurebottrue
22:16Chouser,(some #{[:b 2]} {:a 1 :b 2 :c 3})
22:16clojurebot[:b 2]
22:21ozy`,(atom 1)
22:21clojurebot#<Atom@1542cdc: 1>
22:21ozy`huh
22:21ayrnieuwhat do you huh about?
22:24ozy`,(atom 'desu)
22:24clojurebot#<Atom@4c8422: desu>
22:24ozy`nothin'
22:25ayrnieuyou're not going through The Little Schemer, are you?
22:25ozy`nope
22:25Chouserhttp://code.google.com/p/clojure/issues/detail?id=56
22:27ayrnieuputting your crazy patches into clojurebot so that they can seep insiduously into the channel, eh?
22:28Chouserheh, um, what?
22:28ayrnieu,(-> 1 inc (+ 1 _))
22:28clojurebotjava.lang.Exception: Unable to resolve symbol: _ in this context
22:28Chouserthat's already in. I wondered if ozy` was noting the new(ish) printing behavior of atoms
22:28ozy`,'desu
22:28clojurebotdesu
22:29ozy`Chouser: (atom) returns a new, unique symbol, right?
22:29ayrnieuno, that's (gensym); atams are simpler refs.
22:29ozy`all right
22:29ozy`see
22:29ayrnieualso, atoms. I guess I've been getting the new revisions but not actually building them...
22:29Chouserno, it returns an atomic reference http://clojure.org/atom
22:29ozy`I don't actually know clojure.
22:30ozy`I just hang out here.
22:30Chouserhttp://clojure.org/atoms
22:30Chouserheh
22:31skogswow, nasty surprise with defmethod ordering
22:31ozy`,(gensym)
22:31clojurebotG__1646
22:32ayrnieuChouser - I don't see the new behavior.
22:32skogsi guess they r not ordered as they r written in source
22:32ayrnieuclojurebot: latest
22:32clojurebotlatest is 1252
22:32Chouserskogs: I don't think the order matters
22:32ayrnieuyeah, nothing.
22:32skogsunless multiple method match the args
22:33ayrnieuskogs - that's an advantage, actually; it lets http://github.com/ayrnieu/clj-actors/blob/edab5efb3626e00901e24ca4b0b538776c341e61/src/act/simple_server.clj work
22:33Chouserthen it should use the inheritence tree
22:33ayrnieu(github, why do you have horrible URLs?)
22:34ayrnieuthat sets up default methods that can be overriden later on.
22:37lisppaste8skogs pasted "smart match" at http://paste.lisp.org/display/75037
22:38skogsjust posted the smart match using defmulti, plz comment
22:40Chouseryou can use import so you don't need to repeat package names each time you mention a class
22:43skogsaha
22:43skogsuser=> (match 3 [3 4])
22:43skogsjava.lang.IllegalArgumentException: Multiple methods match dispatch value: [java.lang.Integer clojure.lang.LazilyPersistentVector] -> [java.lang.Object java.util.Collection] and [java.lang.Object clojure.lang.IFn], and neither is preferred (NO_SOURCE_FILE:0)
22:45ayrnieu,(doc prefer-method)
22:45clojurebot"([multifn dispatch-val-x dispatch-val-y]); Causes the multimethod to prefer matches of dispatch-val-x over dispatch-val-y when there is a conflict"
22:45ayrnieu,(doc prefers)
22:45clojurebot"([multifn]); Given a multimethod, returns a map of preferred value -> set of other values"
22:46ayrnieubut even if biordered arguments is more smart matchy, perl6 ~~y, it's odd in Clojure.
22:47skogsi'm planning on using this as a switch macro
22:48skogscondp with this smart-matcher as predicate => define a new macro called: given
22:48Chouser,(:foo #{:foo}) (#{:foo} :foo)
22:48clojurebot:foo
22:49ayrnieuChouser, that doesn't demonstrate biordered arguments.
22:49Chouserok, then I don't know what you mean. :-)
22:50ayrnieu(f a b) and (f b a) having the same semantics. iFn? true keys is something different.
22:50Chouseroh, I see.
22:50Chouser(+ 1 2) (+ 2 1) ?
22:51ayrnieu,[(- 1 2) (- 2 1)]
22:51clojurebot[-1 1]
22:51Chousersome clojure functions care about the order of their args, others don't.
22:51ayrnieusome don't care, pretty much everything does.
22:51skogs(given "chouser" #"c.*r" "yes") is same as (given #"c.*r" "chouser" yes")
22:52ayrnieuah, OK.
22:53skogsits basically perl6's switch statement
22:55skogs(given x nil? "nil" even? "even number" #(= 3 %) "its 3")
22:56Chouserruby has a similarly powerful case statement, using a === operator, but it doesn't let you reverse regex and string
22:56skogsoh
22:57Chouserjust fyi. :-)
22:57Chousercase "foo" when /f/; 1 end ==> 1
22:57Chousercase /f/ when "foo"; 1 end ==> nil
22:58skogsgiven works biorder in DWIMish way ala perl6 or perl5's switch.pm
22:59ChouserI can certainly imagine having a string and wanting to test several regexs against it.
23:00Chouserwhich as far as I can tell couldn't be done with ruby's "case"
23:01skogswith clojure, we r the same footing as the lang developer
23:01skogsi love macros
23:03Chouseryeah, me too
23:04ChouserRich won't let us have reader macros, though.
23:05skogsi just started on macros, so readers ma be too much power
23:05Chouser:-)
23:07stimuliI doubt I'll ever miss reader macros
23:07stimuliand it stops people who try to be *clever*
23:07dreishYou could always write your own reader.
23:07stimuliyeah
23:07Chouseryou can fork clojure and add whatever you want.
23:08stimuliwell yeah
23:08Chouser...so unsatisfying.
23:09ayrnieuthe Tower of Babel solution to design complaints.
23:10stimuliwell .. you'll never satisfy everyone ... and for folks who can only bitch and bitch about things they don't like "fork and do it yourself" is ultimately the only answer
23:11stimulithey almost never do it, of course
23:11ChouserI've not seen a whole lot of that kind of complaining about Clojure, though.
23:11stimuliwell .... it helps that it is so awesome ! :)
23:11Chouserheh. yeah.
23:12ayrnieustimuli, I don't mean that rich has taken the Tower of Babel approach to complaints, but that "fork it and change it incompatibly with everyone else" is the Tower of Babel solution to one's own design complaint.
23:13Chouserayrnieu: that's how I understood your statement.
23:13stimuliyeah
23:13stimuliI was speaking in generalities
23:14stimuliI haven't been using Clojure long enough to really have any opinion about how Rich does things
23:14ayrnieuoh, OK. Well, it's good that they almost never do this, because they'd be impoverishing themselves.
23:14Chouserwell, technically I guess I do have my own running fork of clojure.
23:15Chousergit-svn makes this easy to do.
23:15stimuliyou could call it an "experimental branch"
23:16ChouserI've only got patches in there that I reasonably expect Rich to take someday, and none of them create breaking changes.