#clojure logs

2010-01-30

00:11krumholtwill a compiled jar file increase executing speed compared to evaluating something in the slime repl?
00:12chouserkrumholt: the compiled jar might load faster, but once it starts running it should be the same
00:13krumholtchouser, ok thanks
00:30krumholti 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?
00:31chouserA is for Abstract
00:32chouseran Interface provides no implementation at all for any method
00:32krumholtok and abstract provides some implementation for all subclasses?
00:32chouseran Abstract class provides implementations for some methods, but not all of them, so you still can't instantiate one.
00:32krumholtok thanks for clearing that up
00:33chouseryou 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)
00:35krumholti get the idea thanks. is there a convention to name protocols?
00:35chouserThat's a great question. I don't think any has emerged yet.
00:36chouserI suspect they'll be capitalized like type names, but beyond that I don't know.
00:37krumholtok. i think i just go with PMyprotocol for now
00:41chouserWe'll all have to get such conventions ironed out before fogus and I get around to writing the protocols chapter. :-P
00:43krumholtok 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.
00:44chouserfields? are you talking about deftype?
00:45RaynesI think he is.
00:45RaynesOtherwise, he's using a different language than the one I'm using.
00:45Raynes:o
00:45RaynesSpeaking, or otherwise.
00:46chouserkrumholt: 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.
00:46krumholtchouser, so i should provide a make-instance function for a deftype
01:10chouserkrumholt: yes, if it users will be wanting to make instances of that deftype
01:35krumholtin 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?
01:35krumholthttp://paste.lisp.org/display/94136
01:39RaynesI hereby declare that load-file is the most awesome thing ever.
01:40RaynesArbitrary user configuration has never been so easy.
02:06RaynesThis email client is going to be the most hilarious mess of code evar.
02:20RaynesIs there a version of load-file that takes a java.io.File?
02:25krumholtRaynes, (load-file (.toString yourjava.io.File)) that shuold work
02:25Rayneskrumholt: Hah. Nice. I didn't know Files had a toString method.
02:26RaynesThanks.
02:26RaynesHrm. They've been "migrating to ircd-seven shortly" for the last two weeks or so. >.>
03:11RaynesHrm. Why is it that lein new spits out src/projectname.clj with a namespace of projectname.core?
03:11RaynesShouldn't the namespace just be projectname, considering it's top level in src?
03:15_atoRaynes: yes, that's a bug that was fixed a while ago. You might want to update to lein 1.0.1
03:15RaynesI didn't know I was using an old version.
03:16_atolein -v should tell you what version you have
03:16_atoalthough I don't know when that -v option was added
03:17Raynes_ato: The way to upgrade would be to download the install script, and do that stuff again right?
03:17RaynesThere isn't any update magic I don't know about, I'm hoping.
03:19_atoRaynes: 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
03:20RaynesJust checking. Didn't want to fry anything. :p
04:59Hali_303is 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?
05:03krumholtam 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?
05:04_atoHali_303: not for :use AFAIK. _mst did this hack for java :imports though: http://dishevelled.net/Generating-Clojure-import-lines-using-SLIME.html
05:05Hali_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?
05:08_atoHali_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
05:09_atokrumholt: if I understand it correctly the idea is that deftype methods are only for java interop (ie implementing a java interface)
05:09Hali_303_ato: I see, thanks
05:10_atoah wait.. I see protocols get called "methods" as well
05:11krumholt_ato, i am not using any java at all
05:11_atodefprotocol will define the functions
05:12_ato(just think of them like grouped multimethods)
05:12_atoso to answer your question directly: yes you are correct. ;-)
05:13krumholtok but except for the speed gain they are really a lot of extra work. multimethod is somewhat nicer
05:14_atoyes, I agree
05:16_atothey 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
05:16krumholti think i am using them wrong. i am stuck in object oriented thinking :)
05:19_atoyeah, 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.
05:21RaynesI 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
05:21RaynesI've yet to have a reason to use multimethods or protocols so far.
05:23Hali_303how can I have rainbow parentheses in emacs?
05:23Hali_303I've got emacs installed, but it's still black and white
05:23Hali_303I mean slime installed
05:23somniumbeing able to implement IFn on deftypes is cool. They feel really first class.
05:23RaynesHali_303: highlight-parentheses-mode
05:23Hali_303Raynes: thanks
05:24RaynesHali_303: Also, show-paren-mode is awesome.
05:25Chousukehmm
05:26ChousukeRaynes: as long as you don't overuse types. :)
05:26RaynesChousuke: Structs are used for maps that have keys in common, right?
05:27Chousukeit's a good thing that types are interoperable with standard maps but I fear people will use them for every little thing :/
05:27_atoHali_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
05:27RaynesI want. :D
05:28_atoHali_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. ;-)
05:28Hali_303:D
05:28Hali_303I'll try it and see if it helps or not
05:28Chousukeparedit does away with most need for paren highlighting though. :)
05:29Hali_303hm. I'm not using that, what is that good for?
05:29RaynesParedit doesn't help me with that sort of thing at all.
05:29RaynesIf anything, it slightly hinders me.
05:29ChousukeHali_303: it lets your edit s-expressions instead of text
05:29_atoheh.. I prefer less-visible parens. I don't look at them much
05:29the-kennyC-k doesn't kills the current line, but the next sexp :)
05:30ChousukeHali_303: you will never have to hunt for the missing paren again!
05:30Chousukethe-kenny: that's what I like most
05:30Hali_303thanks, I'll try that then
05:30Chousukemakes moving code around very easy
05:31the-kennyChousuke: Yeah, that's very cool
05:31_atotechnomancy 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
05:32krumholtok i have a question if i just want to dispatch on type is there a way to do that with multimethods that is fast?
05:32Chousukethe-kenny: I also like barf and slurp eg. for wrapping things in a let (or removing one)
05:32Chousukekrumholt: deftype :P
05:32Chousukekrumholt: it's only on master right now.
05:32Chousukewhoops, deftype *and* protocols I mean :)
05:33_atothis might be what I'm thinking of: http://p.hagelb.org/paredit-outline
05:34krumholtChousuke, ok thanks
05:34the-kennyChousuke: Yes, the wrap-stuff is pretty neat
05:39Hali_303yet 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?
05:42noidiHali_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 :)
05:43_atoI 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
05:43ChousukeI hadn't even thought of that :P
05:43_atoin my output the errors are prefixed with "Unknown location"
05:43_atoalthough it does have the line number in the actual error message
05:43_atoI suspect SLIME is the one saying that "Unknown location"
05:43Chousukeusually the error is local to what I was previously editing so having a jump function wouldn't be that much faster anyway :/
05:44ChousukeHali_303: also, that's "C-c C-k" in emacs parlance :)
05:44_atoI just usually M-g g and type the line number in the error
05:44_atoit'd be nice if there was a shortcut though :(
05:44Hali_303Chousuke: ok :)
05:44Hali_303_ato: better than nothing, thanks
05:49Hali_303paredit is really cool :D
05:50Hali_303hm. however, it only insert normal parentheses automatically, not { or [
05:51Hali_303ok [ also works, but { does not
05:51hiredmanmy paredit does ( and [, but not {
05:51Hali_303yes
05:51hiredmanright, *shrug*
05:51Hali_303hiredman: btw what code are you using to auto-load it for slime?
05:52Hali_303now I have to manually type M-x paredit-mode
05:52noidi(add-hook 'clojure-mode-hook (lambda () (paredit-mode +1)))
05:52Hali_303noidi: thx
05:53noidior for slime (add-hook 'slime-mode-hook (lambda () (paredit-mode +1)))
05:53noidithe latter doesn't work for me though, for some reason
05:53noidiand to highlight parens every time you load paredit:
05:53noidi(add-hook 'paredit-mode-hook (lambda () (show-paren-mode +1)))
05:54the-kennymyn paredit does { [ and ( :)
05:55noidithe-kenny, how did you manage that?
05:55_atomine does all three as well. I added this for the M-{ hotkeys: http://gist.github.com/290508
05:55noidiI always have to insert the closing } manually or paredit gets confused
05:55the-kennynoidi: I think I got the file from someone here. Maybe _ato?
05:55noidiok
05:56_atoI'm also using paredit version 22 if that makes any difference
05:57noidiHali_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
05:57Chousukemy paredit works just fine as well
05:57_atohttp://mumble.net/~campbell/emacs/paredit-beta.el
05:58noidihere's parenface.el with clojure support added http://gist.github.com/290509
05:58noidiI've probably changed the paren color, too, to match zenburn
05:59Hali_303after typing (str-join how do I display the docs for str-join?
05:59noidiah, I'm using paredit 20 from elpa
05:59Hali_303I know that it shows the parameters at the bottom
05:59Hali_303but I'd like to see the full docs
05:59_atoC-d C-d d
05:59noidihow the %#¤& can the elpa package be 2 versions behind? o_O
06:00Chousukeno-one has bothered to update it :)
06:00_atoyou can also use C-. to jump to the source code for str-join
06:00_atoerr. I mean M-.
06:01Chousukeand technically it's just one version behind, as 22 is beta
06:01_atoand then M-, to return to where you were
06:01noidiChousuke, okay, thanks... I'll upgrade to 22b then
06:02noidi_ato, thank you! I didn't know about the jump functions in slime!
06:02noidiI thought I needed tags like with C
06:02noidiso I never bothered :)
06:04_atoyeah, 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:
06:04_ato,(meta #'drop-while)
06:05_atohuh.. no clojurebot? well then the result is: {:ns #<Namespace clojure.core>, :name drop-while, :file "clojure/core.clj", :line 1857, :arglists ([pred coll]), :doc "..."}
06:08hiredmanoh, right
06:08hiredmanstupid registeration requirement
06:09hiredmanclojurebot: ping?
06:09clojurebotPONG!
06:09hiredman,(meta #'drop-while)
06:09clojurebot{: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."}
06:09_atoweirdly it replied to me in privmsg which I thought also required registration
06:09_atoor have they changed it now so messaging a channel requires registration but privately doesn't any more?
06:09hiredmanI don't know
06:10Chousuke_ato: isn't it configurable by the user?
06:10_atoChousuke: ah.. yeah that's probably it
06:11kotarak_ato: I have trouble with clojars and every scp which is not scp.
06:11Hali_303do cross-reference shortcuts work for you? I tried C-c C-w c, but it doesn't work "Evaluation aborted"
06:11kotarak_ato: neither jsch nor ganymede work with clojars :(
06:12Hali_303C-c < this doesn't work either
06:13hiredmanI thought clojars used jsch
06:13_atoHali_303: nope they don't work for me either. Probably more SLIME features not implemented for Clojure
06:13Hali_303_ato: sad :/ that's a feature that is very useful in practice
06:14kotarakjsch + "real" ssh = works, ganymede + "real" ssh = works, "real" scp + clojars = works, jsch + clojars = nope, ganymede + clojars = nope
06:14_atokotarak: hmm I wrote a (pure) jsch client that works
06:15_atoI knew it didn't work with maven
06:15kotarak_ato: huh? May I use that? I tried with the jsch ant scp task, didn't work.
06:15_atomaven also uses jsch I think
06:15kotarak_ato: I'd like to have a look what that does differently.
06:16kotarak_ato: jsch is a little annoying because there are lots of incompatibilities with jsch, ant, gradle, bleh.
06:16_atoit 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)
06:16kotarak_ato: But I'd like to know why it doesn't work.
06:17_atokotarak: http://github.com/ato/lein-clojars/blob/master/src/leiningen/push.clj
06:19kotarak_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
06:20_atoI wondered whether it's because I'm doing this to hook up the SSH session's error stream to stdout: (.setErrStream System/err true)
06:20_atomaybe the other JSch scp implementations don't do that and a buffer somewhere gets blocked up
06:20_atomaven just hangs when you try to make it scp something to clojars
06:21_atothat's just a guess though, I might be completely wrong. I never got around to trying to debug it
06:23kotarak_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.
06:24_atookay. If you find out what it is, let me know so I can try and fix it on the server side
06:24kotarakk
06:24kotarak_ato: btw. goot to see you back :)
06:24kotaraks/goot/good
06:25_ato:)
06:27kotarak_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...
06:29_atoyep.. search fails to find things without a description (root cause: the result of concatenating a string to a null in sqlite is null :-P)
06:30_atofix will be out soon (I know I've been saying that for a while... just keep getting distracted by other things)
06:30kotarakLauJensen: clojureql needs a description on clojars to show up in the search
06:32kotarak_ato: oh, and another thing (sorry, collected some topics...): I'd like to be able to delete artifacts again.
06:32kotarakeg. my clojares-deploy-testcase for my scp experiments (couldn't do it on my server, because there it worked.... :( )
06:34_atoyeah... 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).
06:34_atofor now just email me if you need something deleted and I'll do it by hand
06:35_atoat 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
06:35LauJensenkotarak: I'll fix it, I'm AFK
06:35kotarak_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.
06:38kotarak_ato: /again sorry/ and the foo-1.2.3.pom change is not live
06:39krumholtin 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?
06:39_atokotarak: what foo-1.2.3.pom?
06:39kotarak_ato: clojars didn't recognise the .pom extension. You changed that, but the change didn't go live.
06:40_atoaah.. right. Yep, sorry. I'll try to get all that stuff out tomorrow. I've been really slack about it. :(
06:56hoeckkrumholt: multimethods have no arglist metadata attached, so the minibuffer help has nothing to display
06:57hoeckkrumholt: but if you define your multimethod with explicit :arglists metadata, minibuffer help works for them too
06:57krumholthoeck, can i do that?
06:57krumholthoeck, super thanks
06:57kotarakthis can be remedied by defining multimethods as: (defmulti multifn "Some multimethod" {:arglists '([arg1 arg2 arg3])} dispatch-fn)
06:58krumholtis that possible for protocol methods too?
06:58kotarakHmm.. Protocol methods don't have arglist info?
07:00hoeckno, they have not, but I guess its on the todo-list
07:00krumholtno. or at least they don't have minibuffer help
07:01krumholtcan i add it manually? or will i just have to wait a while?
07:02patrkrisDoes 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.
07:02hoeckkrumholt: yes, defprotocol methods are normal fns bound to a var
07:03hoeckkrumholt: just use alter-var-root and with-meta
07:04krumholtso (alter-var-root myvar (with-meta myvar {:arglist '([arg1 arg2])}) ?
07:06hoeckkrumholt: sorry, its (alter-meta! #'myvar assoc :argslist '([a]))
07:06krumholthoeck, many thanks
07:07RaynesHow do I comment out a line of code with paredit active?
07:07hoeckkrumholt: np :)
07:07RaynesIf I attempt to comment out a piece of code the old fashioned way, it inserts a newline after the semi-colon.
07:08AWizzArd,(doc alter-meta!)
07:08clojurebot"([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"
07:08AWizzArdThe docstrings don't mention functions or symbols.
07:10mikemtomoj: 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
07:11mikemClassNotFoundException: clojure.contrib.pprint.ColumnWriter (PrettyWriter.clj:17)
07:11hoeckAWizzArd: the protocol function is bound to a var, just like a normal defn function
07:13hoeckRaynes: I don't like this behaviour, so I removed the paredit-semicolon command from my keymap
07:13Rayneshoeck: Good idea.
07:15krumholthoeck, it's arglists not argslist :) if anyone else tries but thanks anyway
07:16hoeckkrumholt: you're right
07:17_atopatrkris: it's not particularly clean code, but you could look at my code for the clojars webapp
07:18_atopatrkris: I have a clojars.web.whatever module roughly for each page
07:18_atohttp://github.com/ato/clojars-web/tree/master/src/clojars/web/
07:19_atono idea whether it's the "right" way of doing it
07:19_atoI couldn't find any examples either, so just went off and did my own thing :p
07:21_ato"controller" like functionality is usually in the same file but a different function
07:24_atothis might be another one to look at, the old compojure.org code: http://github.com/weavejester/compojure.org/tree/master/src/org/compojure/
09:30dabd..
09:48tomojmikem: hmm
09:48tomojon a different project I just added 1.2.0-master-SNAPSHOT deps and it worked fine
09:49tomojhaven't tried again yet to build contrib manually
09:49tomojand I still don't really understand what happened when I had the problem
09:49tomojbut, good luck :/
09:52mikemtomoj: 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
09:52tomojapparently it doesn't
09:52tomojwell, something's not quite right anyway
09:53tomojclojure-contrib is red at build.clojure.org
09:53mikemgood point :) looking at that now...
09:53tomojnot sure whether that means tests failed or what exactly
09:54tomojthe jars I got seemed to work fine, so someone must be building successfully...
09:54mikemit's the same thing I'm seeing: http://build.clojure.org/job/clojure-contrib/lastFailedBuild/console
09:54mikemmaybe the jars are from the last successful run
09:54tomojyep, looks like the error I got as well
09:54tomojah, good point
09:54mikemi don't know enough about maven or clojure-contrib to figure it out :S
09:55tomojif the last successful build was also tagged as 1.2.0-master-SNAPSHOT, I'd get that from lein deps I guess
09:55tomojbut..
09:55tomoj"last success: N/A"
09:55tomojheh
09:55mikemjust noticed an email to the mailing list asking about this
09:56tomojoh, thanks
10:07leafwwhat is the preferred way to build clojure-contrib? There isn't a build.xml anymore
10:07leafwwith mvn ? UGH
10:09krumholti 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:10leafwsp Stuart Sierra, what motivated the removal of the ant build.xml ?
10:11leafwclojure.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:11noidikrumholt, by applying twice, do you mean (f (f x))?
10:11noidior (f x) (f x) for side effects
10:12krumholtnoidi, (f (f x))
10:12krumholtno siede effects
10:12krumholt-e
10:12noidiok
10:12_atoleafw: http://groups.google.com/group/clojure-dev/browse_thread/thread/cd807a1e5d7ce77d
10:15somnium,(map #(take %1 (iterate inc %1)) (range 5))
10:15clojurebot(() (1) (2 3) (3 4 5) (4 5 6 7))
10:15leafwthanks. I forgot the music moved to clojure-dev
10:16AWizzArdis there a reader macro for entering symbols or keywords that contain spaces?
10:16somniumkrumholt: something like that?
10:16AWizzArd,(keyword "hello guys")
10:16clojurebot:hello guys
10:16krumholtsomnium, i am trying to understand that
10:17AWizzArd,:hello guys
10:17clojurebot:hello
10:18_atoAWizzArd: I doubt a keyword/symbol that contains spaces could really be considered valid
10:18krumholtsomnium, i want something like that just simpler
10:18krumholt,(defn foomap [fn lst] (if (empty? lst) lst (let [temp (map fn lst)] (cons (first temp) (foomap fn (rest temp))))))
10:18clojurebotDENIED
10:18somnium,(let [f #(* % %)] (map #(take %1 (iterate f %2)) (iterate inc 1) (range 10 14)))
10:18clojurebot((10) (11 121) (12 144 20736) (13 169 28561 815730721))
10:19AWizzArd_ato: well, see what i did to Clojurebot some seconds ago
10:19AWizzArd,(keyword "a b c d e")
10:19clojurebot:a b c d e
10:19AWizzArd,(symbol "Once upon a time...")
10:19clojurebotOnce upon a time...
10:19_ato,{:a 1 :a 2}
10:19clojurebot{:a 1, :a 2}
10:19_atois that a valid map? ;-)
10:20AWizzArd_ato: no, that's a bug
10:21krumholt,((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:21clojurebot(2 3 4 5 6)
10:21_atoit just doesn't verify input. same with symbol/keyword
10:21krumholtthats what i want
10:24_ato,(namespace (symbol "foo///bar////baz"))
10:24clojurebot"foo///bar///"
10:25AWizzArdI don't know why (symbol "a b c d e") should *not* be a valid symbol.
10:26AWizzArdCommon Lisp also allows arbitrary symbol names
10:26Raynes,(def !$&*)
10:26clojurebotDENIED
10:26Rayneslol'd
10:27AWizzArdyeah, it needs a reader macro to enter them
10:27_ato,(let [!$&* 5] (inc !$&*))
10:27clojurebot6
10:28krumholtwhat happens to clojurebot if i evaluate an endless loop? and can i try? :)
10:28AWizzArd,(symbol "hello\nworld")
10:28clojurebothello world
10:28Rayneskrumholt: Wont let you.
10:28AWizzArdkrumholt: the bot gives you only a few seconds of execution time
10:28Raynes,(iterate inc 0)
10:28clojurebotEval-in-box threw an exception:java.lang.OutOfMemoryError: Java heap space
10:28_atoAWizzArd: what would you use a symbol with whitespace in it for?
10:29Raynes_ato: Kicks. :p
10:29AWizzArd_ato: can be a nicer name. As in strings, whitespacecansometimesbeanicethingtohave
10:29krumholt,((fn [x] (x x)) (fn [x] (x x)))
10:29clojurebotjava.lang.StackOverflowError
10:29tomojI never realized that arraymaps could have duplicate keys like that
10:29_atobut as a variable/function name?
10:30AWizzArdprobably not a common thing, but for symbolic computation.. why not?
10:30AWizzArd"Some men see things as they are and say 'why'? I dream things that never were and say: 'why not?'" :)
10:32_atoheh. 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:32AWizzArdStrings don’t support metadata yet
10:32tomojyet?
10:32AWizzArdtomoj: even if they never will have my statement is true j)
10:32tomojhow could they ever?
10:33AWizzArd;)
10:33tomojah
10:33tomojhehe
10:33tomojjust the implicature
10:33_atothen define your own box type
10:34AWizzArd_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_atoIndeed, 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:36tomojhmm
10:36AWizzArdwith your hashmap example i would certainly agree that an error message would be the right thing
10:36tomojI would've expected it to just take the latest value
10:36AWizzArdfor symbols.. i could accept both solutions, error or reader syntax
10:36tomojs/latest/last/
10:36AWizzArdtomoj: yes
10:37AWizzArdthat would also be okay
10:37tomoj,(assoc {:a 1 :a 2} :b 3 :c 4 :d 5 :e 6 :f 7 :g 8 :h 9 :i 10)
10:37clojurebot{:a 2, :c 4, :b 3, :f 7, :g 8, :d 5, :e 6, :i 10, :h 9}
10:37AWizzArd,(hash-map 1 :x, (long 1) :y)
10:37clojurebot{1 :x, 1 :y}
10:38AWizzArd,(apply identical? (keys (hash-map 1 :x, (long 1) :y)))
10:38clojurebotfalse
10:38tomojI assume there it's just iterating through the arraymap and copying over, so the last value stays through the conversion?
10:38tomojhaha
10:38cgrandAWizzArd: 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:38Raynes(let [tehmapz {:a 1 :a 2}] (+ (:a tehmaps) 1))
10:38AWizzArdthis is okay, because (int 1) and (long 1) are different things.
10:38Raynes,(let [tehmapz {:a 1 :a 2}] (+ (:a tehmaps) 1))
10:38clojurebotjava.lang.Exception: Unable to resolve symbol: tehmaps in this context
10:38AWizzArdcgrand: oh good
10:38Raynes,(let [tehmapz {:a 1 :a 2}] (+ (:a tehmapz) 1))
10:38clojurebot2
10:39RaynesThat's what I get for using semi-leetspeek in variable names.
10:39tomojas long as it's consistent I guess it doesn't matter too much that it gets printed that way?
10:39tomojjust weird
12:39qedam I identified now?
13:02Chousukeqed: apparently, since you can send to the channel
14:37alexykI use this to get fn names, but it errors on unbound vars:
14:37alexyk,(->> (ns-interns *ns*) (map (fn [[k v]] [k (fn? (var-get v))])) (filter second) (map first))
14:37clojurebot()
14:37alexykhow do I guard against unbound vars?
14:41alexykit happens when I do a defn and it fails to compile; but apparently the var is left semi-defined.
14:49cgrandalexyk: .isBound
14:49cgrand,(.isBound #'print)
14:49clojurebottrue
14:51alexykcgrand: cool. But why if you do (defn xyz some-screwed-up-wrong-thing), xyz is somehow defined, but causes:
14:51alexykjava.lang.IllegalStateException: Var mongol.repliers/fetch-graph-xyz is unbound.
14:52alexykalso, is there an opposite of fn?, aside from (not (fn? ...)) ?
14:53alexyki.e. an attempt to defn xyz fails with an error, such as some name used in defn is undefined.
14:53alexykbut that leaves a trace oof xyz in the namespace, which then leads to that error
14:59alexykis there a grep for a list of strings?
15:00arohneralexyk: you're wanting to search through a list of strings for a regex?
15:01alexykyessir
15:01arohnermap over re-find
15:01arohner,(doc re-find)
15:01clojurebot"([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:03alexykarohner: hm, ok; but wondered why isn't there just a grep. :)
15:03arohnerit's your lucky day
15:04arohnerclojure.contrib.str-utils2/grep
15:05alexykah, super.
15:06alexykthe flushing handle, the car, and the heater all broke, and the internet is slow, but the grep is there -- a lucky day indeed!
15:06alexyk:)
15:07alexykit'll keep me warm in this New England frost :)
15:09arohnernice
15:09arohneryeah, it's really cold in Texas. It's almost 40!
15:10alexykwow
15:36alexyksomnium: how do I force reload congomongo?
15:38alexykis there a way to force (use ...)?
15:42chouserthere'a :reload option to use and require
15:42alexykso it looks the state of some vars in the namespace for congomongo got corrupted; I need to reload it... is there a way?
15:44chouserthere'a :reload option to use and require
15:44dnolenalexyk: you can ns-unmap those problem vars I think.
15:44chouserthere's :reload option to use and require
15:45chouserhello
15:45alexykdnolen: ok so some things in ns X got messed up; just found remove-ns and did (remove-ns 'X)
15:45alexyknow (use 'X) fails since each var is still aliased to 'X from my current ns!
15:46alexykhow can redo (use 'X) now?
15:48alexykso I did ns-unmap, and now (use 'X) returns nil and doesn't refill the namespace
15:48dnoleni think you need to do something different here
15:49dnolenyou need to get all the mappings in your namespace
15:49dnolenfilter out ones that don't belong
15:49dnolenand unmap those one by one.
15:50dnolencould probably done quickly with a set operation
15:52chouserhello?
15:52clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline chouser
15:52chouseryay, it works again.
15:52krumholtcan i get a better timing than currentTimeMillis on the jvm?
15:53chouserdnolen: did you want the :reload option for use and require?
15:54dnolenchouser: my ^ was actually a response to alexyk having ns issues.
15:54chouserah, alexyk, right sorry.
15:55dnolenchouser: so there's a :reload?
15:55chouserI was fighting freenode moderation and lost the log
15:55alexykI do need :reload asap!
15:55chouseryes, :reload is there
15:55chouserand :reload-all
15:55chousercheck the docstring for 'require'
15:56chouseryou and use :verbose as well to confirm it's reloading what you want it to
15:56chousernote that won't unmap any vars, so you might still want to do that, depending.
15:57alexykwhat 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:57dabdI'm working a bit with JSON and I was thinking of how I could generate
15:57dabd a JSON object that conforms to a given JSON Schema. Something like JSON
15:57dabd Beans but instead of beans I would have a bunch of functions. The
15:57dabd functions could be automatically generated by a macro given a JSON
15:57dabd Schema. Is something like this already implemented or is there a better solution?
15:57dabd
15:58chouseralexyk: I guess I'd try (use 'SC :reload-all :verbose) and see whatn happens
15:59alexykno names of vars are printed, only three lines for load, in-ns, refer
15:59hiredmandabd: why?
16:00alexykthen trying to use a var says it's unbound
16:00hiredmanclojure json libraries tend to transform json into clojure lists and maps
16:00hiredmanwhy do you need some special functions?
16:01alexykback later...
16:15dabdhiredman: 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:21dabdhiredman: 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:41alexykok, 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:42alexykI 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:43dnolenalexy: you could just unmap everything
16:44alexykdnolen: am not getting it! unmap references from current ns A, to the purged SC?
16:44dnolenI think so.
16:45dnolen(map #(ns-unmap 'A %) (ns-map 'A)), then reload your A library
16:47alexykaha
16:47alexykdnolen: but I have many valuable vars in A!
16:47alexykI need only to unload those referring to SC
16:48dnolen(ns-imports 'A)
16:48alexykhotter
16:48dnolenoops
16:48dnolensorry
16:48dnolenthat's for java imports
16:49alexykyeah, I need only references to SC
16:50dnolenyou're going to have to write a filter for this
16:51dnolenns-map returns all the symbols in the current name space, each with it's name and it's var
16:54alexykdnolen: with a grep on the qualified name I guess
16:55dnolenno, something like this (str (:ns (meta (second (first (ns-map 'A))))))
16:55dnolenthen you can check if that string is = to "SC"
16:55dnolenif so unmap
16:55dnolenactually
16:56dnolenyou can also just compare the actually namespace object SC
16:56dnolensorry
16:56avarushi
16:58alexykdnolen: cool, I was looking for that
17:00alexykdnolen: you mean without str, the result of :ns? how do I make an ns object to compare to from literal 'SC?
17:03alexykhow do you supply a literal regex-pattern to re-find?
17:04dnolen#"pattern"
17:05alexykok, almost there: (->> (ns-map *ns*) (map second) (filter #(= (-> % meta :ns str) "somnium.congomongo")) (map #(ns-unmap *ns* %)))
17:06alexykthe only error is, in the end we get a list of Var's, and unmap needs Symbol
17:06alexykhow do I convert a #'var to 'var symbol?
17:07Chousukehmm
17:07Chousuke,(.sym #'+)
17:07clojurebot+
17:09alexykaha! but printed without ', even though a Symbol
17:09Chousukeof course
17:09Chousuke'+ would be (quote symbol) :)
17:09Hunno need to quote it in the output
17:09alexyklovely
17:10alexykhere's the killing buzzsaw: (->> (ns-map *ns*) (map second) (filter #(= (-> % meta :ns str) "somnium.congomongo")) (map #(ns-unmap *ns* (.sym %))))
17:12alexykbut, 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:13alexyksomehow it fails to actually refill the namespace
17:14alexykwhen 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:14alexyki.e. shouldn't any namespace refer to clojure.core?
17:17dnolenalexyk: 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:18alexykdnolen: my repl is precious indeed, it contains 30 GB of painfully computed data
17:18alexykit used to get more from mongo but mongo is mangled
17:18alexyksince I've seen it before, I want to solve the general problem of reloading a namespace
17:18chouseralexyk: you could try load-file directly on the .clj files that define the things you want to fix
17:19alexykchouser: ok
17:20dnolenalexky: I see.
17:20alexykis there an uptime for repl, and also a check of how much Xmx remains available?
17:20alexykI'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:22alexykok 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:23alexykdid 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:24KirinDaveHuh...
17:24KirinDave… #() is kinda brittle, isn't it?
17:27avarusI don't get "let" ...
17:28KirinDaveavarus: Which part?
17:28avarusin general :)
17:28cgrandKirinDave: how's #() brittle?
17:28hiredmanlet x be equal to the result of some expression in the following expressions
17:28avarusthe book says something about bindings
17:28KirinDavecgrand: I'm just surprised how it expands.
17:28hiredmanavarus: it binds a name to a value
17:28KirinDavecgrand: I'm used to the way lambda in common lisp works, which is more amenable to certain things.
17:28avarushiredman: oh my god...so simple :)
17:28hiredmana limited lexical scope
17:29avarusya, got it, thanks :)
17:29KirinDaveavarus: For more edification on the subject, expand let into lambda forms.
17:29avarusI'm just reading programming clojure and I just arrived "bindings" and the example there confused me
17:29cgrandKirinDave: I'm not an expert in other lisps but isn't Clojure's lambda is fn, no?
17:29hiredmanKirinDave: doesn't really work in clojure
17:30KirinDavehiredman: It doesn't?
17:30hiredmanyou can recur across lets, but not across fns
17:30KirinDavehiredman: "recur across lets?"
17:31cgrandyou can't recur across a fn, you always recur to the nearest fn or loop
17:31hiredman,((fn [x] (when x (let [y (not x)] (recur y)))) true)
17:31clojurebotnil
17:31hiredman,((fn [x] (when x ((fn [y] (recur y)) (not x)) )) true)
17:32KirinDavehiredman: That sort of defeats the purpose of what I was trying to explain, but that's interesting.
17:32hiredman*BOOM*
17:32clojurebotExecution Timed Out
17:32hiredmanI wrote a macro that turned a let looking binding form into a sequence of fns
17:33hiredmannot a Sequence sequence, just a bunch of nested fns
17:33KirinDaveRight.
17:33KirinDaveAnd it didn't work, because let is a special form in clojure, not just an expansion.
17:33KirinDaveBut that doesn't mean that it doesn't have value as an exercise, which is why I was recommending it to avarus.
17:34hiredmanKirinDave: well, to fair, it is a special form in most lisps that I've seen
17:34KirinDavehiredman: I didn't say it wasn't.
17:34hiredmansure
17:34KirinDaveSo I'm not sure what kind of balance we're striking. :)
17:34hiredman~sicp
17:34clojurebotsicp is http://www.codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages:Clojure:Chapter_1
17:34hiredmanclojurebot: not that one
17:34clojurebotclojurebot: google nothing
17:35hiredman~sicp
17:35clojurebotsicp is http://web.mit.edu/alexmv/6.001/sicp.pdf
17:35KirinDavecgrand: Anyways, I made a mistake that seems to make clojure's compiler shit the bed and return "No message" for the error.
17:35KirinDaveOr rather, I wrote some code and then it was used in a way I didn't intend. :)
17:51avarusI start to like clojure :>
18:06hiredmanhmm
18:08clojurebottest
18:08hiredmanclojurebot: ping?
18:08clojurebotPONG!
18:08hiredmana wild ride
18:32technoma`replaca: just checked in that change to clojure-http-client
18:33technoma`_ato: hey,
18:33technoma`somebody squatted on my clojure-http-client group, so I can't upload
18:33technoma`also, I squatted on org.clojure
18:33technoma`any chance those could be fixed?
18:34technoma`_ato: also: welcome back! assuming you're back.
18:36_atotechnomancy: clojure-http-client is now yours
18:36technomancy_ato: thanks!
18:37technomancyhow's things going?
18:40_atotechnomancy: not bad, I'm gonna devote today to Clojars hacking. It's badly needing some love. :-)
18:40technomancywas starting to get worried about you
18:40technomancyglad to see you're back in action
18:41technomancywhat's on the table for today?
18:43_atofixing 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:43technomancywow, fun
18:43technomancyI'm excited about the couchdb migration
18:43technomancyespecially if it means we can move jars into couch attachments and then mirror via replication... that would be hawt
18:44_atoyes, I want to ditch relying on maven itself, it just makes things painful
18:45_atoI 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:53technomancycool
18:57technomancysorry I dropped the ball on implementing browse myself
18:59_atodon't worry about it. :-)
19:49replacatechnomancy: thanks!
19:59AWizzArd,(/ 12800 1600)
19:59clojurebot8
20:30kibahello
20:53kibahmm
20:58abrookstechnomancy: 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:58abrookstechnomancy: BTW, I love leiningen -- it's great stuff!
20:59kibabut I determine that I should build my first web application in clojure
20:59kibawhich I have no idea about building web application in the first place
21:29hiredmanclojurebot: ping?
21:29clojurebotPONG!
21:33technomancyabrooks: there's a thread on the mailing list about someone who already added that as a plugin
21:33technomancyI may merge it to lein proper down the road
21:34abrooksHm. I must have missed it -- thanks for letting me know. Consider this my +1. :)
21:36abrooksOh, there's a leiningen group. I missed that.
21:58abrookstechnomancy: Having now used leiningen-run I'll give a verified +1. Quite nice. Particularly if eval-in-project gets nailgun support.
22:00abrooksHm. I guess it's not eval-in-project getting nailgun, it's really lein/lein.bat.
22:01abrooksBy eval-in-project we're already in a running JVM aren't we...
22:02hiredmanI think eval-in-project spins up a new jvm
22:03hiredmanI think someone did some kind of nailgun plugin for lein
22:04hiredman~google lein nailgun
22:04clojurebotFirst, out of 521 results is:
22:04clojurebotIndex of /repo/lein-nailgun/lein-nailgun/
22:04clojurebothttp://clojars.org/repo/lein-nailgun/lein-nailgun/
22:26kibahmm
22:37hiredmancompojure seems to be the framework most people use
22:37hiredmanit has it's own irc channel and google group, dunno how active they are
22:38kibanot very active
22:39kibadocumentation is so poor that it's hard to learn
22:40hiredmankiba: you might checkout http://data-sorcery.org/category/compojure/
22:58technomancykiba: the mailing list for compojure is probably more active than the channel
23:33kibahow do I load other files
23:33kiba?
23:41mtdkiba: (load "filename-without-clj-extension") ?