#clojure log - Aug 06 2010

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

0:04 Bahman: Hi all!

0:04 pdk: OH YES YES

0:10 cais2002: (doc throw-arg)

0:10 clojurebot: "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."

1:26 vIkSiT: hi all

1:26 is anyone here using clojure-http-client?

1:27 for some reason, a lein uberjar fails on any code that uses it

1:27 (ns foo (:use [clojure-http.client :only [url-encode]]))

1:27 lein deps works.

1:28 Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure_http/client__init.class or clojure_http/client.clj on classpath

1:28 on a lein uberjar.

1:31 wwmorgan: vIkSiT: I'm having trouble replicating it. What versions of clojure, leiningen, and clojure-http-client are you using?

1:32 vIkSiT: wwmorgan, let me pastebin that

1:34 http://paste.lisp.org/display/113241

1:34 wwmorgan, ^

1:35 lein deps goes through fine

1:35 pasting lein uberjar error.

1:36 wwmorgan, http://paste.lisp.org/display/113241#1

1:50 wwmorgan: vIkSiT: in your ns declaration in cljtwitter.clj, you need to (:use [clojure.http.resourcefully]). Not clojure-http.resourcefully

2:18 quotemstr: Are there any plans to get symbol-macros into the core?

2:20 tomoj: quotemstr: I still don't know what you mean

2:20 but there is &env, maybe that's what you're looking for?

2:21 probably not actually

2:21 ah

2:21 probably so

2:21 quotemstr: I'm talking about CL-style symbol-macros.

2:22 As I mentioned in the other channel, without core support, symbol-macros can't become part of the lexical environment object.

2:22 tomoj: I was talking about the environment thing

2:22 all macros receive an implicit parameter &env

2:23 quotemstr: Oh, the parameter itself is called "&env" anaphorically?

2:28 tomoj: yeah

2:31 I actually have no idea how to use it though

2:31 * slyrus thinks comp would be cooler if clojure had multiple values support

2:31 quotemstr: tomoj: You want to use it when you write a tree-walker so you can be sure you've completely expanded all your arguments.

2:31 tomoj: &env is a map of symbols to clojure.lang.Compiler$LocalBinding's

2:32 but clojure.lang.Compiler$LocalBinding seems to give no way to access the value

2:32 quotemstr: Hrm, that's interesting. macroexpand doesn't take an environment argument.

2:33 * quotemstr really needs to stop assuming that everything works like it does in CL.

2:36 tomoj: I'm now wondering what the hell &env is there for

2:39 oh

2:39 quotemstr: Oh?

2:40 tomoj: https://gist.github.com/21ca8d61004767771bc7

2:40 that can't be the way we're supposed to use it...

2:40 quotemstr: That looks evil.

2:40 tomoj: yeah

2:41 quotemstr: What are .eval and .init doing here?

2:41 tomoj: that's the only way I could find to get a value from a LocalBinding

2:41 sid3k: morning guys

2:41 tomoj: .init on the LocalBinding returns an Expr, then .eval to get the value

2:42 unless there's something I'm missing &env must only be useful for compiler hackers

2:43 quotemstr: Ah, I see.

2:43 sid3k: It's bedtime for me, you insensitive clod.

2:47 tomoj: oh, found something in the log

2:47 well..

2:48 the suggestion was to just look at the keys in &env and use resolve

2:48 that doesn't seem to work

2:51 vIkSiT: hey wwmorgan

2:51 looks like I got disconnected before..

2:51 wwmorgan: vIkSiT: did you get my fix?

2:51 LauJensen: Good morning all

2:51 vIkSiT: wwmorgan, you mentioned . instead of - in clojure.httpd

2:51 er http*

2:51 but now I get a : Exception in thread "main" java.lang.IllegalAccessError: spit does not exist (client.clj:1)

2:52 wwmorgan: on lein uberjar?

2:53 vIkSiT: wwmorgan, thats right

2:56 wwmorgan, I changed clojure-http.resourcefully to clojure.http.client

2:56 since thats what i wanted to test in the first place

3:01 wwmorgan, ideas?

3:01 wwmorgan: vIkSiT: I can't seem to reproduce it. What version of leiningen are you using?

3:02 vIkSiT: Leiningen 1.2.0 on Java 1.6.0_20 Java HotSpot(TM) 64-Bit Server VM

3:05 bartj: how do I get a double quote ?

3:05 , (def x "\"")

3:05 clojurebot: DENIED

3:05 bartj: (def x '"')

3:05 both don't work as expected ?

3:05 Chousuke: just \"

3:06 bartj: oh, I don't need to quote the double quote ?

3:06 Chousuke: if you want it as a char, no.

3:06 bartj: Chousuke, gee thanks!

3:07 wwmorgan: vIkSiT: works on my machine :-/ http://paste.lisp.org/display/113241#2

