#clojure logs

2010-08-06

00:04BahmanHi all!
00:04pdkOH YES YES
00:10cais2002(doc throw-arg)
00:10clojurebot"clojure.contrib.except/throw-arg;[[& args]]; Throws an IllegalArgumentException. All arguments are optional: cause? format? format-args* - cause defaults to nil, if present it must be a Throwable - format is a format string for clojure.core/format - format-args are objects that correspond to format specifiers in format."
01:26vIkSiThi all
01:26vIkSiTis anyone here using clojure-http-client?
01:27vIkSiTfor some reason, a lein uberjar fails on any code that uses it
01:27vIkSiT(ns foo (:use [clojure-http.client :only [url-encode]]))
01:27vIkSiTlein deps works.
01:28vIkSiTException in thread "main" java.io.FileNotFoundException: Could not locate clojure_http/client__init.class or clojure_http/client.clj on classpath
01:28vIkSiTon a lein uberjar.
01:31wwmorganvIkSiT: I'm having trouble replicating it. What versions of clojure, leiningen, and clojure-http-client are you using?
01:32vIkSiTwwmorgan, let me pastebin that
01:34vIkSiThttp://paste.lisp.org/display/113241
01:34vIkSiTwwmorgan, ^
01:35vIkSiTlein deps goes through fine
01:35vIkSiTpasting lein uberjar error.
01:36vIkSiTwwmorgan, http://paste.lisp.org/display/113241#1
01:50wwmorganvIkSiT: in your ns declaration in cljtwitter.clj, you need to (:use [clojure.http.resourcefully]). Not clojure-http.resourcefully
02:18quotemstrAre there any plans to get symbol-macros into the core?
02:20tomojquotemstr: I still don't know what you mean
02:20tomojbut there is &env, maybe that's what you're looking for?
02:21tomojprobably not actually
02:21tomojah
02:21tomojprobably so
02:21quotemstrI'm talking about CL-style symbol-macros.
02:22quotemstrAs I mentioned in the other channel, without core support, symbol-macros can't become part of the lexical environment object.
02:22tomojI was talking about the environment thing
02:22tomojall macros receive an implicit parameter &env
02:23quotemstrOh, the parameter itself is called "&env" anaphorically?
02:28tomojyeah
02:31tomojI actually have no idea how to use it though
02:31quotemstrtomoj: You want to use it when you write a tree-walker so you can be sure you've completely expanded all your arguments.
02:31tomoj&env is a map of symbols to clojure.lang.Compiler$LocalBinding's
02:32tomojbut clojure.lang.Compiler$LocalBinding seems to give no way to access the value
02:32quotemstrHrm, that's interesting. macroexpand doesn't take an environment argument.
02:36tomojI'm now wondering what the hell &env is there for
02:39tomojoh
02:39quotemstrOh?
02:40tomojhttps://gist.github.com/21ca8d61004767771bc7
02:40tomojthat can't be the way we're supposed to use it...
02:40quotemstrThat looks evil.
02:40tomojyeah
02:41quotemstrWhat are .eval and .init doing here?
02:41tomojthat's the only way I could find to get a value from a LocalBinding
02:41sid3kmorning guys
02:41tomoj.init on the LocalBinding returns an Expr, then .eval to get the value
02:42tomojunless there's something I'm missing &env must only be useful for compiler hackers
02:43quotemstrAh, I see.
02:43quotemstrsid3k: It's bedtime for me, you insensitive clod.
02:47tomojoh, found something in the log
02:47tomojwell..
02:48tomojthe suggestion was to just look at the keys in &env and use resolve
02:48tomojthat doesn't seem to work
02:51vIkSiThey wwmorgan
02:51vIkSiTlooks like I got disconnected before..
02:51wwmorganvIkSiT: did you get my fix?
02:51LauJensenGood morning all
02:51vIkSiTwwmorgan, you mentioned . instead of - in clojure.httpd
02:51vIkSiTer http*
02:51vIkSiTbut now I get a : Exception in thread "main" java.lang.IllegalAccessError: spit does not exist (client.clj:1)
02:52wwmorganon lein uberjar?
02:53vIkSiTwwmorgan, thats right
02:56vIkSiTwwmorgan, I changed clojure-http.resourcefully to clojure.http.client
02:56vIkSiTsince thats what i wanted to test in the first place
03:01vIkSiTwwmorgan, ideas?
03:01wwmorganvIkSiT: I can't seem to reproduce it. What version of leiningen are you using?
03:02vIkSiTLeiningen 1.2.0 on Java 1.6.0_20 Java HotSpot(TM) 64-Bit Server VM
03:05bartjhow do I get a double quote ?
03:05bartj, (def x "\"")
03:05clojurebotDENIED
03:05bartj(def x '"')
03:05bartjboth don't work as expected ?
03:05Chousukejust \"
03:06bartjoh, I don't need to quote the double quote ?
03:06Chousukeif you want it as a char, no.
03:06bartjChousuke, gee thanks!
03:07wwmorganvIkSiT: works on my machine :-/ http://paste.lisp.org/display/113241#2
03:07vIkSiThrm
03:08vIkSiTinteresting
03:08vIkSiTWARNING: spit already refers to: #'clojure.core/spit in namespace: clojure.http.client, being replaced by: #'clojure.contrib.duck-streams/spit
03:09vIkSiTi wonder if thats causing this
03:13vIkSiTthere we go
03:14vIkSiTreplacing 1.2.0-master-SNAPSHOT with 1.2.0-beta1 gives me the warning as above
03:15vIkSiTwwmorgan, ^
03:16tomojbartj: what did you expect "\
03:16tomojer
03:16tomojwhat did you expect "\"" to do?
03:16bartjis there a library function which prefix and suffixes a string with a character ?
03:17bartjtomoj, was expecting a double-quote string
03:17wwmorganvIkSiT: is that good enough for your purposes?
03:17tomojisn't that what it is?
03:17bartjtomoj, yes, that was stupid on my part
03:17vIkSiTwwmorgan, :) well it works. but I guess the important point is - when I do make this a production script - I wouldn't want it totally breaking heh
03:18quotemstr /join #cygwin
03:18quotemstrDamn spaces before commands.
03:19Deranderdon't worry
03:19DeranderI just saw #hunter2
03:21quotemstrAt least it wasn't #midgetfetish or something equally compromising to any future political campaigns.
03:32bartjquotemstr, have only heard of widgets :)
03:46bartjer, why is (not (empty? coll)) not advised (as per the documentation)
03:48quotemstrWhere does it say that?
03:50Chousukebartj: because (seq coll) does the same thing.
03:50Chousukebartj: in fact, empty? is defined as (not (seq coll))
03:51Chousukebartj: It's not wrong to use not + empty?, but using seq is idiomatic
04:15bartjChousuke, thanks again!
04:15slyrusname for my nascent computational chemistry package -- chemiclj or covalence? or go with the idea of naming it after a famous, relevant person and call it lewis?
04:16bartj, (doc empty?)
04:16clojurebot"([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"
04:16bartjaargh, quotemstr has quit
04:18LauJensenI think ERC has a hook, where if you are chatting with someone and that person quits within some timeout, you actually see that quit message - but I might be mistaking ERC for something else
04:19slyrusany votes before I turn in for the night?
04:19LauJensenslyrus: clovalence? :)
04:20slyrushrm... I'll sleep on that. thanks.
04:20tomoj"lewis" seems bad for google
04:20slyrusyeah, there is that...
04:20tomojI guess it doesn't matter much though
04:21tomojunlikely people will try to find your app by googling for "lewis"
04:28LauJensentomoj: but then again, you could say the same about 'jetty' but most people end up there anyway
04:38neotykHi *
04:39neotykis there a test coverage tool for clojure already?
04:40lpetitLauJensen: hi
04:40LauJensenhey Laurant
04:47esjmorning guys
04:54LauJensenmorning home dawg
05:22AWizzArd~seen ordnungswidrig
05:22clojurebotno, I have not seen ordnungswidrig
05:23AWizzArd~max people
05:23clojurebotmax people is 283
05:58xkbis there something like a "times" function in clojure?
05:58xkbto chain a function?
05:59Chousukerepeatedly?
05:59Chousukeor iterate
05:59xkb(times 10 (mutate-code code))
05:59xkbsomething like that
05:59Chousukelooks like you might want iterate
06:00Chousukeit'd work something like (nth 10 (iterate mutate-code code))
06:00xkbah yes
06:00xkbthanks
06:01xkbhmm I get an error on that
06:01xkbCons cannot be cast to Number
06:02Chousukehm, I suppose I got the order the wrong way around
06:02xkblol, reminds me to read (doc
06:02xkb:)
06:05LauJensenor you slime, it prints the argument list in the minibuffer
06:05LauJensens/you/use/
06:05sexpbotor use slime, it prints the argument list in the minibuffer
06:07ben_ms/.*//
06:07ben_mAww :3
06:20bartjtrying to detect russian characters
06:20bartjwhy doesn't this work please - http://pastebin.org/450630
06:20bartjbasic idea is:
06:20bartj(intersection #{russian character} (re-seq #"." "string"))
06:21bartjcurrently get a: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPersistentSet
06:21Chousukeyou need to make a set out of the sequence first
06:23bartjChousuke, yes, I unforunately tried with a sorted-set
06:24bartj(set [coll]) != (sorted-set [coll]) ?
06:24Chousukeheh, hmm
06:24Chousuke(doc sorted-set)
06:24clojurebot"([& keys]); Returns a new sorted set with supplied keys."
06:24Chousukeso if you want a sorted-set of a collection, you need to use apply
06:27bartjI am afraid, I don't really understand why I need an "apply" here
06:27bartjnaively, wouldn't you just expected sorted-set to work ?
06:31Chousukebartj: sorted-set doesn't take a collection as an argument, so you need apply
06:32bartjChousuke, gee thanks! I just over-looked that.
06:57raekjava regexes has unicode class support
06:58raekso \p{L} matches a unicode code point that is a letter
06:58raekno matter what script
06:58raekbartj: maybe there is a unicode class for cyrillic letters
07:00raekhttp://www.regular-expressions.info/unicode.html
07:01raek#"\p{Cyrillic}" should work... :)
07:02bartjraek, hmm, thanks - will look into that!
07:02raekhrm, potentially disregard that... script matching might not be supported by java
07:18AWizzArdChallenge: is there a very simple way to mirror/proxy a file in Compojure? I would like to offer a .swf file on my server which is not local, but to which I have remote access. This .swf file changes constantly, so I don't want to cache it locally on my disk.
07:19AWizzArdCurrently I have a byte-array BA and .read from a clojure.java.io/input-stream into BA, then save it as a temp file on disk and return (File. "mytemp.swf")
07:21tomojon every request?
07:21tomojyour clients don't have remote access, I guess?
07:23AWizzArdThe setup is a little complicated. The Flash thing wants to use a webservice, but is restricted to do cross-site-requests.
07:23AWizzArdSo I want to proxy the .swf transparently on my server.
07:26tomojah
07:26tomojI don't actually have any advice, I was just curious :P
07:27AWizzArdOki, I think I can use an input stream directly. Will try that.
07:38raekserving from disk should be fairly straight forward
07:38raek...but that wasn't what you needed, right?
07:39raek,(-> (java.net.URL. "http://google.com/") bean :contents class)
07:39clojurebotjava.lang.NullPointerException
07:39raek,(-> (java.net.URL. "http://google.com/") bean :content class)
07:39clojurebotjava.lang.reflect.InvocationTargetException
07:39raek,(-> (java.net.URL. "http://google.com/") bean)
07:39clojurebotjava.lang.reflect.InvocationTargetException
07:40raek,(.openStream (java.net.URL. "http://google.com/"))
07:40clojurebotjava.security.AccessControlException: access denied (java.net.SocketPermission google.com:80 connect,resolve)
07:40raekI think that should make an input stream
07:41raekmaybe that can be passed as thre body
07:41raekiirc, the body of a compojure response can be a input stream
07:41AWizzArdServing from disk is done simply like: (GET "/my/file.swf" (File. "/some/path/to/app.swf"))
07:41AWizzArdraek: yes, and this is what I am trying now
07:42AWizzArdThe only question I have is: who will close this IS?
07:43bartjneotyk, this is the only link I could find related to doing coverage using clojure - http://www.talios.com/code_coverage_of_clojure_code.htm
07:43bartjneotyk, hope this helps!
07:45raekAWizzArd: I think I read somewhere that compojure closes the IS after it is done with it
07:45raekor was that ring?
07:45AWizzArdProbably ring then.
07:45AWizzArdAnyway, would be good. Otherwise I have a resource leak.
07:46raekit makes sense for it to close the stream
07:57AWizzArdraek: yes, and I just checked that it indeed does close it.
08:04old_sound_hi guys
08:04old_sound_and gals…
08:04old_sound_I have a question regarding import and java packages
08:05old_sound_how to do something like this: import com.blah.me.something.*
08:05old_sound_I
08:05old_sound_I've only seen examples of importing classes, but not using the '*'…
08:05AWizzArdThis is (intentionally) not directly possible in Clojure.
08:06AWizzArdAnd in clean code you don't want to do this (:
08:06old_sound_hoho, thanks :)
08:07LauJensenAWizzArd: The benefits still arent tangible enough, imo
08:09AWizzArdIt's not a huge win, right.
08:10lpetithello
08:10LauJensenAWizzArd: I think there are some promises in the pipe for certain optimizations, but I dont think any of its implemented
08:10LauJensenlpetit: hey
08:11LauJensenAnd it especially bugs me, if Im just testing something where all the examples use .*. Sure I agree that shouldnt go into production code, but for rapid prototyping it would be nice
08:12AWizzArdI agree. For fast hacks in the repl it could be beneficial, saving a few minutes.
08:12lpetittalking 'bout what, buddies ?
08:12LauJensen(import '(java.util.*))
08:13lpetitoh this
08:13AWizzArdIn general I think Rich decided for the "right" solution in the long run, but agree that it also has disadvantages.
08:14LauJensenSure - But while we wait for tangible benefits, it would have been nice to have
08:15LauJensenDont know if its trivial to implment or not
08:15lpetitmaybe some distinct function, just for the repl (and which could be installed by default when on a repl), e.g. (clojure.repl/import-* 'java.util)
08:16LauJensenYea, I wonder if this could be plugged in
08:18lpetitLauJensen: I guess it's not a problem of being trivial , but rather of being accurate under all circumstances, since I guess it's impossible to get the classes from the Java API, the tricks used in e.g. clojure contrib are to get a location, detect whether it's local on the filesystem, if it's a directory or a jar, etc. and then if it's handled, it has to recursively search for .class resources, sort out those that are internal cla
08:18LauJensenFor repl experiments, we could probably suffer a slight inaccuracy
08:18lpetitLauJensen: will not be accurate for dynamically created classes in the package, will not work if the specific type of classloader is not known in advance
08:18AWizzArdlpetit: that message got cut off: "[...] out those that are internal cla"
08:18lpetitLauJensen: I also think so
08:19lpetitAWizzArd: "...ses (XXX$YYY.class), etc."
08:31cemericklpetit: I had no idea that you had a quasi-remote REPL in ccw already
08:31lpetitcemerick: yeah, maybe I didn't manage to get the point clear.
08:31AWizzArdHow can I check in ring if a specific route exists, and/or which methods it allows (GET, PUT, ...)?
08:32lpetitcemerick: I've tried to keep it very simple, though robust.
08:32lpetitcemerick: did it a long time ago !
08:33cemericklpetit: It doesn't change my plans, but they'll be side-by-side for a while, until the dependencies on the existing REPL can be switched over. The enclojure one is more complete.
08:33lpetitcemerick: in fact it's more a "general purpose remote sexpr evaluator" than a REPL. The idea is that it could even be used by the client IDE to "install/update" dynamically the server helper functions, e.g. "repair/upgrade" the server backend :)
08:34lpetitcemerick: sure, np
08:34cemerickRight, that's what any remote REPL needs to do. :-)
08:34lpetitcemerick: :)
08:37lpetitcemerick: what i've done with mine, is that it's not the remote repl which determines when it's time to evaluate what it received. With my version, the string's length is computed and sent as part of the message, and in the other end, it's used to know when to stop listening and try evaluating (so even if some bug made the client send an incomplete sexpr)
08:37lpetitcemerick: I don't know if other remote repls do that or not
08:45cemericklpetit: yeah, the same notion is in the enclojure repl (it sends chunked strings instead of bytes, but the result's the same).
08:46lpetitcemerick: FYI, I'll try to meet Lee's expectations, and will do a new RC release on monday. I'll be invaluable to have a full class of users. Lots of bugs to correct. Lots of ergonomics to modify. Paradise on earth :-)
08:47cemericklpetit: I think he's overly optimistic. And, he's only 15 minutes from me, so I'm not sure about being the closest target of his irritation come mid-terms! ;-)
08:47lpetitcemerick: so in enclojure REPL, it's not the PushBackReader which decides when he got a complete form ?
08:47lpetitcemerick: (rofl)
08:48cemericklpetit: no, it's the chunks-len in the read-socket fn that determines how much to read.
08:49lpetitcemerick: ok, 'cause I would not like if there's a bug in the IDE's client code, and say e.g. it sends "(find-completion foo" (note the missing paren), and then the client will have no answer (with ccw's backend, he'll get a malformed expression error)
08:50cemerickyeah, the same thing will happen
08:52lpetitcemerick: cool
09:14cemericklpetit: where are ClojureConsole and ClojureConsoleFactory hooked in? I don't see any references to them anywhere in the project.
09:14lpetitcemerick: they are artifacts of the past. Currently the REPL you see is just the standard ProcessConsole with a few additional hooks (implementation dependent)
09:16cemerickoohkay, that makes more sense now
09:16lpetitcemerick: I did not remove them until the time when someone would create proper REPL views, and see whether they could serve as a base or not. I don't know them well, they are a real artifact of the past, when Casey Marshall started the plugin
09:17cemericklpetit: so that's for an IDE-internal REPL/console, right?
09:17lpetitcemerick: I guess so
09:18cemerickI think that's the only way they'd be usable. There's in-process references to RT, etc., so it can't be working with even an external clojure process.
09:18cemerick(nevermind remote, etc)
09:21lpetitcemerick: yes, I'm pretty sure you're right. So there's little to keep from this 2 classes codebase, but (maybe) the skeleton
09:24lpetitcemerick: and I'm not even sure that's a good idea or not to plug the REPL's GUI into the Console framework. What if you want to see the (locally) launched JVM console side by side with your REPL ? What if you want to put 2 REPLs side by side ? What if you want to keep side by side a REPL and a totally unrelated type of console? I haven't (yet) been able to find how to do this with the Eclipse console (seeing several different cons
09:25cemericklpetit: I've been down this road before, when I worked on cusp for a little while years ago. Unless things have *significantly* changed, you can't customize IOConsoles much at all.
09:26cemerickMy current plan is to continue to reuse the JDT launch stuff, but have a separate REPL interaction window/frame (with a hotkey/button to switch to the corresponding console when you want to see *out*/*err*
09:27cemerickThat's the only way we'll be able to roll in the editor capabilities (highlighting, completion, etc), command history, etc etc.
09:27lpetitcemerick: yeah, I've started a WIP local ccw branch where I try to plug my own SourceConfiguration, but it's rather hackish, need to recurse down the Widget tree to find the right one, etc. . Never got this one finished, and with your WIP, think it'll never get.
09:28cemerickYeah, that seems like a hard road. The JDT does a good job, and interops with all of the various things that can impact process invocation (different build tools, PDT stuff, etc). Trying to replace it isn't something I want to contemplate.
09:29lpetitcemerick: indeed, I would probably have started as you said. Separating the launch of a process (or of a connection to a remote process) from the instanciation and connection of REPL windows to sockets.
09:30lpetitcemerick: wait. In the case of "pure" remote connection, we don't need to launch a remote java debugger connection at all, do we ? enclojure's server process uses its own port.
09:32lpetitcemerick: so the "link" between launch configuration , launched configurations and the REPL window will be loose. E.G. provide facilities to open a new REPL window from a process console, etc.
09:32cemericklpetit: Yes, the REPL runs on its own port. Ideally, we'll be able to dynamically attach the debugger to the REPL's process.
09:32cemerickExactly.
09:33cemerickThe environments will be the same, but you'll have a separate REPL interaction windows.
09:33lpetitcemerick: ok, I see we follow the same goals :-D
09:33cemerickI wouldn't lead you astray. :-)
09:34cemerickI think that's all for today. Good progress, I think the plan has been validated. Now I just need to relearn the eclipse APIs :-0
09:38cemericklpetit: should the plugin be using clojure 1.1 or 1.2? I see the latter in the project dependencies, but the former in the plugin.xml manifest.
09:38lpetitcemerick: plugin.xml manifest is not up to date.
09:38cemerickOK, thanks. I'll stop bugging you now. :-)
09:41lpetitcemerick: np. If I can't answer, I won't. So bug as you need, and I'll say "stop" when I can't any more :)
09:42cemerickHeh, sure. I have to get back to work now anyway.
09:42rhickeyhas anyone tried the latest from git?
09:44lpetitrhickey: sorry no
09:45rhickeylpetit: I figured I might have to get in in an RC in order to get people to try it
09:46lpetitrhickey: maybe yeah
09:49cemerickrhickey: if there's no maven artifact, it's almost like it doesn't exist *shrug*
09:49rhickeycemerick: what a world we live in
09:51cemerickrhickey: it's hard to argue with, from a user perspective
09:51cemericktwiddle a single line in a file....oh, look, new version of clojure to bang on, etc.
09:54AWizzArdrhickey: I often update my clojure to whatever is available under build.clojure.org
09:54AWizzArdIf the .jar from 20 hours ago includes your updates then I have them. But I did not do particular tests.
09:55cemerickactually, it's even better for leads and similar; distribution isn't exactly a low hurdle for most projects.
10:39fogus_Martin Odersky on Clojure -> http://blog.fogus.me/2010/08/06/martinodersky-take5-tolist/
10:41dnolenfogus: nice!
10:43fogus_thanks. he's a cool dude
10:48esji liked his joke... perfect humour.
12:49BahmanHi all!
13:13esjfoguse: wow, that's #2 on HN right now...
13:49slyrushmm... I don't suppose clojure's format has a ~{ ... ~} equivalent?
13:52maravillas,(doc cl-format)
13:52clojurebot"clojure.contrib.pprint/cl-format;[[writer format-in & args]]; An implementation of a Common Lisp compatible format function. cl-format formats its arguments to an output stream or string based on the format control string given. It supports sophisticated formatting of structured data. Writer is an instance of java.io.Writer, true to output to *out* or nil to output to a string, format-in is the format control string and t
13:54slyrusmaravillas: thanks!
13:54maravillasno prob
13:59dulanovwhat is the preferred method to binary search in sorted lists? (contains? el (sort <some_coll>)) work for that?
14:08raekcontains? only checks for keys in maps and sets
14:08raekit also works for vectors, where it checks if the index is in range
14:08raekhas-key? would probably be a more accurate name
14:16Lajlaraek, your shadow is most magnificent, let me worship her
14:28mebaran151lancepantz, did you have a chance to test out my hack?
14:36bonegais there some sort of take-while that needs a pred that works on taken list?
14:36bonegafor example: (take-while + #(< % 100) (iterate inc 0))
14:39wwmorganbonega: what does the + do in your pseudocode?
14:39bonegathat's the function passed for reduction
14:40bonegaso: reduce list with +, until sum > 100
14:41wwmorgan,(->> (iterate inc 0) (reductions +) (take-while #(< % 100)) last)
14:41clojurebot91
14:42wwmorganI don't think there's a function like that in core or contrib.
14:42bonegathanks but
14:42bonegaWhat I want is to return the list that equals the sum
14:43bonegareturn all values which sum < 100
14:47cemerickfogus_: You're probably the only one that could have brought East and West together like that. :-)
14:47cemerickfogus_: where's the loperOS guy's reaction? I could use a good laugh.
15:01wwmorganbonega: here's what I came up with. It's quadratic in time, so if your collection is especially large you'd want to rewrite it as something that performs one pass only. http://paste.lisp.org/display/113260
15:03ecyrbI defrecord'd a record with a field name that conflicted with a (:use) import name. I agree that I'm a dolt, but should clojure complain instead of silently screwing me over?
15:03ecyrb(should I file a bug report?)
15:05tomojthe problem is that inside the defrecord methods, you can't use the :use'd var?
15:06ecyrbtomoj: sorry, I'm bad at explaining stuff.
15:07ecyrbI did a (ns my-namespace (:use (clojure.contrib server-socket))) (defrecord R [server-socket])
15:08ecyrbAnd clojure sort of created a type R for me, but I could never construct it
15:08tomojworks fine for me
15:09tomojhttps://gist.github.com/c6388f583a7e2cfbc4e4
15:10ecyrbyeah, it works for me too
15:10ecyrbsorry
15:10ecyrbI obviously haven't isolated the behaviour I was seeing.. Sorry about that.
15:11tomojno problem
15:14fogus_cemerick: Thanks. :-) http://www.loper-os.org/?p=198
15:16ecyrbhttp://paste.lisp.org/+2FE6
15:17ecyrbwhoops. see the annotation: http://paste.lisp.org/display/113262#1
15:18ecyrb(s/srv-socket/server-socket/)
15:22ecyrbtomoj: Does that still work? Can you instantiate a CondorServer?
15:23tomojyep https://gist.github.com/b64b0da1681e35bfcda8
15:25ecyrbHmmm. I'm getting a NoSuchMethodError
15:25tomojclojure version?
15:25ecyrb1.2.0-RC1
15:25tomojme too
15:26ecyrbif I rename server-socket to srv-socket it works though
15:27tomojwhat's the NoSuchMethodError say?
15:27ecyrbdid you use the original or annotated lisppaste?
15:28ecyrbjava.lang.NoSuchMethodError: com.maple.util.condor.Server.CondorServer.<init>(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V (NO_SOURCE_FILE:0)
15:28tomojthe one with "server-socket"
15:28tomojare you using leiningen?
15:28ecyrbNo
15:29tomojmaven? or what?
15:29ecyrbjust a regular inferior-lisp
15:29tomojso you constructed the classpath yourself?
15:29ecyrbyes
15:29tomojno clue, then
15:30arohnertechnomancy: dammit man, I wrote reducate like 3 days ago. But I called it "fold"
15:30arohnertechnomancy: exact same signature
15:31bonegawwmorgan: thank you
15:33ecyrbclasspath checks out
15:35ecyrbtomoj: Well, thanks for trying it out for me. I'll just rename and keep going for now
15:50jlf`is it expected behavior for functions like intersection/union to be unavailable prior to doing (use 'clojure.set) ?
15:51Chousukeyes
15:51Chousukethey're in that namespace
15:54jlf`hmm, i wonder why set operations get that treatment while operations on other standard data structures do not
15:55Chousukejlf`: they're not "basic" operations
15:55jlf`fair enough
16:26technomancyarohner: hah; awesome.
16:27technomancyarohner: it was a really fun group exercise
16:28technomancyjlf`: there's certainly room for improvement; see http://code.google.com/p/clj-nstools/
16:29jlf`interesting
16:31technomancyI don't know if nstools is useful in its current state, but if something like it were integrated into Clojure itself it would probably help a lot.
16:59herdrickhaving ns trouble
17:00herdrickjust doing (ns my-namespace) gets me an error
17:00herdrickUnknown location:
17:00herdrick error: java.lang.IllegalStateException: repeat already refers to: #'clojure.contrib.string/repeat in namespace: my-namespace
17:01herdrickthat contrib package is one which previously i had done a require clause on
17:01herdrickbut if I get rid of that clause, i would think that I would start with a fresh slate
17:09lozhI wonder if (ns-unmap 'my-namespace 'repeat) would fix it?
17:09herdrickit's just odd, because I haven't seen anything like this happen before
17:09herdrickif i do this:
17:09herdrick(ns my-namespace
17:09herdrick (:use clojure.contrib.jmx)
17:09herdrick (:use clojure.contrib.combinatorics))
17:09herdrickand 'compile' it
17:10herdrickit works fine once
17:10herdrickthe second time it blows
17:10lozhI'm not sure :use makes sense without specifying classes
17:12lozhAh no, refers to all public vars of ns subject to filters, that should be fine
17:14herdrickdo you get the same result?
17:16lozhI'm just starting up a repl now, sec
17:16herdrickthanks, lozh:
17:17edbondI'm trying to use deftemplate from enlive, got NullPointerException. How to debug/fix?
17:17lozhyep same thing, though I get the error with #'clojure.core/read and #'cloure.contrib.jmx/read
17:18herdrickright, same thing here
17:18lozhGet a warning first time, then an error second
17:18herdricktry just saying (ns my-namespace)
17:19lozhsame error
17:19herdrickyeah
17:19herdrickalso the ns-unmap doesn't work
17:19dnolenedbond: that's almost always because deftemplate can't find the html resource you're pointing to, in my experience anyway
17:20herdrickso I've been restarting my 'lein swank' everytime i get into this problem
17:20herdrickwhich is ridiculous
17:21edbonddnolen: thanks, does it looks for it on compile?
17:22herdricklozh: what do you do for 'importing' packages
17:22herdrick?
17:23lozhI've not had to import a complete package yet, just a few named classes
17:23herdrickok
17:24herdrickso, what... I'm supposed to only do a "require" and never "use"?
17:24rhudsonherdrick, you'd likely be better off doing (:require [clojure.contrib.jmx :as jmx])
17:25herdrickrhudson: actually I can't even do that
17:25herdrickapparently i need to restart my REPL
17:25herdrickbecause what I was doing has it in a state where even this:
17:26herdrick(ns your-namespace
17:26herdrick (:require clojure.contrib.string)
17:26herdrick (:require clojure.contrib.combinatorics))
17:26edbonddnolen: created a file and still have NPE.
17:26herdrickbreaks it
17:26herdrickerror: java.lang.IllegalStateException: repeat already refers to: #'clojure.contrib.string/repeat in namespace: your-namespace"
17:26Raynes(ns your-namespace (:require clojure.contrib.string clojure.contrib.combinatorics)) also works.
17:27rhudsonThe rule of thumb I use is require instead of use unless I'm absolutely sure there are no confligcts
17:27herdrickwhich is extremely annoying
17:27pdkwhat, did 1.2 come out today
17:27herdrickrhudson: ok
17:28RaynesIf you're using 1.2, clojure.contrib.string is deprecated in favor of clojure.string.
17:29lozhif there's only a small number of conflicts then you might be able to stuff a :except in your :use
17:29lozhassuming it supports everything use does
17:32lozherm :exclude, not :except
17:33edbondwhere does enlive looks for templates?
17:33lozhherdrick: If you change your :use clause to (:use [clojure.contrib.jmx :exclude (read)]) then I can run it repeatedly
17:34lozhI guess you could refer to read specifically if you needed the jmx method too
17:34herdricklozh: hmm, i had tried that - maybe i got the syntax wrong will check
17:38lozhThe unmap thing worked for me too, (ns-unmap 'my-namespace 'read) meant I could rerun the (ns...)
17:38lozhI think the exclude thing only works provided you haven't already errored
17:39herdricklozh: that new clause isn't working for me, though it might if I restart my REPL
17:39dnolenedbond: have you tried running a file exists on that file or reading it by other means?
17:39dnolenedbond: deftemplate uses html-resource, you might want to call that directly
17:39lozhyep, I did it multiple times from a fresh repl
17:40lozhthe ns-unmap thing fixes it for me without restarting the repl, though
17:40herdricklozh: BTW how did you decide upon surrounding clojure.contrib.jmx plus the :exclude thing in a vector?
17:41lozhgoogle
17:41lozhhttp://clojure.org/libs
17:42lozhI copied the way :only is used near the top of example lib
17:42herdricklozh: right, copying and pasting works
17:42herdrickit's just that I want to know why
17:42herdrickwhy surround with a vector
17:43herdrickwhy are :exclude and :use and whatnot keywords
17:43herdrickI just find the ns and require and use stuff to be a baffling mini-language, not much documented
17:43rhudsonI know that frustration.
17:44herdrickrhudson: thanks
17:44rhudsonI finally figured out the right way to do (require [xxx :as yyy]) by reading the source code
17:44lozhI got the :use reference from the docs for :ns and then went to http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/use to guess what options were available with :use
17:45rhudsonThe reason might be that generally in Clojure, places where symbols are bound use vectors
17:45herdrickso that's "require" not within a "ns"?
17:45rhudsonwithout ns: (require '[xxx :as yyy])
17:46rhudsoninside ns: (:require [xxx :as yyy])
17:46herdricki don't think quoting out that vector is necessary, right?
17:47rhudsonI think the docstring for ns says that the options for :require :use etc are the same as the standalong require use etc
17:47slyrusfor the clojure-loving chemists/bioinformaticians: http://github.com/slyrus/chemiclj
17:47edbonddnolen: (enlive/html-resource "www/index.html") raises exception.
17:47dnolenedbond: there you go
17:48dnolenedbond: is www in your src directory? are you using lein to manage the classpath?
17:48edbondwww is in project root (where project.clj is), yes I use lein
17:49dnolenedbond: project root is not on the classpath, src is
17:49dnolenedbond: just move www into src
17:50dnolenedbond: lein also support setting resource-path I believe or something like that
17:50rhudsonThe quote's necessary in (require '[xxx :as yyy]) because the construct is expecting a couple of symbols.
17:51edbonddnolen: works, many thanks.
17:51dnolenedbond: np
17:51rhudsonWithout the quote, it's trying to resolve xxx and yyy, and complaining when it can't
17:51neotykhow do one start swank-clojure-project for project managed by new lein?
17:52rhudsonBut in (ns ... (:require [xxx :as yyy])...) you're inside a macro, so it's actually dealing with the symbols & not trying to resolve them
17:53lozhneotyk: you need to make sure something like :dev-dependencies [[swank-clojure "1.2.0"]] to your project.clj, then then run lein deps then lein swank
17:53herdrickrhudson: someone please make the pain stop
17:54rhudsonIt just takes a while to get used to. You'll get it
17:55herdrickI don't want to. Clojure is beautifully designed. That's a big part of the appeal. But this stuff is awful.
17:55rhudsonYou don't actually need to use namespaces until you start writing multi-file programs
17:55herdrickbut thanks, rhudson:
17:56herdrickbut you still need require or use
17:56herdrick(which of course are calling differently than if they were within an "ns". yuk.)
17:57rhudsonRight. Like if I'm exploring in the repl, it's convenient to (use 'clojure.repl), so I can look at source by (source ns)
17:57rhudsonor if I want to parse xml, then (require '[clojure.xml :as xml]) then (xml/parse whatever)
17:58herdrickAHA! Thank you! Someone was telling me about 'source' last night at the Clojure meetup in San Francisco but I hadn't heard of it and he wasn't sure why it wasn't bound in my repl
17:58herdrickok, clojure.repl, cool
17:58rhudsonNamespaces are kind of like maps -- you wouldn't want to be restricted to having all your maps have distinct keys
17:59rhudsonSo the ns/require/use stuff gives you control over how names are bound.
18:00herdrick...through use of its mini-language
18:00rhudsonRight. And I'm not saying it's not a little tricky to get the hang of
18:01rhudsonBut that mini language is all Clojure keywords and functions and macros.
18:02herdrickRaynes: the capabilities seem fine (except that it seems to have borked my REPL, but never mind that) it's the notation that's the problem
18:02rhudsonSomewhere (Joy of Clojure maybe) I saw the remark that in a language like Clojure, there's not a sharp distinction between a domain-specific language and an API
18:02herdrickRaynes: that's why we're all using Clojure instead of C++ after all
18:02RaynesI don't see anything wrong with it. :\
18:02dnolenherdrick: I think that's overstating a bit. When used inside the ns macro everything is clear. but require is function. while the cognitive dissonance is annoying at first, require and use being functions is crazy powerful.
18:03Raynesdnolen: Indeed! I've made magics happen with require that were only possible thanks to it being a function. :D
18:03herdrickrhudson: yes, there are lots of mini languages in Clojure and other lisps. it's just that some of them, like Common Lisp's "do" are... kind of a mess
18:05herdrickdolen: it is not clear. the usage I had above wasn't even idempotent. the first time you try it, it works as expected. it breaks each subsequent time.
18:05herdrickand the REPL is then borked and needs a restart
18:06rhudsonI've never seen much need to use namespaces in the REPL unless I'm specifically trying to explore what namespaces do.
18:06jlfherdrick: there's nothing messy about CL's do
18:07jlfmaybe you mean loop?
18:07herdrickdnolen: Raynes: sounds interesting. what have you done with require and use as functions where they being functions has mattered?
18:07herdrickjlf: oops, thanks. yes, loop
18:08herdrickbut i don't want to get into a flamewar. sometimes mistakes are made. it's better to be open to recognizing them as such.
18:09dnolenherdrick: no flamewar. you're use of use is un-idiomatic. only use require with an alias, if you use use, only with :only. you'll save yourself a lot of trouble.
18:10dnolen(require '[some.long.ns :as ns]) or (use '[some.ns.with.lots.of.defs :only [the-one-you-need]))
18:10dnoleneverything else is asking for trouble
18:10rhudsonwhat dnolen said
18:11herdrickdnolen: all of the docs for clojure.contrib stuff says no
18:11herdrickexample: http://richhickey.github.com/clojure-contrib/string-api.html
18:11gfrloghas anybody made use of remove-ns?
18:11dnolenherdrick: says no ?
18:12rhudsongfrlog: yes, I had reason to define some temporary namespaces & remove them afterward
18:12hiredmandnolen: he's pointing at the usage example at the top
18:12herdrickdnolen: right, at the top of that page is:
18:12herdrickUsage:
18:12herdrick(ns your-namespace
18:12herdrick (:require clojure.contrib.string))
18:12herdrickand all the other such pages
18:12hiredmanherdrick: that is the "simplest" possible usage, not the correct one
18:13herdrickdnolen: rhudson: ok, thanks for the tip. I very much appreciate it. but I must say that I am frustrated that I have to get such a tip on IRC from you guys instead of from the docs
18:13hiredmanimport java.util.*; vs import java.util.HashMap;
18:13dnolenherdrick: note the use of require, it's doesn't say different from what I just said
18:13rhudsonIt's a young language yet, and we're living on the frontier
18:13herdrickwell... maybe the correct one should be simpler or put the correct on there instead
18:13herdrickrhudson: right! which is good.
18:14herdrickhow about making the docs wiki?
18:14gfrlogrhudson: are there any gotchas related to messing with namespaces? I get errors resolving the symbol I pass
18:14hiredmanthe correct one depends on which functions you are using
18:14rhudsonIt's not incorrect, just kind of inconvenient: with that you need (clojure.contrib.string/capitalize whatever)
18:14herdrickdnolen: it doesn't use :as
18:14rhudsonwith an alias (say ccstr) you just need (ccstr/capitalize whatever)
18:14hiredman:use and :only
18:15rhudsonclojuredocs.org
18:15dnolenherdrick: :as is just a convenience. it is recommending the right thing.
18:16herdrickdnolen: i thought that was asking for trouble
18:16dnolenherdrick: no, sorry. require or require + :as is always fine. a use without :only is the problem.
18:17rhudsonWith those usages, you know exactly what symbols you're introducing
18:18dnolenherdrick: use is basically a blind import, you can and will get clashes. require keeps that from happening.
18:18herdrickdnolen: rhudson: ok, thanks
18:18rhudsongfrlog: what kinds of errors?
18:20gfrlogrhudson: http://gist.github.com/512112
18:21lozh(remove-ns 'x) ?
18:21rhudsonI think you need to do (remove-ns 'x)
18:22gfrlogI bet so :)
18:22gfrlogbut only because I didn't think of it this time
18:22gfrloggreat, thanks
18:24technomancyuse and require have a rehaul in the works planned
18:24technomancyclojurebot: google ns use require overhaul
18:24clojurebotFirst, out of 35900 results is:
18:24clojurebotHouse sends health bill to Obama&#39;s desk - Politics - Health care ...
18:24clojurebothttp://www.msnbc.msn.com/id/35961584/
18:25technomancyyeah... anyway. check the mailing list archives.
18:37neotyklozh: thanks, it works!
18:38herdricktechnomancy: very very good to hear that. and i'm not surprised that it stuck out as being unclojurian to the leadership
18:40lozhcool!
18:40lozhI think http://www.mail-archive.com/clojure@googlegroups.com/msg20403.html is some of the discussion.
18:41lozhand http://onclojure.com/2010/02/17/managing-namespaces/ would have been quite handy to read as a primer to namespaces, ignoring the extra stuff he's put in to ns-tools
18:51kencauseyThis must be an FAQ but I can't find the answer. How do you exit the repl? One started via lein repl for example.
18:52kencauseyI expected ctrl-d to work, but nothing happens. ctrl-c works for some value of work but doesn't seem like the likely polite manner.
18:52mebaran151is there a general utility to turn a map into a record, given they share the same keys?
18:53mebaran151kencausey, ctrl-d works on linux, I think it's ctrl-z on Windows, and you can always do a (System/exit)
18:54mebaran151sorry (System/exit 0)
18:54kencauseymebaran151: ah, I'm in cygwin which blurred my thinking here, ctrl-z it is, thanks.
18:54kencauseythanks again
18:54mebaran151glad I could help
18:54mebaran151kencausey, what are you using Cygwin for though?
18:54mebaran151you can run clojure pretty easily in plain ol' windows
18:55kencauseybecause I like a unix environment?
18:55mebaran151ah, I was just checking, because I know ruby hatd Windows
18:56mebaran151without cygwin to support it
18:56kencauseyI hadn't assumed clojure needed cygwin
18:57mebaran151sorry, just being too presumptuous
19:19slyrus_anyone using cow-blog?
19:22pdkbrian carper would be an obvious guess :p
19:28slyrus_well, yeah, anyone else? and what's his nick?
20:13raekhas anyone made a "forcat"
20:14raek...that works like for, but concatenates all the results into one sequence
20:14raek("result" = result sequence)
20:14slyrus_forcan, a la mapcan
20:15slyrus_if course this lisp doesn't have nconc :)
20:18slyrus_raek: I see you have fontlock on for defrecord. but you left the indentation the way it was?
20:20raekit requires you to activate the backtracking indentation mode
20:20raekbut I think I added a rule for the usual mode too...
20:21raek(defrecord 2)
20:22raekyep, when using the default indentation mode, the two first forms will be indented 4 spaces and the rest 2 spaces
20:22raekthis will not indent the methods correctly, though
20:23raekslyrus_: M-x customize-variable, clojure-mode-use-backtracking-indent
20:23raekthat should make defrecord indent well
20:25DeranderI need to create some sort of random facts repository
20:26Deranderstuff like that is so incredibly useful when you need it, but it's so incredibly forgettable when you don't
20:29slyrus_raek: hmm... no all the lines are indented two spaces, as before. perhaps I'm doing something wrong though.
20:31raekslyrus_: can you do a paste?
20:31raekmaybe I overlook something
20:31slyrus_sure, of what?
20:31raekah, misread
20:33raekin the backtracking mode, the name and fields of the record are indented two additional spaces
20:33raekthis doesn't happen for you?
20:34raekthis seems to happen in both modes for me
20:34slyrus_Oh, I see... that's not what I want :) I want the names of the protocols to be 2 spaces and the names of the methods to be 4.
20:34slyrus_no, I just throw all that stuff on one line
20:34slyrus_or w.w. the fields, if need be.
20:35raekcurrently, I don't think that would be possible to do
20:36raekalso, indenting the method forms at the same column as the protocol names is what I've seen in most code
20:36slyrus_well, yeah, because that's what emacs does! :)
20:37slyrus_trying to override your editor's indentation preferences is madness. fixing those preferences, not so much
20:38raekyeah, I never manually corrected the indentation for method contents before
20:38slyrus_heh. maybe somebody will write a clojure mode for climacs.
20:39raekthought I'd either change clojure-mode or accept it
21:00technomancyraek: if you want commit on clojure-mode that'd be fine by me; just ask. I don't have time to give it attention right now.
21:22raekI would consider the commits I've made so far on my fork to be ready for integration with your fork
21:22raektechnomancy: feel free to pull them whenever you like it
21:24raekbtw, how would you like to be notified when I have something ready?
21:31slyrus_hrm... it's annoying having to change all of these project.clj's to use, say, RC2. there has to be a better way to say "hey, maven, give me some version of clojure 1.2, preferably the latest"
21:47rplevyfor some reason scripture can't find clojure.contrib.string when I load it in leiningen (while other libraries that use other clojure.contrib libraries seem to work fine)
21:47rplevy*scriptjure
22:08rplevydoes anyone know of an example of using scriptjure in leiningen?