#clojure log - Jan 30 2010

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

0:11 krumholt: will a compiled jar file increase executing speed compared to evaluating something in the slime repl?

0:12 chouser: krumholt: the compiled jar might load faster, but once it starts running it should be the same

0:13 krumholt: chouser, ok thanks

0:30 i noticed that a few type in clojure start with an A like ASeq and APersistentVector. There is also ISeq which i assume stands for Interface. what does the A stand for? and is it a kind of interface?

0:31 chouser: A is for Abstract

0:32 an Interface provides no implementation at all for any method

0:32 krumholt: ok and abstract provides some implementation for all subclasses?

0:32 chouser: an Abstract class provides implementations for some methods, but not all of them, so you still can't instantiate one.

0:32 krumholt: ok thanks for clearing that up

0:33 chouser: you need a concrete class like PersistentVector in order to actually make instances. It will provide implementations for the methods the abstract class left out, plus could provide new methods of its own (though that's generally bad practice)

0:35 krumholt: i get the idea thanks. is there a convention to name protocols?

0:35 chouser: That's a great question. I don't think any has emerged yet.

0:36 I suspect they'll be capitalized like type names, but beyond that I don't know.

0:37 krumholt: ok. i think i just go with PMyprotocol for now

0:41 chouser: We'll all have to get such conventions ironed out before fogus and I get around to writing the protocols chapter. :-P

0:43 krumholt: ok one more question. can i have my own constructor for protocols? because i need 4 fields but the user really only ever needs to supply 3 of those.

0:44 chouser: fields? are you talking about deftype?

0:45 Raynes: I think he is.

0:45 Otherwise, he's using a different language than the one I'm using.

0:45 :o

0:45 Speaking, or otherwise.

0:46 chouser: krumholt: Users will not generally create deftype instances directly -- instead you'll want to provide a regular function they can call, and create your instance in there.

0:46 krumholt: chouser, so i should provide a make-instance function for a deftype

1:10 chouser: krumholt: yes, if it users will be wanting to make instances of that deftype

1:35 krumholt: in a deftype i should be able to use the unqualified name for calls to new and instance?. this seems not to work for calls to instance?

1:35 http://paste.lisp.org/display/94136

1:39 Raynes: I hereby declare that load-file is the most awesome thing ever.

1:40 Arbitrary user configuration has never been so easy.

2:06 This email client is going to be the most hilarious mess of code evar.

2:20 Is there a version of load-file that takes a java.io.File?

2:25 krumholt: Raynes, (load-file (.toString yourjava.io.File)) that shuold work

2:25 Raynes: krumholt: Hah. Nice. I didn't know Files had a toString method.

2:26 Thanks.

2:26 Hrm. They've been "migrating to ircd-seven shortly" for the last two weeks or so. >.>

3:11 Hrm. Why is it that lein new spits out src/projectname.clj with a namespace of projectname.core?

3:11 Shouldn't the namespace just be projectname, considering it's top level in src?

3:15 _ato: Raynes: yes, that's a bug that was fixed a while ago. You might want to update to lein 1.0.1

3:15 Raynes: I didn't know I was using an old version.

3:16 _ato: lein -v should tell you what version you have

3:16 although I don't know when that -v option was added

3:17 Raynes: _ato: The way to upgrade would be to download the install script, and do that stuff again right?

3:17 There isn't any update magic I don't know about, I'm hoping.

3:19 _ato: Raynes: yeah, just do the install steps again. Probably it'll eventually get a lein self-update or something, but it doesn't do that yet

3:20 Raynes: Just checking. Didn't want to fry anything. :p

4:59 Hali_303: is there something in slime that allows me to automatically insert a :use in case I start to type a form with (str-join? so that I don't have to manually type the :use at the top?

5:03 krumholt: am i correct that methods from deftype are not to be invoked by the user of a library directly. instead there should be a number of functions using the methods?

5:04 _ato: Hali_303: not for :use AFAIK. _mst did this hack for java :imports though: http://dishevelled.net/Generating-Clojure-import-lines-using-SLIME.html

5:05 Hali_303: _ato: so for example, if you'd like to use str-join, but it's early morning and you don't know what package has that, what do you do?

5:08 _ato: Hali_303: heh, if I was smart, I'd probably just leave http://richhickey.github.com/clojure-contrib/ open in another window and search it. But actually I tend to just do: grep -r 'str-join' ~/src/clojure-contrib/src

5:09 krumholt: if I understand it correctly the idea is that deftype methods are only for java interop (ie implementing a java interface)

5:09 Hali_303: _ato: I see, thanks

5:10 _ato: ah wait.. I see protocols get called "methods" as well

5:11 krumholt: _ato, i am not using any java at all

5:11 _ato: defprotocol will define the functions

5:12 (just think of them like grouped multimethods)

5:12 so to answer your question directly: yes you are correct. ;-)

5:13 krumholt: ok but except for the speed gain they are really a lot of extra work. multimethod is somewhat nicer

5:14 _ato: yes, I agree

5:16 they were originally introduced so that you can write fast data structures in Clojure. If you're not writing a data structure (or have crazy performance requirements) then you probably better off sticking with multimethods, maps and vectors

5:16 krumholt: i think i am using them wrong. i am stuck in object oriented thinking :)

5:19 _ato: yeah, it's too easy to start thinking of them as OO objects, but a lot of the time what you're really looking for when you think "object" is just a plain old map and some plain old functions.

5:21 Raynes: I use deftypes where I would use structs. For instance, in my email client, I have a MessageInfo type that holds all relevant email message information. A processing function processes an email folder and turns an array of Messages into a sequence of MessageInfos

5:21 I've yet to have a reason to use multimethods or protocols so far.

5:23 Hali_303: how can I have rainbow parentheses in emacs?

5:23 I've got emacs installed, but it's still black and white

5:23 I mean slime installed