3:07 vIkSiT: hrm

3:08 interesting

3:08 WARNING: spit already refers to: #'clojure.core/spit in namespace: clojure.http.client, being replaced by: #'clojure.contrib.duck-streams/spit

3:09 i wonder if thats causing this

3:13 there we go

3:14 replacing 1.2.0-master-SNAPSHOT with 1.2.0-beta1 gives me the warning as above

3:15 wwmorgan, ^

3:16 tomoj: bartj: what did you expect "\

3:16 er

3:16 what did you expect "\"" to do?

3:16 bartj: is there a library function which prefix and suffixes a string with a character ?

3:17 tomoj, was expecting a double-quote string

3:17 wwmorgan: vIkSiT: is that good enough for your purposes?

3:17 tomoj: isn't that what it is?

3:17 bartj: tomoj, yes, that was stupid on my part

3:17 vIkSiT: wwmorgan, :) 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

3:18 quotemstr: /join #cygwin

3:18 Damn spaces before commands.

3:19 Derander: don't worry

3:19 I just saw #hunter2

3:21 quotemstr: At least it wasn't #midgetfetish or something equally compromising to any future political campaigns.

3:32 bartj: quotemstr, have only heard of widgets :)

3:46 er, why is (not (empty? coll)) not advised (as per the documentation)

3:48 quotemstr: Where does it say that?

3:50 Chousuke: bartj: because (seq coll) does the same thing.

3:50 bartj: in fact, empty? is defined as (not (seq coll))

3:51 bartj: It's not wrong to use not + empty?, but using seq is idiomatic

4:15 bartj: Chousuke, thanks again!

4:15 slyrus: name 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?

4:16 bartj: , (doc empty?)

4:16 clojurebot: "([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"

4:16 bartj: aargh, quotemstr has quit

4:18 LauJensen: I 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

4:19 slyrus: any votes before I turn in for the night?

4:19 LauJensen: slyrus: clovalence? :)

4:20 slyrus: hrm... I'll sleep on that. thanks.

4:20 tomoj: "lewis" seems bad for google

4:20 slyrus: yeah, there is that...

4:20 tomoj: I guess it doesn't matter much though

4:21 unlikely people will try to find your app by googling for "lewis"

4:28 LauJensen: tomoj: but then again, you could say the same about 'jetty' but most people end up there anyway

4:38 neotyk: Hi *

4:39 is there a test coverage tool for clojure already?

4:40 lpetit: LauJensen: hi

4:40 LauJensen: hey Laurant

4:47 esj: morning guys

4:54 LauJensen: morning home dawg

5:22 AWizzArd: ~seen ordnungswidrig

5:22 clojurebot: no, I have not seen ordnungswidrig

5:23 AWizzArd: ~max people

5:23 clojurebot: max people is 283

5:58 xkb: is there something like a "times" function in clojure?

5:58 to chain a function?

5:59 Chousuke: repeatedly?

5:59 or iterate

5:59 xkb: (times 10 (mutate-code code))

5:59 something like that

5:59 Chousuke: looks like you might want iterate

6:00 it'd work something like (nth 10 (iterate mutate-code code))

6:00 xkb: ah yes

6:00 thanks

6:01 hmm I get an error on that

6:01 Cons cannot be cast to Number

6:02 Chousuke: hm, I suppose I got the order the wrong way around

6:02 xkb: lol, reminds me to read (doc

6:02 :)

6:05 LauJensen: or you slime, it prints the argument list in the minibuffer

6:05 s/you/use/

6:05 sexpbot: or use slime, it prints the argument list in the minibuffer

6:07 ben_m: s/.*//

6:07 Aww :3

6:20 bartj: trying to detect russian characters

6:20 why doesn't this work please - http://pastebin.org/450630

6:20 basic idea is:

