#clojure logs

2009-11-19

00:04tomojwell M-x clojure-mode on your erc buffer is not the way to do it :)
00:42rahulkmrI have been exploring clojure for past 1 week now. I still have a very fundamental doubt. How do I do standalone .clj files? I can do a "java clojure.lang.Script foo.clj args" but everytime I do this, it does a dynamic compilation and the startup time is high. I run at repl but I don't see how it can be used beyond interactive usage. i can generate java classes but the syntax seems convoluted and it feels like forcing the lang to behave otherwise
00:44rahulkmrI don't know about the implementation but won't it be beneficial for stand-alone scripts to generate the compiled class file when I run "java clojure.lang.Script foo.clj" first time and look for it's presence thereafter. The dynamic compilation is significantly slow for something even as trivial as "hello world" script. For scripts which are long running, it doesn't matter much as I believe that with type hints and metadata, the app runs quite fast. But
00:46rahulkmrI was thinking something on the lines of Python. Python generates .pyc(python compiled) files from .py and it decreases the startup time. Since clojure runs on jvm, can't the .class file be produced first time I run the script without the explicit gen-class magic?
00:47danlarkinrahulkmr: compiling to java bytecode is a tiny fraction of the delay you're seeing. Most of it is JVM startup time
00:47danlarkinwhich is not a clojure issue, so to say
00:49rahulkmrdanlarkin: Pardon my ranting, but I was talking more from a clojure end-user point of view. If it's so, why do I see a large diff between some java .class file exec and clojure stand alone script execution? Since the compilation time is low and the majorhead is bringing in jvm in memory, ideally the diff between executing "java Hello" and "java clojure.lang.Script hello.clj" should give me a rough estimate of time taken to dynamically compiling clojure?
00:52rahulkmrOn a related note, how do you do your clojure scripts? When I began, I expected something like I write a .clj script in clojure and some compiler will produce .class file. But now, I see the options are to run standalong clj scripts or AOT. What is the preferred method? My exposure to clojure is quite limited. The only thing I have done with it is read "Programming clojure" and write some toy scripts.
00:54bryteI keep an emacs slime session available for scripts, but since I live in emacs this is just as convenient as having a compiled script to run 90% of the time.
00:54bryteThe other 10% I use a different language
00:55_atorahulkmr: there's nailgun, but it's not perfect
00:56_atohttp://martiansoftware.com/nailgun/index.html
00:56_atostartup time is a problem for all JVM languages :(
00:56rahulkmrbryte: That's more of how do you do development. Say I write a clojure code to parse apache log files and want to deploy it on some server. What's the prefered method? In my short stint with clojure, I couldn't get an idea about deploying code
00:56rahulkmr_ato: Yes, I know about nailgun. I set up vimclojure last night.
00:57rahulkmr_ato: So, regarding startup time, that looks like it is counter productive for short, repeatedly invoked scripts
00:57rahulkmrIt does make sense for long running tasks on which initial dynamic compilation and jvm overheads can be ignored
01:01rahulkmrIf this topic has been already extensively discussed, can someone point me to the discussion? I can't find anything related on usenet. That may be coz my search terms are generic.
01:03rahulkmrRegarding nailgun, it seems far from production ready. It's good for development but can I use it for actual deployment?
01:03bryterahulkmr: Well if it can be scheduled within clojure or have clojure parsing a scheduling file that seems like a possibility you could try. I have no experience with nailgun.
01:04technomancythere's no one-size-fits-all solution for the problem, but startup time can be improved by specifying the -client JVM on the java command-line if you're on 32-bit
01:04fanaticorahulkmr: You can always run put the JVM in client mode, which is tuned for faster startup. What kind of machine are you running it on?
01:04fanaticohah, what technomancy said.
01:04technomancybut there's no denying the JVM is bad for stuff that needs to launch quickly. you couldn't write (for instance) git on the JVM.
01:05michael_teterHi. I'm very new to Clojure, and I'm having trouble making multi-line strings work.
01:05michael_tetershould I be able to say (def x ""
01:06michael_teterline1
01:06michael_teterline2
01:06michael_teter"")
01:06michael_teterOr am I misunderstanding?
01:06danlarkinmichael_teter: you're missing something. Don't double quote the string, just single quote it
01:06michael_teteroh!
01:07michael_teterThanks
01:09rahulkmrfantico: technomancy: I get it. I am running it on a 32-bit rhel 5 box. So the possible solns are "java -client" (though that limits some resources but it doesn' matter since we are talking short, repeatedly invoked scripts) and nailgun for devel
01:09fanaticoA lot of the JVMs optimizations are based on the execution profile of the code (hence the name HotSpot), which won't be run if the script dies quickly.
01:10rahulkmrbryte: nailgun is a project which aims at making startup times slow by loading jvm in it's ng server module and ng -client communicates with the ng-server to run the programs(something like that). The concept looks novel and good for dev work but they themselves claim about security and other shortcomings on their page
01:12rahulkmrFurther, running nailgun on some production node means running additional setup which I personally don't like. I prefer s/w to be packaged as much as possible with min deps on external entities.
01:14fanaticoJVM defaults to -server if you have two or more physical processors, and two or more GBs of RAM.
01:14rahulkmrfanatico: Yes, I do know about JVM optimization(I used to program java in college:)). I was under the impression that clojure can replace my day to day needs as well as complex projects requiring concurrency. But looks like my Python/Bash isn't going to be replace(not that I was going to do that anyway:)). Anyways, right tool for the right job.
01:18rahulkmrfanatico: The machine I am running on is uni processor(though, dual core). So, I take it it doesn't qualify the server-class criteria - For Java SE 6, the definition of a server-class machine is one with at least 2 CPUs and at least 2GB of physical memory.
01:19fanaticoToo bad :-/ As you said before, square peg and a round hole. Clojure isn't an ideal scripting language.
01:21rahulkmrfanatico: This is just my dev box. I am not writing any production code yet. The production servers are what situation demands but I am yet to see something with a single cpu:-). Thanks for all the help in exploring clojure.
01:23technomancy_ato: lein-clojars isn't downloading from clojars, do I have to install manually?
01:25technomancy_ato: also: I moved deps-if-missing to the shell script, so lein-clojars won't compile anymore... just a heads-up!
01:43kzarI'm trying to map a vector with a function that takes 2 parameters. The second parameter is always the same. I could map the vector with a (fn that calls the function and adds the second parameter but is there a better way?
01:43_ato,(map #(+ % 4) [1 2 3])
01:43clojurebot(5 6 7)
01:44_atoI don't think there's anything better than that if it's the second parameter that's fixed
01:46kzar_ato: Cool thanks
01:55chouserClojure on JVM startup time is very annoying for command-line driven scripting tasks.
01:55chouserYet another reason to look forward to clojure-in-clojure.
01:56tomojwhy does the jvm take so long to startup anyway?
01:57chouserI really don't know.
01:58chouserWhat I do know is that I have no right to be awake at the moment. Good night!
04:26KjellskiHow can I get some more detailed information about why a proxy implementing an interface is failing its cast to the target interface?
04:27yasonKjellski: what do you get, then? Usually I just see an exception that some method wasn't found
04:27Kjellskiyason: Something like: ... de.haw_hamburg.otto_j$my_sip_listener__1 cannot be cast to javax.sip.SipListener (otto_j.clj:62) ...
04:29KjellskiI did a (proxy [SipListener] [config] (method1 ....
04:31hiredmanwhats on line 62?
04:32Kjellskihiredman: my call to the funciton defining that proxy...
04:32hiredmancan you pastebin the code and the exception?
04:32KjellskiSure, sorry...
04:38Kjellskihiredman: got it... thanks for forcing the rethink...
04:39hiredman*shrug*
04:49nipraHow can I change the pwd? anything similar to CL *default-pathname-defaults*?
04:50_atonipra: unfortunately you can't change the pwd, it's one of those crazy JVM restrictions :(
04:51nipra_ato, hmm... Ok.
04:52_atoI think the java folks decided to not allow it due to thread safety issues (if one thread changes the current directory how does that affect the others?)
04:54_atonipra: if you're trying to run another program with a different working dirctory from your clojure code, clojure.contrib.shell_out has options for setting it
04:57nipraNested #()s don't work. Is that a limitation because (fn ..) inside #() works.
04:57nipra_ato, Thanks! will try.
04:57_atothat is indeed a limitation of the #() syntax
04:58niprahmm..
04:58_atothe reason why it's not allowed is Clojure wouldn't know whether % refers to the arguments for the outer or inner function
04:59_atoso you have to change one of them to (fn ..) and name the arguments
05:01nipra_ato, yes. e.g. (count (filter #(every? (fn [a] (= a :h)) %) (partition 2 1 [:h :t :t :h :h :h]))) :-)
05:01nipra,(count (filter #(every? (fn [a] (= a :h)) %) (partition 2 1 [:h :t :t :h :h :h])))
05:01clojurebot2
05:01nipracool
05:01nipra,(count (filter #(every? #(= % :h) %) (partition 2 1 [:h :t :t :h :h :h])))
05:01clojurebotNested #()s are not allowed
05:02_ato,(count (filter (partial every? #(= % :h)) (partition 2 1 [:h :t :t :h :h :h])))
05:02clojurebot2
05:03_ato^ another way is to use partial
05:03nipra_ato, yeah.. I'm reading Programming Clojure :-)
05:03nipraIt's fun.
05:04hiredman,((comp count filter) (partial every? (partial = :h)) (partition 2 1 [:h :t :t :h :h :h])))
05:04clojurebot2
05:06AWizzArdCan I typehint a field in a deftype to be a native long?
05:06AWizzArdIs #^long doing that?
05:07hoeck,(->> [:h :t :t :h :h :h] (partition 2 1) (filter #(every? #{:h} %)) count)
05:07clojurebot2
05:07hiredmanAWizzArd: I think so
05:20nipra,(#{:h} :h)
05:20clojurebot:h
05:20AWizzArdHow can I typehint an object as a (Clojure) persistent collection?
05:20nipra,(#{:h} :t)
05:20clojurebotnil
05:20niprahmm..
05:20hiredmanAWizzArd: they all implemented various interfaces
05:20AWizzArdWhat common type do maps (of all kinds), vectors and sets have?
05:21ChousukeAWizzArd: IPersistentCollection I think.
05:21AWizzArdok, so it should be one of those
05:21hiredman,(map class [[] {} #{}]
05:21clojurebotEOF while reading
05:21Chousukethat won't help :P
05:22hiredman,(doc clojure.set/union)
05:22clojurebot"([] [s1] [s1 s2] [s1 s2 & sets]); Return a set that is the union of the input sets"
05:22AWizzArd,(instance? clojure.lang.IPersistentCollection clojure.lang.PersistentHashMap)
05:22clojurebotfalse
05:22hiredmanhmmm
05:22Chousuke(map (comp #{clojure.lang.IPersistentCollection} ancestors class) [[] {} #{}])
05:22Chousuke,(map (comp #{clojure.lang.IPersistentCollection} ancestors class) [[] {} #{}])
05:22clojurebot(nil nil nil)
05:22Chousukehmm
05:22AWizzArdhm
05:22hiredmanAWizzArd: correct
05:23hiredmana class is not an instance of anything but Class
05:23ChousukeI wonder if I'm just remembering the instance name wrong.
05:23AWizzArdah ok, right
05:23AWizzArd,(instance? clojure.lang.IPersistentCollection [])
05:23clojurebottrue
05:23AWizzArd,(instance? clojure.lang.IPersistentCollection {})
05:23clojurebottrue
05:23AWizzArdk, that looks good
05:24hiredman,(apply clojure.set/intersection (map (comp set ancestors class) [[] {} #{}])))
05:24clojurebot#{java.lang.Object clojure.lang.IMeta clojure.lang.Obj java.io.Serializable java.lang.Iterable clojure.lang.AFn java.util.concurrent.Callable java.lang.Runnable clojure.lang.IFn :clojure.contrib.generic/any clojure.lang.IEditableCollection clojure.lang.Seqable clojure.lang.Counted clojure.lang.IObj clojure.lang.IPersistentCollection}
05:24hiredmanancestors may already return a set
05:24Chousukeit does.
05:28AWizzArdLet's say I have a (deftype player [name points position]), what foo do I then need so that (foo Player) ==> ::player?
05:28hiredmantype
05:28AWizzArdthx
05:30AWizzArdhmm, I get a class returned: (type player) ==> user$player__2226
05:32hiredmanyou need to create a player
05:33hiredman(type (player))
05:33hiredman(type (player some-name some-points some-position))
05:34hiredmanI assumed that player was the datatype and Player was an instance
05:35AWizzArdah okay, for a concrete player instance this works
05:35AWizzArdBut can one also go there from the deftype itself?
05:36hiredmanwhy?
05:37AWizzArdI want it, for an index. Saying: instances of the type ::player sit in here.
05:37AWizzArdProgramatically it is more elegant to say: create this index for this certain type vs. creating a dummy instance and get its type
05:38hiredmanor just use ::player
05:38AWizzArdWell yes, maybe this is indeed possible, and if yes this would be the best of course.
05:38hiredmanmaybe?
05:38hiredmanthe type for the datatype player is ::player
05:39AWizzArdI just don't know yet how my code will evolve.
05:39AWizzArdI think I can directly put ::player into the sources.
05:40hiredman
06:32Licenserhmm how can I force clojure to wait 1 ms?
06:33Chousukeyou can force the current thread to wait with Thread/sleep
06:34Chousukebut of course that won't affect other threads.
06:36KjellskiWhat does that mean? "Exception in thread "main" java.lang.Exception: namespace 'de.haw-hamburg.otto-j' not found after loading '/de/haw_hamburg/otto_j' "
06:36LicenserChousuke: that is fine, I need it for a remote command to finish
06:40ChousukeKjellski: your file is missing a namespace declaration?
06:40hoeckKjellski: or your ns decl uses underscrores instead of dashes
06:43Kjellskiokay... I´ll try that..
06:44ChousukeNamespaces are actual objects so you need the (ns ...) declaration to create one for Clojure to access after it loads the file
06:47mrSpecWhere should I paste some clojure code to show it to you?
06:48Chousukelisppaste8: url
06:48lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
06:49mrSpecthanks
06:54Licenserhmm I'm fideeling with clojure & ssh, any thoughts on this: https://gist.github.com/d0facb6eab4bc5c758d1
06:55lisppaste8mrSpec pasted "load image" at http://paste.lisp.org/display/90719
06:55mrSpecIt is my first clojure program, I'd like to change image when user click on the button, Could you tell me why it loads new image, instead of reloading old one?
07:00djpowellurgh, clojure is wrapping my checked exceptions
07:01djpowellis there a good reason for that? couldn't it just declare everything to throw Exception? that's what I tend to do with the pesky things
07:02AWizzArdtechnomancy: which branch of your clojure-swank is the newest and supports most features?
07:07__JokerHi there, is there any tutorial apart from clojure.org for a starter who does not know lisp ?
07:07Licenseryes a very good one actually
07:07Licenserhttp://java.ociweb.com/mark/clojure/article.html
07:15hoeckmrSpec: because you add the new picture to the frame instead of replacing it
07:16mrSpechoeck: yes :/ but how can I replace it?
07:19__JokerLicenser : Thanks :)
07:20hoeckmrspec: or just swap the new image into the jpanel, wait a minute, I'm going to annotate your paste
07:20mrSpechoeck: ok, thanks
07:39lisppaste8hoeck annotated #90719 "updating the image" at http://paste.lisp.org/display/90719#1
07:41hoeckmrSpec: there ^^^, updated the image only and called redraw after doing so to ensure the frame is updated with the new image contents
07:44mrSpechoeck: Thanks!
07:45mrSpecbtw. do you know some good tutorials about clojure + swing?
07:45mrSpecI know lisp, but have some java problems while learning clojure
07:46hoeckmrSpec: nothing more than googling clojure + swing, sorry
07:47fogus_mrSpec: http://blog.n01se.net/?p=30
07:47hoeckmrSpec: but if you basically understand lisp, C-syntax, javadoc and the sun swing tutorials are enough, IMO
07:47mrSpecfogus_: o, thanks
07:48hoeckmrSpec: personally, I prefer using pivot (http://incubator.apache.org/pivot/ :)
07:48mrSpecyeah, I'll start doing swing tutorials
07:49mrSpechavent heard, I'll read read about it :)
08:40esjguys, is there a way to coerce lazy-seq to return something of a particular datatype ? Specifically, I'm looking to build a lazy list, such that consing happens on the front.
08:41chousertechnomancy, _ato: I don't know anything about maven repos, but does anything in the maven/lein/clojars stack address trust issues around who has the ability to upload jars in my dependency tree?
08:41AWizzArdesj: maybe (into ...) can help, depending on what you need
08:42chouseresj: 'cons' always happens on the front, it's 'conj' that's more polymorphic
08:42esjAWizzArd, yeah, I tried this and killed the laziness :(
08:42chouseryeah, it would.
08:43chouseryou should be able to use 'cons' to add to the left side of a list without touching the laziness of the 'rest' part.
08:44AWizzArd~max people
08:44clojurebotmax people is 218
08:44esjhttp://pastie.org/705840
08:44esjare my paltry attempts
08:46chouseresj: 'conj' on a lazy-seq is the same as 'cons'
08:46chouseresj: are you trying to guarantee it's a lazy seq?
08:46_atochouser: once a groupId is first used with Clojars only the initial uploader (or people they add to the group) can push jars to that group. For me that's enough security.
08:46esjdefinitely want lazy
08:46_atoMaven does have a mechanism for signing jars
08:46_atoI haven't looked into it yet though
08:46chouser_ato: ok
08:48esjchouser: I'm not getting consing to the LHS, definitely its coming onto the right.
08:49chouser,(cons 'x (range 5))
08:49clojurebot(x 0 1 2 3 4)
08:49cemerickesj: cons always adds on the left
08:50ohpauleezesj: conj may be on the right or the left. Right for vectors, left for lists and seqs I believe
08:50cemerickthe (into '() some-seq) will just reverse the seq
08:50ohpauleezbut as said, cons will always push on the LHS
08:50esjone sec please
08:50cemerickand into is not lazy
08:50_atoyou can of course also use your own repository if you trust nobody and want to vet everything that goes into. I believe this is what a lot of larger companies that use maven do.
08:52carkhello
08:53ohpauleezhi
08:53esjokie kokie.... here is the behaviour I observe
08:53esjhttp://pastie.org/705852
08:53esjadding to my confusion
08:54esji think my clojure has gone dyslexic on me
08:54cemerickI don't see anything particularly wrong there
08:55esjbut the consing is onto the RHS ?
08:55chouseresj: 'builder' is recursing in the 'rest' position, so you're adding to the right. This is normal for lazy-seqs.
08:55_atobut take 4 takes the first 4 elements from the left
08:56esjyeah, this is sensible, and I understand why it builds it that way
08:56chouseresj: you want to get a new value each time you call (first aa) ??
08:57esjessentially I want the sequence to be built out to the LHS
08:57esjdo I need to switch the (cons a b) to (cons b a) ?
08:58_atolazy sequences don't build out the LHS
08:58_atootherwise (first some-seq) would not actually be the first element
08:58chouseresj: did you see my question? I don't think we understand what you're trying to do.
09:00esjchouser: sorry. Yes, I saw your question, and understand what you're saying (that each element of the list is defined as some value with the 'rest' on the RHS). Needless to say I'm feeling increasingly silly. What I'm trying to do is build a lazy queue.
09:01cemerickwell, you've got your queue, you just need to let go of the head as you pull each element off of it with first
09:01esjas I'm filling it with a promise I need some way to determine what the most recent value is, as its lazy, there is no (last or (count.
09:01esjso thought something that build a LIFO queue would allow me use (first to get that most recent value
09:03cemerickesj: a lazy seq + first is a FIFO. You want something like a vector + pop
09:03esjcemerick: I have multiple consumers of this queue, so was worried about shortening the queue in case they didn't all see it first.
09:04chouseresj: ah, a lazy queue! you have several options.
09:04esjcemerick: yes, exactly. So what I'm looking for is the lazy-seq equivalent to build the vector
09:05esjas lazy-seq produced an interface (ISeq) I thought i coerce it, hence my initial question.
09:05chouserclojure.core/seque, clojure.contrib.seq-utils/fill-queue, and http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/
09:06cemerickthat was a nice piece of work by cgrand
09:06chouserhm, if you've got multiple consumers I'm not sure any of those will fit.
09:06chousercemerick: yeah. He beautiful code puts my fill-queue to shame.
09:06chouserHis
09:06ohpauleezchouser: why not fill-queue?
09:07ohpauleezhappens in another thread, blocks when needed, etc
09:07esjchouser: thanks for the links.
09:07cemerickchouser: is it a complete replacement for fill-queue? I haven't looked at the latter in some time.
09:07esjohpauleez: I've made fill queue work, but it gives me random java exceptions
09:08chousercemerick: pretty close. fill-queue can have a limited queue size, so the producer can block if the queue is full -- pipe doesn't support that
09:08esjprobably due to misuse from yours truly
09:08_atoesj: how are the multiple consumers supposed to work? should on consumer popping prevent the others from seeing that item or should they all see every item?
09:08ohpauleezweird, that's what I would have suggested to us
09:08esj_ato: they should all see every item
09:09_atoit sounds like pipe might be a fit then
09:09chousercemerick: also pipe has the producer close it manually, fill-queue calls a producer fn and closes it for you when you return from the fn.
09:10chouseresj: oh! if they all see every item, then all these options are back on the table.
09:10esjohpauleez: if I try to acces the queue before the first element has hit, it doesn't block me, but exceptions.
09:10chouseresj: what's your producer look like? 'seque' would be my first option unless it doesn't fit somehow.
09:11ohpauleezI see that now, sorry esj. I thought it blocked on consumer not producer. My b
09:11chouserfill-queue should block both
09:11esjohpauleez: I think it should do so, but i'm not observing that for the first element. For subsequent elements it is working.
09:11chouseresj: may just be a bug. looking now.
09:12esjlet me pastie what I'm seeing.
09:12Licenserif I fire off multiple actions into threads with future the programm will wait untill all are done before exeting right?
09:13chouserLicenser: it'll probably wait until you manually shutdown the agent pools
09:13Licenseryuck
09:13chouser:-)
09:14LicenserMy thing is I've a set of tasks that can be carried out in paralell since they are entirely unrelated from eachother
09:15ohpauleezesj: Also, you can do (Thread/sleep 1000) to save some keystrokes if you like
09:15Licensernow I thought just putting them into a future and have the program exit when all are done :P
09:15chouser(first (fill-queue (fn [fill] (Thread/sleep 1000) (fill :a))))
09:15chouserThis works for me -- 'first' blocks for a second and then returns :a
09:17weissjcan someone point me in the right direction w emacs/slime - how do i do paren matching and show different levels of paren in different colors? also if someone knows a color theme that's black bg with not too many widely differing colors?
09:18the-kennyweissj: I think there is a script for the color-thing.. just search on emacswiki.
09:19esjchouser: here is how I kill it http://pastie.org/705892
09:20esjohpauleez: thanks.
09:20ohpauleezesj: np
09:20ohpauleezesj: you can do that with all static method calls
09:21the-kennyweissj: Emacs displays the matching paren to the paren were the cursor is positioned.. I'm googling for a way to color the parents..
09:21_atosearch for "rainbow parens" and you'll find heaps of stuff
09:22_atoeg http://lemonodor.com/archives/001207.html
09:22weissjthe-kenny: i got paren matching turned on now, thanks. _ato thanks, searching
09:24weissj_ato, not finding much with 'emacs 'rainbow parentheses'" on google. just for vim
09:24chouseresj: hm... I don't get an exception there.
09:25esjchouser: interesting !
09:26chouserit takes 2 seconds because of how run-sum is written
09:30_atoweissj: hmmm you're right. there's lots of examples of screenshots and lost of people saying they hacked something together that does it but no code
09:32_atothere's various different paren modes here but none of them are your classic rainbow parens :/ http://www.emacswiki.org/emacs/ParenthesesAppearance
09:35ohpauleezDoes anyone in here use rainbow parens?
09:35chouseresj: you might try clean re-builds of clojure and contrib. if you still get that exception, maybe paste the whole thing and we can try to figure it out.
09:36esjchouser: ok, let me do that, and I'll get back to you all.
09:37st3fanhow do i explin the difference between a list and a vector to people?
09:38st3fanon one slide :)
09:38chouserjust say what they're good at.
09:38chouserlists add/remove on the left. that's it.
09:38st3fanlists are more like linked lists while vectors are direct addressable?
09:39liwpst3fan: a list is a linked list with O(n) access, a vector is like an array with O(1) access (with some caveats)
09:39_atohttp://upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Singly-linked-list.svg/408px-Singly-linked-list.svg.png
09:39chouservectors add/remove on the right, plus allow fast lookups and updates by numberic index.
09:39st3fanyeah that is good enough
09:39st3fani don't want t complicate things too much for this intro :)
09:39chousermake sure you use the word "numberic" It's important. :-P
09:40liwp:P
09:40st3fanok :-)
09:40st3fanis numberic a real word?
09:41the-kenny"numberic - A spelling mistake often made by those whom can't spell."
09:41st3fanyeah
09:41cgrandcemerick, chouser: yes, pipe doesn't introduce an inversion of control unlike fill-queue, the producer(s) must close the pipe itself(themselves).
09:41st3fanjust making sure it is not some lisp term that i need to know haha :)
09:48esjchouser: fixed ! Thanks.
09:50chouseresj: oh good. Just a clean build?
09:51esjchouser: yeah, nothing more.
09:51Maddasst3fan: the difference between a list and a vector is the difference between a duffel bag and a suitcase
09:51Maddas(ok, an infinitely long duffel bag...)
09:52Maddas(never mind, maybe the analogy is not that good after all)
09:53esjMaddas: I've had one or two infinitely heavy duffel bags in my time...
09:56MaddasYou know you haven't slept enough when you find yourself entertaining the thought of writing a guide to okasaki's paper explaining all results by analogy to travel equipment.
09:59djpowellsounds like the monads as spacesuits tutorial
10:00the-kenny,(contains? [:foo :bar :baz] :foo)
10:00clojurebotfalse
10:00the-kennyI think I understood contains? wrong...
10:00_ato,(contains? [:foo :bar :baz] 1)
10:00clojurebottrue
10:00_ato,(doc contains?)
10:00clojurebot"([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."
10:00stuartsierrathe-kenny: contains? works on sets and maps, not sequences
10:00_atoit's a very isleadingly named function
10:01cemerickdysinger: is this clj-interface by esessoms the jinterface bit you were talking about earlier this week?
10:01the-kennystuartsierra: Okay. Thank you
10:01djpowellhttp://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html is the best monads tutorial I've seen
10:01cemericktoo bad I can't read haskell
10:16stuartsierrait's pretty readable even with a casual acquaintance with haskell
10:26st3fanso in 1.1, will Datatype+Protocols+MultiMethods be a good replacement for CLOS?
10:26st3fanor at least a pretty powerful way to do OO in Clojure?
10:38stuartsierraIt's a different approach from CLOS, but should be equally powerful
10:38stuartsierraIt's a different approach from almost every OO design I've seen.
10:44chouserprotocols and multimethods don't really fit together (yet anyway)
10:45chouserthay can each make use of the same deftype objects. Maybe that's enough.
10:45chouserAnything you can do with protocols you can do more slowly with multimethods I think.
10:59lpetitchouser: do we have an idea of the performance gain one could have. An example : pprint currently is said to be slow (by its author himself). I guess it's partly due to the use of multimethods when the algorithm may extensively use recursive calls to multimethods. Should we expect a substanticial performance gain by porting it to protocols, that would make to port worth the pain ?
11:00chouserthat's a pretty comprehensive question.
11:02chouserI think protocol methods come very close to the speed of a direct java method call. I think rhickey said that protocol methods appear to be faster than the manually created clojure.core polymorphic fns (conj, count, seq, etc.) that we have now.
11:04lpetitchouser: wow
11:04chousermultimethods on the other hand always call the dispatch function first, then do a (possibly cached) inheritance test that even when cached has to do a map lookup, and then finally a "plain" function call.
11:05lpetitok
11:06chouserwhat I don't know is how much of pprint's time is spent on multimethod dispatch vs. normal algorthmic complexity, nor whether it uses features of multimethods that protocols don't provide, nor whether its speed is critical enough to warrant porting to protocols. :-)
11:09lpetitok, I guess I'll have to ask tom then :)
11:17AWizzArdIs APersistentMap the common super type of all clojure maps?
11:17AWizzArdWill it continue to be? I would like to typehint something as APersistentMap.
11:20ChousukeAWizzArd: use IPersistentMap instead
11:21AWizzArdok good
11:28polypusis clujure compiled to bytecode directly, or first translated to java which is then compiled to bytecode? just curious.
11:28AWizzArddirectly
11:28polypusby clojure i mean user programs
11:28AWizzArdalso
11:29polypusthx
11:30AWizzArdWhat happens when I typehint a slot S of a deftype T and then *not* store instances of S in instances of T?
11:30stuartsierraan exception
11:31stuartsierraoh, with deftype, don't know
11:31stuartsierrabut it should throw an exception
11:31AWizzArdfor me it does throw one if I have (deftype foo [#^int i]). (foo 10) ==> ok, (foo \x) ==> Exception
11:32AWizzArdbut if I use #^clojure.lang.IPersistentMap instead it doesn't complain
11:32stuartsierrait probably will complain as soon as you call a function on it
11:33AWizzArd(class (:i (foo "hello"))) ==> String
11:33stuartsierraeh, maybe not
11:34AWizzArdrhickey: should hints in a deftype result in (final) fields that really have this type?
11:39weissjcan someone help me understand slime/swank. i want to have it start up and read all the clojure source i already have, i tried executing this emacs lisp to change the classpath, restart slime with slime-repl-sayoonara, slime. but the REPL doesn't have any clue about my namespaces.
11:39weissjhttp://paste.lisp.org/+1Y0G
11:40stuartsierraslime/swank won't load code, just add directories/jars to the classpath
11:41stuartsierrayou still need to require/use the namespaces you want
11:43weissjstuartsierra: ok, i still can't require/use them
11:44weissjCould not locate jon/auto/clojure_ng__init.class or jon/auto/clojure_ng.clj on classpath:
11:44weissj [Thrown class java.io.FileNotFoundException]
11:44stuartsierraJava doesn't support the "~" expansion in paths; that may be a problem also
11:47weissjstuartsierra: it does actually seem to expand ~. but my execution of that block of emacs lisp to set the swank classpath doesn't work:
11:47weissjuser> (map #(.getFile %) (-> (ClassLoader/getSystemClassLoader) .getURLs))
11:47weissj("/home/weissj/workspace/clojure/clojure-1.1.0-alpha-SNAPSHOT.jar" "/home/weissj/workspace/swank-clojure/src/main/clojure/" "/home/weissj/workspace/swank-clojure/src/main/clojure/" "/home/weissj/workspace/clojure-contrib/clojure-contrib.jar")
11:47weissjthe stuff i added isn't there
11:48weissjdo i have to restart swank separately from slime? or does restarting slime do this
11:48stuartsierrayou have to restart swank/Clojure/Java to change the classpath
11:48weissjstuartsierra: how do i do that within emacs
11:48stuartsierrakill the *inferior-lisp* buffer and restart slime
11:49weissjah ok
11:51the-kennyIsn't there a function if clojure to programatically add classpaths?
11:51weissjsigh, that still didn't load my classpath. i guess executing that block of elisp doesn't do what i want? http://paste.lisp.org/+1Y0G
11:51chouser~add-classpath
11:51clojurebotadd-classpath is bad, avoid it. I mean it!
11:51chouserthe-kenny: ^^
11:53stuartsierraweissj: I don't know enough about swank-clojure internals to know what you to tell you. I use Maven to manage dependencies and start swank now.
11:53the-kennyclojurebot always bashes my suggestions :(
11:55stuartsierrathe-kenny: it's true, though. add-classpath doesn't really work
12:15dysingercemerick: that clj-interface code on github looks like a copy of the simple code in the google group under "files"
12:16dysingerthere isn't really anything more to it.
12:16dysingerI just started from scratch as I didn't need full inter-op
12:28technomancyweissj: re-invoke M-x swank-clojure-project to have the classpath updated with new jars put in lib/ etc.
12:28hiredmanAWizzArd: possibly deftype only cares about primitives
12:28weissjtechnomancy: i'll try that thx
12:29technomancyassuming you're using swank-clojure-project to begin with, which you should. =)
12:30weissjtechnomancy: i guess i'm not since emacs can't find that
12:30weissjthe autocomplete gives me only swank-clojure-import
12:30defnlol my friend just solved a project euler problem in excel
12:30esjno !
12:30technomancyweissj: http://github.com/technomancy/swank-clojure/blob/maven/README.md <= install instructions for the latest
12:32defnesj: it's true
12:32defnand quite funny
12:32defnhe solved the #11 grid problem with excel
12:33weissjtechnomancy: oh yeah i've seen this, it won't work for me, i have to use an existing project which doesnt' follow their convention. classes are in bin/
12:35technomancythat's nutty. you can try symlinking, but otherwise just try to talk them into doing things the right way. =)
12:36weissjtechnomancy: that would involve telling them that i'm using clojure and i'm not doing that :)
12:37weissji suppose a symlink
13:05grammati#rails
13:05grammatioops
13:15cemerickdysinger: ah, I see your tweet about it now
13:16cemerickand, it's AGPL, which is bizarre. And probably not legit, if it is pulled from a public forum.
13:18dysingercemerick: my thoughts exactly
13:19dysingerI look at the code and it's exactly the same IMO
13:19dysingerjust the package was changed and license added
13:19dysingerlame-o
13:19cemerickstrange
13:20dysingerGPL lame - AGPL lamer
13:20dysingereven the (comment code at the bottom is the same
13:20Licensergee and I wonder why I get highlighted :P
13:22cemerickit was so fortunate that rhickey has managed clojure's license the way he has. Those important early choices...
13:23dysingeranyway the jinterface is easy - you don't need that library - just the jinterface docs from erlang. It's easy.
13:23dysingerthe jar file comes with erlang
13:23cemerickyeah, I just noticed the name, and thought for a moment a collaborator of yours had pushed out whatever you're working on
13:24dysingerwhat I am doing is pushing strings from clojure through erlang to another clojure repl
13:24dysingerso I don't need all the other conversions.
13:57jweisstechnomancy: "You can also start the server directly from the "java" command-line launcher if you use "swank.swank" as your main class." i am not sure waht launcher you're referring to, i don't think you mean just plain java
14:03dysingerjweiss: it means put a manifest in your jar with the main class being swank.swank then launching your jar with java -jar XXXX.jar
14:03jweissdysinger: except there is no swank.swank class, just swank.swank.clj.
14:05dysingerthere is
14:06dysingerTim-Dysingers-MacBook-Pro:~ tim$ cd src/swank-clojure/
14:06dysingerTim-Dysingers-MacBook-Pro:swank-clojure tim$ ls target/classes/swank/swank.class
14:06dysingertarget/classes/swank/swank.class
14:06dysingerTim-Dysingers-MacBook-Pro:swank-clojure tim$
14:06KirinDavedysinger: Trying to get swank-clojure working?
14:07jweissdysinger: not for me
14:07jweiss[weissj@hiredgoons jon-2.0]$ find /home/weissj/workspace/swank-clojure/target/classes/ -name "*swank.class"
14:07jweiss[weissj@hiredgoons jon-2.0]$
14:07dysingeryou have to compile it.
14:07dysingermvn compile
14:07dysingerKirinDave: it's been working for a long time (swank)
14:07jweissdysinger: doesn't mvn install do the compile? i got a jar file and classes
14:08KirinDaveAhh you're helping someone else.
14:08dysingerwhat are you trying to do jweiss ?
14:08dysinger(the end goal)
14:09jweissdysinger: i went down this path because i couldn't get swank to use the right classpath from inside emacs, so i'm trying to start swank myself with the right classpath
14:09KirinDavejweiss: There is a simple variable to setq.
14:10dysingerstep 1 - install swank-clojure, clojure-mode from elpa, step 2 - M-x swank-clojure-project
14:11jweissdysinger: that will NOT work for me. i have 2 separate eclipse projects, one depends on the other. swank-clojure-project cannot work for me unless i start writing mvn scrpits, which i'm not going to do.
14:12dysingerjweiss: what build system?
14:12dysingeroh you just said "no maven"
14:12jweissdysinger: right :)
14:12dysingerso you just have eclipse with IDE project dependencies ?
14:12jweissdysinger: 2 projects each with their own /lib and /classes
14:13jweissthe 2nd proj is a dep of the first
14:13jweissthat's why i wanted to just set the classpath, start swank via cmdline and be done w it
14:14jweissbut somehow my build of it doesn't have the main class
14:14dysingerI stopped using eclipse 5 years ago so I'm not sure how to help. You need all your libs and classes in the classpath + swank and then you can run swank.swank as a main clj script/class
14:15jweissdysinger: like i showed you, swank.swank.class is not there
14:16jweissnot sure why
14:19jweissdysinger: i think my mistake was following this: http://riddell.us/tutorial/slime_swank/slime_swank.html
14:20dysingerwhere are you getting your swank from ?
14:20jweissthat uses someone else's
14:20jweissi didn't realize that until just now
14:20jweissso i'm starting over
14:23jweisssorry for the confusion :(
14:25dysingerjweiss: it does work
14:25dysingerTim-Dysingers-MacBook-Pro:swank-clojure tim$ java -cp target/dependency:target/classes swank.swank
14:25dysingerclojure.core=> Connection opened on local port 4005
14:25dysinger#<ServerSocket ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=4005]>
14:25dysingerYou can also just put (swank! 4005) in your code
14:25jweissdysinger: yeah, i believe you, i was cloning the wrong git repo
14:27jweissdysinger: ok NOW i'm back on track. much easier when you have the right repo :)
14:27dysingerthen in emacs it's M-x slime-connect
14:43jweissdysinger: ok i think i'm almost there. i think i'll try the (setq swank-clojure-classpath
14:43jweissbut what's the format? a list, or a string with : separators, or what
14:43dysingerthat's the hard ay
14:43dysingerway
14:43dysingerM-x swank-clojure-project
14:43dysingersets it on the fly
14:43jweissdysinger: i wish that would work but i have those 2 eclipse projects with their own jars
14:43dysingeroh but you don't have a build system that works across your two projects
14:44jweissi'd rather just save a snippet of elisp and just exec it when i need to
14:44dysingerM-x customize-group swank
14:44dysingerthen save it.
14:44dysingeractually M-x customize-group swank-clojure
14:44dysingersorry
14:46jweissdysinger: but this will permanently alter the cp so that i have to change it again for any other project
14:46jweissi don't want that
14:46jweissi'd rather store some elisp with my project and exec it when i am working w it in emacs
14:46technomancyjweiss: incanter has something like that; you could use it as an example
14:59jkkramertechnomancy: with lein, in project.clj, if your project name has multiple words, is there a "correct" separator? I used a dash (defproject foo-bar ...), and `lein jar` generated a file like foo-bar.jar, which is different from how .clj files are named (with underscore). not sure if it matters.
15:00scgilardithe underscore is important for files within classpath (under the classpath roots). Jar files are classpath roots so they don't need to follow that convention.
15:01jkkramerok
15:01jkkramerso hyphenation is probably fine then
15:03technomancyjkkramer: that's correct
15:09liebketechnomancy: If I want to upload all of Incanter's dependencies to clojars.org using Leiningen, do I need to create a project for each using defproject?
15:11_atoliebke: some of them will probably already be in maven central, eg: http://mvnrepository.com/artifact/colt/colt
15:12liebkeI actually need parallelcolt, and a bunch of other things
15:12technomancyliebke: yeah, you can search jarvana.com for them; the majority should be uploaded to central already
15:12liebkeokay, let me check
15:13_atoliebke: _mst's already uploaded the latest JFreeChart to clojars: http://clojars.org/search?q=jfreechart
15:13technomancy(jarvana is like mvnrepository search except with better than 50% uptime)
15:13_atobut other than that, yeah you can make a project.clj for them and generate a pom with "lein pom" and then scp it along with the jar to clojars@clojars.org:
15:14liebkeokay, that's what I'll need to do with more than a few of them
15:14_atoI recommend putting jars written by something else that you've uploaded under a person group, so define them with something like (defproject org.clojars.username/parallelcolt ...)
15:14_mstliebke: it's sickenly simple to do :)
15:15_mst(I'm coining "sickening simple" as the unofficial slogan of clojars :)
15:15_atothat's so that if they do get uploaded to maven central at some point, there won't be any confusion about which is the official version
15:16_atough.. I can't type this morning. s/something else/someone else/ s/person group/personal grouop/
15:16liebkeYeah, I wanted to avoid the naming confusion too, although I wanted to upload the dependencies under the incanter name space instead of org.clojars.liebke.
15:18kzarSo I've fucked up my recursion logic somewhere causing stack overflows. I'm trying to debug what's going on so I chucked a println at the start of the problem function. Nothing gets printed though, I would have expected thousands of lines?
15:18_atoliebke: that's fine
15:18scgilarditry (flush) after your println
15:18liebkeokay, as long as you're okay with it
15:19kzarscgilardi: Good idea, didn't help though :(
15:22hiredmanprintln should, unless you are doing something weird, flush
15:22hiredmanif you are using println, print is a different story
15:22hiredmankzar: are you doing this via slime?
15:22kzarhiredman: Yea
15:23jweisstechnomancy: i think i am almost there. i got (setq swank-clojure-extra-classpaths
15:23jweiss (append (swank-clojure-default-classpath) (list "blah" "blah1")))
15:23jweissto load all my java deps. but the clojure sources aren't there. does that need to be a separate variable?
15:24hiredmankzar: you will need to consult someone who uses slime (not me) but slime from what I have been able to gather from people in the channel looking for help has some weird io wiring
15:24jweissie, swank-clojure-library-paths ?
15:24technomancyjweiss: swank-clojure-default-classpath should include ~/.swank-clojure/clojure.jar etc., so if that's included it might be enough
15:24kzarhiredman: Oh that sounds like a pain in the arse
15:25_mstusually I find (do (.println System/err "foo") (.flush System/err)) has a better chance of not being grabbed by slime
15:25jweisstechnomancy: what i mean is, i included my clojure sources (in my own project), but on the repl, it doesn't see them. it does see all the java libs.
15:25kzarhiredman: Thanks for the warning, hmm I'll ask "googly" as my roomate calls it
15:25_mst(such output should land in your *inferior-lisp* buffer)
15:26technomancyjweiss: depends on what "blah" "blah1" etc. is replaced with I guess? is your clojure project's src/ directory in there?
15:26jweisstechnomancy: correct
15:26jweiss"/home/weissj/workspace/automatjon/jon-2.0/src/
15:27jweisstechnomancy: but when i start typing (use 'j then TAB, no autocomplete, if i type out the ns name, and finish the use, there's no ns-publics there
15:28technomancyautocomplete only works on code that's already loaded.
15:28kzar_mst: Oo thanks
15:28jweisstechnomancy: how do i load all that code?
15:28technomancyjweiss: use or require
15:29technomancywait, so you called use on it, but the ns is empty?
15:29technomancythat doesn't sound like a swank problem
15:30jweisstechnomancy: ah, i see, when i tried the use command, i fat-fingered the name. so your explanation about autocomplete means everything is working. thanks.
15:30technomancycool
15:32kzar_mst: Is there a way of stopping code that's running if it doesn't cause a stack overflow? C-g doesnt' seem to work
15:32_mstdoes C-c c-b do anything for you? It's been a while since I upgraded my slime/swank-clojure
15:33kzar_mst: yea that worked :) thanks
15:34ordnungswidrigdoes anybody now which is a working clojure/clojure-swank/slime-combination? I'm somewhat lost.
15:35technomancyordnungswidrig: go with what's on elpa; install instructions here: http://github.com/technomancy/swank-clojure/blob/maven/README.md
15:36ordnungswidrigtechnomancy: no branch of slime needed?
15:36technomancyordnungswidrig: not if you use elpa
15:37ordnungswidrigtechnomancy: and debian unstable slime works?
15:38ordnungswidrigtechnomancy: btw. is clojure-test-mode working/usable/needed?
15:38technomancyordnungswidrig: oh, I don't know about slime from apt-get. I think if you use elpa it will have higher-priority though.
15:38ordnungswidrigok
15:38technomancyclojure-test-mode works for me... that's all I will say.
15:38technomancyit might be dependent on project layout
15:39gravitytechnomancy: kudos for lein! It's exactly what I've been wanting!
15:49kotarakCould someone reproduce the problem I have with defprotocol and def? http://tinyurl.com/yhqmvud
15:50kotaraktechnomancy: where does the name leiningen come from? I know a village "Altleiningen" ("Old Leiningen")
15:50kotarakBut I somehow don't believe, that that's related. ;)
15:51the-kennyThere's a town in Germany called "Leiningen"
15:51kotarakAs is above mentioned village.
15:51polypusLeiningen vs the ants
15:53_atohttp://en.wikipedia.org/wiki/Leiningen_Versus_the_Ants
15:54polypusa short story. http://en.wikipedia.org/wiki/Leiningen_Versus_the_Ants
15:55polypuswas just reading about it this morning
16:01spuz_ato: just saw clojars, looks very nice :)
16:01spuzalso good job on squeezing another pun out of Clojure :)
16:02spuzI'd like to know though, where are the libraries hosted, and can we rely on them always being there?
16:03kotarakI believe Alex does this on spare time, no?
16:03kzarI wish we could get closure on these puns
16:03hiredmanhttp://daeken.com/designing-a-net-computer <-- ho hum, lisp machine
16:10_atospuz: they're hosted on a Linode.com VPS which in my experience so far has very good uptime
16:10liebketechnomancy: I've got one java class that needs to be compiled first in Incanter, can I specify that in Leiningen?
16:10_atoif the repository grows in size substantially I'll probably move them to S3
16:11spuz_ato: what about bandwidth and storage costs?
16:13_atospuz: there's a soft 200 GB a month for bandwidth which I think should be fine unless the Clojure community suddenly gets much larger, again if it becomes a problem I'll move to S3. If it starts becoming really expensive (and it'd take a *lot* of traffic for that) I'll probably ask if anyone wants to sponsor it
16:13spuz_ato: sounds good :)
16:19kzarso (if '() true false) returns true, what's the best way to test if a sequence is empty?
16:20danlarkincall seq on it
16:20froog,(empty? '())
16:20clojurebottrue
16:20Chousukeusing seq is often more idiomatic though.
16:21Maddas,(if (seq '()) true false)
16:21clojurebotfalse
16:22kzar,(doc "seq")
16:22clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol
16:22kzar,(doc seq)
16:22clojurebot"([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable."
16:23kzarI'm unclear what it meens by "Returns a seq on the collection", what's the difference between a seq and a collection?
16:23danlarkinlaziness is your issue
16:23Chousukea seq is just a view on a collection
16:24kzardanlarkin: always has been
16:24danlarkin:)
16:24danlarkinlazy evaluation, I mean
16:24kotarakkzar: a seq is an abstract view on the collection.
16:25kotarakkzar: so seqs can be infinite, eg. (iterate inc 0)
16:25kzarseq and lazy sequence are interchangable?
16:26patrkriscgrand: hey. any idea why (html-resource "test.html") would give NullPointerException with enlive?
16:29danlarkinkzar: no
16:30danlarkinyou can't test a lazy seq for truth though
16:30danlarkinbecause in order to test it, you have to evaluate it, and then that breaks the rules of keeping it lazy
16:30danlarkinthat is my understanding
16:30fanaticokzar: http://clojure.org/lazier explains the new model.
16:34kzarthanks I'll read that
16:36solussdwhen extending a class in the (ns macro using (:genclass :extend), do I specify the parent class like this? org.something.package.theclass ? or do I need to :import it first?
16:38liebkeLooking through the source for Leiningen, it doesn't appear to be able to compile Java classes in a project yet, can anybody confirm this?
16:39kotaraksolussd: org.something.... you have to qualify everything not in java.lang.
16:42solussdthanks
16:48ordnungswidrigIf have a complex decision tree which shall be parametrized by functions that each represent a simple decision and basically return true/false. How would you model it? A map of functions, multimethod or, now new protocols?
17:06jweissanyone know if there's context help in the source editor for clojure-mode or is that only for swank
17:06jweiss(emacs)
17:07ordnungswidrigjweiss: context help regarding what exactly? Doesn't C-h help you?
17:08jweissordnungswidrig: i mean like tab completion for vars defined at least in this file
17:08jweissor say, classes in the classpath if i'm doing java interop
17:12ordnungswidrigjweiss: I think you have to refer to swank. completion is usually C-c TAB
17:12jweissordnungswidrig: aha! thats what i was looking for, thanks
17:13ordnungswidrigjweiss: C-h b shows you the key bindings for the buffer
17:15kzarIs there any way to get more useful debug information? It's giving me the name of my function that caused there error but not the problem line / call
17:18cgrandpatrkris: what is your file layout? html-resource (or rather the classloader) does not find the resource named "test.html"
17:19patrkriscgrand: i just run the clojure repl in the same directory as the file i'm trying to load
17:19patrkriscgrand: i can get it working by passing ia java.io.FileReader to (html-resource ...)
17:19fyuryuanyone wants to test leiningen on Windows?, I translated the bash script to powershell
17:21fyuryuworks on my machine (tm)
17:21cgrandif you want to use (html-resource "test.html") "test.html" have to be on your classpath
17:22patrkriscgrand: aaah... sorry, missed that... if I have the directory that contains test.html in the classpath, is that enough?
17:22cgrandit should (I have a little doubt since test.html has no "namespace")
17:23patrkriscgrand: ok, thanks
17:26cgrandpatrkris: must go, send a mail to the google group if you have any other problem with enlive.
17:26patrkriscgrand: sure, thanks
17:29scottjDoes enlive work when you need to login to a website or handle stuff with javascript, or is htmlunit still the way to scrape those kinds of sites?
17:35dnolenscottj: ? it's just a templating library.
17:38scottjI read a blog post that showed how enlive could be used to scrape, and it looked pretty easy for basic websites, but I was wondering if it connected well with something else (i.e. htmlunit) to handle scenarios w/ js and login
17:45dnolenscottj: again it's just a general html templating library. It's for manipulating html. it doesn't handle login per se, though it can certainly help in rendering a login page with the right css and js included in the page <head> tag.
17:58{newbie}Do you guys think it is good idea to simulate a low level and thus highly mutable environment with clojure
17:58{newbie}(I need to make a simulation of virtual memory)
18:01_ato{newbie}: sure. You can always just use arrays instead of clojure collections (of course arrays won't be thread safe, but for a low level simulation you probably don't want it to be thread safe as real memory isn't automatically thread safe)
18:02{newbie}_ato: the simulation won't be multi threaded of course
18:02{newbie}so thread safety is not an issue
18:02_atoalthough if you want a simulation where you cheaply backtrack and trace changes and the like, clojure's vectors might actually be quite handy
18:03{newbie}_ato: there wil be no backtrack
18:03{newbie}just chaging pages
18:07kzarWhat's the best way to debug problems with clojure code if you use Emacs? It doesn't seem to give you as much information as with SBCL
18:07fanaticokzar: http://georgejahad.com/clojure/cljdb.html
18:08fanaticohaven't used it yet, though, so hopefully someone here knows it a little better.
18:09froogI haven't tried cljdb either yet, but there's a git repo as well: http://github.com/GeorgeJahad/cljdb
18:12kzarI was just reading about it, it seemed like I would have to tell it which file has my code and implicitly the file would have to be all neat, up to date and saved. I don't know if that's right but if so it would kind of mess up my way of working. I like to just mess around in a buffer and eval something here n' there while I'm figuring out how stuff is going to fit together
18:14kzarHmm I'm giving it a blast anyway
18:22fyuryutechnomancy: ping
18:28kzarDo you know how to add command line arguments to the clojure process that slime starts? I want to specify a port to attach a debugger
18:36ordnungswidrigkzar: (setq swank-clojure-extra-vm-args '("-agentlib:jdwp=transport=dt_socket,address=8021,server=y,suspend=n"))
18:43kzarordnungswidrig: That doesn't seem to work :( I checked swank-clojure.el and it seems to use that variable so I don't see the problem
18:44kzarI evaled that and it set the variable, I killed inferior-lisp and did M-x slime again. It started up but a quick telnet to 8021 said it's closed and I looked at the java process and I don't see those extra arguments
18:46ordnungswidrigkzar: hmmm, I remember I had problems with that, too. I switched to staring the process manually or by maven
18:48kzarordnungswidrig: I guess ultimately I will need to start the process with a script because I'm going to use it for webdev. It would be cool to have it all working locally on my laptop though in case I want to play with clojure when I don't have net access
18:48ordnungswidrigkzar: Nothing prevents you from having it locally.
18:51kzarordnungswidrig: Oh yea that's true I could have a script to run clojure locally and then connect with slime-connect?
18:52ordnungswidrigof course.
18:54ordnungswidrig(swank.swank/start-server "/tmp/swank.port" :port 4005 :dont-close true)
18:54ordnungswidrigthen M-x swank-connect RET localhost RET 4005 RET
18:55kzarordnungswidrig: Cool thanks
19:32kzarWhen I google for swank clojure I see two githubs, technomancy's and jochu's. I installed swank from clojurex and I can't figure out which one it uses. How can I figure out which one is being used by clojurex so that I can report a bug?
19:33cheddarkzar, did your install do a git clone of the directory?
19:33cheddarif so, you can do a
19:33cheddargit remote -v
19:33cheddarin the directory and it will tell you where it was cloned from
19:34kzarcheddar: Cool that worked
19:34cheddarHello clojure peeps. I'm using clojure.lang.Script from the command line and it seems to run everything fine, but never exits. Any ideas about what I might be doing to make it not exit? (I'm hoping this has happened to someone else)
19:37Chousukecheddar: you might need to execute shutdown-agents at the end of your script
19:38cheddarah, so agents will keep the vm alive? I was wondering about that
19:38cheddarI'm using the http.agent stuff from contrib
19:38cheddarso that's most likely what it is
19:40cheddaryup, that seemed to work
19:40cheddarthanks
20:21quidnuncHow do you use clojar as a user
20:27cgordonI'm trying to understand namespaces. Why is it that "in-ns" is recommended for use from the REPL, and not "ns"? I think I understand the difference between the two, but I can't answer that question, so I must be missing something.
20:28chousersome of the reasons are philisophical. I think the major techincal reason is that 'ns' brings in all the names from clojure.core, regardless of any earlier 'ns' that may have restricted that.
20:29chouser'in-ns' doesn't -- it creates the namespace if it doesn't exist, but otherwise only does to it what you specifically request.
20:29cgordonhmm, but "ns" would only bring them in for the namespace you specifically switched to
20:30ChousukeI think ns redefines any possibly existing namespaces
20:30chouserright, but if you were switching to a namespace that had renamed a core function, for example, using 'ns' to switch to it could overwrite things like that.
20:30cgordonso maybe you're saying that if I start with "(in-ns 'foo)", then switch to "(in-ns 'user)", then later go back to foo, but accidentally type "(ns foo)", I would inadvertently pull in a bunch of extra stuff?
20:30chousercgordon: right
20:31chousercgordon: don't tell rhickey, but sometimes I switch namespaces at the repl using 'ns', just to save a few keystrokes.
20:31cgordonaha, that makes a lot of sense
20:31cgordonso it's really a matter of keeping it straight in your head
20:31cgordon:)
20:32cgordonthis may be blasphemy, but it feels like Clojure namespaces were designed to be identical to Perl's packages
20:32cgordonthey even use the same keywords: use, require
20:34lisppaste8kzar pasted "server.clj" at http://paste.lisp.org/display/90761
20:34lisppaste8kzar annotated #90761 "error" at http://paste.lisp.org/display/90761#1
20:34kzarSo I'm trying to start clojure with a swank server from a script. If I run clj and type the 4 commands in it works fine. If I save those commands to server.clj and run clj server.clj I get an error "java.lang.IllegalAccessError: Context classloader is not a DynamicClassLoader (server.clj:0)"
20:34kzarIt doesn't seem to make any sense
20:35chousernamespaces were designed first with fns like in-ns, import, refer, and load. Lib support was added later to do those things in combinations with things like ns, use, and require.
20:42cgordonkzar: seems to be a problem with the (add-classpath...) line
20:43kzarcgordon: Yea, but when I run it from clj repl it works fine
20:43cgordonif I remove that, and run your script after just setting CLASSPATH (on the command line), it works
20:43kzarcgordon: I paste the lines of server.clj into a repl and it works fine but if I run clj server.clj to load it I get that error.
20:44cgordonkzar: yep, I got that, and I'm sorry I can't be more help, but I can get the script to work by removing the "add-classpath" line and setting the CLASSPATH on the command line
20:44cgordonI'm looking at the documentation for add-classpath now
20:44cgordonclearly there is something about the REPL that changes its behavior
20:44kzarcgordon: I can't remove that line because my clj command doesn't add swank for me so without it I get an error that it doesn't know what swank is
20:45cgordonkzar: charles-gordons-computer:~/Projects/clojure cgordon$ CLASSPATH=/Users/cgordon/lisp/clj/swank-clojure/src/main/clojure/ clj-env-dir swank.clj
20:45cgordonConnection opened on local port 4005
20:45cgordonmy clj command doesn't add swank either
20:48kzarcgordon: I don't understand that last part, what's that?
20:48cgordonsorry, that didn't paste very well. That is the command line I used to run your server.clj
20:48cgordonthe last bit is the output (which opened a connection)
20:49cgordon(require 'swank.swank)
20:49cgordon(swank.swank/start-server "/tmp/swank.port" :port 4005 :dont-close true)
20:49cgordonthat is the server.clj I used
20:51lisppaste8cgordon annotated #90761 "source of exception" at http://paste.lisp.org/display/90761#2
20:52cgordonkzar: I found the source of the exception in clojure/lang/RT.java
20:52cgordonstill trying to understand why it is throwing
20:52kzarcgordon: Yea I'm brand new to clojure and I haven't ever done any java so that doesn't mean much to me :(
20:53kzarcgordon: I tried to emulate your command, I didn't really understand it, is this right?
20:53kzarCLASSPATH=/Users/kzar/clojure/swank-clojure/src/main/clojure/ clj server.clj
20:53cgordonkzar: the add-classpath function is very simple, and just calls out to clojure.lang.RT.addURL, which is doing some Java magic to load the appropriate class file
20:53cgordonkzar: I'm also new to Clojure, and not much of a Java expert :)
20:55cgordondid that work?
20:55cgordonI found the documentation for Thread.getContextClassLoader, but it's greek to me
20:55cgordonhttp://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#getContextClassLoader%28%29
20:56cgordonit does say that it depends on the initial context (the parent thread), so that would explain why it works differently under the REPL
20:57kzarcgordon: No, setting CLASSPATH doesn't seem to have an effect for me. I can't see any mention of it in the clj bash script either
20:57cgordonis your clj bash script overwriting CLASSPATH?
20:57twbrayWrote up latest cut at Clojure in Wide Finder: http://www.tbray.org/ongoing/When/200x/2009/11/18/Clojure-Parallel-I-O
20:57cgordoncan you paste it?
20:58kzarcgordon: http://github.com/citizen428/ClojureX/blob/master/clj
20:58kzarcgordon: It doesn't seem to be
20:59cgordonkzar: try changing this "CP=$PWD:$CLOJURE:$JLINE:$CONTRIB" to this "CP=$PWD:$CLOJURE:$JLINE:$CONTRIB:$CLASSPATH"
21:00kzarcgordon: Hmm no that doesn't help
21:01beutdeucehow do i check if an element is part of a list
21:01cgordontwbray: I read your first post on Clojure with a lot of interest. I'm new to Clojure (and Lisp in general), and ran into nearly all the same problems you did (particularly with namespaces!)
21:01cgordontwbray: looking forward to the latest WideFinder; I've been following it since you did one on Erlang
21:02cgordonkzar: hrm, well, I'm not sure what to say. I am using "clj-env-dir", which I got from following these instructions: http://riddell.us/tutorial/clojure/clojure.html
21:02kzarcgordon: If I echo $CLASSPATH from the script it's blank. Wierd because if I echo it from the shell before and after I run the script it's not
21:02cgordonoh, that is odd
21:04cgordonkzar: maybe cheat and add "CLASSPATH=/Users/kzar/..." at the top of the clj script? Just to see if it works?
21:09kzarcgordon: Wow yea that works
21:09cgordonkzar: great!
21:09cgordonkzar: I'm completely confused as to why it isn't getting the CLASSPATH from the shell
21:09kzarcgordon: Thanks for your help, I'm getting a headache so I'm gona go eat some food... been staring at this for hours now
21:10cgordonkzar: no problem :)
21:10kzarcgordon: I'm going to figure that out and then learn how to commit patches to git and try and get your change added to clojurex
21:12kzarcgordon: Oh whoops I'm supposed to set the classpath in a .clojure file. I'll have a look at it later anyway http://mark.reid.name/sap/setting-up-clojure.html
21:12kzarcgordon: thanks for the help, it was starting to really piss me off heh
21:13cgordonkzar: yeah, that was a weird one
21:34beutdeucecan someone please help me figure out why am i getting an out of bounds when i shouldn't? thanks: http://pastie.org/707046
21:39_mstbeutdeuce: your 'recur' form isn't dependent on the above condition--it runs no matter what
21:39beutdeuceoh right
21:40beutdeucethanks
21:40_mstno problem
21:44beutdeucehmm, where would i place the tail recursion call then?
21:45beutdeucewell, i could use a do block
21:45_mstI think you want the recur form to be in the 'else' position of your if
21:46_mstand then make the 'cond' the second argument of your recur
21:46_mstsort of turning the whole thing inside out
21:47beutdeucehmm, right, that makes more sense
21:47_mstI'm also not sure the 'contains?' on lists will quite do what you want; you might be better off using sets like #{"man" "ate"} instead
21:48beutdeucek, i will try that. Why though? just curious
21:49_mst,(contains? '("hello" "there" "world") "hello")
21:49clojurebotfalse
21:50beutdeucehmm, why is that?
21:50chouser'contains?' is for keys in an associative collection.
21:50beutdeuceoh,k
21:50chouser,(contains? {:h 1, :n 2} :n)
21:50clojurebottrue
21:50beutdeucewhat would be the equivalent of nth for sets?
21:51_mst,(contains? #{"a" "the" "an"} "the")
21:51clojurebottrue
21:51_mstor just:
21:51_mst,(#{"a" "the" "an"} "the")
21:51clojurebot"the"
21:51chouserhash sets don't keep things in any particular order, but you can walk through a seq on a set if you want to
21:52chouser,(nth (seq #{5 6 7}) 1)
21:52clojurebot6
21:53beutdeucehm, k
21:54beutdeucehmm, *command-line-args* returns a list. How do i make a set of the (rest) of the list?
21:54beutdeuceif i try to do that, i get a set of a list of the rest
21:54beutdeucei just want a set of the rest
21:55chouser,(set (next '(1 2 3 4)))
21:55clojurebot#{2 3 4}
21:55beutdeuceah, k, so i use next. i assume thats the set equiavalent of rest?
21:57beutdeucehmm, that doesnt retain the order of the elements which is important
21:57chouserno, rest and next both operate on seqs.
21:57chouserbeutdeuce: no, sets don't maintain order
21:58_mstah hang on, so don't want to treat your user input as a set anyway, do you? I meant to suggest treating your article/verb/noun lists as sets
21:59beutdeuceoh, ok
21:59_mstsince all you ever want to do is test whether a given word appears in one of those lists
21:59beutdeuceyes
21:59beutdeucemhm
21:59Qvintvsbased on this code: http://pastebin.com/m6c8cb97f, what does it seem like the result of (myparse [:subject]) to be. I'm trying to get it to be [:subject], but I keep getting nil.
22:01beutdeuceQvintvs: lol, hey
22:01Qvintvsbeutdeuce, hehe, hey
22:29Qvintvsare people as lost as i am or is no one here? :/
22:33djorkwhat is the difference between a map entry and a vector with two entries
22:35djorksince they pr the same output
22:35chouserQvintvs: only the final expression in a 'when' clause is returned
22:35_atodjork: they're different java classes, I haven't tried it but I assume you can't use assoc and such on a map entry
22:35chouser,(when true :this :that :the :other)
22:35clojurebot:other
22:36chouserhm. I'd never tried before, but it appears you *can* assoc on a mapentry.
22:36chouseryou just get a vector back.
22:37Qvintvschouser, hm, how could I rearrange that so that the result of the (if (= (first list) :subject)... statement is returned?
22:38chouserQvintvs: 'cond' might work well for you here.
22:41Qvintvschouser, i'll look into cond, but what's the issue with this version: http://pastebin.com/m1387a91b ?
22:43lisppaste8kzar annotated #90761 "Solution" at http://paste.lisp.org/display/90761#3
22:50chouserQvintvs: what's the final expression of the 'when'?
22:50Qvintvschouser, huh? I don't see a when in that version
22:51chouseroh. right, sorry.
22:51chousersame thing applies to fns
22:52chouserthe function returns the value of the final expression in its body.
22:52Qvintvsahhh, so it will always return the result of (if (empty? list) nil) ?
22:52chouserexactly
22:52chouserwhich, if the list is empty, will be nil. Otherwise, it will be nil.
22:52Qvintvsbut if I use cond, it will return the value of the expression following the first test case that is true?
22:53chouseryes
22:57Qvintvschouser, thx, got it working now :)
23:02chousergreat
23:04danlarkin_ato: what's the state of the art on lein/clojars integration, does the plugin still exist?
23:04danlarkinI can't find it now
23:32piccolinoThis is probably a dumb question, but is there some function that will let you take a file or string that contains Clojure code, and parse it into its data structure form? (like so you could pass it to eval)?
23:32danlarkin(read-string (slurp "/path/to/file"))
23:33piccolinoOh awesome, thanks.
23:33piccolinoI was looking in clojure.org/evaluation and didn't see anything.
23:35tomojare you really just passing it to eval?
23:35piccolinoNo, I wanna mess with it first.
23:36tomojah
23:49technomancy_ato: (and whoever else cares) http://groups.google.com/group/leiningen <= go join!
23:49kzarI've got Jswat attached to my clojure process and emacs connected via swank but when I eval dodgy code nothing happens in jswat and emacs displays the same info as before
23:52kzaroo looks snazzy
23:55_atotechnomancy: ooh, ooh, I'm in. :)
23:55technomancy_ato: there's also a #leiningen channel, but it's just me and danlarkin
23:55cgordonstupid question: is it possible to have a "var" that isn't bound to a symbol?
23:56technomancycgordon: sure; declare
23:56cgordontechnomancy: cool, thanks
23:59cgordonhmm, alright, another dumb question: why would I need forward references?