#clojure logs

2011-02-24

00:00hugod_sritchie: we're also in #pallet
00:01joshua__If I wanted to contribute to Incanter for Google Summer of Code what do you guys think I should do?
00:05amalloyjoshua__: seems pretty obvious: you should contribute to Incanter for Google Summer of Code
00:06jacortinasamalloy: that does not seem to be a useful response :-\ although I do understand what you mean
00:06joshua__amalloy, :P I love doing that to people
00:07amalloyjacortinas: see, it's about knowing your audience
00:07joshua__amalloy, "Would you like milk or coffee?" "Yes."
00:07jacortinashaha
00:10Sgeo_Why do I keep having the impression that Clojure is too... enterprisey for hobbyist development?
00:20amalloyin lieu of competing theories, i'm going to propose that it's because you're nuts
00:30amalloyi think i just misused "lieu" there. i probably mean "in the absence of"
00:43Scriptorcan someone link me to the source for the persistent hashmap nodes?
00:43ScriptorSgeo_: I'm not sure, it's pretty unenterprisey
00:44Scriptorit's a different way of thinking, but still pretty simple
00:47Sgeo_I guess I'm thinking in terms of dealing with Ant and Java in general etc.
00:47amalloyScriptor: http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/ good enough?
00:48Scriptoramalloy: I was looking at that, there's something that confused me a little
00:48Scriptorbasically, the whole point of the index() function
00:48Scriptorafaict, you can get that just by looking at the 5-bit block of the hash
00:49ScriptorSgeo_: you only deal with those if you want to
00:50Scriptorand there are some really nice build tools that let you use clojure itself, no xml silliness
00:52joshua__Sgeo_, have you used lein?
00:53Sgeo_I'm a bit scared to even learn what it is, tbh. Build managers scare me
00:53Sgeo_>.>
00:53tomojyou'd rather fetch every dependency by hand all the time?
00:53Sgeo_Oh, it's just a package manager?
00:54tomojnot just, but how else were you planning to do that
00:54Sgeo_Is Lein similar to Racket's PLaneT?
00:54Sgeo_I should probably actually look up Lein
01:01Scriptoramalloy: any idea what index() is used for, when you can just use the hash?
01:02amalloyScriptor: haven't read that for ages, and too busy to get back into it atm
01:02Scriptorok
01:02amalloy(plus i probably never knew)
01:02Scriptordamn, I'll ask Ritch next clojure meetup :D
01:08technomancy,google leiningen tutorial
01:08clojurebotjava.lang.Exception: Unable to resolve symbol: google in this context
01:08technomancyclojurebot: put a sock in it
01:08clojurebotexcusez-moi
01:10amalloytechnomancy: i know someone who can introduce you to lein if you're having trouble
01:11technomancyamalloy: I've heard lmgtfy is a pretty good site; is that what you're talking about?
01:12amalloytechnomancy: never heard of lmgtfy. how would i find out more about it?
01:12Scriptoramalloy: altavista
01:14technomancyif you type /whois lmgtfy.com, it will show you their address; maybe you could send them a postcard.
01:16joshua__http://lmgtfy.com/?q=what+is+lmgtfy
01:18amalloyjoshua__: sexpbot actually has a lmgtfy plugin for when you're too lazy to launch a browser to be snarky at someone
01:18amalloy$lmgtfy lmgtfy
01:18sexpbothttp://www.lmgtfy.com/?q=lmgtfy
01:18joshua__Very nice.
01:25amalloyjoshua__: by the way, have you paid any attention to the findfn plugin since you wrote it? the functionality is still basically the same but i've had to turn it into a monster: https://github.com/Raynes/sexpbot/blob/master/src/sexpbot/plugins/clojure.clj#L146-206
01:27joshua__amalloy, ! what have you done to my beautiful code
01:27joshua__amalloy, =) at least it works
01:28amalloymostly, sandbox it more robustly
01:28amalloy$findfn [1 2] 1
01:28sexpbot[clojure.core/first]
01:29amalloyaw. i like it when rand-nth makes the list
01:29amalloy$findfn [1] 1
01:29sexpbot[clojure.core/last clojure.core/count clojure.core/peek clojure.core/first clojure.core/rand-nth]
01:30joshua__amalloy, imagine writing a test case for this thing that is fairly robust... everyone would keep wondering why sometimes it would be failing because of stray rand-nths etc
03:27nunbdoes slime's machine-instance work equivalently with swank-clojure?
03:40G0SUBnunb: no :(
04:06xkbis there any way to "find" an agent back if u dont keep a reference to it somehow?
04:06xkbso I start an agent from within a function and directly send it it's behaviour
04:07xkbthere's no function like (find-all-agents) :)
04:12TobiasRaedermorining
04:12TobiasRaeder*morning
04:14TobiasRaederanyone used lein-ring to build a war in here?
04:48tscheiblhey there
05:51nunbGOSUB: no partic. reason it can't be done, right?
06:23tscheiblwhen I want to override deref/@ for a specific var, should I do this using reify, implementing clojure.lang.IDeref/deref? This smells so bad of relying on implementation details...
06:26tscheiblany ideas?
06:28cemericktscheibl: IDeref is a widely-implemented interface.
06:29cemerickwhat do you mean by "override deref for a specific var"?
06:29tscheible.g.
06:29tscheibl(let [server-channel* (atom (closed-channel))]
06:29tscheibl (def server-channel
06:29tscheibl (reify clojure.lang.IDeref
06:29tscheibl (deref [this] ...
06:30cemericksure, that's OK
06:30tscheiblI need to recreate the channel if it is closed before dereferencing
06:30cemerickYou're defining deref for that reify-defined instance though, not the var.
06:31tscheiblI'm using a local binding and a closure for the underlying atom to hide it from unqualified access
06:31cemericksure; what I'm saying is, you're not modifying the var in that case
06:31cemerick`def` defines the var
06:32cemerickyou're defining what's going into the var
06:32cemerick#'+ vs. +
06:32cemerick,#'+
06:32clojurebot#'clojure.core/+
06:32cemerick,+
06:32clojurebot#<core$_PLUS_ clojure.core$_PLUS_@15ee9d9>
06:32octehm
06:33tscheiblyes.. for the atom instance...
06:33octewhat's the most idiomatic way to create a def that can be changed globally
06:33octean atom?
06:34tscheiblocte: depending on your needs: attom, ref or agent... I suppose
06:34octeyes
06:34octeit's for keeping a reference to for example the jetty instance my program runs
06:35tscheiblocte: "The Joy of Clojure" Book describes the differences very well
06:35octei can't def it immediately to that since the compiler would start a jetty server.. so i define it as an (atom nil)
06:35octeand in my main-method use swap!
06:35octetscheibl, right. i forgot i bought that book, i should really read all of it ;-)
06:37cemerickvars can be changed just as the other reference type can
06:38cemerickChoosing among them is a question of the change / concurrency semantics you're after.
06:38octein my case i don't really see any reasons for chosing one over another
06:39cemerickan atom is most idiomatic in your case
06:52octehow annoying that manning timelimits the download links
06:56tscheiblocte: btw... did you manage to create a user account at mannings? It didn't work for me
06:57octetscheibl, um, i don't remember if i had to create an account
06:57octei just bought joy of clojure a while ago and received an email with a link.
06:59tscheiblme, too... that has worked so far. But they say you could create an account using your email as login where you can download all your purchases at any time.. in case you delete something accidentally
07:00tscheibl.. trying that showed me an error
07:01tscheibl.. actually I could ask the guys at Mannings...just wanted to know if it actually worked for someone
07:01tscheibl.uhm.. anyone
07:02octetscheibl, that sounds nice, didn't know about that
07:02tscheiblocte: yep.. nice... if it worked ;)
07:06octetscheibl, the download link i got expired.. but going to http://ebook.manning-sandbox.com and filling in the order number and email, i got a new download link
07:06octecan't find anything about registering an account though
07:07tscheiblah, well
07:07tscheiblit said something about "beta phase"... whatever that means ;)
07:08tscheiblhttps://account.manning.com/
07:08tscheiblocte: https://account.manning.com/
07:11tscheiblocte: tried it again, this time it worked! :)
07:11tscheiblgot my Manning account
07:11octetscheibl, that worked for me
07:11octeyeah
07:11octenice
07:12octethat will probably make me buy more books from them :-)
07:14tscheibl.. if they bother to release more clojure stuff... I don't think I want to do any other language again ;)
07:14tscheiblmaybe some other Lisp dialect...
07:15tscheibl... but only if oracle destroys the JVM
08:08raek_speaking of books... what is the estimated date for the dead-tree version of The Joy of Clojure?
08:28kencauseyraek_: March - http://manning.com/fogus/
08:30kencauseykencausey: I wonder about that though considering the last meap has a fair number of errors and hasn't been updated in months. Which is not to say that they aren't fixed, it's just odd that manning is not issuing fixed digital versions. The authors have complained a bit that they have little more input or awareness into this than anyone else.
08:53clgvwhat does the ^:static metadata cause in a defn statement?
09:23octethe joy of clojure book is quite interesting
10:17jcromartietscheibl: on other Lisp dialects... I am a fan of Scheme if I have to get closer to the hardware
10:17jcromartieChicken Scheme is quite awesome
10:17jcromartieit compiles to run on pretty much anything with a C compiler
10:18jcromartiesame with Gambit
10:27Sgeo_Meh
10:28Sgeo_I intended to have a part message
10:39tscheibljcromartie: how does scheme handle concurrency? Is it somewhat comparable to Clojures concurrency features (STM and so on)?
10:40Draniktscheibl, I guess the enhanced syntax of clojure also counts :-)
10:40jcromartietscheibl: it doesn't have a strong opinion
10:41jcromartiethere are systems built on top of Scheme to handle it
10:41tscheiblwhat about a native implementation of Clojure?
10:42tscheibl..implemented as Scheme Macros... lol
10:45tscheiblhmm.. there are quite some eggs available fpr chicken scheme
10:46pppaulanyone used clojure for something like a command-line tool?
10:47pppauli made a command and try to execute it like: java -jar uberjar.jar <file
10:48pppauland the args variable says that it is empty
10:48pppaulthe file has a list of things in it, though
10:48pppaulcat <file works
10:49Raynespppaul: You're passing the name of a file as a command-line argument? And then getting the name from the *command-line-args* var, right?
10:49pppauli want to give the contents of the file as input
10:49pppaulthe contents of the file as arguments
10:50jweissif I define (defn blah [& {:keys [x y z] }] ...) is there a way to get the list of keys that were actually passed in?
10:50clojurebotPlease do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.
10:50RaynesAlright, but you're looking at *command-line-args* right? There is no 'args' var.
10:50Raynesclojurebot: Shush.
10:50clojurebotGabh mo leithscéal?
10:50pppauli'm using -main [args]
10:50pppaulvia lein
10:51pppaullet me see about the *command-line-args* thing
10:52Raynesjweiss: (defn blah [& {:keys [x y z] :as all}] (keys all))
10:52Raynespppaul: You're doing it properly.
10:52raek_pppaul: if you execute your program with "java -ajr ubserjar.jar a b c", it will result in the call (-main a b c)
10:52jweissRaynes: ah thanks
10:52Raynes*command-line-args* is only relevant if you're not calling the uberjar.
10:52raek_pppaul: *command-line-args* is only for when clojure.main is used as the main class
10:53Raynesraek_: What is the -aj for there?
10:53RaynesThat shouldn't be necessary for passing command-line arguments.
10:53pppaulok, i'll try -ajr
10:53raek_pppaul: also note that when you execute it with "<file", file is not an argument
10:54raek_pppaul: sorry. that was a typo for "-jar"
10:54RaynesOh.
10:54pppaulok, i'm confused as to what <file does
10:55pppauli thought it would redirect the file as input to the command
10:55raek_sorry for diverting you...
10:55raek_pppaul: yes. it will cause that file to be opened and used as
10:56pppaul?
10:56pppaulas what?
10:56raek_... as *in*
10:56pppaulok
10:56Raynespppaul: Be patient with him. He is probably typing on a phone.
10:56pppauloh
10:56raek_(gah! my computer switched keyboard layout in the middle of that sentance)
10:56pppaullol
10:56RaynesEven more likely on a bumpy bus ride somewhere. :p
10:57pppauli want my file, which is a list of arguments to my command, to be fed into my command
10:57pppauli thought <file would do so, but i guess not
10:57raek_yeah. on a phone on a bumby buss ride. *whistles*
10:57pppaul:)
10:57RaynesI'm not sure that doing that is very common with command-line tools.
10:58RaynesYou'd probably be better off just reading from *in* or taking the name of the file and calling line-seq on it.
10:58raek_pppaul: that sounds more like java -jar uberjar.jar `cat file_with_args`
10:58pppaulhmmm
10:58raek_if I understood you correctly
10:59pppaulok, i'll try that
10:59raek_<file will replace the "keyboard input" with the contents of that file
11:00raek_so you have to decide to either read the commands from the input stream or from the command line arguments
11:01pppaulhmmm
11:01pppaulthis is over my head
11:01pppaul`cat` worked, sorta
11:01dnolenconsumer quad-core laptops mmm ... Clojure.
11:14_fogusMarginalia v0.5.0 is a go
11:55cinchyey! 2k requests per second on jetty with on disk cache of the html (~40/s without)
11:57rata_hi
11:57rata_I'm protocolifying my library
11:57rata_is that encouraged?
11:59rata_(or protocolizing?)
12:01ejacksonprotocollating ?
12:06rata_is it common that protocols are like IProt and implementation (types and records) are AProt?
12:06ejacksoni thought the other way around ?
12:06rata_sounds weird with Prot, but IFoo and AFoo?
12:07ejacksondunno though
12:07rata_really? implementation are IFoo?
12:07rata_I thought I was for interfaces
12:07rata_I mean "I", the letter
12:10ejacksonhttp://clojure.org/protocols shows Rich using AProt at least
12:11sattvikrata_: In some naming schemes, I... is for interfaces and A... is for abstract concret types.
12:12sattvikI don't know if there is any convention for protocols and records, aside from using camel case.
12:12rata_mmm ok
12:13rata_well then I'll use AFoo for protocols as http://clojure.org/protocols says
12:13rata_and, well, I don't know for the concrete type... maybe just Foo
12:18ejacksonanother approach is using protocol names such as Countable, Serializable, FooBarable.
12:18ejacksoni find that very readable
12:22rata_ejackson: but that approach doesn't apply to my case because I'm using the protocol to define a foo-like thing
12:23ejacksonk
12:24rata_are there any problems using for example name or merge as methods of my protocol? will they collide with name and merge from c.core?
12:25ejacksondon't think so, you use them (.method-name ....)
12:26ejacksontry and see :)
12:26robonobohi
12:28robonobosoi'm trying to draw a triangle on a JPanel using .drawLine 3 titmes in a doto block, but it only draws one of the lines
12:28robonobohttps://gist.github.com/842487
12:30amalloyrobonobo: seems like it ought to work. maybe you need to send a .repaint?
12:31rata_$source str
12:31sexpbotstr is http://is.gd/cn9qbS
12:31amalloythough btw, in (do (doto ...)) there's no need for a do
12:33__name__The implementation of cartesian-product in contrib is really putting me of.
12:33__name__I don't think I ever could parse this.
12:34amalloy__name__: meh, just write it as (for [x xs y ys z zs] [x y z]). not much need for contrib there
12:34jkdufairInteresting that .NET 4.0 has all sorts of concurrency stuff baked in. Wonder if that will help clojure on the CLR.
12:35__name__amalloy: Could they not have made a macro for that?
12:35__name__amalloy: And I know that, still, I never think I will understand this code.
12:35amalloylink me?
12:35__name__Oh, I forgot. Excuse me.
12:35__name__https://github.com/richhickey/clojure-contrib/blob/2ede388a9267d175bfaa7781ee9d57532eb4f20f/src/main/clojure/clojure/contrib/combinatorics.clj#L107
12:37amalloyhaha wtf is this code. gross
12:38__name__So this is not what Clojure is supposed to look like I guess.
12:39amalloywell i can't read it either. *maybe*, though i'm highly dubious, this is the "best" way to write it from scratch
12:39amalloybut there's no reason to do that when you have lots of lovely functions available to do this already
12:39__name__If that's the best way I am sad :(
12:39__name__What if you data is runtime, then the for will not work.
12:39Despiteas i recall the combinatorics lib is highly optimized
12:40__name__i.e. the amount seqs
12:40Despitei guess readability was not a concert
12:40Despiteconcern
12:40__name__How can one maintain this?
12:44amalloy__name__: take chunks of code out and turn them into independent functions. pick tolerable names for them. that probably helps a lot
12:45__name__amalloy: Yes; so they just did not do that for performance reasons?
12:45amalloy*shrug*
12:45rata_is this right? (deftype Foo [a] AFoo (bar [_] a))
12:45rata_ or is it better to write (deftype Foo [a] AFoo (bar [f] (.as f)))?
12:46danbellThe :or keyword in function parameters
12:46danbell : or
12:46amalloyone possibility is it's just hard to factor out closures because you don't want to pass them as arguments all the variables they close around (but it shouldn't have performance implications afaik)
12:46danbellran across it in Incanter, can't find any documentation
12:46danbellanyone know where it's described?
12:46amalloydanbell: it's a destructuring feature
12:47__name__typo? http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/defonce
12:47__name__‘iff’
12:47amalloyhttp://stackoverflow.com/questions/3337888/clojure-named-arguments looks like it explains it, danbell
12:48amalloy__name__: mathematicians use "iff" to mean "if and only if". if that makes sense in context that's probably why
12:48danbellha, after you told me it was destructuring, I plugged it into google and found that same question ;)
12:48__name__amalloy: ah, thank you
12:49danbellamalloy: awesome, thanks
12:56bobo_When wrapping a java library, where you need to set properties on the objects al the time. whats a good syntax for that? any good example to look at?
12:58Vinzentbobo_, doto?
12:58bobo_well if im going to write a wrapper so i dont need doto.
13:00rrc7czfrom a high level, how is security provided when implementing something like clojurebot or sexprbot?
13:00rrc7czmy first thought was a java policy on the JVM to prevent system calls, though that wouldn't really address blowing out the heap on purpose, etc.
13:04amalloybobo_: perhaps (defmacro set-fields! [fields object] `(do ~@(for [[k v] fields] `(set! (. ~object ~(name k)) ~v)) object)) or some such?
13:04amalloyif your goal is to make it easy to set several fields at once
13:05bobo_my goal is to make it easy to use
13:05bobo_i realised swing might be a good example.
13:05bobo_or rather, my goal is to make it look more like clojure and less like java
13:05amalloyrrc7cz: have you looked at clojail? it's what powers sexpbot's sandboxing
13:06rrc7czamalloy: thanks, I didn't know about that. I've been trying to pick out where in those two bots the security is implemented
13:07AislingHello; are there packages for statistical inference on clojure?
13:07amalloyrrc7cz: well i'm your man, more or less. i've been maintaining sexpbot's security model more or less on my own for a couple months :P
13:08rrc7czamalloy: awesome. I'll definitely be interested to see how you prevent memory issues
13:10amalloyAisling: not sure what statistical inference actually is, but incanter has a lot of math and statistics
13:11rata_Aisling: https://github.com/getwoven/infer?
13:11Aislingamalloy: thanks, I'll take a look!
13:11Aislingrata_: thanks
13:12pppaulanyone do webprogramming with clojure here?
13:12rata_pppaul: many... ask
13:13amalloyrrc7cz: step into #sexpbot perhaps?
13:13rata_how would you make a type behave as a map that's in one of its fields?
13:13pppaulhow hard would it be to use clojure to create a website with user authentication and a members area (everything is static HTML/JS)
13:14rrc7czpppaul: I just checked in an example/skeleton webapp in Clojure today: http://bit.ly/esJtCV
13:14rata_pppaul: mmm I was wondering the same thing =)
13:16pppaulthanks
13:16pppaulrrc7cz does your app have user login?
13:16pppauli guess if it doesn't, it wouldn't be too hard to add
13:16rrc7czpppaul: shouldn't be very difficult. Check out Compojure and Ring for the Session middleware. Serving static files is supported out of the box by both
13:16pppaulcool
13:17pppaulso, what does your app skel do?
13:17rrc7czpppaul: not yet, but I'll probably add it. I was more concerned with showing restful crud
13:17pppauli read the link btw
13:17pppauli haven't heard of crud before
13:18rrc7czpppaul: just means create/retrieve/update/delete, basically the standard operations you perform on entities
13:18pppaulis there admin work with your app?
13:18BennylHi, I wondering about the dispatch (#) operator, reading from the site documentation I didn't understand how it exactly worked
13:18pppauldo i need to setup the DB or something before running your app?
13:19rrc7czpppaul: not sure I understand. Really it's just meant to be a bare min example of restful crud, not a rails or django by any means
13:19rrc7czpppaul: it comes with an embedded db so you don't have to worry about it
13:19pppaulok cool
13:19pppauli may try it out for a site a friend wants help with
13:19pppaul:D
13:20rrc7czpppaul: good luck, and make sure to check out ring/compojure's session support in case I don't add it
13:20amalloyBennyl: # activates various "special" parsing modes for the compiler
13:21amalloyhttps://github.com/clojure/clojure/blob/1.2.x/src/jvm/clojure/lang/LispReader.java#L75 is a relevant part of the source if you're into that sort of thing
13:22Bennylamalloy: thanks! I will look at it
13:23rata_how would you make a type (deftype) behave as a map that's in one of its fields?
13:24Chousukerata_: that sounds rather weird.
13:24bobo_il try with an example, https://gist.github.com/842596 either of thoose look sane? or any other ideas? as syntax for using jbutton for example. Im just thinking so far.
13:27sattvikrata_: try defrecord
13:28rata_sattvik: defrecord isn't useful as I don't know the keys at compile time
13:29rata_Chousuke: it's not that wierd... I just want to have a map that has additional information outside that map but in the same object
13:29rata_I've been using meta before, but I'm trying to protocolize my code
13:29sattvikrata_: Hmm... then I think you'll need to implement IPersistentMap in your deftype
13:30rata_I thought that protocolizing it would perhaps make my code cleaner
13:30rata_sattvik: is it just IPersistentMap?
13:33sattvikrata_: That's the main interface, you'll also have to implement the various methods from inherited interface like Associate, Iterable, etc. Depending on what you need, you may be able to get away with lesser interface, such ILookup.
13:35rata_I want it to behave as a map
13:37rata_sattvik: where is the interface Iterable?
13:37amalloyrata_: java.lang
13:37rata_oh ok
13:38amalloyrrc7cz: poking around at my dev copy of sexpbot in #sexpbot if you're interested. he seems to survive OOM errors with no harm done
13:39rata_amalloy: hmmm that seems difficult to implement from clojure
13:39Dranikhi all!
13:40Dranikwhat is the difference between the type hints #^ and ^
13:41amalloyDranik: #^ is old
13:41rata_is there an easy way to redirect a bunch of methods from a type to a field of that type?
13:44amalloyrata_: if your heart is set on this you could probably generate some kind of proxy class
13:45rata_amalloy: do you any recommendations on what to do otherwise?
13:45rata_I'm interested in other viewpoints
13:46amalloyrata_: can't really suggest an alternative without context. all i know is you want to do X, don't know why
13:47Dranikamalloy, ok, but is it still usable? and are there any details: which is the difference?
13:48amalloyi don't think there's any difference at all
13:48amalloyas long as your version of clojure supports ^, you can use either (but should use ^ of course)
13:50rata_I'm trying to protocolize my code... in particular, I have three domain-specific kind of objects... two of them were implemented as records and the other one as a map
13:50rata_amalloy: ^
13:50clojurebotamalloy: therfor I return [previous] if rest is empty
13:51amalloylol thanks clojurebot
13:51rata_hahaha
13:52rata_amalloy: and the map usually had some meta, which I'm trying to put together in a type with the map
13:52rata_but I still want the type to behave as the map it was
13:53rata_to minimize the amount of code I'll have to change
13:53amalloyrata_: just put meta on the record object?
13:53rata_no record object, as I don't know the keys beforehand
13:53rata_that's the reason it was a map
13:53rata_and not a record, as the other two
13:59dnolenrata_: why do you need to know the keys before hand? records work like maps.
14:00dnolen(defrecord Foo [])
14:00rata_dnolen: yes, but otherwise they don't perform better afaik
14:00rata_nor will a record help me in any way
14:00rata_compared to a map
14:01dnolenrata_: you get protocol dispatch perf. if you don't know the keys beforehand then you want a map.
14:03dnolenyou have to know the keys if you want performance. if you don't, then you have to accept the performance hit. or resort to runtime compilation of types/records which seems icky.
14:05rata_dnolen: I know I want a map... that's not the point
14:06rata_I wasn't saying I don't want a map
14:06dnolenrata_: yet you want to use protocols to make things 'cleaner'
14:06dnolenthat seems suspect to me.
14:08rata_dnolen: that's ok... I'm not sure if it's a good decision
14:08rata_dnolen: therefore I said that perhaps protocols could help me make this cleaner
14:08rata_and I asked if it encouraged to protocolize libs
14:09rata_to make things a little clear, here's the protocol and type https://gist.github.com/842663
14:10rata_before the as field (which is a map) was the whole "type" and cs was put in the meta of that map
14:12rata_the library I'm talking about is this one https://github.com/rhz/kapjure
14:12rata_specifically this file https://github.com/rhz/kapjure/blob/master/src/kappa/language.clj
14:14rata_is there a way to collect the name of the methods of an interface from the REPL?
14:15Licenserfor the record, clojure does well with soap - the mistake was mine :) also M$ sucks
14:20amalloyrata_: clojure.contrib.repl-utils/show
14:20dnolenrata: only glanced quickly, but your code doesn't look particularly 'not-clean' to me.
14:22rata_dnolen: thanks =)
14:22rata_you're right, it's not particularly not-clean
14:22rata_but the question then is: is it encouraged to protocolize libs?
14:24Chousukerata_: why not?
14:24rata_Chousuke: why yes?
14:24dnolenrata_: I see only a couple cases for protocolizing a lib. You really, really, really want the performance. You have solid interfaces that you want to expose to downstream users.
14:24Chousukefor performance?
14:24Chousukerata_: though my understanding is that optimally your users shouldn't need to care whether you're using protocols or functions or multimethods
14:25Chousukeso that you're free to use whatever you need.
14:26rata_dnolen: well, I really, really, really want the performance, but I'm not sure protocols are helping me with the performance here
14:26rata_dnolen: also, it'd be nice to expose my interfaces to downstream users, but not required
14:30dnolenrata_: what is the bottleneck in yr code?
14:41rata_got disconnected
14:43rata_if two interfaces requires the same method, I don't have to mention that method twice in deftype, do I?
14:43cemerickanyone here use rhickey's sdb library?
15:06cemericktechnomancy: ping
15:07pppaulis there a way for me to see the code that defines a def?
15:08cemerickdef defines a var
15:08midsgrep?
15:08pppaulok
15:08pppaulis there a way for me to see the code that is in a var?
15:08pppaullike a macro expand, but for a var
15:08cemerickdef is a special form, not a macro
15:09pppaulactually, not really like macroexpand
15:09cemerickIf you want to see what def does, you need to dig into the Clojure runtime
15:09pppauli don't want to see what it does
15:10pppaul(def a (map ....)) -> (map....)
15:10cemerickah!
15:10pppauli want to see the code i wrote for a
15:10cemerick,(source +)
15:10clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
15:10pppaulthanks :D
15:10cemerickbleh
15:10cemerickyeah, use `source` :-)
15:10clojurebotI don't understand.
15:10cemerickclojurebot: that's because you're a fool.
15:10clojurebotIt's greek to me.
15:10cemerickPerfect. :-D
15:10pppaulthat's not working for me :(
15:11cemerickpppaul: what version of clojure are you using?
15:11pppaul1.2
15:11pppauli'm using the repl, and i lost my code
15:11cemerickhrm, it should be bound in your REPL already
15:11pppauli want to find it again
15:11cemericktry
15:11cemerick(clojure.repl/source var-name)
15:11pppaulthanks
15:12pppaulstill doesn't work
15:12cemerickwhat's the error?
15:12pppaulsource not found
15:12cemerickoh, I see, you typed the code into the repl, you didn't load it from a file.
15:13pppaulyup
15:13cemerick,(doc clojure.repl/source)
15:13clojurebot"([n]); Prints the source code for the given symbol, if it can find it. This requires that the symbol resolve to a Var defined in a namespace for which the .clj is in the classpath. Example: (source ...
15:13cemericksorry, man
15:13pppaulhmm
15:13pppauldo you think what i want is possible?
15:14pppaulshould i avoid using the repl to write code without saving it to a file frequently?
15:14cemerickNo, probably not.
15:14pppaulok, thanks
15:14cemerickIf you are using an environment that keeps REPL command history, then it's fine.
15:15cemerickpppaul: I take it you're just on the command line?
15:16pppaulin emacs
15:16pppauli really like the relp
15:16pppaulmaybe too much
15:16cemerickSurely emacs/swank/whatever has command history in the REPL?
15:17pppaulyup, but i clear the screen sometimes
15:17cemerickno, I mean a recallable command history
15:17cemericke.g. Ctrl+up, whatever
15:17pppaulit gets slow after i fill it up with thousands of lines of crap from whatever i'm doing
15:17pppaulyeah it has that
15:17midspppaul: maybe interesting discussion for you: http://groups.google.com/group/clojure/browse_thread/thread/4812633ea878c59a
15:18pppaulthanks!
15:18cemerickYou can't bounce up through your prior entries until you get your function definition?
15:18arohnerpppaul: your slime input history is stored in another buffer, so it's still accessible after a C-c C-l
15:19arohneras long as M-P still works, you can find it
15:21pppaulmy slime completions go back way too far
15:25robonobohello
15:31jhirnHello. Newb question. What is the best way to filter nil from a list? I am trying all combinations of (filter (not nil?) list) but I'm starting to think there's a different way.
15:32dnolen,(remove nil? [1 nil nil 2 3])
15:32clojurebot(1 2 3)
15:33dnolenjhirn: ^
15:33jhirnthat did the trick =)
15:33jhirndanke
15:36morphling$findfn [1 nil nil 2 3] [1 2 3]
15:36sexpbot[]
15:37RaynesThat's too clever for him.
15:37morphling$findfn [1 2 3] [2 3 4]
15:37sexpbot[]
15:37morphlingno higher order functions at all?
15:37RaynesNope. That would be really time consuming and difficult.
15:38Fossiit's impressive enough as is imho
15:39Raynesamalloy and I have talked about adding support for arbitrary expressions with placeholders for functions that would make that sort of thing plausible.
15:40morphlingcool
15:44rata_$findfn nil? [1 nil nil 2 3] [1 2 3]
15:44sexpbot[clojure.core/remove]
15:48raek_,(for [x [1 2 3 4] :when (odd? x)] (* x 100))
15:48clojurebot(100 300)
15:49raek_hrm, I should use the various of 'for' more often...
16:19TeXnomancycemerick: pong
16:20cemerickTeXnomancy: was going to ask you: http://groups.google.com/group/clojure/browse_frm/thread/8912e783aeba6b02
16:21TeXnomancycemerick: oh... my dirty little secret is that I sometimes don't delete github forks in order to skew the Github language high-score board.
16:22TeXnomancyI think I may have done a couple tweaks to it two years ago in vague exploration-mode, but I haven't touched it since
16:22cemerickah-ha
16:22cemerickTeXnomancy: that's a good strategy, tho :-)
16:23hiredmanlast time I thought about playing with sdb the dependencies as a zip was too high a barrier to entry
16:23Raynesamalloy deletes all of our forks. :(
16:24amalloyRaynes: well stop giving me push access to your repos if you want me to keep forks around
16:52jweissanyone know of a git browser whose clj highlighting >= github, but can be hosted yourself (eg, on corp network)
16:52jweisslooked at gitorious, clj highlighting is not good
16:54amalloyjweiss: just use SyntaxHighlighter for the highlighting, then it doesn't matter what git browser you use?
16:55jweissamalloy: i'd have to integrate syntaxhighlighter into whatever it is, wouldn't i?
16:56amalloySH is pure javascript; you can just tell it to render some dom element
16:57amalloyso let the browser load up its stuff, and add some js afterwards. doesn't sound like a heavy integration burden
16:58jweissamalloy: this isn't for me - it's for people who won't be bothered to load up extra js
16:58jweissit needs to be included in the pages as they browse
18:00ossarehjweiss: I might be misunderstanding something but SyntaxHighligher is js that gets thrown into your page and then looks for <pre/> tags with a "brush" defined on it.
18:01ossarehjweiss: the source of this page shows this effectively: http://alexgorbatchev.com/SyntaxHighlighter/manual/demo/
18:25maaclDoes the cake deploy task exist? I don't see any documentation anywhere
18:37raekanyone know how to go from \A to "U+0041 LATIN CAPITAL LETTER A", btw?
18:39TeXnomancyM-x describe-char?
18:39TeXnomancyoh wait, wrong channel
18:43amalloyraek: http://www.unicode.org/Public/6.0.0/ucd/UnicodeData.txt
18:44amalloylooks like a CSV-ish file describing zillions of charactera
18:45raekamalloy: most of that data seems to be accessible from the methods of Character, but I haven't found how to get the name
18:46raekin python there is a method for that, so was hoping there was one in java too
18:48raekamalloy: anyway, thanks for the link. looks like I need to use it.
18:48joegallogoogle says to use icu4j
18:49raekTeXnomancy: ah, that might come handy. thanks!
18:50raekjoegallo: ok, will check out. :)
18:50joegallohttp://icu-project.org/apiref/icu4j/com/ibm/icu/lang/UCharacter.html#getName(int)
18:50joegalloneato.
19:03raek(com.ibm.icu.lang.UCharacter/getName "𐌰" "") => "GOTHIC LETTER AHSA"
19:03raeknice.
19:03raeksildaleiks!
19:05joegallobangarang!
19:07SgeoYesterday, I would have asked if Clojure has something like C#'s thing where the fact that two different interfaces that define the same function name can be made to not conflict. Today, I realized that that's automatic in Clojure
19:16TimMcSgeo: Via :as?
19:17TimMcI like that about Python too.
19:17TimMcHaving to use the original author's names seems so backwards now. :-P
19:17SgeoI don't even know what that is. Just that implementing protocols/interfaces requires naming the protocol/interface
19:18SgeoSo one protocol's somefunc doesn't interfere with the other protocol's somefunc when defining that something implements those protocols
19:18TimMcOh! Nvm, misread.
19:19TimMcWas thikingabout (require ... :as ...)
19:33SgeoAre all impure functions supposed to use io! ?
19:37TimMcI use side-effects all the time from within dosync. I just make sure they're idempotent.
19:37TimMc(I don't know if that's bad, though.)
19:47SgeoIs ->> inside -> a commonly used idiom?
19:48amalloySgeo: not very
19:58tscheiblbb
19:58tscheiblgn8
20:53SgeoHow do multimethods interact with protocols?
20:54brehautSgeo: what do you mean? they are seperate mechanisms
20:55SgeoThey seem to do similar things to some extent.
20:56brehautSgeo: they both provide polymorphic facilities yes
20:56brehautand in both cases they look like functions
20:57brehautmultimethods have creator defined dispatch functions whereas protocols are type based single dispatch
20:59brehautadditionally protocols provide built in support for grouping functions
20:59SgeoWhich is used more for someone still in an OO mindset?
20:59brehautand are a bunch faster than multimethods
20:59brehautSgeo: that question breaks my brain
21:00Sgeo>.>
21:00brehautProtocols are probably closest to what you are used to
21:00brehautie, type based single dispatch
21:00brehautbut you can do the same thing with multimethods
21:00brehautmultimethods are much more general
21:01brehautsome people would tell you to writing things with multies until you know you have a bottleneck that needs performance
21:02SgeoWould it be possible to define the protocol macros etc. in terms of multimethods?
21:02SgeoWould that make more sense than the current setup?
21:02brehautno
21:02brehautand yes
21:02brehautin reverse order
21:02furryrealsthere'd probably be a performance hit
21:02brehautwhat doesnt make sense about the current set up?
21:03SgeoJust that two distinct non-interchangable mechanisms are used for basically the same thing
21:04brehautSgeo: if by 'basically the same thing' you mean 'polymorphism'
21:04brehautthen you need to learn about more kinds of polymorphism than type based single dispatch
21:05brehautSgeo: until you know enough to be able to understand the difference, pretend protocols dont exist and go learn multimethods
21:05Scriptormultimethods are also not difficult at all, a naive implementation can be done fairly quickly in clojure itself
21:06SgeoI understand the difference just fine. I just don't see how two separate language mechanisms where one is just a subset of the other is necessarily a good idea
21:06brehautSgeo: then you dont understand the difference just fine
21:07amalloySgeo: good point. i'm not sure why we have * and + when you could just use - for all of those with a little more work
21:08Scriptorare protocols implemented in Java or Clojure?
21:08Scriptorer
21:08technomancySgeo: the short version is that multimethods are to slow for self-hosting Clojure
21:09SgeoOk
21:09technomancyif you're not implementing Clojure you can probably ignore them
21:10technomancythey provide dispatch that hotspot is really good at optimizing
21:10Scriptorwhat, multimethods?
21:10technomancysorry; protocols
21:10Scriptorah
21:10technomancybut they are a lot less flexible than multis
21:10Scriptorright, that makes sense
21:10Scriptorso in the future would the sequence code for clj-in-clj be using protocols?
21:11technomancyI think primitive vectors are already there.
21:13SgeoI guess I just want to mix protocols and multimethods freely
21:57mattmitchelli'm attempting to get a basic leiningen project running with swank. I've followed several tutorials/readme's and can't seem to get "lein swank" to work. I get a message from lein: "That's not a task. Use "lein help" to list all tasks."
21:57mattmitchellanyone know what i could be doing wrong?
22:00amalloymattmitchell: you need to install the swank plugin
22:00mattmitchellamalloy: ah, how do i do that?
22:00Null-AIs it possible to deftype with mutable fields, that aren't part of ctor parameters, but are private member variables?
22:01amalloymattmitchell: ask technomancy. i use cake
22:03mattmitchelltechnomancy: would you mind telling me how to get the swank plugin installed?
22:07mattmitchellamalloy: are you able to use swank with a cake project?
22:07amalloyyeah
22:08amalloyjust add :dev-dependencies [[swank-clojure "1.2.1"]] to ~/.cake/project.clj, and all your projects will have swank added as a default dependency
22:12Null-Ais it possible to call clojure functions from java?
22:13Null-Anvm
22:22SgeoI think I misunderstood the concept of orthogonality of language features
22:39technomancymattmitchell: lein plugin install swank-clojure 1.3.0-SNAPSHOT will do it
22:40mattmitchelltechnomancy: nice :) finally working. thank you.
23:09spewnIs there something more idiomatic than (if foo foo bar)?
23:10DespiteItAllI'd do (or foo bar
23:10spewnThat's the one; thank you.
23:18amalloy&(macroexpand '(or foo bar))
23:18sexpbot⟹ (let* [or__3470__auto__ foo] (if or__3470__auto__ or__3470__auto__ (clojure.core/or bar)))
23:25amalloyspewn: anyway that's basically what (or foo bar) macroexpands to
23:27Sgeohttp://www.infoq.com/interviews/hickey-clojure-protocols
23:27SgeoWhy can't I hear a single thing grrrr
23:27ScriptorI always wondered about that, does it get optimized?
23:27Scriptorusing an entire if expression when you just want to or feels like it would have a lot of overhead
23:29amalloyScriptor: huh? at the hardware level it has to be an if anyway (eg, jump-if-less-than a b), so there's nothing to optimize
23:29Scriptoroh, right
23:51amalloyScriptor: it's actually the let that always "feels" wasteful to me. of course the guy writing the (or) macro has to allow for the fast that my first condition is a complex expression, and probably the compiler is smart enough to avoid copying when the let is unimportant, but it's like augh i already have a let, why are you making another?
23:52forensicdoes anyone have experience with lein daemon? I'm getting an error "jsvc error: Cannot locate Java Home" but $JAVA_HOME is definitely pointing to the right place... anyone know?
23:52Scriptoramalloy: true, but like you mentioned, the compiler is pretty advanced, probably good CoW optimization