5:23 somnium: being able to implement IFn on deftypes is cool. They feel really first class.

5:23 Raynes: Hali_303: highlight-parentheses-mode

5:23 Hali_303: Raynes: thanks

5:24 Raynes: Hali_303: Also, show-paren-mode is awesome.

5:25 Chousuke: hmm

5:26 Raynes: as long as you don't overuse types. :)

5:26 Raynes: Chousuke: Structs are used for maps that have keys in common, right?

5:27 Chousuke: it's a good thing that types are interoperable with standard maps but I fear people will use them for every little thing :/

5:27 _ato: Hali_303: if you want vim-style rainbow parens, where all the parens are coloured, not just the ones the cursor is inside, then there's this one: http://dishevelled.net/elisp/rainbow-parens.el

5:27 Raynes: I want. :D

5:28 _ato: Hali_303: personally I find that way too "busy" though. _mst just made that because of all the people complaining that emacs didn't do vim-like rainbow parens, he doesn't use it either. ;-)

5:28 Hali_303: :D

5:28 I'll try it and see if it helps or not

5:28 Chousuke: paredit does away with most need for paren highlighting though. :)

5:29 Hali_303: hm. I'm not using that, what is that good for?

5:29 Raynes: Paredit doesn't help me with that sort of thing at all.

5:29 If anything, it slightly hinders me.

5:29 Chousuke: Hali_303: it lets your edit s-expressions instead of text

5:29 _ato: heh.. I prefer less-visible parens. I don't look at them much

5:29 the-kenny: C-k doesn't kills the current line, but the next sexp :)

5:30 Chousuke: Hali_303: you will never have to hunt for the missing paren again!

5:30 the-kenny: that's what I like most

5:30 Hali_303: thanks, I'll try that then

5:30 Chousuke: makes moving code around very easy

5:31 the-kenny: Chousuke: Yeah, that's very cool

5:31 _ato: technomancy or someone did a paredit tutorial didn't they? it takes a little while to learn the hotkeys but once you do it's extremely handy, I find it really painful coding without paredit now

5:32 krumholt: ok i have a question if i just want to dispatch on type is there a way to do that with multimethods that is fast?

5:32 Chousuke: the-kenny: I also like barf and slurp eg. for wrapping things in a let (or removing one)

5:32 krumholt: deftype :P

5:32 krumholt: it's only on master right now.

5:32 whoops, deftype *and* protocols I mean :)

5:33 _ato: this might be what I'm thinking of: http://p.hagelb.org/paredit-outline

5:34 krumholt: Chousuke, ok thanks

5:34 the-kenny: Chousuke: Yes, the wrap-stuff is pretty neat

5:39 Hali_303: yet another slime question: when I do a CTL c CTL k to do compilation and there is an error, how do I jump to the line where the error is?

5:42 noidi: Hali_303, great question, I've wondered about that too, but I've been always too busy fixing my code to remember to ask about it :)