6:20 (intersection #{russian character} (re-seq #"." "string"))

6:21 currently get a: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPersistentSet

6:21 Chousuke: you need to make a set out of the sequence first

6:23 bartj: Chousuke, yes, I unforunately tried with a sorted-set

6:24 (set [coll]) != (sorted-set [coll]) ?

6:24 Chousuke: heh, hmm

6:24 (doc sorted-set)

6:24 clojurebot: "([& keys]); Returns a new sorted set with supplied keys."

6:24 Chousuke: so if you want a sorted-set of a collection, you need to use apply

6:27 bartj: I am afraid, I don't really understand why I need an "apply" here

6:27 naively, wouldn't you just expected sorted-set to work ?

6:31 Chousuke: bartj: sorted-set doesn't take a collection as an argument, so you need apply

6:32 bartj: Chousuke, gee thanks! I just over-looked that.

6:57 raek: java regexes has unicode class support

6:58 so \p{L} matches a unicode code point that is a letter

6:58 no matter what script

6:58 bartj: maybe there is a unicode class for cyrillic letters

7:00 http://www.regular-expressions.info/unicode.html

7:01 #"\p{Cyrillic}" should work... :)

7:02 bartj: raek, hmm, thanks - will look into that!

7:02 raek: hrm, potentially disregard that... script matching might not be supported by java

7:18 AWizzArd: Challenge: 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.

7:19 Currently 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")

7:21 tomoj: on every request?

7:21 your clients don't have remote access, I guess?

7:23 AWizzArd: The setup is a little complicated. The Flash thing wants to use a webservice, but is restricted to do cross-site-requests.

7:23 So I want to proxy the .swf transparently on my server.

7:26 tomoj: ah

7:26 I don't actually have any advice, I was just curious :P

7:27 AWizzArd: Oki, I think I can use an input stream directly. Will try that.

7:38 raek: serving from disk should be fairly straight forward

7:38 ...but that wasn't what you needed, right?

7:39 ,(-> (java.net.URL. "http://google.com/") bean :contents class)

7:39 clojurebot: java.lang.NullPointerException

7:39 raek: ,(-> (java.net.URL. "http://google.com/") bean :content class)

7:39 clojurebot: java.lang.reflect.InvocationTargetException

7:39 raek: ,(-> (java.net.URL. "http://google.com/") bean)

7:39 clojurebot: java.lang.reflect.InvocationTargetException

7:40 raek: ,(.openStream (java.net.URL. "http://google.com/"))

7:40 clojurebot: java.security.AccessControlException: access denied (java.net.SocketPermission google.com:80 connect,resolve)

7:40 raek: I think that should make an input stream

7:41 maybe that can be passed as thre body

7:41 iirc, the body of a compojure response can be a input stream

7:41 AWizzArd: Serving from disk is done simply like: (GET "/my/file.swf" (File. "/some/path/to/app.swf"))

7:41 raek: yes, and this is what I am trying now

7:42 The only question I have is: who will close this IS?

7:43 bartj: neotyk, this is the only link I could find related to doing coverage using clojure - http://www.talios.com/code_coverage_of_clojure_code.htm

7:43 neotyk, hope this helps!

7:45 raek: AWizzArd: I think I read somewhere that compojure closes the IS after it is done with it

7:45 or was that ring?

7:45 AWizzArd: Probably ring then.

7:45 Anyway, would be good. Otherwise I have a resource leak.

7:46 raek: it makes sense for it to close the stream

7:57 AWizzArd: raek: yes, and I just checked that it indeed does close it.

8:04 old_sound_: hi guys

8:04 and gals…

8:04 I have a question regarding import and java packages

8:05 how to do something like this: import com.blah.me.something.*

8:05 I

8:05 I've only seen examples of importing classes, but not using the '*'…

8:05 AWizzArd: This is (intentionally) not directly possible in Clojure.

8:06 And in clean code you don't want to do this (:

8:06 old_sound_: hoho, thanks :)

8:07 LauJensen: AWizzArd: The benefits still arent tangible enough, imo

8:09 AWizzArd: It's not a huge win, right.

8:10 lpetit: hello

8:10 LauJensen: AWizzArd: I think there are some promises in the pipe for certain optimizations, but I dont think any of its implemented

8:10 lpetit: hey

8:11 And 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

8:12 AWizzArd: I agree. For fast hacks in the repl it could be beneficial, saving a few minutes.

8:12 lpetit: talking 'bout what, buddies ?

8:12 LauJensen: (import '(java.util.*))

8:13 lpetit: oh this

8:13 AWizzArd: In general I think Rich decided for the "right" solution in the long run, but agree that it also has disadvantages.

8:14 LauJensen: Sure - But while we wait for tangible benefits, it would have been nice to have

8:15 Dont know if its trivial to implment or not

8:15 lpetit: maybe 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)

8:16 LauJensen: Yea, I wonder if this could be plugged in

8:18 lpetit: LauJensen: 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

8:18 LauJensen: For repl experiments, we could probably suffer a slight inaccuracy

8:18 lpetit: LauJensen: 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

8:18 AWizzArd: lpetit: that message got cut off: "[...] out those that are internal cla"

8:18 lpetit: LauJensen: I also think so

8:19 AWizzArd: "...ses (XXX$YYY.class), etc."

8:31 cemerick: lpetit: I had no idea that you had a quasi-remote REPL in ccw already

8:31 lpetit: cemerick: yeah, maybe I didn't manage to get the point clear.

8:31 AWizzArd: How can I check in ring if a specific route exists, and/or which methods it allows (GET, PUT, ...)?

8:32 lpetit: cemerick: I've tried to keep it very simple, though robust.

8:32 cemerick: did it a long time ago !

8:33 cemerick: lpetit: 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.

8:33 lpetit: cemerick: 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 :)

8:34 cemerick: sure, np

8:34 cemerick: Right, that's what any remote REPL needs to do. :-)

