#clojure logs

2011-11-23

00:00alexbaranoskyamalloy: any interest in working on Midje? we could use your skills :)
00:00amalloyalexbaranosky: the case i'm concerned about is (.foo IBar b) => 10 (.bar IBar b) => 9
00:01alexbaranoskyamalloy: I wonder what Midje does now for the fn analog of that? Probably just uses the last defined provided
00:02devnmidje is great.
00:02alexbaranoskyamalloy: oop misread
00:02alexbaranoskyhey devn
00:03alexbaranoskydevn: I'm the dude you were talking about pair programming and philosophy with first day of the Conj
00:03devnoh, right! how's it going?
00:03alexbaranoskyamalloy: I see your point now and will add it to the notes I'm accruing on the Github Issue
00:03alexbaranoskydevn: good!
00:04devnalexbaranosky: working on midje, eh?
00:05alexbaranoskydev: yeah, I've got three features on my list of things that seem most useful:
00:06alexbaranoskydevn: colorized console, auto/lazy-test powers, mocking java methods (including static ones)
00:06alexbaranoskyif you've got the burning urge to do any, that could be arranged :)
00:07devnIf I commit to anything else I think I might implode
00:07devnI absolutely want to, but wanting does give me extra hours :(
00:07alexbaranoskyme too, he
00:07reiddraperanyone know if there's a quickcheck for clojure that's actively maintained?
00:07reiddraperi've found a couple but they seem abandoned
00:08alexbaranoskywell, you can always give more feedback on GitHub issues, or to me; that stuff is really useful
00:08devnreiddraper: how abandoned is abandoned in your estimation?
00:08reiddraperdevn: no commits in 2011
00:08amalloyreiddraper: halloway has test.generative, which i think is similar
00:08devnalexbaranosky: yeah, I will definitely do that. I haven't used midje a *ton*, but when I have used it I've really enjoyed it.
00:08devnreiddraper: so clojurecheck is out of the picture, yes?
00:09amalloyand i think he's working on it
00:09alexbaranoskydevn: we don't get enough people adding their two cents to issues imho
00:09reiddraperdevn: that's the one i was looking at, perhaps it's great and just hasn't needed anything since 2010
00:10devnalexbaranosky: i have spent a fair amount of time on the wiki for midje. next time I'll peek at issues. :)
00:10reiddraperamalloy: I'll look more at test.generative. It wasn't well documented and I didn't dig further than that
00:11devnreiddraper: haskell ports seem to have the property of standing the test of time
00:11devnreiddraper: but they require some care and feeding
00:11devnreiddraper: have you looked at test.generative?
00:12reiddraperdevn: just enough to see there weren't many docs. should look more.
00:12devnreiddraper: I think you're right -- there aren't many docs, but I believe there are examples under src/
00:12reiddraperdevn: i coudldn't tell if it indented to be like quickcheck, or just a random input testing facility
00:12devnreiddraper: also, fogus' libraries clache and unk use test.generative, so that might be helpful
00:13devnreiddraper: honestly I don't know, but if you check out fogus' projects that might give you the answer you're looking for
00:13reiddraperdevn: ok, will take a look at those as well. I'm particularly interested in the "simplification" of failing cases that haskell/erlang QC provide
00:14reiddraperI suppose there's always the possibility of using a Java lib too :)
00:14bartjI thought re-seq returned a sequence of matches
00:15brehaut,(re-seq #"a+" "aababaabaababbbba")
00:15clojurebot("aa" "a" "aa" "aa" "a" ...)
00:15bartj, (re-seq #"(?i)\b(Mission Road|Bangalore)\b" "45, Mission Road, Bangalore")
00:15clojurebot(["Mission Road" "Mission Road"] ["Bangalore" "Bangalore"])
00:15bartjbut, it seems to return a sequence of matches
00:15bartjwhere the matches seem to be vectors!
00:16bartjbrehaut, ?
00:16brehautbartj: its because you have capture groups
00:16devn,(doc re-groups)
00:16clojurebot"([m]); Returns the groups from the most recent match/find. If there are no nested groups, returns a string of the entire match. If there are nested groups, returns a vector of the groups, the first element being the entire match."
00:17devn,(doc re-seq)
00:17clojurebot"([re s]); Returns a lazy sequence of successive matches of pattern in string, using java.util.regex.Matcher.find(), each such match processed with re-groups."
00:17devn"each element is processed with re-groups"
00:17brehaut,(map first (re-seq #"(a+)" "abaabaaa"))
00:17clojurebot("a" "aa" "aaa")
00:23bartjbrehaut, devn cool, thanks
00:27amalloycan i just say, this kind of "you can't predict the return type" seems pretty evil to me?
00:32tensorpuddinghow does clojure do error handling?
00:32tensorpuddingcan you specify your own errors?
00:32amalloy&(/ 1 0)
00:32lazybotjava.lang.ArithmeticException: Divide by zero
00:32amalloyi created an error right there. awesome
00:32tensorpuddingokay, so it uses java's exceptions
00:32tensorpuddinghow do i throw an exception
00:32tensorpuddinghow do i create new exceptions
00:33amalloytensorpudding: i seem to recall you hate reading docs, right?
00:33tensorpuddingis the only facility in java?
00:34tensorpuddingi skimmed the clojure docs but couldn't find anything talking about exceptions
00:36alexbaranosky&(throw (RuntimeException. "boom"))
00:36lazybotjava.lang.RuntimeException: boom
00:37alexbaranoskytensorpudding: also checkout slingshot on github
00:37tensorpuddingwhere is throw defined?
00:37choffsteinIf I am trying to upgrade a project to 1.3 and have a dependency that is still on 1.2, is there anything I can do to stop some conflicts?
00:37tensorpuddingi didn't see it in the api docs
00:38alexbaranoskyclojure.core??
00:38lazybotalexbaranosky: What are you, crazy? Of course not!
00:38clojurebotthis is not IRC, this is #clojure. We aspire to better than that.
00:38alexbaranosky(doc throw)
00:38clojurebotIt's greek to me.
00:38amalloytensorpudding: the compiler
00:38tensorpuddingsorry
00:38tensorpuddingi meant to say, which module is it in
00:39alexbaranoskyclojurebot is pissed man
00:39brehauttensorpudding: amalloy already told you: the compiler; its a special form
00:39tensorpuddingoh
00:39brehauthttp://clojure.org/special_forms#Special%20Forms--(throw%20expr)
00:40choffsteinanyone use weavejester's hiccup library?
00:40alexbaranoskytensorpudding: http://clojuredocs.org/clojure_core/clojure.core/throw
00:40amalloychoffstein: most webapps use hiccup, though not all
00:41tensorpuddingdang
00:41choffsteinamalloy: yeah, I realized after typing it that it was a pretty stupid question
00:41tensorpuddingi forgot
00:41tensorpuddingto check the clojuredocs instead of the api page on clojure.org
00:41choffsteinI'm trying to figure out if its dependence on 1.2.0 is breaking my 1.3.0 move
00:42amalloychoffstein: probably not. if you have the latest hiccup you're fine
00:42choffsteinI can't find which dependency is breaking. I'm getting a strange error: java.lang.IllegalStateException: Can't dynamically bind non-dynamic var: clojure.contrib.pprint/*format-str*
00:42amalloyeven if it depends on 1.2, so long as it doesn't use contrib
00:44amalloythat's pretty much what happens to everyone who tries to upgrade (including me).
00:44tensorpuddingwhy does the api page on clojure.github.com not cover throw
00:44amalloysome dependency uses contrib, and old-style contrib isn't 1.3 compatible
00:45brehauttensorpudding: because its not part of the api, its part of the compiler?
00:45tensorpuddinghmm
00:45tensorpuddingi had assumed let was a special form
00:45tensorpuddingbut it's a macro?
00:45amalloyso you have to track down who's using contrib, and update those
00:46tensorpuddingbrehaut, except clojuredocs has it
00:46brehautlet is a macro that wraps let* which is a special form
00:46amalloytry: $ lein pom && mvn dependency:tree
00:46amalloythis will at least tell you about *one* of your deps that uses contrib
00:46brehauttensorpudding: clojuredocs is not an autogenerated project, its a curated by humans
00:48tensorpuddingwell
00:48tensorpuddingit'd be more helpful if the info on clojuredocs were front-and-center on the clojure.org page
00:49choffsteinamalloy: so does that mean I either need to a) fork the dep with the contrib dependency and try to move it to 1.3, b) not use the dep, or c) something else?
00:49devntensorpudding: not always.
00:49brehauttensorpudding: everything that makes clojuredocs great in some areas means its very weak in others
00:49devntensorpudding: i agree, but it is not always the case that I want to see potentially mediocre example code. the clojure.org docs are very clear.
00:49devnthey describe intent, philosophy, etc.
00:49devnclojuredocs is icing
00:49amalloychoffstein: often you can (c) use a more recent version of the dep that's already updated
00:50tensorpuddingthat's a reasonable point, that clojuredocs has possibly mediocre content, but it seems clearer and more helpful
00:50devntensorpudding: yes, but now you probably see the issue: not everyone is looking for API docs
00:50choffsteinI'm confused because none of my deps seem to depend on clojure-contrib :-\
00:51devnthey could make relatively short documentation pages long and difficult
00:51devntensorpudding: you could always create a greasemonkey script or something that adds them to the page
00:51tensorpuddingapi docs are the main thing that i want when i go there now
00:51tensorpuddingi read the reference
00:52devntensorpudding: why not just use clojure.repl?
00:52devn,(doc +)
00:52clojurebot"([] [x] [x y] [x y & more]); Returns the sum of nums. (+) returns 0. Does not auto-promote longs, will throw on overflow. See also: +'"
00:52tensorpuddingi use doc 99% of the time
00:52tensorpuddingbut it doesn't help if i don't know what i'm looking for
00:52devntensorpudding: do you have an example? not trying to grill you, just trying to understand
00:52tensorpuddingbrowsing vs. querying
00:52tensorpuddingwell, i wanted to know how to throw an exception
00:53tensorpuddingturns out that you use throw, a special form
00:53tensorpuddingit wasn't in the api docs, i missed it
00:54devntensorpudding: so you went to clojure.org and you weren't satisfied with the documentation there, so you went to clojuredocs?
00:54devntensorpudding: is that correct?
00:54tensorpuddingwell, clojuredocs was pointed out to me
00:55tensorpuddingfor the second time
00:55tensorpuddingi had heard of it before
00:56devntensorpudding: so you think clojure.org should prominently display clojuredocs.org for the purposes of additional information?
00:56tensorpuddingno
00:56devntensorpudding: sorry, I'm just trying to understand what might have made your life easier.
00:57tensorpuddingi just really wanted throw to have appeared in the place i expected to find it, the docs
00:57devntensorpudding: 1.4.0 looks like it's going to get some documentation love FWIW
00:58devntensorpudding: http://dev.clojure.org/display/design/Clojure+1.4+docstrings
00:58tensorpuddingbetter docstrings would be nice
00:59tensorpuddinghelpful exceptions would be a lot nicer
00:59devntensorpudding: you're in luck! http://dev.clojure.org/display/design/Clojure+1.4+error+messages :)
00:59tensorpuddingwell, that's good news
01:00devnnothing is done yet, but those concerns have definitely been heard before and there is an effort to make people's lives a bit easier in clojure land
01:01amalloywe should elect devn as Chief Finder-of-Things From dev.clojure.org
01:01devnamalloy: I am sort of a librarian
01:03devnamalloy: along those lines, I have a friend who thinks the idea of "architects" as they have been traditionally defined in large software development companies is wrong, but that what a lot of projects need is someone who knows the terrain, the papers to read, etc.
01:04devnamalloy: it's an interesting thought. "team librarian" -- the guy who knows which library you should use because he's reviewed its code and kicked its tires.
01:06devntensorpudding: in the meantime, if i could suggest to you another tool you might use to avoid a trip to clojure.org: clojuredocs-client @ http://dev.clojure.org/display/design/Clojure+1.4+error+messages
01:06devnwoops: https://github.com/dakrone/clojuredocs-client
01:06tensorpuddingi'll check it out
01:06devnyou can include that in your project and query clojuredocs' api from the REPL
01:08Raynes$examples clojure.core/defmulti
01:08lazybothttps://gist.github.com/1387995
01:08clojureboteg, https://github.com/clojure/tools.logging is the new version of clojure.contrib.logging
01:08Raynes$cd defmulti
01:08lazybotclojure.core/defmulti: http://clojuredocs.org/v/1989
01:08lazybotclojure.core/defmulti: http://clojuredocs.org/v/5452
01:08RaynesOr you can just use lazybot. ;)
01:10amalloyRaynes: seems like you could put those on one line
01:10Raynesamalloy: You proposed that before and I told you no then as well.
01:10amalloywell, i'll get back to you in a month when you've forgotten
01:37amalloy~logs
01:37clojurebotlogs is http://clojure-log.n01se.net/
02:40tuubowin clojure if (= '(1) (quote (1))) is true then why (= '(1) (first '('(1) '(2)))) is false..is this a bug or i am doing something wrong..
02:41hiredmanwhat do you think is more likely?
02:42tuubowi am doing something wrong i guess
02:42hiredmanand what do you think the best way to figure out what you are doing wrong is?
02:42tuubowbut (first '('(1) '(2))) is (quote (1))
02:43tuubowso it should be true.
02:43hiredmantuubow: is it?
02:43hiredmanand what is '(1)?
02:43hiredman,'(1)
02:43clojurebot(1)
02:44tuubowsame thing isn't '(1) is same as (quote (1))
02:44hiredmanthats not (quote (1))
02:44hiredmanyes '(1) is the same as (quote (1)), but (list 'quote (list 1)) is not the same
02:44hiredmanneither is ''(1)
02:45hiredmanor (first '('(1)))
02:45Raynes&(first '('(1)))
02:45lazybot⇒ (quote (1))
02:46hiredmanhttp://en.wikipedia.org/wiki/Lisp_%28programming_language%29#Self-evaluating_forms_and_quoting
02:46tuubowbut how come then (= '(1) (quote (1))) is true
02:46hiredmanbe cause they are equal
02:47hiredmanlook, you need to spend sometime learning about quoting and how it works, sit down with a repl somewhere
02:48tuubowin repl when i type this (first '('(1) '(2))) it gives (quote (1))
02:48hiredmansure
02:48hiredman,(= (+ 1 2) 3)
02:48clojurebottrue
02:48hiredman,(= '(+ 1 2) 3)
02:48clojurebotfalse
02:48hiredman,(= '3 3)
02:48clojurebottrue
02:48hiredman,(= ''3 3)
02:48clojurebotfalse
02:49hiredman,''3
02:49clojurebot(quote 3)
02:49hiredman,3
02:49clojurebot3
02:49hiredman,'3
02:49clojurebot3
02:49tuubow(= '(1) (first '('(1) '(2)))) so if replace (first '('(1) '(2))) with (quote (1)) it should be true
02:49hiredmanlike I said, sit down with repl and figure it out, a solid understanding of quoting will serve you well
02:49tuubowas (= '(1) (quote (1))) is true
02:50hiredman,'(1)
02:50clojurebot(1)
02:50hiredman,(quote (1))
02:50clojurebot(1)
02:50hiredman,(quote '(1))
02:50clojurebot(quote (1))
02:51hiredmananyway, I am going to put you on ignore now
02:51tuubowsorry i will look at it thanks.
02:59raektuubow: '<foo> is just a shorthand for (quote <foo>). quote is also a special form
02:59raekwhen you evaluate a quote expression, the value is the "content" of the quote
03:00raek(quote x) evaluates to the symbol x. (quote (quote x)) evaluates to (quote x), i.e. a sequence of length two where the first element is the symbol quote and the second element is the symbol x
03:02raekso to evaluate (= '(1) (first '('(1) '(2)))) you first eval the arguments to =, namely '(1) and '('(1) '(2))
03:02raek(quote 1) evaluates to 1
03:02raeksorry
03:03raek'(1) is (quote (1)), which evaluates to (1)
03:03raek'('(1) '(2)) is the same as (quote ((quote (1)) (quote (2)))), which evaluates to ((quote (1)) (quote (2))))
03:04raek(1) and ((quote (1)) (quote (2))) are not the same data, so (= ...) returns false
03:08tuubowthanks raek
03:18jidotnetHi! Anybody knows if/when the videos of the Conj will be available?
03:18amalloyjidotnet: they will be available, supposedly sooner than last year's were, but i don't know details
03:19G0SUBamalloy
03:20jidotnetamalloy: thanks, is there a way to get an alert when that happens?
03:21raektuubow: btw, you usually use vectors as sequence literals
03:21raek,(= 1 (first [1 2 3]))
03:21clojurebottrue
03:21amalloyjidotnet: probably if you follow @clojure_conj and #clojure_conj on twitter you'll find out
03:22tuubowwell i am trying to implement set with this although clojure already has it.I would have gone to scheme for doing that but preferring clojure
03:23tuubowso was trying to implement a member function as there is one scheme
03:24Raynesjidotnet: @confreaks is supposed to tweet when videos are ready.
03:24tuubowand as scheme doesn't have vectors so can't use it
03:25tuubowit is a part of the assignment i am doing
03:27raektuubow: in Clojure lists and quote work the same as in Scheme, except that you cannot have "dotted pairs"
03:27amalloywait, they tweet all kinds of stuff i don't care about. i'll just assume someone i follow retweets
03:29raek(in Clojure-land you will hear about sequences which is a generalization of lists)
03:29tuubowraek, cons is there so i don't think i will need dotted pair,but i would have loved to have the member function on lists but i have implemented it now.I am loving clojure
03:30raektuubow: yes, but you cannot have a non-sequence as the cdr
03:30raek,(cons 1 1)
03:30clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
03:31amalloyclojure makes it so easy to get a generalized version of member, so you don't really need member
03:31amalloy&(some #{5} (range 10))
03:31lazybot⇒ 5
03:31amalloy&(some #{50} (range 10))
03:31lazybot⇒ nil
03:31amalloy&(some #{1 5} (range 10))
03:31lazybot⇒ 1
03:33tuubow&(cons 1 '(1))
03:33lazybot⇒ (1 1)
03:35tuubow&(defn member "Looks for the member in the lists return false if not found else return part of the list" [key list] (if (nil? (first(seq list))) false (if (= key (first list)) list (member key (rest list)))))
03:35lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
03:36amalloytuubow: (member nil '(1 nil 2))
03:36tuubowsorry i didn't know the lazybot don't expect functions
03:36G0SUBamalloy: isn't it possible to play with lazybot in a PM window?
03:36amalloyG0SUB: yes?
03:37G0SUBamalloy: I was thinking if people could just use the bot in a private window the channel noise could be reduced
03:38tuubowamalloy: yeah that is the corner case.
03:38amalloyindeed you can do that, and if people are being super-noisy i encourage it. but it's not like we're trying to have a philosophical conversation and being drowned out by lazybot
03:38G0SUBamalloy: not really, was curious about the possibility. thanks.
05:19cataskaany one has "Practical Clojure" book ? I have a question on page 160
05:21G0SUBcataska: I can try. have the book.
05:22cataskalast sentence on page 160, "..., and because the update-average involves just processing and waiting for IO"
05:23cataskabut update-averate is only processing with no IO, right ?
05:23cataskaupdate-average
05:23G0SUBcataska: should read "and no waiting for IO..."
05:24cataskaG0SUB: ok, thanks
05:24cataskait seems not in official errata
05:25G0SUBcataska: if IO in involved, you're better off using send-off
05:25G0SUB&(doc send-off)
05:25lazybotjava.lang.SecurityException: You tripped the alarm! send-off is bad!
05:25G0SUB&(doc 'send-off)
05:25lazybotjava.lang.SecurityException: You tripped the alarm! send-off is bad!
05:25G0SUB:(
05:26cataskaG0SUB: :)
05:26G0SUB&doc
05:26lazybotjava.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc
05:27G0SUBhmm, this thing is broken.
05:28G0SUB&(:doc (meta #'clojure.core/send-off))
05:28lazybotjava.lang.SecurityException: You tripped the alarm! send-off is bad!
05:28G0SUBamalloy: are you guys using regex on the command as well?
05:28G0SUBit seems the var itself is blocked somehow.
05:29amalloyyes, it is. not using regexes, though; i don't see why that would be relevant
05:29G0SUBamalloy: can't I even see the docs of all the core fns?
05:30amalloyevidently not. it would be nice if we could tell you're using doc, and take out the blocks in that case; patches welcome
05:30G0SUB&(keys (ns-publics (:ns (meta #'clojure.core/first))))
05:30lazybotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
05:31G0SUB:-)
05:31G0SUBamalloy: cool
05:34G0SUBamalloy: what about a doc plugin? won't that be easier?
05:37Fossi,(doc 'send-off)
05:37clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol>
05:38Fossi,(doc send-off)
05:38clojurebot"([a f & args]); Dispatch a potentially blocking action to an agent. Returns the agent immediately. Subsequently, in a separate thread, the state of the agent will be set to the value of: (apply action-fn state-of-agent args)"
05:39amalloyG0SUB: sure
05:55fliebelI forked and basically rewrote a small utility. Not likely to get merged back, but I'm using it in a project. How should I distribute it?
05:56fliebelActually, I did this twice.
05:57fliebelFor now I just did lein install, but one way or another, I need to get it on Clojars or something.
05:59fbru02hey guys how do i make the repl/swank overshadow some function when i evaluate it ? i think it's 1.2.1 onwards that the overshadowing doesn't occur automatically
06:18tsdhfbru02: What do you mean with overshadowing? Can you given an example?
06:18fbru02tsdh: sorry, i just meant re-writing when re-evaluating
06:21tsdhfbru02: I still don't get it... You want to redefine some clojure functions when you do "lein repl" or M-x clojure-jack-in?
06:22fbru02what i'm doing now : i load a bunch of functions using "(use 'ns1)" one of the fns is called foo. I want now to load foo from my souce code so i step on another function called foo and evaluate it, that doesn't work i get an exception
06:22fbru02is there a way no to get an exception ?
06:23fliebeldrewr: https://github.com/drewr/postal/issues/13
06:29fliebelHm, how do I push a project to org.clojars.pepijndevos/whatever?
06:30clgvfliebel: create an account. add an ssh public key of your computer and copy it per scp there.
06:30clgvit = jar
06:30fliebelclgv: Yes, but the namespace.
06:31clgvoh right. I have no idea about that. I would have liked a description on my jar as well - but no idea ho to get it there
06:31fliebelclgv: Another project I pushed just ended up under foo:foo
06:31clgvyeah, my only project also landed there under its plain name
06:32clgvI miss some editing/managing functionality on clojars when you are logged in
06:32fliebelclgv: just, maybe puting the namespace in the project.clj or editing the po file might do the trick. let me see.
06:33clgvfliebel: there is a chance that you can provide metadata via project.clj, but the question is how^^
06:34fliebelclgv: I'm pretty sure that if I change groupid in the pom, it'll work.
06:34clgvoh, I never touched the pom^^
06:35fliebelclgv: ah, if I change project.clj to (defproject org.clojars.pepijndevos/ring-http-basic-auth, the pom changes its groupid to that.
06:35clgvah, interesting
06:37fliebelclgv: What is your one project on clojars?
06:37clgva leiningen plugin: lein-checkouts
06:37clojurebotleiningen is a build tool designed not to set your hair on fire (http://github.com/technomancy/leiningen)
06:39clgvfliebel: changing the project name to contain the group-id is also suggested in some tutorial I found
06:39fliebelclgv: As well as in my Java book :P
06:40fliebelclgv: Doesn't lein already do checkouts?
06:40clgvfliebel: I wanted to build all "checkouts" projects from the project that is using them.
06:41clgvlike "lein checkouts uberjar" will "install" all "checkouts" and then build an uberjar of the current project
06:41fliebeloh, nice
06:42clgvyeah. that was a missing piece since I structured my main project in several libraries that I might share with students
07:01Blktgood day everyone
07:36clgvfliebel did it ;)
07:36fliebelclgv: ?
07:36clgvpushing to clojars ;)
07:37fliebel,botsnack
07:37clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: botsnack in this context, compiling:(NO_SOURCE_PATH:0)>
07:37fliebelhm
07:37clgvclojurebot: botsnack
07:37clojurebotthanks; that was delicious. (nom nom nom)
07:50fliebelclgv: ?
07:51clgvfliebel: the pmap implementation is a nightmare briefly said - if you want to apply a function on a sequence.
07:53clgvI turned it into a producer-consumer scenario with a bounded queue which fits better for most parallelization purposes on sequences.
07:53fliebelclgv: ok, that is briefly, what is the full store? (maybe you could write it down in a Jira issue?)
07:54fliebelclgv: Talking about producer-consumer, seque is just as much of a nightmare.
07:54clgvfliebel: a jira issue does not fit. it has no bug - but is inappropriate in all cases I wanted to parallelize something.
07:54clgv&(doc seque)
07:54lazybot⇒ ------------------------- clojure.core/seque ([s] [n-or-q s]) Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n bu... https://gist.github.com/1388585
07:55fliebelTry running that with a priority queue. It makes invalid assumptions about what a que is.
07:55clgv&(source seque)
07:55lazybot⇒ Source not found nil
07:55fliebel$source seque
07:55lazybotseque is http://is.gd/aZK2oD
07:56clgvI hate the slow github highlighting :(
07:56clgvhumm lazybot linked another defn
07:58fliebelclgv: This is my implementation: https://gist.github.com/934781
07:59clgvits hard to diff between two tabs ;)
08:01fliebelclgv: Basically the core version just puts and takes until it encounters itself. My version uses a second FIFO queue, to send to the other end what to do next.
08:02clgvah ok
08:03clgvfliebel: my implementation definitely applies f to all items of the passed sequence but has a bounded queue size so that it wont run out of memory (I'll process big files with it)
08:04fliebelclgv: So it is basically like (pmap f (seque s limited-queue))?
08:04fliebel$source pmap
08:04lazybotpmap is http://is.gd/zPdiIH
08:04clgvfliebel: no pmap only processes a sliding window on consumption
08:05fliebelclgv: I don't get it. source?
08:07clgvfliebel: (lazy-)seq -> producer takes elements puts them into bounded queue -> queue -> consumer threads process items from queue and put the results in a result queue -> result queue -> returned lazy-seq reads from result queue
08:07clgvthe producer will block when the bounded queue is full
08:08clgvso the entire calculation is async but you can acces already computed elements via the lazyseq as soon as they are calculated
08:08fliebelclgv: in order? Or just asap?
08:08clgvat the moment order is preserved but I also want a version where first calculated is first in result seq
08:09clgvI use it like (pprocess f coll :thread-count 4 :queue-size 8)
08:11fliebelclgv: I don't see why you have a queue for the producer. Presumably, f takes long, so the queue is just a buffer of realized items?
08:12clgvfliebel: to bound the items that are in memory the producer reads only as much as allowed
08:12clgv*many
08:13fliebelclgv: But if the input is a lazy seq, why realize even a buffer full of them?
08:14clgvfliebel: I dont understand your question
08:15clgvone problem there is that I cant let multiple threads access one lazy-seq like a queue
08:16fliebelclgv: Well, you have a lazy seq of unrealized items. You realize 8 ahead of time. Why not realize none at all?
08:16fliebelhmm, is that true? hm, I guess
08:16clgvfliebel: and how can the 4 consumer threads access the sequence like a queue?
08:17fliebelclgv: Not, unless you put it in an atom or something.
08:18fliebelref, even
08:18clgvfliebel: extracting something from the lazy-seq means calculating it anyways
08:18clgvso I have to realize an item to pass it into a thread
08:18fliebelclgv: Yea, so you just go ahead and put it in a queue, I get it.
08:20clgvfliebel: indeed you have to be aware to put all of the expensive computation in the function and not some of it in the lazyseq
08:26clgvfliebel: one could think of a concurrent lazy-seq that acts like a queue by passing elements out as futures one-by one
08:26notostracaHow do I pass the contents of a seq as arguments to a constructor that takes lots of arguments?
08:26notostracaLike apply, but for a constructor
08:27clgvnotostraca: if you cant write a function for it in advance (manually or as part of a macro) you probably have to fall back to reflection
08:27fliebelnotostraca: (apply new object seq)?
08:27notostracaclgv, I never quite figured out macros
08:27notostracafliebel, I will try it
08:27clgvfliebel: that works?
08:28fliebelclgv: No idea...
08:28clgv,(apply new java.util.Date [])
08:28clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: new in this context, compiling:(NO_SOURCE_PATH:0)>
08:28fliebelno, new is a special form :(
08:29clgvI dont think it is possible. but for a defrecord you can enhance the defrecordmacro to create a factory function in 1.2 or use the automatically generated one in 1.3
08:30notostracaclgv, I am using defrecord...
08:30clgvclojure 1.3?
08:30notostracano, not yet
08:30notostracaI am using CCW in Eclipse, which hasn't updated yet
08:31notostracais there a better way, I wonder...
08:31clgvnotostraca: thats not an issue simply delete the clojure jars and replace them with 1.3 ones if nothing else helds you back
08:31notostracaso what would I use in 1.3?
08:31notostracafor this particular problem
08:32notostracaI will switch now if it fixes it...
08:32cemericknotostraca: you can use 1.3 in your projects with ccw without a problem
08:32clgv(->Rec 1 2 3) for (defrecord Rec [a b c])
08:32clgvin your case: (apply ->Rec [1 2 3])
08:33notostracaclgv, great
08:33clgvCCW: just installs default clojure 1.2 in your new project but that doesnt prevent you from switching to 1.3
08:34clgvmaybe it should have an option for selecting 1.2.1 or 1.3.0
08:35fliebelWould it be possible to somehow proxy an instance of a class? I want to extend it, but it doesn't have a public constructor.
08:35fliebelomg, I can of course just define a protocol and extand that to it.
08:35clgvfliebel: you can call the constructor via reflection anyway and use it as aggregate
08:36clgvprotocol approach is much better if possible ^^
08:37pyri supposed core.incubator is meant to get into core eventually
08:37fliebelclgv: Yea, I'll do that. I'm trying to handle java.xmail.* objects nicely, so i converted them to maps, but now I can't use the methods of the objects anymore of course.
08:38clgvfliebel: writing the next spambot? ;)
08:39fliebelclgv: Almost... more like a... web mail rss twitter client... I need to work on my elevator pitch.
08:39clgv"elevator pitch"?
08:40fliebelclgv: short introduction, like you stand in the elevator with an investor, and you have 10 seconds to explain your product.
08:41clgvfliebel: ah. you got a startup?
08:41fliebelclgv: hmmm, dunno, I guess you could call it that. A serious project at least.
08:43clgvfliebel: so you are still hanging out in elevators waiting for the investors? ;)
08:43fliebelclgv: nope, I just started building, and i want to take it to WebFWD.
08:44clgvdidnt know about that program, yet
08:45fliebelclgv: Random question: where are you from?
08:45clgvfliebel: seems not that random. germany.
08:47clgvand you?
08:47fliebelclgv: How is it not random? Netherlands.
08:49clgvfliebel: scientifically speaking "cant judge since we didnt tie the model". personally, it just doesnt seem random like 11111 doesnt seem ;)
08:50fliebelclgv: Well, yea, it's a perfectly normal question, but one moment we're talking about clojure, the next I ask where you are from.
08:51notostracaOK, I'm debugging now, it is getting the wrong number of arguments somehow
08:51fliebel(tbh, I mostly assume everyone who speaks reasonable english is an american)
08:51notostracaIt might be that I defined the record with 1 field?
08:52fliebelnotostraca: paste?
08:53notostracasure, it's kinda a mess and it is meant to read in a TSV table
08:54notostracahttp://pastebin.com/AwbSxKdu
08:55notostracathe TSV file is pasted directly from a spreadsheet
08:55notostracathe column names are the first row, everything after that is data
08:56clgvnotostraca: I have the feeling you are using defrecord strangely
08:56notostracaclgv, yeah
08:56clgvnotostraca: the defrecord contains the header and the map part of the defrecord the values?
08:56notostracaI need to define it at runtime
08:56clgvnotostraca: defining at runtime is not a problem
08:57notostracaclgv, I am calling defrecord with a vector drawn from parsing the file
08:57notostracaI don't know if that works
08:57clgvnotostraca: did you have a look at incanter and how they manage their datasets?
08:57notostracaI don't know what incanter is
08:57clgv$google incanter
08:57lazybot[Incanter: Statistical Computing and Graphics Environment for Clojure] http://incanter.org/
08:57clgvthats it^^
08:58clgvif you need any visualization for your data you should consider it
08:59notostracaclgv, no I don't think I need that
08:59clgvok, you might have a look at their dataset implementation - they have a defrecord for it as well
08:59notostracaI just need to get this in a hashmap of things, so I can persist it as clojure code with prn
08:59notostracait doesn't need to be records
09:00clgvafaik they divided it into a headerfield and a rows field
09:00notostracathere's some old code in that paste that gets the TSV into a sorted-map of hash-maps of strings
09:01clgvthe header contains the keywords for the columns and the rows field contains the row data with each row beaing a hashmap from column name (keyword) to value
09:01notostracabut ideally it would be able to take integer fields in the TSV and convert them to ints instead of strings
09:01pyris there a cleaner (simpler) way to sanitize a map
09:01clgvthat layout could work for you as well
09:01pyrthan this:
09:02notostracapyr: pastebin
09:02pyr(->> {:a nil, :b :foo} (filter #(val %)) (reduce merge {}))
09:02notostracaclgv, it doesn't seem like it needs a lib dependency honestly
09:03clgvyes. you can easily build it like that as well.
09:03pyrnotostraca: i don't think it's warranted
09:03clgvnotostraca: ^^
09:05clgvpyr: you could do a reduce + dissoc approach to keep sharing structure
09:06pyrreduce dissoc on keys ?
09:08clgvpyr: (let [m {:a nil, :b :foo}] (reduce #(dissoc % %2) m (filter nil? (keys m))))
09:08clgv&(let [m {:a nil, :b :foo}] (reduce #(dissoc % %2) m (filter nil? (keys m))))
09:08lazybot⇒ {:a nil, :b :foo}
09:09fliebelclgv: filter is wrong
09:09clgvdamn... somehting missing. #(let [m {:a nil, :b :foo}] (reduce #(dissoc % %2) m (filter #(nil? (m %)) (keys m))))
09:09clgv&(let [m {:a nil, :b :foo}] (reduce #(dissoc % %2) m (filter #(nil? (m %)) (keys m))))
09:09lazybot⇒ {:b :foo}
09:10fliebelclgv: ##(+ 1 1)
09:10lazybot⇒ 2
09:10clgvyeah. typo^^
09:10pyractually, mine should read (->> {:a nil, :b :foo} (filter val) (reduce merge {}))
09:10pyr,(->> {:a nil, :b :foo} (filter val) (reduce merge {}))
09:10clojurebot{:b :foo}
09:10pyr&(->> {:a nil, :b :foo} (filter val) (reduce merge {}))
09:10lazybot⇒ {:b :foo}
09:11clgvpyr: yours doesnt share structure with the old map. thats only not that optimal if the map is large and there are few "nil keys"
09:12pyrclgv: agreed
09:14fliebelI really wish clojure used protocols, so I could extend java.foo.Bar to clojure.lang.IBaz
09:16notostracawhat is the equivalent of (last) that drops the last element instead of the first?
09:17notostracalike first, but all of the entries but the last
09:17joegallobutlast, drop-last
09:17notostracathanks
09:18joegallohttp://clojure.github.com/clojure/ (Ctrl+F, "last" and looked around)
09:18joegallo;)
09:18notostracabutlast doesn't show up?
09:19notostracain clojure.core
09:19notostracahuh, nvm
09:21clgvyou can use lazybot as well
09:21clgv$findfn [1 2 3 4] [1 2 3]
09:21lazybot[clojure.core/butlast clojure.core/drop-last clojure.core/pop]
09:22bendlaswut?
09:22bendlasthat's advanced
09:25pyr$findfn {:a nil :b :foo} {:b :foo}
09:25lazybot[]
09:28clgvit cant build functions compositions although that should be doable as well until the timeout strikes ;)
09:29marchdownhello
09:31notostracahmm, maybe that's it
09:32notostracacan you create records with string keys?
09:32notostracaor do they have to be symbols?
09:32clgvdefrecord will always have keywords of the symbols you provide
09:32notostracaah
09:33clgvbut you can easily create a keyword via ##(keyword "bla")
09:33lazybot⇒ :bla
09:33notostracaso there's the problem
09:33notostracaand if there's a space in "some random phrase" ?
09:33notostraca,(keyword "something happy...")
09:34clojurebot:something happy...
09:34notostracawoah what
09:34clgvthats probably a bad idea since it works but is not supposed to, i.e. you cant read it back
09:34clgv,(read-string (with-out-str (pr (keyword "something happy..."))))
09:34clojurebot:something
09:35notostracais there a way to format a string nicely as a symbol?
09:35clgvthere is also ##(symbol "bla")
09:35lazybot⇒ bla
09:35clgv&(class (symbol "bla"))
09:35lazybot⇒ clojure.lang.Symbol
09:35notostraca(symbol "oh yeah")
09:35notostraca,(symbol "oh yeah")
09:35clojurebotoh yeah
09:36notostracaah
09:36joegallo,(name 'foo)
09:36clojurebot"foo"
09:36joegallooh, that's backwards from what you want. :)
09:36marchdownI'm struggling to install clojure. $ java -cp clojure.jar works, but lein barfs out an error.
09:36notostracamarchdown, lein should grab its own clojure
09:36notostracai think it needs maven
09:37notostracamaybe you need to run "lein self-install"
09:37joegallommm.... i'm not sure about that. marchdown, can you gist the error you're getting?
09:37notostracamaybe you need to run "lein selfinstall" instead, not sure what the word is
09:37duck1123lein uses maven stuff, but it doesn't actually need maven installed
09:38marchdownI don't know the first thing about maven, but I've run 'mvn install' in clojure repo as per instructions, and it did something. I'm on a mac with system-provided java.
09:39joegalloyeah, i don't think that does what you'd like it to do
09:39joegallothat's "install this jar into my local .m2 directory"
09:39joegallowhich isn't quite as awesome as it sounds... :)
09:39notostracamarchdown, have you run lein just as "lein" ?
09:39duck1123Some clojure projects use maven, also as part of lein install, a basic pom file is created
09:40marchdownhttps://gist.github.com/1388808
09:40joegallodon't try to install leiningen 2.0.0
09:40joegalloit's a highly experimental in-development version -- i think
09:41notostracause stable -- https://raw.github.com/technomancy/leiningen/stable/bin/lein
09:42notostracayou can probably just wget that
09:43notostracadownload that into somewhere on your PATH, like /usr/bin , "chmod 755 lein", "./lein"
09:44notostracayou may need to run the last two as sudo if you put it somewhere where you need root permission to write
09:45duck1123I prefer to put mine in ~/bin or similar, that way I can upgrade without sudo
09:45marchdowncool, thanks. I'm feeling so stupid now for not noticing it was a plain old 404. The reason is, this is the second box I'm installing clojure on, and the first time I had an error at the same stage, but it was far more cryptic.
09:45duck1123just have to make sure that dir is on PATH
09:46marchdownOkay. So, how'd I hook it up with emacs now?
09:46marchdownI need a clojure-runner script, right?
09:46joegallono
09:47notostracamarchdown, are you familiar with emacs? Because I'm not, and there are good IDE plugins too
09:47notostracaand the IDE plugins probably have better support for Java, though I can't be certain
09:47marchdownI am.
09:47notostracaok
09:48joegalloyou need clojure-mode
09:48marchdownGot that.
09:48joegalloyou need lein-swank-[latest stable version].jar in you ~/.lein/plugins/ directory.
09:48notostracain that case, I imagine you will be sticking with mostly- or pure-clojure projects, which will be pleasant compared to switching your mindset from one to the other
09:55dablhi all, /quit
10:06notostracais there a good way to get an Integer or int or some number from a String in clojure?
10:07kephale,(read-string "1")
10:07clojurebot1
10:07notostracahuh good to know
10:07notostraca,(read-string "1 2 3 4"
10:07clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
10:07notostraca,(read-string "[1 2 3 4]")
10:07clojurebot[1 2 3 4]
10:07notostraca,(read-string "1 2 3 4")
10:07clojurebot1
10:08joegallo,(doc read-string)
10:08clojurebot"([s]); Reads one object from the string s"
10:09notostraca,(/ (read-string "1") 3)
10:09clojurebot1/3
10:10Wild_Cat,(Integer. "2")
10:10clojurebot2
10:12clgvnotostraca: there is also Integer/parseInt
10:13notostracaI'm going to read-string on every value, individually -- it handles string data so I don't need to have types as part of the data
10:16fliebelnotostraca: read-string is a bit of a security issue, I think. I don't know if that matters to you.
10:18jcromartieSo I was playing with this on the train this morning: https://gist.github.com/1388915
10:18jcromartiecreating a temporary memoization context for certain functions... is there any chance that this is already idiomatic?
10:18notostracafliebel, I am making the data in a spreadsheet, so it will be fine
10:18jcromartieit makes writing this kind of math code very nice
10:19fliebelnotostraca: I just saw you already evaluated a list.
10:19clgv,(read-string "(System/exit 0)")
10:19clojurebot(System/exit 0)
10:20clgv,(read-string "(eval (System/exit 0))")
10:20clojurebot(eval (System/exit 0))
10:20clgvlol
10:20clgv,(eval (read-string "(System/exit 0)"))
10:20clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
10:20clgvhehe ok^^
10:20clgvso read-string cant do any harm I guess, since it is not evaling
10:21clgv,(read-string "#=(System/exit 0)")
10:21clojurebot#<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>
10:21clgv,(binding [*read-eval* true] (read-string "#=(System/exit 0)"))
10:21clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.ClassNotFoundException: System>
10:21floatbothclgv: sandbox won't let you eval anyway
10:21fliebeljcromartie: You should talk to fogus, he's putting a memoization lib in contrib.
10:22jcromartieI got my math wrong :P
10:26fliebelDo there exist functions for translating and selecting keys from a map? {:foo 1 :bar 2} -> {:baz 2}
10:28fliebelwee, armagedom :)
10:28fliebelclojurebot: botsnack
10:28clojurebotThanks! Can I have chocolate next time
10:28fliebelI'll see...
10:29clgvfliebel: select-keys, rename-keys
10:30clgv$findfn {:bar 2}{:baz 2}
10:30lazybot[]
10:30clgv$findfn {:bar :baz} {:bar 2}{:baz 2}
10:30lazybot[]
10:30clgv$findfn {:bar 2} {:bar :baz} {:baz 2}
10:30lazybot[clojure.set/rename-keys]
10:31fliebelah, it's hiding in set...
10:31clgvyep, they always do ;)
10:33fliebelclgv: Maybe it should be named clojure.map then...
10:33fliebelI should revive clojure-quiz
10:34clgv&(keys #{1 2 3})
10:34lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry
10:34clgv&(rename-keys #{:a :b :c} {:a :z})
10:34lazybotjava.lang.RuntimeException: Unable to resolve symbol: rename-keys in this context
10:34clgv&(use 'clojure.set)
10:34lazybot⇒ nil
10:35clgv&(rename-keys #{:a :b :c} {:a :z})
10:35lazybotjava.lang.ClassCastException: clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative
10:35clgvfliebel: yes it should be renamed indeed ^^
10:35fliebelhm, what about rename-keys-in? [:foo bar] [:baz] :D
10:36apgwozhas anyone used the ring-netty-adapter ?
10:37clgvno I meant clojure.set -> clojure.map
10:43fliebelapgwoz: *netty*? Interesting. No, but I've used Aleph, which uses Netty.
10:43fliebel.. and provides a ring wrapper.
10:44apgwozfliebel: might be worth finally jumping into aleph if that's the case. cool, i'll have a look
10:45apgwozis there a specific ring-aleph-adapter? or were you just doing (respond! (ring-handler whateer)) like i saw in an old clojure list thread?
10:46apgwozfliebel: nevermind. gonna research aleph. the answers probably sitting there waiting for me to read it
10:46apgwoz:)
10:47fliebelapgwoz: I can't remember either.
10:48apgwozfliebel: looks like aleph.http has (wrap-ring-handler ...) that is the magic button
10:50clgv$inc aleph
10:50lazybot⇒ 2
10:57cemerickhuh, didn't realize you didn't need a handle for that
10:57cemerick$inc kittens
10:57lazybot⇒ 1
10:59jidotnetcemerick: just had a look at your conj slides
11:00jidotnetcemerick: any idea when the code will be available?
11:02cemerickjidotnet: should have been out already. I'm running behind on about 83 different things. :-|
11:02cemerickI'll definitely make some noise when it's up :-)
11:04jidotnetcemerick: cool thanks; i'll keep whatching ;)
11:16jweisscan someone recommend a way to have metadata added to an object (eg, with ^{:my :meta} that doesn't overwrite the meta that is already there?
11:17jweissor can i not use ^ at all, must i do (with-meta obj (merge (meta obj) newmeta))
11:25clgvjweiss: there is vary-meta - see ##(doc vary-meta)
11:25lazybot⇒ ------------------------- clojure.core/vary-meta ([obj f & args]) Returns an object of the same type and value as obj, with (apply f (meta obj) args) as its metadata. nil
11:26jweissclgv: thanks, was hoping to be able to use ^ but that does not appear possible. i'll just make a function with a short name to make it convenient for my users :)
12:02fliebelWhere and how do you usually store configuration?
12:03fliebelfor a web app
12:05duck1123I have a library that allows you to store config maps in the root of the project and then query them like (config :foo :bar :baz)
12:05duck1123It'll merge the default environment with the specified environment
12:06duck1123It works well enough for my needs
12:11fliebelduck1123: Nice idea.
12:13duck1123fliebel: If you're interested https://github.com/duck1123/ciste/blob/master/src/ciste/config.clj
12:16reiddraperI'm trying to understand the difference between clojure.lang.Seqable and clojure.lang.ISeq, could just be that my java-reading skills are rubbish
12:17cemerickSeqables can provide an ISeq
12:18reiddrapercemerick: If I'm making a new type with deftype, which should I be looking to implement, both then?
12:18cemerickThe tricky part is that `seq` provides polymorphism that isn't entirely captured by Seqable.
12:18joegallosounds like iterables which can return an iterator, from java collections
12:18cemerickThat's the right corollary.
12:19cemerickreiddraper: if your type *is* a seq, then implement ISeq (or some derivative). If it can provide a seq, Seqable.
12:19cemerick'course, the former extends the latter
12:20reiddrapercemerick: ok that makes sense. I'm making a Set, so it sounds like I want to provide a seq
12:20reiddraperon second that, i suppose a set *is* a seq
12:20reiddrapers/that/thought
12:21cemerickhow is a set a seq?
12:21hiredmanno
12:21reiddrapermaybe i have a poor seq definition
12:21Chousukemost things aren't seqs
12:21Chousukebut lots of things are seqable
12:22Chousukein core only lists are true seqs (and lazy seqs of course)
12:22cemerickThe only built-in that are their own seqs are lists
12:22cemerickhah
12:22cemerickoh, Cons too :-P
12:24reiddraperi remember coming across definitions for these before... so are all things that *are* seqs, sequential?
12:28cemerickfor want of a reasonable class hierarchy viewer online
12:28cemerickoh, hah
12:29cemerickreiddraper: http://www.clojureatlas.com/org.clojure:clojure:1.2.0?guest=t#clojure.lang.Sequential — click on the 'i' or roll over 'Sequential' while holding down Ctrl.
12:29reiddrapercemerick: cool, thanks
12:52shequoI'm interested in learning about how clojure implements efficient creation of modified datastructures via structural sharing etc...can anyone point me in a good direction to research this?
12:52fliebelWhat kind of magic could be going on here? I have a ring handler, if I call it on the repl, I get a result, if I launch jetty with it, a weird NullPointerException.
12:53fliebelshequo: You could try the research papers for them.
12:53dnolenshequo: Okasaki - Purely Functional Data Structures
13:00fliebelMagic: The handler has no default route, returns nil, end of story.
13:12antares_hey. I have a question: where do I need to sign up to publish jars to oss.sonatype.org? Looks like clojars.org is having some issues, my freshly published jars cannot be accessed even though project page loads fine and displays the version I pushed.
13:44gfredericksanybody know what's messed up if my `lein repl` goes nuts whenever I backspace?
13:45gfredericksby "goes nuts" I mean continues functioning properly, but deletes a bunch of characters so I can't tell what's going on
13:48duck1123gfredericks: does it do this even if you open a new terminal?
13:49gfrederickshmm, no
13:49gfredericksit's been happening for a day or two now, across different terminal instances. I'm not sure what the common thread is
13:50gfredericksoh let me try it with this particular project...
13:50duck1123are you printing out "odd" values?
13:50gfredericksnope
13:51gfredericksokay, it does do it for this project
13:52gfredericksmaybe it's this dependency on jruby
13:53gfredericksyep, remove jruby dep and it's better
13:53gfrederickswell if there's one thing you can count on ruby to do, it's magical crap in the background that you have no hope of ascertaining.
13:54duck1123don't forget screwing up your UTF-8
13:55gfredericksduck1123: thanks for rationally talking me through it. Being punished for backspacing can make you go batty.
13:56duck1123bah! real programmers don't need backspace. Everything is perfect the first time.
13:57gfredericksThat'd be a funny feature for an elite keyboard
13:57moogatronicor a mode for emacs.
13:57amalloygfredericks: but ^H would still work
13:58amalloygfredericks: if jruby was a problem, i bet it's because it pulls in a ruby version of readline, conflicting with the one your system wants to use
13:58gfredericksamalloy: holy crap this might drastically improve my life
13:59gfredericksby which I mean my finger pain
13:59gfredericksdoes ^H work everywhere?
13:59amalloyanywhere that expects emacs/readline-style stuff
13:59amalloyon a mac, i think that's pretty much anywhere
13:59duck1123most of the emacs commands work in terminals
13:59gfredericksI'm on ubuntu
14:00gfredericksit works on irssi and in the bash terminal at least
14:00duck1123I always feel so awesome when I make use of C-t correctly
14:00moogatronici'd be surprised if it didn't do the same everywhere in ubuntu
14:00amalloygfredericks: like i said, anyplace that uses readline
14:00gfredericksI bet it doesn't work in vim, but I'm sure that can be changed
14:00amalloymoogatronic: prepare to be surprised, bro
14:00duck1123it's an option
14:00gfredericksis there a key shortcut for enter as well
14:00amalloygfredericks: ^J
14:01gfredericksomg.
14:01amalloy*now* will you learn emacs?
14:01gfredericksno.
14:01amalloygfredericks: you can also configure readline to use vim bindings instead of emacs bindings
14:01amalloyin your .inputrc i think
14:02duck1123gfredericks: https://help.ubuntu.com/community/AdvancedCommandlineHowto
14:02gfredericksoh ^H and ^J both work in vim
14:02gfredericksduck1123: that looks like a good link
14:02amalloyit seems weird to me that you'd want to use them in vim, though. doesn't vim encourage you to go into edit-mode and then type d<something>?
14:03duck1123actually, not as good as I'd hoped for the key shortcuts
14:03amalloydh, i guess
14:03gfredericksamalloy: true, I probably don't really use backspace and enter in vim. I just expected I could get annoyed if I got used to ^H/J and then vim didn't support them
14:03gfredericksbut you're right, probably wouldn't have mattered
14:04gfredericksI'll think about emacs.
14:05gfredericksI don't remember what my objections were.
14:05moogatronicalso ^? .. (http://en.wikipedia.org/wiki/ASCII_code#ASCII_control_characters)
14:06gfredericksmoogatronic: oh. that helps explain it better.
14:09amalloyhaha that dang ^S. i've accidentally frozen a few consoles with that. i guess this was back when i had readline set up in vim mode, though, because ^S does something different normally
14:22R4p70rLet’s try this again. Is anyone in Canada looking for an entry-level Clojure dev? I’m in Montreal but willing to relocate.
14:34amalloyduck1123: thanks for that ascii link, btw. i knew most of that already, but noticing that escape characters get sent as ESC [ helped me figure out a problem i've been having, actually
14:41gfredericksLook maybe I'll think about emacs but not for another couple weeks. Gotta graduate first.
14:44moogatronicgfredericks: yeah, graduation > emacs. =)
14:44gfrederickshuh. I just realized that ^J and ^H mirror the functionality of vim's 'j' and 'h'
14:46gfredericksAt least in not-insert-mode
14:50kephaleare you sure emacs doesn't have a key bind for degree completion?
14:52gfrederickseven if it does I'm sure I'd forget it when I actually needed it
15:11amalloylike C-t
15:13fliebelamalloy: ?
15:13kephalenever used that one
15:14amalloyfliebel: an emacs command you forget whenever you acutally need it (see what i did there?
15:14kijhey guys. Is there an form that would let me do a (dissoc { :a 1 :b 2 :c 3 } (unlist '(:b :c)) ) ... unlist would just return :b :c
15:14amalloy&(doc apply)
15:14lazybot⇒ ------------------------- clojure.core/apply ([f args] [f x args] [f x y args] [f x y z args] [f a b c d & args]) Applies fn f to the argument list formed by prepending intervening arguments to args. nil
15:14amalloy&(apply dissoc {:a 1 :b 2 :c 3} [:b :c])
15:14lazybot⇒ {:a 1}
15:17gfredericksworks because ##(dissoc {:a 1 :b 2 :c 3} :b :c)
15:17lazybot⇒ {:a 1}
15:18fliebelamalloy: You wrote {:keys [tag attr content]}, do you mean that every node is actually a map?
15:18amalloyyes
15:18kijthanks!
15:19kij'(:a :b) -> :a :b, is not possible ? what should i read to understand why ?
15:20amalloykij: because one thing is not two things
15:20fliebelamalloy: oh, ok. I'm just using sequences.
15:20gfrederickskij: you're saying you want dissoc to return the keys that you removed?
15:21gfrederickskij: if so, then it doesn't do that because you want it to return the map instead. Clojure maps are immutable, so dissoc creates a new map that doesn't have the keys. If it returned the keys, you wouldn't have the new map, so nothing would have happened.
15:21amalloyfliebel: hiccup uses vectors: [tag attrs & content]
15:21kijgfredericks: no, i would like to remove the list and get the single values.
15:21amalloykij: it is not possible to return two values from a function
15:21fliebelamalloy: I do the same, without the attrs, which is really convenient, because of the first/rest concept in Clojure.
15:22amalloyjust like it is not possible to do that in c, or python, or...
15:22gfrederickskij: I'm not sure what that means
15:22amalloygfredericks: he wants (unlist [1 2]) to return both 1 and 2, but not as a list
15:22amalloyso that he can splice it into some function call
15:22gfredericksamalloy: ah, that makes some sense of it
15:23kijgfredericks: what amalloy says :)
15:23RaynesSo, he wants apply?
15:23gfrederickskij: then amalloy's original recommendation of using 'apply' is what you want
15:23fliebelkij: You can use destructuring: ##(let [[a b] '(1 2)] b)
15:23lazybot⇒ 2
15:23RaynesBut doesnt know it?
15:23Raynes(apply + [1 2 3])
15:23amalloyRaynes: arguably he should know it, because i said that already
15:23Raynes&(apply + [1 2 3])
15:23lazybot⇒ 6
15:24kiji understand now. Thanks!
15:25fliebelHow can I setup, run and test a Maven Clojure project, such as data.xml?
15:25gfredericksmvn clojure:[compile|test]?
15:26fliebelgfredericks: uhm, okay. Let me try...
15:26duck1123mvn test and mvn compile work as well
15:26amalloyfliebel: just $ mvn test
15:26duck1123or mvn clojure:swank or mvn clojure:repl
15:27amalloyduck1123: oh, good to know. i just added a project.clj locally to get swank
15:27duck1123amalloy: be careful. lein install will clobber your pom.xml (but that's what git is for)
15:36fliebelamalloy: Huh, weird output... It sets the namespace as an attribute? Did you setNamespaceAware, as the ticket suggested?
15:37amalloyfliebel: that's actually a perfectly valid way to set the xmlns of a node
15:37fliebelamalloy: Okay, so the test is incorrect?
15:37amalloyby declaring "everything from here (inclusive) on down, is implicitly in the api namespace"
15:37amalloyfliebel: i think the test is *probably* over-specific, but like i said i don't know a ton about namespaces
15:38amalloylast time i had to know anything at all about them was five years ago
15:39fliebelamalloy: You are using SAX for everything, right?
15:39amalloyfliebel: no idea
15:39amalloythat stuff is all chouser's - mostly i just wrote the converter from hiccup-style to enlive-style
15:40fliebelamalloy: Which is which?
15:40amalloyhiccup: [tag {attrs} & content]
15:40amalloyenlive: {:keys [tag attrs content]}
15:41fliebelArmageDOM: ^{attrs} [tag & content]
15:41amalloyMADNESS
15:41brehautwhat
15:41amalloyi know, right? someone tell fliebel that attrs are not metadata
15:42amalloyfliebel: in fairness though i can see how that would be handy, and i can't immediately think of any ways it would cause a problem or be hard
15:43fliebelmeta = about itself, data about the data: <link rel="base">http://example.com&lt;/link&gt;
15:43brehaut,(= ^{:href "http://example.com&quot;} ["a" "a link"] ^{:href "http://google.com&quot;} ["a" "a link"])
15:43clojurebottrue
15:43brehautthats why its bad
15:44amalloyhah
15:44amalloyyes, wow that's bad. thanks, brehaut
15:44brehautno problem
15:45amalloybrehaut: if you care to follow along, the discussion started at http://groups.google.com/group/clojure-dev/browse_thread/thread/dff8e406b7502a0b/0997aaf57a2d4c75?show_docid=0997aaf57a2d4c75 when fliebel kindly volunteered to help with data.xml
15:45fliebelhmm, good point.
15:45brehautamalloy: ah right. /me catches up
15:45amalloythe metadata discussion isn't really germane, i was just astonished by his choice
15:46dnolenfliebel: attributes are not definitely not metadata
15:46dnolenmetadata is not just data about data, it's data about data that should never be considered under equality
15:46amalloybtw fliebel: "at frist glance, mine doesn't have 20-line functions." i didn't get your point here
15:48fliebelamalloy: I mean to say the emit code is rather ugly, if you ask me: https://github.com/clojure/data.xml/blob/master/modules/xml/src/main/clojure/clojure/data/xml.clj#L285
15:49fliebeldnolen: That is indeed a detail of clojure meta data I had not considered.
15:49brehautwait. core.xml is seperate to clojure.xml ?
15:50fliebelbrehaut: According to the readme, it might become clojure.xml later.
15:51amalloyi'm in favor of pulling the configuration out into a separate function, fliebel, but i suspect there's a good reason the code exists (ie, you couldn't just throw half of it away)
15:51brehautfliebel: thanks; ive had to hack about with clojure.xml's emit for necessary-evil (thanks python xmlrpc imp); core.xml looks like it might fix the issue for me
15:51brehaut(https://github.com/brehaut/necessary-evil/blob/master/src/necessary_evil/xml_utils.clj#L30-53)
15:52fliebelamalloy: My initial iteration of ArmageDOM looked like that, but now it's broken into small bits.
15:53amalloybrehaut: so is python's impl incorrect and you need to cover for it, or clojure's is incorrect and you need to send python something more-correct
15:53brehautamalloy: its python's thats dodge; new lines throw it out, which i dont believe should be a problem
15:54brehautamalloy: and 1.2's emit-elements hardcoded emitting new lines (with println)
15:54amalloyi see. so you copied the code but changed println to print. very funny
15:55brehautindeed; i couldnt think of a better way to do it :P
15:55amalloywow clojure.xml is *really* old
15:55brehautoh! https://github.com/brehaut/necessary-evil/blob/master/src/necessary_evil/xml_utils.clj#L42 that line is important
15:56brehautim not sure if i was using the xml tools wrong, or if its an actual bug
15:56fliebelyea, structs and all
15:56amalloycheck out the last three lines:
15:56amalloy;(export '(tag attrs content parse element emit emit-element))
15:56amalloy;(load-file "/Users/rich/dev/clojure/src/xml.clj")
15:56amalloy;(def x (xml/parse "http://arstechnica.com/journals.rssx&quot;))
15:56brehautbut that version of emit wasnt escaping < > and &
16:22fliebelamalloy: I think setting http://xml.org/sax/features/namespace-prefixes to true, would fix the test, but I can;t figure out how to do it.
16:24fliebelcall setFeature on *something*
16:25amalloyfliebel: indeed, that is the crux of most of the data.xml problems. "how do we set a damn feature"
16:25fliebel"Turn features on or off using setFeature."
16:25amalloyright, but features aren't standardized
16:25amalloyacross the various impls
16:26fliebelamalloy: but, but... these are "SAX2 Standard Feature Flags"
16:26amalloythere are *some*. did you find one for indentation/pretty-print?
16:26fliebelamalloy: scroll down here: http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html
16:29amalloyfliebel: i see the one for namespaces, but not for whitespace
16:29fliebelamalloy: me neither....
16:32fliebelamalloy: http://apache.org/xml/features/dom/include-ignorable-whitespace ?
16:33amalloyfliebel: that's for parsing, not output. but not relevant anyway because it's apache-specific. we already set the apache indent-amount, but not every transformer is an apache transformer
16:33amalloywhich is why this whole thing is a mess
16:34fliebelamalloy: so the project is waiting for a minor whitespace issue?
16:34amalloyyes, absurd as i personally think that is
16:34amalloythat's why a number of forks have sprung up on clojars
16:36technomancywe should have clojars alert a library maintainer once a threshhold of forks have been created
16:36technomancy"hey dude, I don't know if you've been paying attention, but you might want to do something about this..."
16:38brehauttechnomancy: thats a great idea
16:42fliebelmeta data counter-argument: href/src is so far the only one that would matter for equality. counter-example: <content type="xhtml">foo</content> <content type="html">foo</content> <content type="text">foo</content>
16:43amalloyfliebel: that is so, so wrong. what about ant build files?
16:43fliebelamalloy: What does an ant buidl file look like... googles.
16:43amalloyshield your eyes
16:44amalloyi'm just saying, attributes are an integral, important part of an xml element
16:44amalloypretending they're metadata is bizarre
16:45amalloyin html, if you prefer: <input type="button" name="submit" /> vs <input type="text" name="name" value="your name here" />
16:47brehautfliebel: i think what you are confusing is that in most xml applications, the attributes are treated as a kind of meta data, but in a tool that is handling xml data, then that isnt meta data, its straight data
16:47fliebelamalloy: well, they are metadata, only not of the same kind as clojure meta data.
16:50fliebelbrehaut: that is true.
16:52tolstoyIs there a handy clojure lib to deal with uint type of issues?
16:52brehauttolstoy: most people just use one size larger primatives
16:53fliebelNow I have a problem, because I like neither the enlive or the hiccup syntax. The one is verbose, the other ambiguous.
16:53tolstoybrehaut: Okay. I've done all that before. I was hoping someone had a handy lib that could read byte-buffers and Do The Right Thing. ;)
16:53brehauttolstoy: i dunno sorry
16:54amalloyfliebel: hiccup isn't ambiguous at all, it's just a teeny bit non-trivial to parse
16:54tolstoybrehaut: No prob! Just curious.
16:55brehautfliebel: enlive is verbose because xml is verbose :P
16:56fliebelbrehaut: I thought the point of a DSL was to... nvm, I'll just use (format "<xml>" foo bar) ;)
16:57brehautfliebel: but you almost never need to reference the node enlive structure directly in either enlive or the older clojure.xml stuff
17:00fliebelamalloy: [:tag {:foo 1} "bar"], now did I make an attribute, or added a map as a child?
17:00amalloyyou can't add a map as a child, because children are always vectors
17:01amalloyyou can't have attrs free-floating in an xml document: they're attached to a tag
17:01amalloyyou're right that it's awkward to add an attribute to a node that might or might not have an attr-map already; you can avoid this by creating nodes that have empty attr-maps instead of no map at all
17:02amalloyi guess you're saying that hiccup isn't a format that's easy to modify programmatically once it's been written - i agree with that
17:04fliebelamalloy: What I'm saying is that tag and content map nicely to key/value or first/rest, attr is why we can't have nice things.
17:05Chousukethat's a fault in XML :p
17:05Chousukeat least regarding a Clojure DSL design
17:06fliebelChousuke: true
17:10amalloykephale: i rebound C-t to transpose-sexps, which is something i use a lot more often
17:10kephaleamalloy: ooo good tip
17:14fliebelamalloy: What is C-t? I don't have emacs.
17:15fliebelbtw, solution: (defn =m [& args] (and (apply = (map meta args)) (apply = args))) :P
17:15amalloyfliebel: transpose-characters
17:16fliebelamalloy: like.. rot-n?
17:16amalloyturns e|t into te|
17:16amalloy(where | is point)
17:17amalloytranspose-sexps turns (map (some-seq) | f) into (map f (some-seq)|)
17:17fliebelnice
17:17RaynesThat makes me happy.
17:20schaeferhi. anyone here familiar with the insides of core.logic? i'm interested in implementing the IUnify* protocols and would like a little direction
17:20clojurebothttp://clojure-log.n01se.net/date/2009-10-13.html#12:02
17:21Raynesambrosebs is totally not familiar with core.logic.
17:21amalloywell, clojurebot, i guess maybe he wanted to know about protocols in general. good try
17:21schaeferheh
17:22ambrosebswell i didn't write them :P
17:22schaeferah.. i missed your nick on the list :)
17:22ambrosebsbut I can open the source and make some sense of it
17:22ambrosebswhat are you try ing to do?
17:22schaeferso, i'm looking to incorporate a database as a source of facts
17:23schaeferi just started looking at the code about an hour ago and it looks like i need to implement the IUnify* protocols but i'm a lost on what each one of them does
17:25klutometisWhat do you call the property of `defn' such that I can do: (let [] (def x 2)) x => 2. Doesn't that break lexical scoping in the sense that `x' shouldn't be visible outside the `let'?
17:25klutometisDoing e.g. `(let () (define x 2)) x' in Scheme gives me ``Error: unbound variable: x'', which is lexically consistent.
17:25klutometiss/defn/def/
17:26schaeferi don't know if you're familiar with mandarax (a java backwards reasoning system). it defines an interface which supplies a set of constraints and return a resultset-like lthing. an RDBMS implementation simply converts the constraint parameters into SQL and returns a wrapped JDBC result set
17:26fliebelklutometis: clo*s*ures
17:27fliebeloh, no
17:27klutometisfliebel: That's my point, dude: x shouldn't be visible outside of that closure. Clojure is breaking lexical scoping.
17:28fliebelklutometis: yes, in Clojure def just defines a var outside of the let scope. Going to bed now...
17:28technomancyklutometis: vars are totally different things from locals; you seem to be confusing the two
17:28klutometisfliebel: Thanks.
17:28aperiodicklutometis: def doesn't create a closure, it defines a var in the namespace
17:30klutometisaperiodic: Oh, ok; I'm used to Scheme, where even `define' won't break lexical scoping.
17:31amalloy"break" is a strong word
17:31technomancydef doesn't create locals; it has nothing to do with lexical scope.
17:31klutometistechnomancy: This whole locals/vars dichotomy is another way of saying: "we don't respect lexical scope."
17:32amalloyscheme just guarantees that if the first "chunk" of expressions in a define are themselves defined, they get given lexical scope
17:32klutometisamalloy: Good point.
17:32technomancyklutometis: lexical scope is for locals
17:32technomancyit's totally unrelated
17:32gfredericksdangit ^J won't work in the browser.
17:32amalloydefine normally creates dynamically-scoped variables, even in scheme
17:32klutometistechnomancy: Right; circular argument, though.
17:32amalloythere's just this crazy exception for if it's at the beginning of another define
17:32amalloygfredericks: i think most browsers do have a shortcut for that though
17:32klutometisamalloy: Really? I'm trying to conjure up an example.
17:33amalloyin the url bar, anyway
17:33klutometisamalloy: Oh, in the sense that `let' reduces to `define'.
17:33amalloyklutometis: well, i'm not a scheme expert at all. but (define (foo x) (...blah...) (define (bar y) 10)) is undefined, i believe
17:34amalloyi read that in sicp, so it must be true
17:35technomancythat's like saying set! "breaks" variables because it changes their value. it's what it's there for.
17:35klutometisamalloy: Hmm; I mean, `bar' is visible within `foo' but not outside of `foo'. Is that what you mean?
17:35klutometisThe actual return value of `define' is the value `#<unspecified>'.
17:36amalloyno, i mean, it's not defined by the scheme standard. your scheme implementation can do whatever it wants
17:36klutometisOh, right; `unspecified'.
17:36klutometisThanks, guys.
17:40amalloytechnomancy: heh. set! *does* break variables, which is what it's there for
17:40technomancyamalloy: the horror
17:46aperiodicis there a handy way to handle posix signals in java/clojure?
17:47Raynesaperiodic: http://stackoverflow.com/questions/40376/handle-signals-in-the-java-virtual-machine
17:49klutometistechnomancy: Heh, missed that the first time around.
17:50aperiodicRaynes: so not within the context of my application?
17:52kd4joaAnyone here know the Midje testing package well and could help with a question?
17:54kd4joaI want to test a function that returns a list of hash maps but only care that the maps have a particular key. I don't care about the rest of the map.
17:54hiredmancontains?
17:54clojurebotcontains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use the java method .contains
17:54kd4joaIn other words the function returns [{:id 1 :score 1.5} {:id 2 :score 0.5}] and I only care that the maps have :id 1 and :id 2
17:55kd4joaI tried contains but it didn't seem to work right. I tried [{:id 1 :score 1.5} {:id 2 :score 0.5}] => (contains [ { :id 1} {:id 2} ])
17:55kd4joaand a couple other permutations of that
17:56hiredmanwell, uh, that is plainly wrong, so I suggest you read some docs
17:58kd4joathanks. that's very helpful.
18:00aperiodic,(contains? {:id 1} :id)
18:00clojurebottrue
18:00aperiodic,(contains? [{:id 1}] :id)
18:00clojurebotfalse
18:01carllercheI'm trying to write some documentation for a async / future library I'm working on. If anybody has some time, i would appreciate feedback: https://github.com/carllerche/momentum/blob/master/src/clj/momentum/core/async.clj
18:06moogatronickd4joa: are you just wanting know know whether every map in your list contains :id ?
18:08kd4joano, I want the maps to have the pair :id 1 and :id 2
18:08kd4joaI thought the Midje contains function was for that but can't get the syntax for it right I guess
18:09kd4joaI don't care about what the rest of the keys and values in the maps are
18:09alexbaranoskyk4djoa: I think you're right
18:09alexbaranoskywhat do you need to test exactly?
18:09alexbaranoskythat a certain map contains some key-val pairs?
18:10moogatroniclooks like he wants to test if a list of maps collectively contain given key-value pairs.
18:11kd4joayes. moogatronic has it right
18:11alexbaranoskydon't think midje has a built-in checker for that
18:11kd4joaok. thanks. I thought the contains checker might work for it, but I haven't been able to get it to work so it must not
18:11alexbaranoskykd4joa: let me investigate further
18:12alexbaranoskyyou can just write function for it
18:12kd4joayeah that's what I'll have to do then. I just thought I was being dense about the contains checker
18:12alexbaranoskythen say: (fact (my-function-call) => (partial maps-contain { ......}))
18:13kd4joathanks for the help! much better than "go read some docs" answer I got a little bit ago
18:13alexbaranoskykd4joa: though don't quote me on the syntax, I haven't needed to test that kind of thing
18:13alexbaranoskyI've used aMidje a lot
18:14alexbaranoskykd4joa: le t me know how it goes, and if you have any more questions
18:14moogatronicAt first i thought you were asking this:
18:14moogatronic(reduce #(and %1 (contains? %2 :id)) true [{:id 1 :score 1.5} {:id 2 :score 0.5}])
18:15moogatronicbut i think just need a function to or some internal may k/v checks
18:17Rayneskd4joa: Don't mind him. He means well.
18:18RaynesYou can't have an apple tree without a few rotten apples at some point.
18:18moogatronichard cider!
18:18technomancymoogatronic: not for Raynes; he's underaged.
18:18technomancy(at least in the US)
18:19Raynes;)
18:19moogatronicI think "hard cider" is a US'ism anyway -- cider means fermented apple juice everywhere else I think.
18:19alexbaranoskytechnomancy: but there's a blue hair law - if your hair's blue you can drink at 16
18:19moogatronicalexbaronsky: ONLY when operating a vehicle though, i'm pretty sure.
18:20RaynesI only drink when I need to drive long distances. It helps me stay focused.
18:20kd4joaThanks all. I've found the clojure community very welcoming to newcomers. I know there are exceptions in every group
18:21alexbaranoskyRaynes: but yeah totally legal in 49 states -- if your hair is blue
18:21RaynesI'm golden then.
18:21alexbaranoskyok, I'll stop polluting the airwaves with bad humor ;)
18:23moogatronicthe uc davis cop may provide you with some sriracha to the face if you don't stop. =)
18:33gfredericksjava interop in jruby never ceases to aggravate.
18:33gfredericks$inc clojure
18:33lazybot⇒ 4
19:10yaron2343Anyone been playing with defrecord? I'm tearing my hear out on an issue and was hoping for some help.
19:11brehautyaron2343: just ask your question, if someone can help they will
19:12yaron2343I am using a trivial defrecord (defrecord connection-record [next-state conf-func]) in my clj file. I then C-c C-l the whole clj file into my repl (e.g. via swank). Any attempt to reference the record fails. I try import (e.g. (import lib-phl.core connection-record)) and that fails to.
19:12yaron2343I just get class errors.
19:15tolstoyIs your repl in the same namespace as the file? (I got nothin.)
19:16yaron2343No, it's not. That's why when I try to reference the record I use a fully qualified name (e.g. lib-phl.core/connection-record
19:16yaron2343I also tried lib-phl.core.connection-record out of desperation
19:16brehautyaron2343: but if you are sending the record to a different name space then its going to be created there
19:18yaron2343I tried connection-record by itself and it doesn't work. Where as other functions I defined in the clj file show up just fine so long as I prefix them with lib-phl.core. For example lib-phl.core/is-connection-record? Shows up just fine.
19:18yaron2343It's only the class defined with defrecord that doesn't show up.
19:18brehautoh, dashes in record names is a bad idea
19:18brehauttry ConnectionRecord
19:18brehautto avoid having name munging
19:19brehauti would guess that connection-record is being name munged to connection_record for the classname
19:19yaron2343I actually figured that as well and tried _ but it didn't make any difference.
19:20yaron2343I also tried that with my namespace that also has a dash in it (e.g. typing in lib_phl.core instead of lib-phl.core)
19:20yaron2343What's weird is that functions defined in my clj file that use the record work just fine!
19:21brehautyaron2343: records are much more complex than functions
19:21yaron2343Indeed, I'm seriously considering just moving all my code back to structs. At least those worked easily. :(
19:21brehauttry running your defrecord directly in your repl, rather than sending it to the repl from the editor
19:21brehautjeez, not structs. just use maps
19:22yaron2343Oh if I define the record in the REPL directly then everything works just fine.
19:22brehautok so its not a defrecord problem, its someting to do with your slime usage
19:22yaron2343It's only if I try to load the file C-c C-L or the buffer segment C-c C-R that I'm in trouble.
19:23yaron2343Yeah it smells strongly like a class path resolution issue
19:23yaron2343It's not finding the class.
19:23yaron2343For example, when I try to C-c C-l my test file I get the error lib-phl.core.connection-record ClassNotFoundException
19:24yaron2343And yes, I tried changing it to (:import [lib-phl.core ConnectionRecord]) and sure enough I get lib-phl.core.ConnectionRecord ClassNotFoundException
19:24alexbaranoskyyaron2343: you could always just use maps
19:24yaron2343Yup, that's sounding like the right answer. (Just using maps)
19:24alexbaranoskyyaron2343: does the namespace also have a dash? That becomes part of the class name I think
19:25yaron2343Yes, the namespace does have a dash.
19:25alexbaranoskythat is getting underscorified too
19:25yaron2343(ns lib-phl.test.core
19:25yaron2343 (:use [lib-phl.core])
19:25yaron2343 (:import [lib-phl.core ConnectionRecord])
19:25yaron2343 (:use [clojure.test]))
19:25alexbaranoskybut really maps are the 90+% tool
19:26alexbaranoskyyaron2343: I ran into similar problems as you, and was told to just NOT put -'s in namespaces that contain records... It may be your problem. I just decided to screw it and use maps instead for my use case
19:27yaron2343Yeah, I think you're right. Records hurt too much and don't give me enough value. I mostly wanted them because they were easier than duck typing and could catch some errors.
19:28yaron2343Although before I finally throw in the towel I will recreate my project without any -s. Won't take long and I hate to give up because I'm confused as opposed to understanding the feature and deciding it doesn't work.
19:29alexbaranoskyyaron2343: let me know how it goes, I would like to know if that fixes the issue or not
19:29yaron2343Will do, am trying to throw it together now.
19:34amalloy(inc maps)
19:34lazybot⇒ 1
19:34mindbender1I hope it's not a stupid question.. but what are the uses of closures in any language?
19:36alexbaranoskymindbender1: they have LOTS of uses
19:37amalloyconsider a simple example: (let [x 10] (filter #(< % x) some-sequence))
19:38yaron2343O.k. so the good news is that removing the - did resolve the problems I was having in the main file. But not in my test file I'm getting a new error "libphl/core__init.class or libphl/core.clj on class path FileNotFoundException.
19:38yaron2343I'm guessing this is because of my import
19:38mindbender1alexbaranosky: please some education
19:38yaron2343I have no clue if lein sets up the class path correctly so that the test files see the src files
19:39alexbaranoskymindbender1: use closures anytime you want to tell another function HOW - anytime you might use a Strategy pattern for example
19:39alexbaranoskyso higher order functions need to be configured with another function -- so you might want to use a closure
19:40alexbaranosky(defn do-something-to-each-twice [f coll] (map f (map f coll)))
19:41alexbaranosky;; better: (defn do-something-to-each-twice [f coll] (map (comp f f) coll))
19:41alexbaranoskythen call it with a given function aor closure
19:42alexbaranosky(do-something-to-each-twice inc [1 2 3]) ;=> (3 4 5)
19:42mindbender1how does f tell do-something-to-each-twice HOW
19:42alexbaranoskymindbender1: you could replace 'inc' here with any closure
19:43alexbaranoskycan you ask a more elaborate question? I don't know what you need to know
19:44mindbender1alexbaranosky: from my understanding closures hold a kind of state right?
19:45alexbaranoskyahhhh, sometimes
19:45aperiodicthey're often used that way in javascript
19:46alexbaranoskyit just means I can create a closure, that references a local var in one context, then pass that closure to another context
19:49amalloyone usage of closures is to let you, basically use a variable that "belongs" to one function inside a completely unrelated function
19:49amalloyeg in my example, (let [x 10] (filter (fn [item] (< item 10)) (range 30)))
19:49amalloyhow can filter, which knows nothing about x, manage to use that variable? it's because we've packaged x up inside of the function we give it
19:50gfredericksamalloy: you left x out there?
19:50amalloyhah, yes
19:51amalloythough it still applies equally well. how does filter, in clojure.core, know about the value 10? i didn't pass it 10
19:51amalloyi passed it this function, which knows about 10
19:53yaron2343O.k. defrecord really is painful. So with a map both (:a b) and (b :a) work just fine. But with defrecord only (:a b) works.
19:56TimMcyaron2343: and (.a b)
19:57gfrederickshmmm...what's the reasoning for that?
19:57yaron2343Yeah, that makes sense. Although it also argues against using defrecord. I want Clojure to get away from Oop.
19:57yaron2343Because the keyword is effectively an accessor and a record is a class.
19:58yaron2343So you are asking for property "a" on the record
19:59gfredericksbut records deliberately have the map interface, so it's strange they wouldn't implement the IFn side of maps as well
19:59brehautyaron2343: why have you decided to use a record over a map?
19:59gfredericksI guess records might want to provide their own IFn :/
19:59yaron2343The reason for going to a record was that I wanted to do type checking and equality checking and records make that much easier.
20:00amalloygfredericks: more importantly calling records wouldn't be nearly as fast as caling keywords
20:00yaron2343I'm also hoping that eventually clojure will make type hints enforceable
20:00yaron2343Yes, I'm a typist. :) But Scala hurt too much so I'm sticking with Clojure
20:00gfredericksamalloy: I would think uniformity of interface would trump that consideration
20:01yaron2343(F# was actually fun, much easier for me than Scala but I there isn't good IDE support on my mac)
20:01amalloygfredericks: if uniformity of interface were all that mattered, we wouldn't have records or structs at all
20:01brehautits fairly idiomatic in clojure maps that are used objectfully to have (:keyword map) access and maps that are used mapfully to have (map index) lookup, and records are specifically an optimized objectful map, so it makes sense that only the former is supported
20:02yaron2343brehaut - How do you tell the difference between an objecfull map and a manful map?
20:02yaron2343er manful I meant :)
20:02yaron2343mapful
20:02yaron2343(Damn you autocorrect!)
20:03brehautwell to start an objectful map will have all keyword keys
20:03brehautquite possibly will have heterogenous values
20:03brehautand as a whole represents one 'object' in the system
20:03brehautwhere as a mapful map may have any kind of key, often has homogenous values and represents an aggregation in the system
20:05gfredericksamalloy: that second one is harder to imagine
20:05gfrederickswhy homogenous values?
20:05gfredericksamalloy: brehaut: sorry, meant to brehaut
20:06yaron2343Then I'm fully guilty of being objectful
20:06brehautyaron2343: objectful maps are idiomatic clojure
20:06brehautgfredericks: because thats often how they are used? perhaps homogenous value _types_ would be clearer?
20:06yaron2343Now if I can just figure out why C-c C-l on my core.clj file in my test directory is producing a "Could not locate libphl/core__init.class or libphl/core.clj on class path: [Thrown class java.io.FileNotFoundException]
20:07yaron2343Note btw that "lein test" from the command line works just fine.
20:07gfredericksbrehaut: do you have an example?
20:07brehautgfredericks: im sure i must
20:07yaron2343brehaut - Then I suppose using records makes sense for me.
20:07yaron2343So whatever my issue is, it's some swank related thing
20:07brehautyaron2343: but its idiomatic to use maps _until_ records are shown to be needed (for protocols, or performance)
20:08brehaut,(frequencies "aababc")
20:08clojurebot{\a 3, \b 2, \c 1}
20:08brehautgfredericks: ^ a really trivial example
20:09yaron2343brehaut - What's the flag that should trip one to think about records? My use of maps is to pass around a state object. The only reason I used records at all is that it made it easy to see if someone submitted the right 'type' of map and to do automatically equality testing when I needed to compare states.
20:09gfrederickshmm
20:09brehautyaron2343: well, typically clojure programmers dont 'check type'
20:09gfredericksyaron2343: why don't maps give you equality testing?
20:10brehautyaron2343: if you profile your code and find map access is slow, then a record may be an option. alternatively if you need to implement a protocol, a map is probably a good choice
20:10brehautyaron2343: records are surprisingly rare in clojure code
20:10yaron2343brehaut - Indeed, I did actually know that. But I'm writing a distributed system where debugging is a nightmare so I need the system to be as helpful as possible in telling me where things went wrong. Checking types helps out a lot with that.
20:10amalloyyaron2343: just put another key in your map
20:10brehautyaron2343: pre and post conditions may also help you
20:10amalloy{:what-kind-of-thing :my-awesome-state-type ...more keys...}
20:11amalloyusing records has way more pitfalls than maps, and taking all of that on just so you can call .getClass for debugging is asking for pain
20:11yaron2343gfredericks - Because I'm an idiot. I just realized that works. :( Thanks for pointing this out. At least now I know.
20:12gfredericksyaron2343: now all you need to do is loosen up about checking types and you're golden :)
20:12yaron2343brehaut - Actually pre and post conditions is where I do the type checking. I use instance?
20:12gfredericksyaron2343: why not write a function that checks if the maps has the expected keys and such?
20:13yaron2343gfredericks - That's what I originally did but records gave me that for free
20:13gfredericksthat tells you more than calling instance? on a record, since a record could be initialized with nulls and all that
20:13gfrederickstells you more if you examine the values as well I mean
20:13yaron2343gfredericks - Which is why the calls after instance walked through the various keys and checked if they were right. And yes, the more I type the more I realize that records were the wrong choice. Just too much overhead for very little benefit.
20:14yaron2343Thankfully Clojure produces such awesomely tight code that changing everything from records to maps will be easy.
20:19yaron2343BTW is something like this idiomatic? (defn
20:19yaron2343 create-state [state-function connections]
20:19yaron2343 (hash-map :state-function state-function :connections connection))
20:19yaron2343The goal is to make it easy to remember what a state is supposed to have
20:19gfredericksa shallow answer is you could use a map literal instead of the hash-map function
20:20yaron2343Yeah, I know. But I find the short syntax makes it harder for me to read the code. That's just a personal thing for me.
20:20yaron2343Does it really make any functional difference?
20:20gfredericksnot that I know of
20:20gfredericksI'm like that too with new
20:21gfredericksso you're asking about having a map-assembler function instead of creating the maps inline everywhere
20:21yaron2343Yup. Just to prevent typos and such.
20:22gfredericksI personally like it, but I tend to be on the type-checking-lover side of things, so I expect people around here to disagree with me
20:23yaron2343gfredericks - I love type checking. The only reason I'm not using Scala is that it's type inference logic was painfully bad and the community is about as friendly as a bear trap. But that could just be me. :)
20:23gfredericksyaron2343: I suspect that testing instead of doing static types is probably more fruitful
20:24yaron2343BTW, what is the difference between FN and IFN?
20:24amalloyinstead, abstract it a level: (defn make-state-object [a b] (...)) (defn is-state-object? [x] (...))
20:24yaron2343I did try looking this up but I couldn't find a good answer
20:24gfredericksthen you're reasonably sure you have your types right, but also reasonably sure the program works right, which static compilers can't tell you
20:24yaron2343am alloy - That's exactly what I'm doing. I have a create-state and is-state?
20:24gfredericksyaron2343: FN is a class, IFN is an interface
20:25yaron2343gfredericks - Bingo! Thank you!
20:25yaron2343So if I want to check if a value is a callable function will IFN? give me wider coverage?
20:25gfredericksmost of the interface names start with I, though for some reason not all of them
20:26yaron2343I notice that just about everything in clojure seems to have interfaces on it
20:26yaron2343I just want to check if a value is a callable function
20:26gfredericks&(instance? clojure.lang.IFn [])
20:26lazybot⇒ true
20:26gfredericksdepends on if you want vectors, maps, and sets to return true :)
20:26amalloythen you can use maps, and later use records if you truly find yourself needing them
20:26yaron2343gfredericks - That's actually o.k., if it walks like a duck…. :)
20:27gfredericksthen yep
20:27amalloy(hint, though: you won't find yourself needing records)
20:28yaron2343:) Makes sense. Gotta run! Thanks everyone for your help! You helped move my clojure project forward. I appreciate it!
20:29brehaut,@#'clojure.core/global-hierarchy
20:29clojurebot{:parents {}, :descendants {}, :ancestors {}}
20:29brehaut,(derive ::a ::b)
20:29clojurebotnil
20:29brehaut,(derive ::c ::a)
20:29clojurebotnil
20:29brehaut,@#'clojure.core/global-hierarchy
20:29clojurebot{:parents {:sandbox/c #{:sandbox/a}, :sandbox/a #{:sandbox/b}}, :ancestors {:sandbox/c #{:sandbox/a :sandbox/b}, :sandbox/a #{:sandbox/b}}, :descendants {:sandbox/a #{:sandbox/c}, :sandbox/b #{:sandbox/a :sandbox/c}}}
20:29brehautgfredericks: ^ global-hierarchy is an objectful map, but its 3 fields are mapful
20:29brehautgfredericks: also, the homogenous type might be an implicit union type
20:29brehautgfredericks: for instance the maps in the fields of the hierarchy have a sets of an implicit union of class and clojure.lang.Named
20:29aperiodicbrehaut: what is the @#' prefix doing there?
20:29brehautits private, so #' is avar quote to access it, and then @ to deref the var to get the actual value
20:29brehaut,clojure.core/global-hierarchy
20:29clojurebot#<CompilerException java.lang.IllegalStateException: var: clojure.core/global-hierarchy is not public, compiling:(NO_SOURCE_PATH:0)>
20:29brehaut,#'clojure.core/global-hierarchy
20:29clojurebot#'clojure.core/global-hierarchy
20:29brehaut,(class #'clojure.core/global-hierarchy)
20:29clojurebotclojure.lang.Var
20:29brehautaperiodic: make sense?
20:29aperiodichuh, i didn't know you could do that
20:29aperiodicbrehaut: yeah, thanks!
20:29brehautaperiodic: extremely useful for testing things
20:29aperiodici'm still not entirely clear on how vars, environments, and namespaces interact during evaluation
20:29brehautaperiodic: with a sprinkling of magic ;)
20:29moogatronichow much documentation does anyone reading this and wanting to reply usually put in their docstrings?
20:29brehautmoogatronic: err… not sure i understand what you are asking
20:29brehautyaron2343: just dont ;)
20:29brehautbut yes
20:29moogatronic(defn function "docstring" [] body) how much do you write in the doc string?
20:29brehautmoogatronic: as much as is required to describe the intent and contract of the function
20:29moogatronicas much as say, a javadoc?
20:29brehautmoogatronic: if you use marginalia you may also write more to add to the overall narrative
20:29moogatronicbrehaut: marginalia is on my list of things to invetigate.
20:29brehautid say its similar to whats normal for python functions, thoguh not classes
20:29brehautmoogatronic: its extremely straight forward.
20:29moogatronicI just like the formalism of javadoc... Defined spot for @param @return etc..
20:29brehautmoogatronic: none of that nonsense, we have metadata for that
20:29brehautmoogatronic: docstrings are for prose (and perhaps example usage)
20:30amalloyyaron2343: "free" is a huge overstatement
20:30gfredericksI think my IRC client just went bonkers
20:30brehautgfredericks: i think you mean ifn?
20:31brehaut,(ifn? [])
20:31clojurebottrue
20:31moogatronicbrehaut: do you have a small example demonstrating metadata as a replacement for some of the 'javadoc' ish crap?
20:31amalloygfredericks: no, network issue of some kind
20:31moogatronicgfredericks: mine too.
20:31gfredericksnow I'm doubting everything that happened in the last 10 minutes
20:31brehautmoogatronic: i have a large example? https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj
20:32moogatronichaha large or small, i was trying to minimize imposed burdon.
20:32brehautmoogatronic: be aware that :tag is the not just documentation, its used by the compiler so dont go adding it wildly
20:33brehautmoogatronic: overall, there is much less of that stuff than javadoc though
20:34gfredericksbrehaut: half of the stuff you said about mapful maps came in in a lump just then
20:35brehautgfredericks: huh. sorry about that
20:35brehautgfredericks: i assume my internet is lagging to crap again
20:35amalloybrehaut: gfredericks is accusing you of causing the network issue that all of freenode just felt
20:35gfredericksbrehaut: I doubt it's your fault :) I was just explaining any apparent lack of ACK
20:35amalloyno apologizing
20:35brehautoh! haha
20:36gfredericksme and amalloy: ignorant cop, explanatory cop
20:36amalloyalthough... relevant: http://xkcd.com/945/
20:39gfredericksoh there goes google wave
20:41brehautgfredericks: it was still around?
20:42gfredericksapparently
20:49amalloyhaha google knol too
20:51brehautare they sending the old dogs to the farm?
20:52gfredericksdog foo is expensive
20:53gfredericksas is dog bar
20:56moogatronic.. i finally discovered what laziness is for. I feel like the world played the "you just discovered a secret room" song from "the legend of zelda"... code I wrote earlier today is now comical.
20:57amalloymoogatronic: well then, what is laziness for? you don't really know until you can explain it :)
20:58moogatronicamalloy: true enough. In my case it was that I just realized how I could utilize the lazy-sequence to accomplish some list generation tasks that I was using loop/recur for...
20:59moogatronicbut everyone knows the answer to everything is 42.
20:59brehautnah, the answer to everything is "No"
20:59gfredericksbrehaut: is it really?
20:59brehautNo
21:00gfrederickswell that explains it then, thanks!
21:00brehautgfredericks: if that seems inconsistent to you, you dont know prolog ;)
21:00gfredericksDo I know prolog??
21:00lazybotgfredericks: Definitely not.
21:00brehautNo
21:01gfredericks~prolog
21:01clojurebotPardon?
21:02moogatronicAre we doing the "This statement is false." thing? =)
21:02brehautNo
21:02moogatronic42
21:02amalloymoogatronic: gfredericks seems to be. near as i can tell, brehaut is enjoying saying "your statement is false, or your question has no correct answers"
21:03brehautamalloy: theres also the 'none of the facts i know imply this'
21:03amalloyNo further universes exist which satisfy all of your constraints
21:03brehautexactly
21:03brehautits the extent of my prolog based humour
21:04brehauti guess i should at least port the joke to core.logic
21:04amalloyyou've got em rolling in the aisles
21:06brehautsorry #clojure
21:07aperiodicgot any erlang jokes?
21:08brehauti do not
21:08gfredericksthere cannot be any erlang jokes because it has no flaws
21:08aperiodicthat's a pretty big flaw right there
21:09gfredericksis nil the only argument for which type returns nil?
21:09amalloyuhhhh, i think that's true, yes
21:09TimMc,(doc type)
21:09clojurebot"([x]); Returns the :type metadata of x, or its Class if none"
21:10TimMc,(type ^{:type nil} [1 2 3])
21:10clojurebotclojure.lang.PersistentVector
21:10gfredericksI've a multimethod that dispatches on type and was just curious if (defmethod nil) knew for sure the argument was nil
21:10TimMcಠ_ಠ
21:10gfredericks,(binding [type (constantly nil)] (type []))
21:10clojurebot#<IllegalStateException java.lang.IllegalStateException: Can't dynamically bind non-dynamic var: clojure.core/type>
21:10amalloyTimMc: i know, i thought of that too. but i remember reading that it does (or (:type (meta x)) (class x))
21:11amalloyas opposed to (:type (meta x) (class x))
21:11TimMc"or its Class if none", right
21:11gfredericks,(with-redefs [type (constantly nil)] (type []))
21:11clojurebotnil
21:11TimMchrmf
21:12amalloyfwiw, putting reader metadata on stuff when you want it to have metadata at runtime makes me super-nervous, TimMc
21:12amalloy(with-meta [1 2 3] {:type nil}) seems a lot safer to me
21:13gfredericksthat's an interesting distinction
21:13gfredericksuntrustworthy macros?
21:13TimMcI will admit to knowing basically nothing about metadata. :-)
21:14TimMc,(:type ^{:type 'foo} [])
21:14clojurebotnil
21:14TimMc,(:type (with-meta [] {:type 'foo}))
21:14clojurebotnil
21:14TimMcugh
21:15amalloygfredericks: not untrustworthy, it's just...reader metadata is for the compiler. in most cases it will leak over into your program and you can use it as runtime metadata
21:15amalloybut depending on that doesn't seem good
21:16TimMc&(meta ^{:type 'foo} [])
21:16lazybot⇒ nil
21:17TimMcright
21:18aperiodicthere are two kinds of metadata?
21:19amalloyno
21:19amalloythere are two times at which you could attach metadata
21:19amalloy(more than two, really)
21:19aperiodicread-time and eval-time?
21:20amalloyyeah, that's the distinction i was drawing
21:20amalloybut there's also macroexpansion time
21:21aperiodicyou say that in most cases metadata attached during read-time exists in runtime, but could you provide an example where that doesn't happen?
21:22amalloy&(meta ^{:type 'foo} [])
21:22lazybot⇒ nil
21:22TimMc^
21:22aperiodichuh
21:23TimMcBut a macro would see it, yeah?
21:23amalloyyes
21:23amalloy&(meta ^{:type foo} [1])
21:23lazybot⇒ nil
21:23amalloyat the moment i can't even find an example where it *does* leak over to runtime
21:24amalloy&(meta ' ^{:type foo} 1)
21:24lazybotjava.lang.IllegalArgumentException: Metadata can only be applied to IMetas
21:24amalloy&(meta ' ^{:type foo} (1))
21:24lazybot⇒ {:type foo, :line 1}
21:25aperiodicwhy does the metadata disappear?
21:25amalloyit doesn't. it was never there
21:25amalloyyou pass the compiler an object, x, with metadata on it. it emits the bytecode necessary to reproduce x
21:26aperiodicup to equality?
21:26amalloyat runtime, that bytecode is executed to create a brand-new x
21:26amalloybut the metadata was for the compiler, not for you
21:26aperiodicah, got it
21:27amalloywell, that makes one of us
21:27amalloyit's a confusing issue either way
21:30aperiodicso if i want to attach metadata visible at runtime, i should use with-meta, rather than the reader macro, because metadata attached at read-time (usually) gets eaten by the compiler?
21:35brehauti pressed some magical emacs chord by accident: all my html got stripped out and left only the text
21:36moogatronicbrehaut: -x u!
21:36aperiodicthe compilation process for clojure is way harder for me to wrap my head around than any other language i've used
21:37hiredmanaperiodic: do go on
21:37brehautaperiodic: and yet its probably much simplier than most of them
21:39aperiodichiredman: well, it seems to start with the reader, which is what takes string data and turns it into clojure forms
21:39brehautaperiodic: so far so good
21:40aperiodicbut i've seen some references to reader macros that cause evaluation (i think #=?)
21:40hiredmanoh, well, if that is complicated then you've never used a lisp
21:40aperiodichow can you be doing evaluation at read-time? what's the environment?
21:40aperiodici haven't
21:41brehautaperiodic: question: what do you think the compilation unit of clojure is?
21:41aperiodicthat's undoubtedly part of my woes
21:41hiredmanwhich means you don't have a basis for comparison
21:41hiredmanI suggest you go write a lisp, even a simple one
21:43aperiodicbrehaut: unit ~ atomic to compilation?
21:43brehautaperiodic: so in java the compilation unit is the class (i believe), it might be the package
21:43brehautin C its the source file
21:43aperiodicbrehaut: the first thing that popped into my head was namespace
21:44brehautaperiodic: its a single form
21:44amalloyman, i don't even know what clojure's compilation unit is
21:44amalloyi'd guess top-level form
21:44brehautamalloy: toplevel or eval expression i think
21:44brehautwhich is why we have declare for forward declarations
21:44amalloysuuuure, but those are just top-level in a different context
21:46brehauti guess you could think of it that way, but its slightly circular
21:46brehautaperiodic: the key difference between macros and normal functions is when they run
21:47aperiodicbrehaut: macros run between read and evaluation, right?
21:47aperiodicwhich is why the arguments are unevaluated forms
21:48brehautaperiodic: macroexpansion is part of the evaluation or compilation process
21:48brehautits not really 'between'
21:48gfrederickswhere's there a function for transforming keys of a map?
21:48hiredmanwell, it runs ahead of the first pass of the compiler
21:49brehauthiredman: its more clearly seperated with a compiler than a traditional lisp evaluator though right?
21:50hiredmanyes
21:51aperiodicbrehaut: well, if it runs after its arguments have been read but before they've been evaluated, i'd call that between the two
21:52brehautgfredericks: theres rename-keys ? but thats not an general transform, just a mapping
21:53gfredericksah
21:53aperiodicbrehaut: but i see your objection (there's evaluation happening in the macro, so they're not distinct phases)
21:53gfrederickswell zipmap is pretty easy
21:55alexbaranoskygfredericks, there's a function `map-keys` in useful
21:56gfredericksI need to start using useful
21:56gfredericksbut only with :only
21:59amalloyi kinda frown on the map-keys/values functions in useful, personally
21:59alexbaranoskyamalloy, do you think that they're a code smell?
22:00alexbaranoskyamalloy, I havent needed them ..... yet
22:00amalloyi don't have a very good reason. i just wish people would stop going map->seq->map, which gets you the worst of both worlds performance-wise
22:52fbru02ehi guys i have a macro question anybody up to help?
22:53amalloy~anyone
22:53clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
22:54fbru02:)
22:56fbru02so i want to check on one of the arguments and recursive call the macro if one of the arguments is not of the specified type (defmacro my-macro [arg1 arg2 & rest] (if-not (map? arg2) `(mymacro arg1 {} ~@rest)))
22:56fbru02so the thing is that i do a macroexpand with this and i never seem to get {} in arg2
22:57fbru02i'm confused
22:58amalloywell, there are a couple issues. one is you don't have an else clause for your if; it's unclear whether that's a bad copy/paste or what
22:59amalloythe other is, are you looking at a macroexpand-1 or what? because if you (macroexpand-1 '(my-macro foo bar baz)) from this definition, it should result in '(my-macro foo {} baz)
23:01fbru02amalloy: let me try again and if not paste real code
23:01fbru02thanks :)
23:10callenokay, you have my attention
23:10callenwhy does the current version of lein not have a "jack-in" verb?
23:10callenbecause that's what my clojure-mode.el is looking for.
23:11callenI need to install swank, don't I?
23:11callensigh.
23:11callenI forget these things every time.
23:16Raynescallen: You don't need to install swank.
23:16RaynesAnd jack-in is definitely in the latest lein.
23:33callenRaynes: not by default, had to install swank-clojure plugin.
23:33callenRaynes: I just fetched the lein earlier from the repo.
23:33RaynesOh, I thought you meant in Emacs.
23:40callenin Emacs?
23:40callenclojure-mode just invokes lein.
23:40callenthere's little that Emacs has to do with it.
23:55georgekhi, I have 'clojure-mode-font-lock-setup added to 'slime-repl-mode-hook in my .emacs, but when I connect to a remote swank with slime-connect, I get error in process filter: run-hooks: Symbol's function definition is void: clojure-mode-font-lock-setup
23:55georgekif I just reconnect, I get the remote repl, but no highlighting
23:55georgekanyone come across this already?
23:59spoon16technomancy around?