5:43 _ato: I think it might be supposed to be: C-x ` (backtick) but it doesn't work for me. I might be one of the SLIME features that swank-clojure hasn't implemented yet

5:43 Chousuke: I hadn't even thought of that :P

5:43 _ato: in my output the errors are prefixed with "Unknown location"

5:43 although it does have the line number in the actual error message

5:43 I suspect SLIME is the one saying that "Unknown location"

5:43 Chousuke: usually the error is local to what I was previously editing so having a jump function wouldn't be that much faster anyway :/

5:44 Hali_303: also, that's "C-c C-k" in emacs parlance :)

5:44 _ato: I just usually M-g g and type the line number in the error

5:44 it'd be nice if there was a shortcut though :(

5:44 Hali_303: Chousuke: ok :)

5:44 _ato: better than nothing, thanks

5:49 paredit is really cool :D

5:50 hm. however, it only insert normal parentheses automatically, not { or [

5:51 ok [ also works, but { does not

5:51 hiredman: my paredit does ( and [, but not {

5:51 Hali_303: yes

5:51 hiredman: right, *shrug*

5:51 Hali_303: hiredman: btw what code are you using to auto-load it for slime?

5:52 now I have to manually type M-x paredit-mode

5:52 noidi: (add-hook 'clojure-mode-hook (lambda () (paredit-mode +1)))

5:52 Hali_303: noidi: thx

5:53 noidi: or for slime (add-hook 'slime-mode-hook (lambda () (paredit-mode +1)))

5:53 the latter doesn't work for me though, for some reason

5:53 and to highlight parens every time you load paredit:

5:53 (add-hook 'paredit-mode-hook (lambda () (show-paren-mode +1)))

5:54 the-kenny: myn paredit does { [ and ( :)

5:55 noidi: the-kenny, how did you manage that?

5:55 _ato: mine does all three as well. I added this for the M-{ hotkeys: http://gist.github.com/290508

5:55 noidi: I always have to insert the closing } manually or paredit gets confused

5:55 the-kenny: noidi: I think I got the file from someone here. Maybe _ato?

5:55 noidi: ok

5:56 _ato: I'm also using paredit version 22 if that makes any difference

5:57 noidi: Hali_303, you might (or might not, depending on how much you like to look at parens) like parenface.el -- it dims the parens so they blend into the background a bit

5:57 Chousuke: my paredit works just fine as well

5:57 _ato: http://mumble.net/~campbell/emacs/paredit-beta.el

5:58 noidi: here's parenface.el with clojure support added http://gist.github.com/290509

5:58 I've probably changed the paren color, too, to match zenburn

5:59 Hali_303: after typing (str-join how do I display the docs for str-join?

5:59 noidi: ah, I'm using paredit 20 from elpa

5:59 Hali_303: I know that it shows the parameters at the bottom

5:59 but I'd like to see the full docs

5:59 _ato: C-d C-d d

5:59 noidi: how the %#¤& can the elpa package be 2 versions behind? o_O

6:00 Chousuke: no-one has bothered to update it :)

6:00 _ato: you can also use C-. to jump to the source code for str-join

6:00 err. I mean M-.

6:01 Chousuke: and technically it's just one version behind, as 22 is beta

6:01 _ato: and then M-, to return to where you were

6:01 noidi: Chousuke, okay, thanks... I'll upgrade to 22b then

6:02 * _ato loves the way M-. will jump to source for a function even if it is in a jar

6:02 noidi: _ato, thank you! I didn't know about the jump functions in slime!

6:02 I thought I needed tags like with C

6:02 so I never bothered :)

6:04 _ato: yeah, that's one of the other nice things about having the editor connnected to the compiler like that. It doesn't need tags, it can just eval this:

6:04 ,(meta #'drop-while)

6:05 huh.. no clojurebot? well then the result is: {:ns #<Namespace clojure.core>, :name drop-while, :file "clojure/core.clj", :line 1857, :arglists ([pred coll]), :doc "..."}

6:08 hiredman: oh, right

6:08 stupid registeration requirement

6:09 clojurebot: ping?

6:09 clojurebot: PONG!

6:09 hiredman: ,(meta #'drop-while)

6:09 clojurebot: {:ns #<Namespace clojure.core>, :name drop-while, :file "clojure/core.clj", :line 1875, :arglists ([pred coll]), :doc "Returns a lazy sequence of the items in coll starting from the first\n item for which (pred item) returns nil."}

6:09 _ato: weirdly it replied to me in privmsg which I thought also required registration

6:09 or have they changed it now so messaging a channel requires registration but privately doesn't any more?

6:09 hiredman: I don't know

6:10 Chousuke: _ato: isn't it configurable by the user?

6:10 _ato: Chousuke: ah.. yeah that's probably it

6:11 kotarak: _ato: I have trouble with clojars and every scp which is not scp.

6:11 Hali_303: do cross-reference shortcuts work for you? I tried C-c C-w c, but it doesn't work "Evaluation aborted"

6:11 kotarak: _ato: neither jsch nor ganymede work with clojars :(

6:12 Hali_303: C-c < this doesn't work either

6:13 hiredman: I thought clojars used jsch

6:13 _ato: Hali_303: nope they don't work for me either. Probably more SLIME features not implemented for Clojure

6:13 Hali_303: _ato: sad :/ that's a feature that is very useful in practice

6:14 kotarak: jsch + "real" ssh = works, ganymede + "real" ssh = works, "real" scp + clojars = works, jsch + clojars = nope, ganymede + clojars = nope

6:14 _ato: kotarak: hmm I wrote a (pure) jsch client that works

6:15 I knew it didn't work with maven

6:15 kotarak: _ato: huh? May I use that? I tried with the jsch ant scp task, didn't work.

6:15 _ato: maven also uses jsch I think

6:15 kotarak: _ato: I'd like to have a look what that does differently.

6:16 _ato: jsch is a little annoying because there are lots of incompatibilities with jsch, ant, gradle, bleh.

6:16 _ato: it might be because Clojars "talks" on stderr, to give feedback about whether it succeeded or not and to give an error if there's a problem (like if you're trying to post to a groupId you don't own, or you didn't include the POM or whatever)

6:16 kotarak: _ato: But I'd like to know why it doesn't work.

6:17 _ato: kotarak: http://github.com/ato/lein-clojars/blob/master/src/leiningen/push.clj

6:19 kotarak: _ato: thank you for the link. I'd really like to support clojars directly from clojuresque. At the moment I'm shelling out to scp. Not very nice and doesn't for windows

6:20 _ato: I wondered whether it's because I'm doing this to hook up the SSH session's error stream to stdout: (.setErrStream System/err true)

6:20 maybe the other JSch scp implementations don't do that and a buffer somewhere gets blocked up

6:20 maven just hangs when you try to make it scp something to clojars

6:21 that's just a guess though, I might be completely wrong. I never got around to trying to debug it

6:23 kotarak: _ato: I get a failure that some read failed and it says connection broken or so. I also thought about the buffer question. I'll see and have a try.

6:24 _ato: okay. If you find out what it is, let me know so I can try and fix it on the server side

6:24 kotarak: k

6:24 _ato: btw. goot to see you back :)

6:24 s/goot/good

6:25 _ato: :)

6:27 kotarak: _ato: another btw: the search doesn't work. When you search for clojureql you find two uploads which are not the official one. And the official one called "clojureql" is not found...

6:29 _ato: yep.. search fails to find things without a description (root cause: the result of concatenating a string to a null in sqlite is null :-P)

6:30 fix will be out soon (I know I've been saying that for a while... just keep getting distracted by other things)

6:30 kotarak: LauJensen: clojureql needs a description on clojars to show up in the search

6:32 _ato: oh, and another thing (sorry, collected some topics...): I'd like to be able to delete artifacts again.

6:32 eg. my clojares-deploy-testcase for my scp experiments (couldn't do it on my server, because there it worked.... :( )

6:34 _ato: yeah... as far as I know there's no way to tell maven to undeploy something from a repo (as you normally wouldn't want to as it'd break dependencies).

6:34 for now just email me if you need something deleted and I'll do it by hand

6:35 at some point I'm going to ditch maven completely from the clojars codebase, and just have it serve up a maven-compatible view of the repo

6:35 LauJensen: kotarak: I'll fix it, I'm AFK

6:35 kotarak: _ato: the thing in question is org.clojars.kotarak/clojuresque-clojars-deploy-testcase, but you can leave it around for now, then I have something to test while investigating the scp issue.

6:38 _ato: /again sorry/ and the foo-1.2.3.pom change is not live

6:39 krumholt: in emacs minibuffer i usually get help for functions. this is not working for multimethods or protocol methods. can i get the minibuffer to work for them too?

6:39 _ato: kotarak: what foo-1.2.3.pom?

6:39 kotarak: _ato: clojars didn't recognise the .pom extension. You changed that, but the change didn't go live.

6:40 _ato: aah.. right. Yep, sorry. I'll try to get all that stuff out tomorrow. I've been really slack about it. :(

6:56 hoeck: krumholt: multimethods have no arglist metadata attached, so the minibuffer help has nothing to display

6:57 krumholt: but if you define your multimethod with explicit :arglists metadata, minibuffer help works for them too

6:57 krumholt: hoeck, can i do that?

6:57 hoeck, super thanks

6:57 kotarak: this can be remedied by defining multimethods as: (defmulti multifn "Some multimethod" {:arglists '([arg1 arg2 arg3])} dispatch-fn)

6:58 krumholt: is that possible for protocol methods too?

6:58 kotarak: Hmm.. Protocol methods don't have arglist info?

7:00 hoeck: no, they have not, but I guess its on the todo-list

7:00 krumholt: no. or at least they don't have minibuffer help

7:01 can i add it manually? or will i just have to wait a while?

7:02 patrkris: Does anyone know of any websites written in compojure, that I can have a look at and learn from? Specifically, if I use the HTML functions in compojrure, how do I best organize "templates" and such.

7:02 hoeck: krumholt: yes, defprotocol methods are normal fns bound to a var

7:03 krumholt: just use alter-var-root and with-meta

7:04 krumholt: so (alter-var-root myvar (with-meta myvar {:arglist '([arg1 arg2])}) ?

7:06 hoeck: krumholt: sorry, its (alter-meta! #'myvar assoc :argslist '([a]))

7:06 krumholt: hoeck, many thanks

7:07 Raynes: How do I comment out a line of code with paredit active?

7:07 hoeck: krumholt: np :)

7:07 Raynes: If I attempt to comment out a piece of code the old fashioned way, it inserts a newline after the semi-colon.

7:08 AWizzArd: ,(doc alter-meta!)

7:08 clojurebot: "([iref f & args]); Atomically sets the metadata for a namespace/var/ref/agent/atom to be: (apply f its-current-meta args) f must be free of side-effects"

7:08 AWizzArd: The docstrings don't mention functions or symbols.

7:10 mikem: tomoj: I saw you had issues building clojure-contrib with pprint.ColumnWriter recently. how did you solve this? the build fails for me building pprint.PrettyWriter

7:11 ClassNotFoundException: clojure.contrib.pprint.ColumnWriter (PrettyWriter.clj:17)

7:11 hoeck: AWizzArd: the protocol function is bound to a var, just like a normal defn function

7:13 Raynes: I don't like this behaviour, so I removed the paredit-semicolon command from my keymap

7:13 Raynes: hoeck: Good idea.

7:15 krumholt: hoeck, it's arglists not argslist :) if anyone else tries but thanks anyway

7:16 hoeck: krumholt: you're right

7:17 _ato: patrkris: it's not particularly clean code, but you could look at my code for the clojars webapp

7:18 patrkris: I have a clojars.web.whatever module roughly for each page

7:18 http://github.com/ato/clojars-web/tree/master/src/clojars/web/

7:19 no idea whether it's the "right" way of doing it

7:19 I couldn't find any examples either, so just went off and did my own thing :p

7:21 "controller" like functionality is usually in the same file but a different function

7:24 this might be another one to look at, the old compojure.org code: http://github.com/weavejester/compojure.org/tree/master/src/org/compojure/

9:30 dabd: ..

9:48 tomoj: mikem: hmm

9:48 on a different project I just added 1.2.0-master-SNAPSHOT deps and it worked fine

9:49 haven't tried again yet to build contrib manually

9:49 and I still don't really understand what happened when I had the problem

9:49 but, good luck :/

9:52 mikem: tomoj: i see. strange, i'm not doing anything special, just building clojure from source, then clojure-contrib. i wonder how it works on the build servers

9:52 tomoj: apparently it doesn't

9:52 well, something's not quite right anyway

9:53 clojure-contrib is red at build.clojure.org

9:53 mikem: good point :) looking at that now...

9:53 tomoj: not sure whether that means tests failed or what exactly

9:54 the jars I got seemed to work fine, so someone must be building successfully...

9:54 mikem: it's the same thing I'm seeing: http://build.clojure.org/job/clojure-contrib/lastFailedBuild/console

9:54 maybe the jars are from the last successful run

9:54 tomoj: yep, looks like the error I got as well

9:54 ah, good point

9:54 mikem: i don't know enough about maven or clojure-contrib to figure it out :S

9:55 tomoj: if the last successful build was also tagged as 1.2.0-master-SNAPSHOT, I'd get that from lein deps I guess

9:55 but..

9:55 "last success: N/A"

9:55 heh

9:55 mikem: just noticed an email to the mailing list asking about this

9:56 tomoj: oh, thanks

10:07 leafw: what is the preferred way to build clojure-contrib? There isn't a build.xml anymore

10:07 with mvn ? UGH

10:09 krumholt: i want to map across a sequence with a function. but i need to apply the function to the first argument once, to the second twice, to the third 3 times ... how can i do that?

10:10 leafw: sp Stuart Sierra, what motivated the removal of the ant build.xml ?

10:11 clojure.git still has it; so now one needs ant for one and mvn for the other? Uh? Or are the plans from removing build.xml from clojure.git as well?

10:11 noidi: krumholt, by applying twice, do you mean (f (f x))?

10:11 or (f x) (f x) for side effects

10:12 krumholt: noidi, (f (f x))

10:12 no siede effects

10:12 -e

10:12 noidi: ok

10:12 _ato: leafw: http://groups.google.com/group/clojure-dev/browse_thread/thread/cd807a1e5d7ce77d

10:15 somnium: ,(map #(take %1 (iterate inc %1)) (range 5))

10:15 clojurebot: (() (1) (2 3) (3 4 5) (4 5 6 7))

10:15 leafw: thanks. I forgot the music moved to clojure-dev

10:16 AWizzArd: is there a reader macro for entering symbols or keywords that contain spaces?

10:16 somnium: krumholt: something like that?

10:16 AWizzArd: ,(keyword "hello guys")

10:16 clojurebot: :hello guys

10:16 krumholt: somnium, i am trying to understand that

10:17 AWizzArd: ,:hello guys

10:17 clojurebot: :hello

10:18 _ato: AWizzArd: I doubt a keyword/symbol that contains spaces could really be considered valid

10:18 krumholt: somnium, i want something like that just simpler

10:18 ,(defn foomap [fn lst] (if (empty? lst) lst (let [temp (map fn lst)] (cons (first temp) (foomap fn (rest temp))))))

10:18 clojurebot: DENIED

10:18 somnium: ,(let [f #(* % %)] (map #(take %1 (iterate f %2)) (iterate inc 1) (range 10 14)))

10:18 clojurebot: ((10) (11 121) (12 144 20736) (13 169 28561 815730721))

10:19 AWizzArd: _ato: well, see what i did to Clojurebot some seconds ago

10:19 ,(keyword "a b c d e")

10:19 clojurebot: :a b c d e

10:19 AWizzArd: ,(symbol "Once upon a time...")

10:19 clojurebot: Once upon a time...

10:19 _ato: ,{:a 1 :a 2}

10:19 clojurebot: {:a 1, :a 2}

10:19 _ato: is that a valid map? ;-)

10:20 AWizzArd: _ato: no, that's a bug

10:21 krumholt: ,((fn foomap [fn lst] (if (empty? lst) lst (let [temp (map fn lst)] (cons (first temp) (foomap fn (rest temp)))))) inc [1 1 1 1 1])

10:21 clojurebot: (2 3 4 5 6)

10:21 _ato: it just doesn't verify input. same with symbol/keyword

10:21 krumholt: thats what i want

10:24 _ato: ,(namespace (symbol "foo///bar////baz"))

10:24 clojurebot: "foo///bar///"

10:25 AWizzArd: I don't know why (symbol "a b c d e") should *not* be a valid symbol.

10:26 Common Lisp also allows arbitrary symbol names

10:26 Raynes: ,(def !$&*)

10:26 clojurebot: DENIED

10:26 Raynes: lol'd

10:27 AWizzArd: yeah, it needs a reader macro to enter them

10:27 _ato: ,(let [!$&* 5] (inc !$&*))

10:27 clojurebot: 6

10:28 krumholt: what happens to clojurebot if i evaluate an endless loop? and can i try? :)

10:28 AWizzArd: ,(symbol "hello\nworld")

10:28 clojurebot: hello world

10:28 Raynes: krumholt: Wont let you.

10:28 AWizzArd: krumholt: the bot gives you only a few seconds of execution time

10:28 Raynes: ,(iterate inc 0)

10:28 clojurebot: Eval-in-box threw an exception:java.lang.OutOfMemoryError: Java heap space

10:28 _ato: AWizzArd: what would you use a symbol with whitespace in it for?

10:29 Raynes: _ato: Kicks. :p

10:29 AWizzArd: _ato: can be a nicer name. As in strings, whitespacecansometimesbeanicethingtohave

10:29 krumholt: ,((fn [x] (x x)) (fn [x] (x x)))

10:29 clojurebot: java.lang.StackOverflowError

10:29 tomoj: I never realized that arraymaps could have duplicate keys like that

10:29 _ato: but as a variable/function name?

10:30 AWizzArd: probably not a common thing, but for symbolic computation.. why not?

10:30 "Some men see things as they are and say 'why'? I dream things that never were and say: 'why not?'" :)

10:32 _ato: heh. In my mind it's similar question to why not have reader macros. Just makes things hard to understand. If you want to do symbolic computation with names that have spaces, why not just use strings as your symbols?

10:32 AWizzArd: Strings don’t support metadata yet

10:32 tomoj: yet?

10:32 AWizzArd: tomoj: even if they never will have my statement is true j)

10:32 tomoj: how could they ever?

10:33 AWizzArd: ;)

10:33 tomoj: ah

10:33 hehe

10:33 just the implicature

10:33 _ato: then define your own box type

10:34 AWizzArd: _ato: I just think that either (symbol "a b c") should throw an error or we could have a reader macro to give us a notation for such symbols

10:36 _ato: Indeed, it probably should throw an error. Just as that map should throw an error. (although their may be efficiency concerns about checking it every single time for the map)

10:36 tomoj: hmm

10:36 AWizzArd: with your hashmap example i would certainly agree that an error message would be the right thing

10:36 tomoj: I would've expected it to just take the latest value

10:36 AWizzArd: for symbols.. i could accept both solutions, error or reader syntax

10:36 tomoj: s/latest/last/

10:36 AWizzArd: tomoj: yes

10:37 that would also be okay

10:37 tomoj: ,(assoc {:a 1 :a 2} :b 3 :c 4 :d 5 :e 6 :f 7 :g 8 :h 9 :i 10)

10:37 clojurebot: {:a 2, :c 4, :b 3, :f 7, :g 8, :d 5, :e 6, :i 10, :h 9}

10:37 AWizzArd: ,(hash-map 1 :x, (long 1) :y)

10:37 clojurebot: {1 :x, 1 :y}

10:38 AWizzArd: ,(apply identical? (keys (hash-map 1 :x, (long 1) :y)))

10:38 clojurebot: false

10:38 tomoj: I assume there it's just iterating through the arraymap and copying over, so the last value stays through the conversion?

10:38 haha

10:38 cgrand: AWizzArd: there is this old ticket http://www.assembla.com/spaces/clojure/tickets/17-GC-Issue-13-%09validate-in-%28keyword-s%29-and-%28symbol-s%29 and in the old "todo" http://clojure.org/todo there's "arbitrary symbols in | |"

10:38 Raynes: (let [tehmapz {:a 1 :a 2}] (+ (:a tehmaps) 1))

10:38 AWizzArd: this is okay, because (int 1) and (long 1) are different things.

10:38 Raynes: ,(let [tehmapz {:a 1 :a 2}] (+ (:a tehmaps) 1))

10:38 clojurebot: java.lang.Exception: Unable to resolve symbol: tehmaps in this context

10:38 AWizzArd: cgrand: oh good

10:38 Raynes: ,(let [tehmapz {:a 1 :a 2}] (+ (:a tehmapz) 1))

10:38 clojurebot: 2

10:39 Raynes: That's what I get for using semi-leetspeek in variable names.

10:39 tomoj: as long as it's consistent I guess it doesn't matter too much that it gets printed that way?

10:39 just weird

12:39 qed: am I identified now?

13:02 Chousuke: qed: apparently, since you can send to the channel

14:37 alexyk: I use this to get fn names, but it errors on unbound vars:

14:37 ,(->> (ns-interns *ns*) (map (fn [[k v]] [k (fn? (var-get v))])) (filter second) (map first))

14:37 clojurebot: ()

14:37 alexyk: how do I guard against unbound vars?

14:41 it happens when I do a defn and it fails to compile; but apparently the var is left semi-defined.

14:49 cgrand: alexyk: .isBound

14:49 ,(.isBound #'print)

14:49 clojurebot: true

14:51 alexyk: cgrand: cool. But why if you do (defn xyz some-screwed-up-wrong-thing), xyz is somehow defined, but causes:

14:51 java.lang.IllegalStateException: Var mongol.repliers/fetch-graph-xyz is unbound.

14:52 also, is there an opposite of fn?, aside from (not (fn? ...)) ?

14:53 i.e. an attempt to defn xyz fails with an error, such as some name used in defn is undefined.

14:53 but that leaves a trace oof xyz in the namespace, which then leads to that error

14:59 is there a grep for a list of strings?

15:00 arohner: alexyk: you're wanting to search through a list of strings for a regex?

15:01 alexyk: yessir

15:01 arohner: map over re-find

15:01 ,(doc re-find)

15:01 clojurebot: "([m] [re s]); Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-groups to return the groups."

15:03 alexyk: arohner: hm, ok; but wondered why isn't there just a grep. :)

15:03 arohner: it's your lucky day

15:04 clojure.contrib.str-utils2/grep

15:05 alexyk: ah, super.

15:06 the flushing handle, the car, and the heater all broke, and the internet is slow, but the grep is there -- a lucky day indeed!

15:06 :)

15:07 it'll keep me warm in this New England frost :)

15:09 arohner: nice

15:09 yeah, it's really cold in Texas. It's almost 40!

15:10 alexyk: wow

15:36 somnium: how do I force reload congomongo?

15:38 is there a way to force (use ...)?

15:42 chouser: there'a :reload option to use and require

15:42 alexyk: so it looks the state of some vars in the namespace for congomongo got corrupted; I need to reload it... is there a way?

15:44 chouser: there'a :reload option to use and require

15:44 dnolen: alexyk: you can ns-unmap those problem vars I think.

15:44 chouser: there's :reload option to use and require

15:45 hello

15:45 alexyk: dnolen: ok so some things in ns X got messed up; just found remove-ns and did (remove-ns 'X)

15:45 now (use 'X) fails since each var is still aliased to 'X from my current ns!

15:46 how can redo (use 'X) now?

15:48 so I did ns-unmap, and now (use 'X) returns nil and doesn't refill the namespace

15:48 dnolen: i think you need to do something different here

15:49 you need to get all the mappings in your namespace

15:49 filter out ones that don't belong

15:49 and unmap those one by one.

15:50 could probably done quickly with a set operation

15:52 chouser: hello?

15:52 clojurebot: BUENOS DING DONG DIDDLY DIOS, fRaUline chouser

15:52 chouser: yay, it works again.

15:52 krumholt: can i get a better timing than currentTimeMillis on the jvm?

15:53 chouser: dnolen: did you want the :reload option for use and require?

15:54 dnolen: chouser: my ^ was actually a response to alexyk having ns issues.

15:54 chouser: ah, alexyk, right sorry.

15:55 dnolen: chouser: so there's a :reload?

15:55 chouser: I was fighting freenode moderation and lost the log

15:55 alexyk: I do need :reload asap!

15:55 chouser: yes, :reload is there

15:55 and :reload-all

15:55 check the docstring for 'require'

15:56 you and use :verbose as well to confirm it's reloading what you want it to

15:56 note that won't unmap any vars, so you might still want to do that, depending.

15:57 alexyk: what happened is this: I Ctrl-C'ed a congomongo op, and the state of internal vars of somnium.congomongo (let's call is SC) got effed up good. It was used with (use 'SC). Things like (fetch-one ...) failed with mongo internal error. Now I did (remove-ns 'SC) since any (use 'SC) did nothing. Now I have fetch-onne referring to SC/fetch-one and (use 'SC) fails still. Should I try :reload or do something else?

15:57 dabd: I'm working a bit with JSON and I was thinking of how I could generate

15:57 a JSON object that conforms to a given JSON Schema. Something like JSON

15:57 Beans but instead of beans I would have a bunch of functions. The

15:57 functions could be automatically generated by a macro given a JSON

15:57 Schema. Is something like this already implemented or is there a better solution?

15:57

15:58 chouser: alexyk: I guess I'd try (use 'SC :reload-all :verbose) and see whatn happens

15:59 alexyk: no names of vars are printed, only three lines for load, in-ns, refer

15:59 hiredman: dabd: why?

16:00 alexyk: then trying to use a var says it's unbound

16:00 hiredman: clojure json libraries tend to transform json into clojure lists and maps

16:00 why do you need some special functions?

16:01 alexyk: back later...

16:15 dabd: hiredman: I'm already using Clojure's JSON libraries but I end up writing code that builds up the Clojure data structures that are mapped to JSON. But I thought I could write a macro that writes the code for me by providing a JSON Schema.

16:21 hiredman: This http://paste.lisp.org/+20NO is an example of code I'm writing to construct JSON. I think this could be automatically generated from a JSON Schema much like JAXB generates Java classes from a XML Schema.

16:41 alexyk: ok, back to the ns problem. So there's nothiing in SC after it was remove-ns'd, and apparently use 'SC does nothing with or without :reload-all.

16:42 I think it's rather general -- you have a ns with internal vars which represent a state, it's messed up; you want to purge the ns and reload it and init it into a virgin state. How?

16:43 dnolen: alexy: you could just unmap everything

16:44 alexyk: dnolen: am not getting it! unmap references from current ns A, to the purged SC?

16:44 dnolen: I think so.

16:45 (map #(ns-unmap 'A %) (ns-map 'A)), then reload your A library

16:47 alexyk: aha

16:47 dnolen: but I have many valuable vars in A!

16:47 I need only to unload those referring to SC

16:48 dnolen: (ns-imports 'A)

16:48 alexyk: hotter

16:48 dnolen: oops

16:48 sorry

16:48 that's for java imports

16:49 alexyk: yeah, I need only references to SC

16:50 dnolen: you're going to have to write a filter for this

16:51 ns-map returns all the symbols in the current name space, each with it's name and it's var

16:54 alexyk: dnolen: with a grep on the qualified name I guess

16:55 dnolen: no, something like this (str (:ns (meta (second (first (ns-map 'A))))))

16:55 then you can check if that string is = to "SC"

16:55 if so unmap

16:55 actually

16:56 you can also just compare the actually namespace object SC

16:56 sorry

16:56 avarus: hi

16:58 alexyk: dnolen: cool, I was looking for that

17:00 dnolen: you mean without str, the result of :ns? how do I make an ns object to compare to from literal 'SC?

17:03 how do you supply a literal regex-pattern to re-find?

17:04 dnolen: #"pattern"

17:05 alexyk: ok, almost there: (->> (ns-map *ns*) (map second) (filter #(= (-> % meta :ns str) "somnium.congomongo")) (map #(ns-unmap *ns* %)))

17:06 the only error is, in the end we get a list of Var's, and unmap needs Symbol

17:06 how do I convert a #'var to 'var symbol?

17:07 Chousuke: hmm

17:07 ,(.sym #'+)

17:07 clojurebot: +

17:09 alexyk: aha! but printed without ', even though a Symbol

17:09 Chousuke: of course

17:09 '+ would be (quote symbol) :)

17:09 Hun: no need to quote it in the output

17:09 alexyk: lovely

17:10 here's the killing buzzsaw: (->> (ns-map *ns*) (map second) (filter #(= (-> % meta :ns str) "somnium.congomongo")) (map #(ns-unmap *ns* (.sym %))))

17:12 but, still same result -- now (use 'somnium.congomongo), with or without :reload-all, says nil, and an attempt (mongo! :db "name") results in: java.lang.IllegalStateException: Var somnium.congomongo/mongo! is unbound. (NO_SOURCE_FILE:0)

17:13 somehow it fails to actually refill the namespace

17:14 when I change to it via (in-ns 'SC) and try (ns-map *ns*), I get java.lang.Exception: Unable to resolve symbol: ns-map in this context. Is this expected?

17:14 i.e. shouldn't any namespace refer to clojure.core?

17:17 dnolen: alexyk: you may be getting yourself into a weird REPL state mire, is it really not possible to restart your REPL? is getting your program to the correct state really that hard that you can't write some functions or put some dummy declarations in a comment to eval later?

17:18 alexyk: dnolen: my repl is precious indeed, it contains 30 GB of painfully computed data

17:18 it used to get more from mongo but mongo is mangled

17:18 since I've seen it before, I want to solve the general problem of reloading a namespace

17:18 chouser: alexyk: you could try load-file directly on the .clj files that define the things you want to fix

17:19 alexyk: chouser: ok

17:20 dnolen: alexky: I see.

17:20 alexyk: is there an uptime for repl, and also a check of how much Xmx remains available?

17:20 I'm flushing the data on disk all the time, still loading it is much longer than saving it, so I try to not reload

17:22 ok now this is tremensously weird: I can still store into mongo while it's all undefined! I have a mongo-store defn in *ns*, which uses some SC defns. And it works! How is that possible?

17:23 did those aux defns close upon somnium.congomongo/defns when they were defined and kept the references and use them, despite remove-ns/use again cycle?

17:24 KirinDave: Huh...

17:24 … #() is kinda brittle, isn't it?

17:27 avarus: I don't get "let" ...

17:28 KirinDave: avarus: Which part?

17:28 avarus: in general :)

17:28 cgrand: KirinDave: how's #() brittle?

17:28 hiredman: let x be equal to the result of some expression in the following expressions

17:28 avarus: the book says something about bindings

17:28 KirinDave: cgrand: I'm just surprised how it expands.

17:28 hiredman: avarus: it binds a name to a value

17:28 KirinDave: cgrand: I'm used to the way lambda in common lisp works, which is more amenable to certain things.

17:28 avarus: hiredman: oh my god...so simple :)

17:28 hiredman: a limited lexical scope

17:29 avarus: ya, got it, thanks :)

17:29 KirinDave: avarus: For more edification on the subject, expand let into lambda forms.

17:29 avarus: I'm just reading programming clojure and I just arrived "bindings" and the example there confused me

17:29 cgrand: KirinDave: I'm not an expert in other lisps but isn't Clojure's lambda is fn, no?

17:29 hiredman: KirinDave: doesn't really work in clojure

17:30 KirinDave: hiredman: It doesn't?

17:30 hiredman: you can recur across lets, but not across fns

17:30 KirinDave: hiredman: "recur across lets?"

17:31 cgrand: you can't recur across a fn, you always recur to the nearest fn or loop

17:31 hiredman: ,((fn [x] (when x (let [y (not x)] (recur y)))) true)

17:31 clojurebot: nil

17:31 hiredman: ,((fn [x] (when x ((fn [y] (recur y)) (not x)) )) true)

17:32 KirinDave: hiredman: That sort of defeats the purpose of what I was trying to explain, but that's interesting.

17:32 hiredman: *BOOM*

17:32 clojurebot: Execution Timed Out

17:32 hiredman: I wrote a macro that turned a let looking binding form into a sequence of fns

17:33 not a Sequence sequence, just a bunch of nested fns

17:33 KirinDave: Right.

17:33 And it didn't work, because let is a special form in clojure, not just an expansion.

17:33 But that doesn't mean that it doesn't have value as an exercise, which is why I was recommending it to avarus.

17:34 hiredman: KirinDave: well, to fair, it is a special form in most lisps that I've seen

17:34 KirinDave: hiredman: I didn't say it wasn't.

17:34 hiredman: sure

17:34 KirinDave: So I'm not sure what kind of balance we're striking. :)

17:34 hiredman: ~sicp

17:34 clojurebot: sicp is http://www.codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages:Clojure:Chapter_1

17:34 hiredman: clojurebot: not that one

17:34 clojurebot: clojurebot: google nothing

17:35 hiredman: ~sicp

17:35 clojurebot: sicp is http://web.mit.edu/alexmv/6.001/sicp.pdf

17:35 KirinDave: cgrand: Anyways, I made a mistake that seems to make clojure's compiler shit the bed and return "No message" for the error.

17:35 Or rather, I wrote some code and then it was used in a way I didn't intend. :)

17:51 avarus: I start to like clojure :>

18:06 hiredman: hmm

18:08 clojurebot: test

18:08 hiredman: clojurebot: ping?

18:08 clojurebot: PONG!

18:08 hiredman: a wild ride

18:32 technoma`: replaca: just checked in that change to clojure-http-client