8:34 lpetit: cemerick: :)

8:37 cemerick: 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)

8:37 cemerick: I don't know if other remote repls do that or not

8:45 cemerick: lpetit: yeah, the same notion is in the enclojure repl (it sends chunked strings instead of bytes, but the result's the same).

8:46 lpetit: cemerick: 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 :-)

8:47 cemerick: lpetit: 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! ;-)

8:47 lpetit: cemerick: so in enclojure REPL, it's not the PushBackReader which decides when he got a complete form ?

8:47 cemerick: (rofl)

8:48 cemerick: lpetit: no, it's the chunks-len in the read-socket fn that determines how much to read.

8:49 lpetit: cemerick: 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)

8:50 cemerick: yeah, the same thing will happen

8:52 lpetit: cemerick: cool

9:14 cemerick: lpetit: where are ClojureConsole and ClojureConsoleFactory hooked in? I don't see any references to them anywhere in the project.

9:14 lpetit: cemerick: they are artifacts of the past. Currently the REPL you see is just the standard ProcessConsole with a few additional hooks (implementation dependent)

9:16 cemerick: oohkay, that makes more sense now

9:16 lpetit: cemerick: 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

9:17 cemerick: lpetit: so that's for an IDE-internal REPL/console, right?

9:17 lpetit: cemerick: I guess so

9:18 cemerick: I 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.

9:18 (nevermind remote, etc)

9:21 lpetit: cemerick: yes, I'm pretty sure you're right. So there's little to keep from this 2 classes codebase, but (maybe) the skeleton

9:24 cemerick: 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

9:25 cemerick: lpetit: 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.

9:26 My 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*

9:27 That's the only way we'll be able to roll in the editor capabilities (highlighting, completion, etc), command history, etc etc.

9:27 lpetit: cemerick: 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.

9:28 cemerick: Yeah, 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.

9:29 lpetit: cemerick: 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.

9:30 cemerick: 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.

9:32 cemerick: 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.

9:32 cemerick: lpetit: Yes, the REPL runs on its own port. Ideally, we'll be able to dynamically attach the debugger to the REPL's process.

9:32 Exactly.

9:33 The environments will be the same, but you'll have a separate REPL interaction windows.

9:33 lpetit: cemerick: ok, I see we follow the same goals :-D

9:33 cemerick: I wouldn't lead you astray. :-)

9:34 I 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

9:38 lpetit: 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.

9:38 lpetit: cemerick: plugin.xml manifest is not up to date.

9:38 cemerick: OK, thanks. I'll stop bugging you now. :-)

9:41 lpetit: cemerick: 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 :)

9:42 cemerick: Heh, sure. I have to get back to work now anyway.

9:42 rhickey: has anyone tried the latest from git?

9:44 lpetit: rhickey: sorry no

9:45 rhickey: lpetit: I figured I might have to get in in an RC in order to get people to try it

9:46 lpetit: rhickey: maybe yeah

9:49 cemerick: rhickey: if there's no maven artifact, it's almost like it doesn't exist *shrug*

9:49 rhickey: cemerick: what a world we live in

9:51 cemerick: rhickey: it's hard to argue with, from a user perspective

9:51 twiddle a single line in a file....oh, look, new version of clojure to bang on, etc.

9:54 AWizzArd: rhickey: I often update my clojure to whatever is available under build.clojure.org

9:54 If the .jar from 20 hours ago includes your updates then I have them. But I did not do particular tests.

9:55 cemerick: actually, it's even better for leads and similar; distribution isn't exactly a low hurdle for most projects.

10:39 fogus_: Martin Odersky on Clojure -> http://blog.fogus.me/2010/08/06/martinodersky-take5-tolist/

10:41 dnolen: fogus: nice!

10:43 fogus_: thanks. he's a cool dude

10:48 esj: i liked his joke... perfect humour.

11:40 * fogus_ is swine (according to the LoperOS guy)

12:49 Bahman: Hi all!

13:13 esj: foguse: wow, that's #2 on HN right now...

13:49 slyrus: hmm... I don't suppose clojure's format has a ~{ ... ~} equivalent?

13:52 maravillas: ,(doc cl-format)

13:52 clojurebot: "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:54 slyrus: maravillas: thanks!

13:54 maravillas: no prob

13:59 dulanov: what is the preferred method to binary search in sorted lists? (contains? el (sort <some_coll>)) work for that?

14:08 raek: contains? only checks for keys in maps and sets

14:08 it also works for vectors, where it checks if the index is in range

14:08 has-key? would probably be a more accurate name

14:16 Lajla: raek, your shadow is most magnificent, let me worship her

14:28 mebaran151: lancepantz, did you have a chance to test out my hack?

14:36 bonega: is there some sort of take-while that needs a pred that works on taken list?