18:33 _ato: hey,

18:33 somebody squatted on my clojure-http-client group, so I can't upload

18:33 also, I squatted on org.clojure

18:33 any chance those could be fixed?

18:34 _ato: also: welcome back! assuming you're back.

18:36 _ato: technomancy: clojure-http-client is now yours

18:36 technomancy: _ato: thanks!

18:37 how's things going?

18:40 _ato: technomancy: not bad, I'm gonna devote today to Clojars hacking. It's badly needing some love. :-)

18:40 technomancy: was starting to get worried about you

18:40 glad to see you're back in action

18:41 what's on the table for today?

18:43 _ato: fixing data migration to couchdb -- yeah I still haven't done that. Holidays (without phone coverage) + work has kept me away. I've also been experimenting with compiling a really tiny subset of Clojure to LLVM byte code, which has been a bit distracting.

18:43 technomancy: wow, fun

18:43 I'm excited about the couchdb migration

18:43 especially if it means we can move jars into couch attachments and then mirror via replication... that would be hawt

18:44 * technomancy is going to get a leiningen release out and then start playing around w/ Duby + Android

18:44 _ato: yes, I want to ditch relying on maven itself, it just makes things painful

18:45 I did a basic browse screen which I might improve with categories/tags of some sort. At the moment it's just browse by alphabet sort of thing

18:53 technomancy: cool

18:57 sorry I dropped the ball on implementing browse myself

18:59 _ato: don't worry about it. :-)

19:49 replaca: technomancy: thanks!

19:59 AWizzArd: ,(/ 12800 1600)

19:59 clojurebot: 8

20:30 kiba: hello

20:53 hmm

20:58 abrooks: technomancy: Would you be interested in patches to add a run task to leiningen? (i.e. "lein run <ARGS>" would call the main entry point with the provided args.)

20:58 technomancy: BTW, I love leiningen -- it's great stuff!

20:59 * kiba is very new to lisp and have no idea what he's doing

20:59 kiba: but I determine that I should build my first web application in clojure

20:59 which I have no idea about building web application in the first place

21:29 hiredman: clojurebot: ping?

21:29 clojurebot: PONG!

21:33 technomancy: abrooks: there's a thread on the mailing list about someone who already added that as a plugin

21:33 I may merge it to lein proper down the road

21:34 abrooks: Hm. I must have missed it -- thanks for letting me know. Consider this my +1. :)

21:36 Oh, there's a leiningen group. I missed that.

21:58 technomancy: Having now used leiningen-run I'll give a verified +1. Quite nice. Particularly if eval-in-project gets nailgun support.

22:00 Hm. I guess it's not eval-in-project getting nailgun, it's really lein/lein.bat.

22:01 By eval-in-project we're already in a running JVM aren't we...

22:02 hiredman: I think eval-in-project spins up a new jvm

22:03 I think someone did some kind of nailgun plugin for lein

22:04 ~google lein nailgun

22:04 clojurebot: First, out of 521 results is:

22:04 Index of /repo/lein-nailgun/lein-nailgun/

22:04 http://clojars.org/repo/lein-nailgun/lein-nailgun/

22:26 kiba: hmm

22:27 * kiba feel crazy for using clojure in writing his first web application

22:27 * kiba doesn't know much about the clojure programming language

22:37 hiredman: compojure seems to be the framework most people use

22:37 it has it's own irc channel and google group, dunno how active they are

22:38 kiba: not very active

22:39 documentation is so poor that it's hard to learn

22:40 hiredman: kiba: you might checkout http://data-sorcery.org/category/compojure/

22:58 technomancy: kiba: the mailing list for compojure is probably more active than the channel

23:33 kiba: how do I load other files

23:33 ?

23:41 mtd: kiba: (load "filename-without-clj-extension") ?

Logging service provided by n01se.net