14:36 for example: (take-while + #(< % 100) (iterate inc 0))

14:39 wwmorgan: bonega: what does the + do in your pseudocode?

14:39 bonega: that's the function passed for reduction

14:40 so: reduce list with +, until sum > 100

14:41 wwmorgan: ,(->> (iterate inc 0) (reductions +) (take-while #(< % 100)) last)

14:41 clojurebot: 91

14:42 wwmorgan: I don't think there's a function like that in core or contrib.

14:42 bonega: thanks but

14:42 What I want is to return the list that equals the sum

14:43 return all values which sum < 100

14:47 cemerick: fogus_: You're probably the only one that could have brought East and West together like that. :-)

14:47 fogus_: where's the loperOS guy's reaction? I could use a good laugh.

15:01 wwmorgan: bonega: 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:03 ecyrb: I 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:03 (should I file a bug report?)

15:05 tomoj: the problem is that inside the defrecord methods, you can't use the :use'd var?

15:06 ecyrb: tomoj: sorry, I'm bad at explaining stuff.

15:07 I did a (ns my-namespace (:use (clojure.contrib server-socket))) (defrecord R [server-socket])

15:08 And clojure sort of created a type R for me, but I could never construct it

15:08 tomoj: works fine for me

15:09 https://gist.github.com/c6388f583a7e2cfbc4e4

15:10 ecyrb: yeah, it works for me too

15:10 sorry

15:10 I obviously haven't isolated the behaviour I was seeing.. Sorry about that.

15:11 tomoj: no problem

15:14 fogus_: cemerick: Thanks. :-) http://www.loper-os.org/?p=198

15:16 ecyrb: http://paste.lisp.org/+2FE6

15:17 whoops. see the annotation: http://paste.lisp.org/display/113262#1

15:18 (s/srv-socket/server-socket/)

15:22 tomoj: Does that still work? Can you instantiate a CondorServer?

15:23 tomoj: yep https://gist.github.com/b64b0da1681e35bfcda8

15:25 ecyrb: Hmmm. I'm getting a NoSuchMethodError

15:25 tomoj: clojure version?

15:25 ecyrb: 1.2.0-RC1

15:25 tomoj: me too

15:26 ecyrb: if I rename server-socket to srv-socket it works though

15:27 tomoj: what's the NoSuchMethodError say?

15:27 ecyrb: did you use the original or annotated lisppaste?

15:28 java.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:28 tomoj: the one with "server-socket"

15:28 are you using leiningen?

15:28 ecyrb: No

15:29 tomoj: maven? or what?

15:29 ecyrb: just a regular inferior-lisp

15:29 tomoj: so you constructed the classpath yourself?

15:29 ecyrb: yes

15:29 tomoj: no clue, then

15:30 arohner: technomancy: dammit man, I wrote reducate like 3 days ago. But I called it "fold"

15:30 technomancy: exact same signature

15:31 bonega: wwmorgan: thank you

15:33 ecyrb: classpath checks out

15:35 tomoj: Well, thanks for trying it out for me. I'll just rename and keep going for now

15:50 jlf`: is it expected behavior for functions like intersection/union to be unavailable prior to doing (use 'clojure.set) ?

15:51 Chousuke: yes

15:51 they're in that namespace

15:54 jlf`: hmm, i wonder why set operations get that treatment while operations on other standard data structures do not

15:55 Chousuke: jlf`: they're not "basic" operations

15:55 * arohner wishes more of core was in namespaces

15:55 jlf`: fair enough

16:26 technomancy: arohner: hah; awesome.

16:27 arohner: it was a really fun group exercise

16:28 * technomancy needs to play with ns+ and nstools some more

16:28 technomancy: jlf`: there's certainly room for improvement; see http://code.google.com/p/clj-nstools/

16:29 jlf`: interesting

16:31 technomancy: I 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:59 herdrick: having ns trouble

17:00 just doing (ns my-namespace) gets me an error

17:00 Unknown location:

17:00 error: java.lang.IllegalStateException: repeat already refers to: #'clojure.contrib.string/repeat in namespace: my-namespace

17:01 that contrib package is one which previously i had done a require clause on

17:01 but if I get rid of that clause, i would think that I would start with a fresh slate

17:09 lozh: I wonder if (ns-unmap 'my-namespace 'repeat) would fix it?

17:09 herdrick: it's just odd, because I haven't seen anything like this happen before

17:09 if i do this:

17:09 (ns my-namespace

17:09 (:use clojure.contrib.jmx)

17:09 (:use clojure.contrib.combinatorics))

17:09 and 'compile' it

17:10 it works fine once

17:10 the second time it blows

17:10 lozh: I'm not sure :use makes sense without specifying classes

17:12 Ah no, refers to all public vars of ns subject to filters, that should be fine

17:14 herdrick: do you get the same result?

17:16 lozh: I'm just starting up a repl now, sec

17:16 herdrick: thanks, lozh:

17:17 edbond: I'm trying to use deftemplate from enlive, got NullPointerException. How to debug/fix?

17:17 lozh: yep same thing, though I get the error with #'clojure.core/read and #'cloure.contrib.jmx/read

17:18 herdrick: right, same thing here

17:18 lozh: Get a warning first time, then an error second

17:18 herdrick: try just saying (ns my-namespace)

17:19 lozh: same error

17:19 herdrick: yeah

17:19 also the ns-unmap doesn't work

17:19 dnolen: edbond: that's almost always because deftemplate can't find the html resource you're pointing to, in my experience anyway

17:20 herdrick: so I've been restarting my 'lein swank' everytime i get into this problem

17:20 which is ridiculous

17:21 edbond: dnolen: thanks, does it looks for it on compile?

17:22 herdrick: lozh: what do you do for 'importing' packages

17:22 ?

17:23 lozh: I've not had to import a complete package yet, just a few named classes

17:23 herdrick: ok

17:24 so, what... I'm supposed to only do a "require" and never "use"?

17:24 rhudson: herdrick, you'd likely be better off doing (:require [clojure.contrib.jmx :as jmx])

17:25 herdrick: rhudson: actually I can't even do that

17:25 apparently i need to restart my REPL

17:25 because what I was doing has it in a state where even this:

17:26 (ns your-namespace

17:26 (:require clojure.contrib.string)

17:26 (:require clojure.contrib.combinatorics))

17:26 edbond: dnolen: created a file and still have NPE.

17:26 herdrick: breaks it

17:26 error: java.lang.IllegalStateException: repeat already refers to: #'clojure.contrib.string/repeat in namespace: your-namespace"

17:26 Raynes: (ns your-namespace (:require clojure.contrib.string clojure.contrib.combinatorics)) also works.

17:27 rhudson: The rule of thumb I use is require instead of use unless I'm absolutely sure there are no confligcts

17:27 herdrick: which is extremely annoying

17:27 pdk: what, did 1.2 come out today

17:27 herdrick: rhudson: ok

17:28 Raynes: If you're using 1.2, clojure.contrib.string is deprecated in favor of clojure.string.

17:29 lozh: if there's only a small number of conflicts then you might be able to stuff a :except in your :use

17:29 assuming it supports everything use does

17:32 erm :exclude, not :except

17:33 edbond: where does enlive looks for templates?

17:33 lozh: herdrick: If you change your :use clause to (:use [clojure.contrib.jmx :exclude (read)]) then I can run it repeatedly

17:34 I guess you could refer to read specifically if you needed the jmx method too

17:34 herdrick: lozh: hmm, i had tried that - maybe i got the syntax wrong will check

17:38 lozh: The unmap thing worked for me too, (ns-unmap 'my-namespace 'read) meant I could rerun the (ns...)

17:38 I think the exclude thing only works provided you haven't already errored

17:39 herdrick: lozh: that new clause isn't working for me, though it might if I restart my REPL

17:39 dnolen: edbond: have you tried running a file exists on that file or reading it by other means?

17:39 edbond: deftemplate uses html-resource, you might want to call that directly

17:39 lozh: yep, I did it multiple times from a fresh repl

17:40 the ns-unmap thing fixes it for me without restarting the repl, though

17:40 herdrick: lozh: BTW how did you decide upon surrounding clojure.contrib.jmx plus the :exclude thing in a vector?

17:41 lozh: google

17:41 http://clojure.org/libs

17:42 I copied the way :only is used near the top of example lib

17:42 herdrick: lozh: right, copying and pasting works

17:42 it's just that I want to know why

17:42 why surround with a vector

17:43 why are :exclude and :use and whatnot keywords

17:43 I just find the ns and require and use stuff to be a baffling mini-language, not much documented

17:43 rhudson: I know that frustration.

17:44 herdrick: rhudson: thanks

17:44 rhudson: I finally figured out the right way to do (require [xxx :as yyy]) by reading the source code

17:44 lozh: I 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:45 rhudson: The reason might be that generally in Clojure, places where symbols are bound use vectors

17:45 herdrick: so that's "require" not within a "ns"?

17:45 rhudson: without ns: (require '[xxx :as yyy])

17:46 inside ns: (:require [xxx :as yyy])

17:46 herdrick: i don't think quoting out that vector is necessary, right?

17:47 rhudson: I think the docstring for ns says that the options for :require :use etc are the same as the standalong require use etc

17:47 slyrus: for the clojure-loving chemists/bioinformaticians: http://github.com/slyrus/chemiclj

17:47 edbond: dnolen: (enlive/html-resource "www/index.html") raises exception.

17:47 dnolen: edbond: there you go

17:48 edbond: is www in your src directory? are you using lein to manage the classpath?

17:48 edbond: www is in project root (where project.clj is), yes I use lein

17:49 dnolen: edbond: project root is not on the classpath, src is

17:49 edbond: just move www into src

17:50 edbond: lein also support setting resource-path I believe or something like that

17:50 rhudson: The quote's necessary in (require '[xxx :as yyy]) because the construct is expecting a couple of symbols.

17:51 edbond: dnolen: works, many thanks.

17:51 dnolen: edbond: np

17:51 rhudson: Without the quote, it's trying to resolve xxx and yyy, and complaining when it can't

17:51 neotyk: how do one start swank-clojure-project for project managed by new lein?

17:52 rhudson: But 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:53 lozh: neotyk: 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:53 herdrick: rhudson: someone please make the pain stop

17:54 rhudson: It just takes a while to get used to. You'll get it

17:55 herdrick: I don't want to. Clojure is beautifully designed. That's a big part of the appeal. But this stuff is awful.

17:55 rhudson: You don't actually need to use namespaces until you start writing multi-file programs

17:55 herdrick: but thanks, rhudson:

17:56 but you still need require or use

17:56 (which of course are calling differently than if they were within an "ns". yuk.)

17:57 rhudson: Right. 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:57 or if I want to parse xml, then (require '[clojure.xml :as xml]) then (xml/parse whatever)

17:58 herdrick: AHA! 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:58 * Raynes hasn't found a good reason to be disgusted at Clojure's namespace capabilities.

17:58 herdrick: ok, clojure.repl, cool

17:58 rhudson: Namespaces are kind of like maps -- you wouldn't want to be restricted to having all your maps have distinct keys

17:59 So the ns/require/use stuff gives you control over how names are bound.

18:00 herdrick: ...through use of its mini-language

18:00 rhudson: Right. And I'm not saying it's not a little tricky to get the hang of

18:01 But that mini language is all Clojure keywords and functions and macros.

18:02 herdrick: Raynes: 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:02 rhudson: Somewhere (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:02 herdrick: Raynes: that's why we're all using Clojure instead of C++ after all

18:02 Raynes: I don't see anything wrong with it. :\

18:02 dnolen: herdrick: 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:03 Raynes: dnolen: Indeed! I've made magics happen with require that were only possible thanks to it being a function. :D

18:03 herdrick: rhudson: 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:05 dolen: 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:05 and the REPL is then borked and needs a restart

18:06 rhudson: I've never seen much need to use namespaces in the REPL unless I'm specifically trying to explore what namespaces do.

18:06 jlf: herdrick: there's nothing messy about CL's do

18:07 maybe you mean loop?

18:07 herdrick: dnolen: Raynes: sounds interesting. what have you done with require and use as functions where they being functions has mattered?

18:07 jlf: oops, thanks. yes, loop

18:08 but 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:09 dnolen: herdrick: 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:10 (require '[some.long.ns :as ns]) or (use '[some.ns.with.lots.of.defs :only [the-one-you-need]))

18:10 everything else is asking for trouble

18:10 rhudson: what dnolen said

18:11 herdrick: dnolen: all of the docs for clojure.contrib stuff says no

18:11 example: http://richhickey.github.com/clojure-contrib/string-api.html

18:11 gfrlog: has anybody made use of remove-ns?

18:11 dnolen: herdrick: says no ?

18:12 rhudson: gfrlog: yes, I had reason to define some temporary namespaces & remove them afterward

18:12 hiredman: dnolen: he's pointing at the usage example at the top

18:12 herdrick: dnolen: right, at the top of that page is:

18:12 Usage:

18:12 (ns your-namespace

18:12 (:require clojure.contrib.string))

18:12 and all the other such pages

18:12 hiredman: herdrick: that is the "simplest" possible usage, not the correct one

18:13 herdrick: dnolen: 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:13 hiredman: import java.util.*; vs import java.util.HashMap;

18:13 dnolen: herdrick: note the use of require, it's doesn't say different from what I just said

18:13 rhudson: It's a young language yet, and we're living on the frontier

18:13 herdrick: well... maybe the correct one should be simpler or put the correct on there instead

18:13 rhudson: right! which is good.

18:14 how about making the docs wiki?

18:14 gfrlog: rhudson: are there any gotchas related to messing with namespaces? I get errors resolving the symbol I pass

18:14 hiredman: the correct one depends on which functions you are using

18:14 rhudson: It's not incorrect, just kind of inconvenient: with that you need (clojure.contrib.string/capitalize whatever)

18:14 herdrick: dnolen: it doesn't use :as

18:14 rhudson: with an alias (say ccstr) you just need (ccstr/capitalize whatever)

18:14 hiredman: :use and :only

18:15 rhudson: clojuredocs.org

18:15 dnolen: herdrick: :as is just a convenience. it is recommending the right thing.

18:16 herdrick: dnolen: i thought that was asking for trouble

18:16 dnolen: herdrick: no, sorry. require or require + :as is always fine. a use without :only is the problem.

18:17 rhudson: With those usages, you know exactly what symbols you're introducing

18:18 dnolen: herdrick: use is basically a blind import, you can and will get clashes. require keeps that from happening.

18:18 herdrick: dnolen: rhudson: ok, thanks

18:18 rhudson: gfrlog: what kinds of errors?

18:20 gfrlog: rhudson: http://gist.github.com/512112

18:21 lozh: (remove-ns 'x) ?

18:21 rhudson: I think you need to do (remove-ns 'x)

18:22 gfrlog: I bet so :)

18:22 but only because I didn't think of it this time

18:22 great, thanks

18:24 technomancy: use and require have a rehaul in the works planned

18:24 clojurebot: google ns use require overhaul

18:24 clojurebot: First, out of 35900 results is:

18:24 House sends health bill to Obama&#39;s desk - Politics - Health care ...

18:24 http://www.msnbc.msn.com/id/35961584/

18:25 technomancy: yeah... anyway. check the mailing list archives.

18:37 neotyk: lozh: thanks, it works!

18:38 herdrick: technomancy: very very good to hear that. and i'm not surprised that it stuck out as being unclojurian to the leadership

18:40 lozh: cool!

18:40 I think http://www.mail-archive.com/clojure@googlegroups.com/msg20403.html is some of the discussion.

18:41 and 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:51 kencausey: This 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:52 I 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:52 mebaran151: is there a general utility to turn a map into a record, given they share the same keys?

18:53 kencausey, ctrl-d works on linux, I think it's ctrl-z on Windows, and you can always do a (System/exit)

18:54 sorry (System/exit 0)

18:54 kencausey: mebaran151: ah, I'm in cygwin which blurred my thinking here, ctrl-z it is, thanks.

18:54 thanks again

18:54 mebaran151: glad I could help

18:54 kencausey, what are you using Cygwin for though?

18:54 you can run clojure pretty easily in plain ol' windows

18:55 kencausey: because I like a unix environment?

18:55 mebaran151: ah, I was just checking, because I know ruby hatd Windows

18:56 without cygwin to support it

18:56 kencausey: I hadn't assumed clojure needed cygwin

18:57 mebaran151: sorry, just being too presumptuous

19:19 slyrus_: anyone using cow-blog?

19:22 pdk: brian carper would be an obvious guess :p

19:28 slyrus_: well, yeah, anyone else? and what's his nick?

20:13 raek: has anyone made a "forcat"

20:14 ...that works like for, but concatenates all the results into one sequence

20:14 ("result" = result sequence)

20:14 slyrus_: forcan, a la mapcan

20:15 if course this lisp doesn't have nconc :)

20:18 raek: I see you have fontlock on for defrecord. but you left the indentation the way it was?

20:20 raek: it requires you to activate the backtracking indentation mode

20:20 but I think I added a rule for the usual mode too...

20:21 (defrecord 2)

20:22 yep, when using the default indentation mode, the two first forms will be indented 4 spaces and the rest 2 spaces

20:22 this will not indent the methods correctly, though

20:23 slyrus_: M-x customize-variable, clojure-mode-use-backtracking-indent

20:23 that should make defrecord indent well

20:25 Derander: I need to create some sort of random facts repository

20:26 stuff like that is so incredibly useful when you need it, but it's so incredibly forgettable when you don't

20:29 slyrus_: raek: hmm... no all the lines are indented two spaces, as before. perhaps I'm doing something wrong though.

20:31 raek: slyrus_: can you do a paste?

20:31 maybe I overlook something

20:31 slyrus_: sure, of what?

20:31 raek: ah, misread

20:33 in the backtracking mode, the name and fields of the record are indented two additional spaces

20:33 this doesn't happen for you?

20:34 this seems to happen in both modes for me

20:34 slyrus_: 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:34 no, I just throw all that stuff on one line

20:34 or w.w. the fields, if need be.

20:35 raek: currently, I don't think that would be possible to do

20:36 also, indenting the method forms at the same column as the protocol names is what I've seen in most code

20:36 slyrus_: well, yeah, because that's what emacs does! :)

20:37 trying to override your editor's indentation preferences is madness. fixing those preferences, not so much

20:38 raek: yeah, I never manually corrected the indentation for method contents before

20:38 slyrus_: heh. maybe somebody will write a clojure mode for climacs.

20:39 raek: thought I'd either change clojure-mode or accept it

21:00 technomancy: raek: 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:22 raek: I would consider the commits I've made so far on my fork to be ready for integration with your fork

21:22 technomancy: feel free to pull them whenever you like it

21:24 btw, how would you like to be notified when I have something ready?

21:31 slyrus_: 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:47 rplevy: for 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:47 *scriptjure

22:08 does anyone know of an example of using scriptjure in leiningen?

Logging service provided by n01se.net