#clojure logs

2011-06-30

00:04technomancyyeah, this looks more like a clojure 1.3 beta bug
00:06technomancyor... it could be that hooke was depending on a clojure 1.2 bug that was fixed
00:07technomancydepending on how you want to frame it
00:07technomancywell, I'll be sure to issue a fix before 1.3.0 lands
00:07technomancy*fix or workaround
00:13amalloytechnomancy: i'm curious what the actual issue was, if you've figured it out
00:13technomancyamalloy: http://p.hagelb.org/fn-meta.html
00:14technomancyI'm leaning towards the 1.2 behaviour being suspect
00:14technomancyas it's my understanding with-meta should create a copy of the function
00:14amalloytechnomancy: i'm inclined to agree
00:15technomancyin retrospect I'm astonished it works in 1.2
00:17technomancywell, I'll hit up the mailing list tomorrow
00:17amalloytechnomancy: https://gist.github.com/1055630
00:17tomojflipping the buffers I thought I read "wetrospect" and was relieved not to find a pun
00:18tomojs/ /through/
00:18amalloytomoj: wow, what a terrible regex that was. good thing we told sexpbot to ignore you, eh?
00:18tomojwell.. I didn't say g
00:18tomojso it's only really a bit terrible, isn't it
00:19technomancyamalloy: crazy town
00:19technomancylooks like we've got some mutability!
00:19technomancyclojurebot: guards
00:19clojurebotSEIZE HIM!
00:20amalloytechnomancy: not necessarily? it's possible that in (fn inner [f] ... inner), the reference to inner is interpreted in some crazy way as "the current function". that would make it possible without mutating
00:20technomancyamalloy: maybe. doubtful considering it doesn't work that way it 1.3 though
00:20amalloyagreed. i think mutation is more likely. writing up a test case to determine the difference
00:28amalloytechnomancy: a bit weird, but that does seem to be what's going on: https://gist.github.com/1055630
00:38technomancyboggled
00:38sexpbotjava.lang.Exception: EOF while reading
00:42amalloyi like a good hunt through the compiler as much as the next guy, but figuring out where that change happened is too hard for me:P
00:43pcavs_I'm confused. It seems like the expected behavior is what's occurring? I guess I just don't have the full context for the bug you are referencing
00:44pcavs_but that gist you sent made perfect sense...
00:49amalloypcavs_: one behavior that might be expected is that (fn foo []) would capture the object referenced by the function, and that a version of it wrapped with (with-meta) would still refer to the same foo
00:50pcavs_,(doc with-meta)
00:50clojurebot"([obj m]); Returns an object of the same type and value as obj, with map m as its metadata."
00:50pcavs_,(doc identical?)
00:50clojurebot"([x y]); Tests if 2 arguments are the same object"
00:50pcavs_So clearly (with-meta) would create a different object, although they would have the same values.
00:51pcavs_Just my 2 cents.
01:02tomojI only just realized you can destructure infinite seqs
01:03tomoj&(let [[x y z] (repeatedly rand)] [x y z])
01:03sexpbot⟹ [0.7348056642450934 0.7090822026528741 0.10813687904097102]
01:15amalloytomoj: yeah, it's even handier for functions with side effects: (let [[x y z] (repeatedly read)] to read three values, or (repeatedly gensym) to create a bunch of gensyms to manage manually for a macro
01:17amalloythough i guess for repeatedly to be at all interesting the function has to have side effects, so i'm not really saying anything you didn't know :P
01:19tomoj.. or side causes?
01:21amalloyreferential opacities?
02:07Scriptordid there used be be a clojure-lounge?
04:02Cozeyis there some convenient way to remove N last characters from a string? or do i have to go subs/count way
04:08teromWell, that or treat string as a seq and use seq functions on it. Not sure about the performance characteristics of these approaches. If you use (.length "str") instead of (count "str"), it could be better performance-wise.
04:09terom,(apply str (drop-last 3 (seq "string")))
04:09clojurebot"str"
04:11amalloyterom: .length will be very marginally faster if type-hinted properly, and massively slower if not type-hinted
04:11teromamalloy: ah, good to know
04:18teromAlso Apache Commons Lang seems to have StringUtils#substring() which accepts negative offsets.
04:31Cozeyoh, ok
05:22sandGorgonhi guys - I have a hash {:a 1 :b 2) . I have a (def mystr "a") - how can I get the value from hash based on mystr -> is there any conversion from mystr to a key ?
05:24morphlingsandGorgon: you can use strings as keys in hash maps
05:24morphlingthere is also ##(keyword "a")
05:24sexpbot⟹ :a
05:25sandGorgonmorphling, that works thanks! the hashmap was coming in from a 3'rd party lib that already used symbols
05:31morphlingsandGorgon: just don't call keyword on user supplied strings, they get interned which allows for easy DoS attacks
06:34ojd20cemerick: Thanks for Bandalore - finding it very useful. I've got a situation where we could go days without a message to receive. Could pass a really large value in to polling-receive :max-wait, or extend polling-receive to poll indefinitely for :max-wait -1. Is there a more sensible alternative, though?
07:16cemerickojd20: Glad you're finding it useful :-)
07:16cemerickLet me refresh my memory of the impl…
07:19cemerickojd20: :max-wait of Long/MAX_VALUE is equivalent to waiting indefinitely
07:20ojd20cemerick: OK, great. Thanks!
07:20cemerickojd20: The more sensible alternative would be for me to reimplement polling-receive to use promises
07:21ojd20cemerick: I'll need to read up on those!
07:22cemerickActually, you'd still need period and max-wait, or you'd end up leaking threads spawned to fulfill those promises.
07:22cemerickojd20: so, yeah, Long/MAX_VALUE if you want to wait indefinitely — but make sure that that's what you really want to do :-)
08:02clgv$findfn {:a 1, b 2
08:02sexpbot[clojure.core/cond clojure.core/dosync clojure.core/import clojure.core/prn clojure.core/refer-clojure clojure.core/print clojure.core/with-loading-context clojure.core/newline clojure.core/comment clojure.core/or clojure.core/load clojure.core/shutdown-agents cloju... http://gist.github.com/1056107
08:02clgvups
08:03clgv$findfn {:a 1 :b 2} {:c 3 :d 5 :a 1 :b 2} true
08:03sexpbot[clojure.core/not= clojure.core/distinct? clojure.core/not-any? clojure.core/not-every?]
08:03clgvhumm not quite my intention I guess
08:04cemerick~max
08:04clojurebotmaxine is http://research.sun.com/projects/maxine/
08:04cemerick~max
08:04clojurebotmax people is 317
08:08clgvok I got it. I want to compare whether a map has certain key value pairs. I do it by (= (select-keys m [:a :b :c]) {:a true, :b 2, :c -1})
08:08clgvI guess this is the shortest way
08:12peteriserinsI do not understand the "where-params" parameter in clojure.contrib.sql/update-values
08:13peteriserinswhat is the syntax for the selection criteria string?
08:13peteriserins(documentation at http://clojuredocs.org/clojure_contrib/clojure.contrib.sql/update-values)
08:14DerGuteMoritzpeteriserins: AFAIUI it wants something like ["foo = $1" value-for-foo]
08:15DerGuteMoritz(assuming postgres and proper bind variables)
08:16peteriserinsDerGuteMoritz: I am using MySql and I want to update every row
08:16peteriserinscan I use [""]?
08:16DerGuteMoritzoh I see
08:16peteriserinsor should I use ["true"]? or something?
08:16peteriserinspeteriserins: looking at the source code, I see now that it is plunked into the UPDATE query
08:17DerGuteMoritzright
08:17DerGuteMoritzprobably best to just use do-prepared directly then
08:19peteriserinsDerGuteMoritz: OK, thanks, I'll try something
08:19DerGuteMoritzgood luck!
08:24peteriserinsDerGuteMoritz: oops, actually, I do want to select specific rows
08:25DerGuteMoritzpeteriserins: heh okay then update-values it is
08:26peteriserinsDerGuteMoritz: basically, I am running map on a select statement
08:26peteriserinsDerGuteMoritz: doing some parsing and I want to update a column for the row I am parsing
08:27peteriserinsDerGuteMoritz: so I should be using something like ["Id = id" id] ?
08:27DerGuteMoritzpeteriserins: yep, seems correct, assuming "Id" is your primary key :-)
08:32peteriserinsDerGuteMoritz: it thinks Id is a parameter, and wants two more arguments in there
08:32DerGuteMoritzoh sorry, you need a parameter placeholder there
08:32DerGuteMoritznot sure what mysql uses for those, in postgresql it's $1, $2 etc.
08:33DerGuteMoritzso ["Id = $1" id]
08:33DerGuteMoritzI'm sure you'll find it in the manual though
08:36clgvis there something like the following macro in clojure or contrib? (defmacro vary-when [value, predicate?, vary-body] `(if (~predicate? ~value) ~vary-body ~value))
08:37clgvI needed it for the 10th time or so,thats why I have written it. but if it already exists in either clojure or contrib I would use the existing one
08:39DerGuteMoritzclgv: not that I'm aware of but how about changing the expansion to be `(let [v value] (if (~predicate? ~v) ~vary-body ~v)) so that if value is function call it doesn't get called twice?
08:40clgvhmm yes thats an option ;)
08:40DerGuteMoritzI guess value getting evaluated twice would surprise a user
08:40DerGuteMoritzoh sorry, forgot to change the ~ properly there
08:41DerGuteMoritzbut you get the idea hehe
08:41sandGorgonhi guys - anybody using enlive ? I have a sequence of maps, gotten from a "with-query-results" & "doall" and I cant for the life of me figure out how to pass it on to enlive templates/snippets
08:42clgvcorrect version: `(let [v# value] (if (~predicate? v#) ~vary-body v#))
08:42clgvoops not completely
08:42DerGuteMoritzoh right, clojure macros are explicit renaming
08:42clgv`(let [v# ~value] (if (~predicate? v#) ~vary-body v#))
08:42DerGuteMoritzannoyingly so :-)
08:47clgvhumm another one is 'use-default it returns a given default-value if the evaluation of the body returns nil
08:48DerGuteMoritzhm question regarding clojure's macro system: the vary-when macro breaks when I redefine `let' or `if' - how can I ensure that the according definition of the macro expansion environment is used?
08:48DerGuteMoritzor does that happen only on the REPL? cause that's where I tried it
08:49clgvDerGuteMoritz: no it doesnt break! syntax-quote does resolution at compile time
08:49DerGuteMoritzclgv: I think `use-default' is the same as `or', is it?
08:49clgvyou would have to redefine clojure.core/let to break it
08:49DerGuteMoritzclgv: ok then it's a REPL thing I guess
08:49clgvright it is 'or
08:58timvisherhey all
08:58timvisheranyone know if compojure supports default values for unbound keys in route destructuring, and what the syntax is for it if it does?
09:16bsod1is there a way to stop VimClojure REPL when it's stuck in a loop?
09:19clgvis there a possibility to findout if there is a certain namespace on my classpath that might not be used/required yet, without requiring it in that instant?
09:21nizzeHi!
09:22nizzeI'm a clojure newbie and I have couple of questions.
09:23nizzeI'd like to know how fast (to run) Clojure is. Is it "fast enought" i.e. I can build most of my webdev tools with it?
09:24nizzealso, I did (source number?)
09:24nizzeWhat kind of black magic is this?
09:24nizzeAnd even more bizarre: (source source)
09:24timvishernizze: it's almost as fast as Java in most cases, and faster than Java in some
09:24nizzetimvisher: Thanks.
09:24timvisher,(source number?)
09:24clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
09:24Fossiwell, as you have the source for source, have a look ;)
09:25Fossibasically it searches for the source file and displays the functions sourcecode
09:25timvisherwhat black magic are you observing?
09:25nizzeYeah :D How come other (Algol based) languages do not let me do this
09:25timvisherthey only score a 7.5 on the awesome scale
09:25nizzeDoes the source really search the source file or does it access the AST?
09:25timvisherclojure get's an 8.5. so it comes with source. ;)
09:26Fossijava/eclipse almost do
09:26timvisherit searches the source file
09:26timvisherfor instance, define a function at the repl
09:26timvisherand then try to source it
09:26Fossibut most of those don't have the sources ready
09:26timvisheryou get nothing
09:26nizzeBummer.
09:26nizzeHow can I access AST?
09:27nizzeI heard that Lisps are special cause I can access the AST at runtime.
09:27timvishernizze: this might help
09:27timvisherhttp://stackoverflow.com/questions/3782970/how-can-i-display-the-definition-of-a-function-in-clojure-at-the-repl
09:28timvisheri never bothered getting it working
09:28timvishernot sure exactly what you would mean by accessing the AST at runtime
09:28timvisherif you mean exposing the runtime AST as a datastructure, i've never heard of such a thing
09:28timvisherif you mean modifying the ast at runtime by simply redefining a function, then you can in fact do that easily
09:29clgvin clojure you can only access the definition of a function (via defn or fn) by intercepting the defining statements (defn/fn) via macros.
09:30nizzeUh. I thought that AST was available for me to toy with. I have to study more.
09:30timvisherthat's what i mean, you're not really being descriptive enough about what you mean
09:30clgvnizze: it can be easily implemented though.
09:30timvisherwhat does 'play with' to you mean?
09:30timvishermean to you*
09:30nizzeA sec:
09:31timvishers/to you mean/mean to you
09:31timvisherhmm
09:31timvisheris that supposed to work?
09:31nizzeWell.
09:32clgvnizze: easiest but not most elegant solution: (defmacro defn-ast [name & args] `(defn ~name {:definition ~args} ~@args))
09:32nizzeThere was a ruby project which let you write things like Users.all.select{|u| u.name == 'john'}.collect{|u| u.lastname}
09:32nizzeAnd turn that to SQL
09:33nizzeI start to get the feeling that I'm asking the wrong question.
09:33timvisherare you saying that's an example of playing with the ast?
09:34clgvnizze: you probably do
09:34nizzeYeah.
09:34timvisherhow is that playing with the ast?
09:34nizzeSo basically what they did there is access AST and looked what user tried to do in Ruby and turn that to SQL
09:34Vinzentnizze, you can do all this sorts of things (and much more) with lisp macros; see at clojureQL for example
09:35nizzeVinzent: thanks!
09:35clgvnizze: AST = Abstract Syntax Tree, right?
09:35nizzeclgv: Yeah.
09:35timvisheri'm not sure you understand the ruby code above, or maybe i don't
09:35timvisherthat looks to me like a DSL, not something that accesses the ast
09:36timvisherthey would take that and transform it into other code at run time and dynamically generate sql based on what you've typed
09:36nizzetimvisher: nono, That was just the regular Ruby code playing with collections.
09:36Vinzentnizze, about AST: I think what's you've heard was about lisp syntax. Programs are actually trees, so the code is much closer to AST than in other languages
09:36nizzeThe library did that "behind the scenes"
09:36timvisheryes
09:36timvisherbut that doesn't mean they're playing with the ast
09:37nizzeHmm. I try to find it.
09:37timvisherthe runtime is examining that 'string' of code and dynamically generating the real code that get's executed
09:37timvishermacros, as everyone else keeps mentioning, are the way you accomplish that in lisps.
09:38nizzeOkay.
09:38nizzeThanks for you trouble. I go study more now :)
09:38VinzentAnd macros transforms code in compile time, which is much faster that ruby's approach.
09:39timvishernizze: if you're in the mood to part with some of what's in your wallet, i'd recommend Joy of Clojure for getting a good flavor for what Macros can accomplish.
09:40nizzeThanks! I've been browsing LOL. For the very first chapters it was nicely written.
09:43nizzeYou guys are really nice. I once visited the CL channel and they started to flame me as soon as I asked a question about some old Lisp related rant.
09:43timvishernizze: good to hear. come back any time. :)
09:48clgvhmm how do I get a namespace from a symbol? namespace returns a string
09:48clgvand I cant use require with a string
10:20joegallo(require (symbol "clojure.set")) seems to work
10:21sandGorgonanybody know how to get the actual java command issued by leiningen when you do "lein repl" ?
10:22pjstadigclgv: the-ns?
10:22pjstadig(doc the-ns)
10:22clojurebot"([x]); If passed a namespace, returns it. Else, when passed a symbol, returns the namespace named by it, throwing an exception if not found."
10:51raeksandGorgon: you can at least get the -cp part by running lein classpath
10:52sandGorgonraek, thanks!
11:10nizzeHI!
11:10nizzeHow can I find which functions (or methods) operate on a string?
11:10nizzeIn OO-language I would look String class. What do I do in Clojure?
11:11sritchiehere are some good ones -- http://clojure.github.com/clojure/clojure.string-api.html
11:13nizzeThanks.
11:14ejacksonnizze: in general you'll find similar functions, like those for strings, in a single namespace.
11:14nizzeejackson: and what ns is that?
11:14ejacksonmy first guess would be clojure.contrib.string
11:15ejacksonnizze: here: http://richhickey.github.com/clojure-contrib/string-api.html
11:16sritchieno, it's a little different!
11:16sritchiethat's contrib, I gave clojure.string
11:16ejacksonaaaah
11:16sritchiewe also have http://richhickey.github.com/clojure-contrib/str-utils2-api.html
11:16sritchieand http://richhickey.github.com/clojure-contrib/str-utils-api.html
11:16ejacksonthere's also this one : http://richhickey.github.com/clojure-contrib/str-utils-api.html
11:16nizzeSo what's the deal with contrib? Is it some experimental stuff?
11:17ejacksonits kindof, but not exactly, like the standard libraries
11:28pcavs_What's the best way to restart lein swank while in emacs, assuming you've updated your dependencies.
11:28pdk[11:10] <nizze> In OO-language I would look String class. What do I do in Clojure?
11:28pdkit's still a java String since it's implemented on top of java, the String methods will still work with the interop forms
11:31wastreli'm going to install emacs and the whole clojure developering stack
11:35nizzeWhat is the recommended editor/ide for clojure?
11:36nizzeCan I use vi?
11:39pcavs_nizze: google vimclojure I believe is the usual setup for VIM
11:39nizzepcavs_: Thanks! What is considered "the editor" here? I guess it's Emacs?
11:40pcavs_uhh, VIM would be the editor
11:40Chousukeuse any editor you want
11:40pcavs_I think it uses something similar to swank/slime although I'm honestly not sure
11:40Chousukeemacs has slime and paredit so it's pretty popular among lispers
11:40dnolenalso slimv for Vim
11:41ChousukeI wonder if there's a vi clone written using some lisp anywhere
11:41dnolenChousuke: well you do have viper-mode
11:41lnostdal-laptopemacs has a vim mode i think
11:41lnostdal-laptopyup
11:41nizzeviper
11:41Chousukednolen: vipermode is bad though
11:42Chousukeit just doesn't work with most emacs extensions. at all
11:42kryftIsn't vimpulse much better?
11:42Chousukekind of defeats the whole point of using emacs.
11:42Chousukenah
11:42Chousukeit's a bit better but not by much
11:43kryftIsn't it orthogonal to emacs modes, meaning that it should work with extensions?
11:43nizzeOkay. I already got accustomed to vim. So using vim with some slime plugin should be ok?
11:43tufflaxnizze: yes emacs is "the editor" :P I think pcavs_ did not interpret your question the way you meant it
11:43dnolenChousuke: really? Some people seem to really like it. But perhaps vim users are used to not demanding much from their editor
11:43dnolennizze: you should be fine with Vim yes.
11:43tufflaxnizze I use vim with vimclojure and im pretty happy
11:44nizzeOkay, thanks.
11:44tufflaxnizze you should take a look at leiningen and lein-vimclojure too i guess
11:48nizzeOkay. Leningen. Is that a de facto build tool for Clojure?
11:48nizzeI loathe Maven and the like.
11:48nizzeNo xml for me pls.
11:48coopernurselein avoids xml
11:48coopernursebut lets you rope in maven dependencies if you need them
11:48tufflaxit's the most popular I guess, but there is also cake and maybe some others
11:52nizzeHow about testing? What is Clojure community's take on testing?
11:57tufflaxI imagine the community likes it. lein can help you out a bit there too
11:59wastrelhi
11:59wastreli have been using vi/vim for 20 years
12:00Vinzentnizze, you should definitely try Midje for testing - it's awesome!
12:01nizzeVinzent: thanks.
12:03wastrelwhat's midje?
12:03tufflaxa testing framework
12:04Vinzenthttps://github.com/marick/Midje
12:06wastrelmy favorite answer to any technology question "it's a framework" :]
12:07Vinzentlol :)
12:20bsod1how can I see result of macroexpand or macroexpand-1? it returns something like #<user$problem_2 user$problem_2@864dfeb>
12:20raekbsod1: macroexpand needs the code in quoted form
12:21raek,(macroexpand '(if-not a b c))
12:21clojurebot(if (clojure.core/not a) b c)
12:21bsod1raek: can I send it a function like in Common Lisp?
12:21mattmitchellI'm trying to use resolve, but the value I'm passing in is a keyword -- which doesn't work. How can I convert a keyword into something resolve wants?
12:22raekbsod1: what happens when you give it a function in common lisp?
12:22bsod1raek: it expands the function's code and prints(at least in REPL)
12:23technomancyCL has interpreted mode as well as compiled, so it keeps the source around. clojure is only compiled.
12:23technomancyhowever
12:23technomancyclojurebot: serializable-fn
12:23clojurebotNo entiendo
12:23technomancyclojurebot: get with the program
12:23clojurebot"There has to be something a little wrong with you for you to be a really good programmer." -- L Peter Deutsch
12:23dnolenmattmitchell: convert the keyword to a symbol? seems like a weird thing to do tho.
12:23raekmattmitchell: are you trying to use a namespace like if was a map?
12:23technomancyclojurebot: serializable-fn is a hack for preserving source of a compiled function: https://github.com/technomancy/serializable-fn
12:23clojurebotc'est bon!
12:24mattmitchellraek dnolen: I have a list of function names as keywords, I want to loop through those names and call corresponding functions
12:25raekmattmitchell: my approach would have been to make a map from keywords to functions
12:26raekespecially if the keyword comes from a (possibly "evil") user
12:27mattmitchellraek: good idea, I'll try that instead
12:27raekmattmitchell: but you can use namespace and name to extract the parts before and after the /, and then call symbol woth those
12:27raek*with
12:27mattmitchellraek: ok cool got it, thanks
12:28tufflaxmattmitchell i did something similar http://pastebin.com/tDs5p2KH
12:29raekmattmitchell: but beware of the security implications, etc etc
12:29mattmitchelltufflax: thanks! i'll check it out.
12:29mattmitchellraek: yeah you're right. thanks for pointing that out.
12:32micahmartinleiningen question: Custom tasks need to be in src/leiningen or else their not found. However 'lein jar' fails because custom tasks depend on leiningen but leiningen in not in the classpath. Is there a common resolution?
12:33micahmartintechnomancy: where should custom lein tasks go if not in src/leiningen?
12:34technomancymicahmartin: lein jar shouldn't fail
12:34technomancyunless you have :aot :all
12:34micahmartinI do
12:35micahmartinkinda need it because I'm doing some dynamic loading
12:35technomancyI guess you need to move the tasks into a plugin if you can't stop using :aot :all
12:35technomancyor define them in project.clj
12:36technomancy(ns leninigen.foo)(defn foo [project] )
12:37technomancy:aot :all is meant more as a convenience thing so you can do quick sanity checks to see if everything compiles
12:37technomancyyou could also do :aot #"myproject"
12:38micahmartinoooh... does that filter by namespace?
12:38technomancyyup
12:39technomancygenerally given transitive AOT you can just specify a single ns and all the ones it requires will be aot'd too though
12:40micahmartinIs there any way to add to lein
12:41micahmartin... lein's default classpath (when it searches for tasks)?
12:41technomancyyou can export CLASSPATH
12:42micahmartin:) old school!
12:44micahmartinIf I submited a patch to make leiningen add configured :resources-path, :dev-resources-path, :source-path, etc... to the CLASSPATH, would you accept?
12:44technomancyunfortunately that can't be done; by the time project.clj is read it's too late
12:45technomancyunless you want to write a clojure parser in sh =)
12:45micahmartingood point...
12:45micahmartinwhat about supporting a .classpath file?
12:45technomancysure; that'd be fine
12:46micahmartinYou'd accept a patch for that?
12:46technomancyyeah
12:46micahmartinsweeet!
12:46micahmartinyou'll have it later today
12:47technomancywill probably have a 1.6.1 release given the bug with hooke in 1.3 that was found last night
13:04halfprogrammeranybody checked out google+?
13:09tufflaxHm. I had a problem with nesting map calls so deep that the I got a stackoverflowerror. But not in a loop/recur or reduce, instead I was saving a map in an atom representing a player in my game, and each frame I calculated the position (a list of x and y) from the old one with a map call. And when I printed the player map, I got the error. What I find strange is that another part of the program used that position every frame. Shouldn't that
13:14S11001001tufflax: might the map you're putting in the atom be a map containing the atom?
13:15tufflaxno
13:16tufflaxWhen I said map calls I meant the fn map, eg (map prn [1 2 3])
13:17raektufflax: try surrounding the map call with (doall ...)
13:17tufflaxyes i did, but I wanna know what was going on
13:18raektufflax: also, your message was clipped after "Shouldn't that"
13:18tufflaxShouldn't that have realized the list? And if not, shouldn't that other function have caused the stackoverflowerror?
13:19raekthe seq is only forced when you look at the first element
13:19S11001001tufflax: map doesn't do anything until you seq it, whether by first or whatever
13:20S11001001,(do (map nil 42) true)
13:20clojurebottrue
13:20raekthe lazy-seq represents something like (map f (map f (map f (map f ...))))
13:20raekeach update adds a layer of laziness
13:20raekwhen the outermost seq is forced, it must ask the seq one step inwards for it value, which must ask the next, and so on
13:21raekeach forcing requires at least one function call stack frame
13:22tufflaxyes i know, but every frame x and y were used to draw the player. So, ok, first: If a have an unrealized such seq (map (map (map ...))) in a data structure, and then use it, will the data structure now contain the realized list or still the same unrealized seq?
13:23tufflaxWill the seq morph into a realized seq inside the immutable datastructure?
13:23S11001001yes
13:24tufflaxthen i dont understand whats happening in my program :p
13:30tufflaxraek S11001001 take a look: http://pastebin.com/ENJ4w8eG
13:30pcavs_what do people use for sql libraries in clojure? clojureql or clojure.contrib.sql?
13:32raektufflax: yes, lazy-seqs mutate internally when they are computed (they do so in a thread safe manner, of course)
13:33S11001001tufflax: I imagine it's because you never forced the (rest (rest pos))
13:34raekmaybe the rest of the rest of the seq is never forced... :7
13:34S11001001I don't think the [x y] destructuring will force the rrest
13:34amalloy&(destructure '[id [x y]])
13:34sexpbot⟹ [id [x y]]
13:34amalloyfeh
13:34tufflaxoh, maybe... im gonna have to think about that, now i have to eat. thank you, back later
13:35amalloy&(macroexpand '(let [[id [x y]] fn-args])
13:35sexpbot⟹ (let* [vec__11920 fn-args id (clojure.core/nth vec__11920 0 nil) vec__11921 (clojure.core/nth vec__11920 1 nil) x (clojure.core/nth vec__11921 0 nil) y (clojure.core/nth vec__11921 1 nil)]) ; Adjusted to (macroexpand (quote (let [[id [x y]] fn-args])))
13:36raek,(letfn [(lazy-bomb [n] (lazy-seq (if (zero? n) (println "BOOM!") (cons n (lazy-bomb (dec n)))))] (let [[x y] (lazy-bomb 2)] [x y]))
13:36clojurebotUnmatched delimiter: ]
13:37raek,(letfn [(lazy-bomb [n] (lazy-seq (if (zero? n) (println "BOOM!") (cons n (lazy-bomb (dec n))))))] (let [[x y] (lazy-bomb 2)] [x y]))
13:37clojurebot[2 1]
13:37raek,(letfn [(lazy-bomb [n] (lazy-seq (if (zero? n) (println "BOOM!") (cons n (lazy-bomb (dec n))))))] (let [[x y] (lazy-bomb 1)] [x y]))
13:37clojurebotBOOM!
13:37clojurebot[1 nil]
13:37raekthis explains it
13:38wastrelbomb!
13:38S11001001sneaky cdr
13:40amalloyraek: and he can verify it by seeing that (println (take 2 whatever)) prints fine, while (println whatever) doesn't
13:41S11001001insert debugging print, code suddenly works
13:43amalloyraek: or...maybe not? if he never forces the tail of the sequence, he may not run out of stack but he'll keep growing heap, won't he? all these lazy-seqs stacked on top of each other have to hang around just in case he ever wants to detonate the bomb
13:44S11001001yeah, and the naming of the binding where the map result goes implies that tufflax meant to use vec there
13:45amalloyS11001001: vector as in mathematics, not clojure's data structure
13:45amalloyi doubt he ever cared what the underlying type of that intermediate sequence was
14:27amalloycemerick: what's git --version say?
14:27amalloyi ask because your issue sounds like https://github.com/blog/809-git-dumb-http-transport-to-be-turned-off-in-90-days
14:28cemerickheh, probably something horribly out of date
14:28cemerick1.6.2.2! :-P
14:29cemerickYup, that's probably it
14:29cemerickamalloy: thanks, that probably saved me some wasted network diagnostic time
14:42tufflaxamalloy raek S11001001 thank you. I tried with (take 2 pos) and that didn't blow up. But I'll use doall now that I know what is happening. :)
15:06jcromartieis there any mechanism within clojure.test that allows you to check simple code coverage?
15:06jcromartielike, what defns are covered and what aren't, etc?
15:07technomancyjcromartie: radagast does that. it's pretty simplistic though.
15:08hiredmanI really wish git kept a .history
15:09jcromartieI guess the easiest way would be to keep tests directly in-line with what they are testing
15:09jcromartiein metadata
15:09jcromartiewait that's what deftest already does
15:12technomancyjcromartie: that tells you nothing about indirect coverage
15:12jcromartieno I read it wrong... I assumed deftest re-def'ed whatever name you passed it
15:14amalloyhiredman: what would it do?
15:18hiredmanamalloy: n-last branches checked out
15:18amalloyhiredman: the reflog does that
15:19hiredmanwell damn
15:19hiredmanalright then
15:19amalloywell. it records them. i'm still not entirely clear how you'd want to use it. but $ git reflog show HEAD will tell you all the commits HEAD has pointed at recently
15:19jcromartiezipmap is wonderful
15:21hiredmanamalloy: mostly I want to be able to figure out which branch I was working before I got interrupted by something else, without having to go through the issue tracker, find which issue it was and then map from issue to branch
15:21amalloyah cool. so it sounds like the reflog is the answer
15:21matthias__hmm, i've been writing a game using penumbra for a while now, i tried adding a new library but then got an error... which seems to be actually penumbra related. i reverted all the changes i made about that new library and now i get an error message saying "geometry.clj:1:1:
15:21matthias__ error: java.lang.Exception: Unable to resolve symbol: dimension in this context (geometry.clj:35)". i've looked, there's no "dimension" in geometry.clj (that is one of penumbra's files).
15:22hiredmanamalloy: looks like it is, thanks
15:23wastrelpenumbra is i think the name of a game
15:40jcromartieyes
15:41jcromartiepenumbra is a horror game
15:41jcromartieis there a way to access nested keys like the way update-in works?
15:41jcromartielike, to just get the value?
15:41mattmitchellto document a function with multi arity arg sets, do you have to add a doc string for each variant?
15:42mattmitchell,(defn c [])
15:42clojurebotDENIED
15:42jcromartieget-in
15:42jcromartiederp
15:42amalloymattmitchell: no, and you're not allowed to
15:43amalloy(defn c "explain all the arities here" ([]) ([x] x))
15:43jcromartieI was originally annoyed by that, and by not being able to add a docstring for defmethod... but then I realized why.
15:44matthias__oenumbra is a clojure library
15:44jcromartieIf your multimethod is so complex that each dispatch value deserves its own documentation then you are Doing it Wrong™
15:44matthias__*pen
15:44jcromartiematthias__: yes but there is also a game
15:44matthias__but i wasnt talking about that oO
15:44mattmitchellamalloy: oh right, thanks!
15:45jcromartie:) someone mentioned that they thought it might be a game
15:45jcromartie"wastrel: penumbra is i think the name of a game"
16:17jcromartieis this channel publicly logged?
16:17jcromartieclojurebot: logs
16:17clojurebotlogs is http://clojure-log.n01se.net/
16:17jcromartieI knew he'd have an answer.
16:18jcromartie(inc clojurebot)
16:24hiredmanhttp://thelastcitadel.com:3000/?page=0&amp;q=channel%3Aclojure
16:30amalloyjcromartie: sexpbot keeps a log too. so that's at least three logs
16:32amalloyhttp://www.raynes.me/logs/irc.freenode.net/clojure/today.txt
16:33amalloydangit, today isn't symlinked right? i guess http://www.raynes.me/logs/irc.freenode.net/clojure/2011-06-30.txt works. Raynes, what's up with the today thing?
16:48bartjwhat is the best library to get tf-idf scores using Clojure ?
16:54mikesomethingwhat's the clojure equivalent of "synchronized(someObject) { ... }" ?
16:54mikesomethingdosync doesn't seem to do that
16:55hiredmanare you sure you want a lock?
16:55mikesomethingyes
16:55hiredman,(dock locking)
16:55clojurebotjava.lang.Exception: Unable to resolve symbol: dock in this context
16:56hiredman,(doc locking)
16:56clojurebot"([x & body]); Executes exprs in an implicit do, while holding the monitor of x. Will release the monitor of x in all circumstances."
16:56scgilardi,(doctor locking)
16:56clojurebotjava.lang.Exception: Unable to resolve symbol: doctor in this context
16:56mikesomethingprobably doing it wrong, but i have a zillion threads working hard and the final output is a quick-write/append to a textfile i want to lock on that output operation
16:58technomancymikesomething: a common idiom is to serialize through an agent
16:59mikesomethingwhat are agents?
16:59hiredman~agents
16:59clojurebotexcusez-moi
17:01technomancyhttp://clojure.org/agents
17:01amalloyyes, agents are the usual solution to this problem
17:02mikesomethingthe lock increased my running time just on the output (i thought it was quicker) by 12%
17:02mikesomethingcan someone give me a small hand-waving about what promises are all about?
17:03pcavs_Hey! I want to create a macro that takes a body, but I want a value bound to a symbol that the body could operate on. Is this possible?
17:03pcavs_In this case I have an ephemeral result set that will get blown away when I step outside of the scope
17:04chousermikesomething: a promise is a reference object, that is you can deref it to get what's inside.
17:04Chousukesomething like `(let [~'a-name foo] ...)
17:04amalloypcavs_: i dont' understand what you want, but it is possible
17:04Chousukethen a-name can be referred to from whatever ... is
17:04chousermikesomething: ...unless there's nothing inside, in which case your deref will block until something is put in there.
17:04pcavs_Chousuke, I saw something else like ~' what does that do?
17:04bartjchouser, usually associated with futures ?
17:04mikesomethingso i can create a bunch of promises
17:04mikesomethingand they just sit there lazily until i deref?
17:04Chousukepcavs_: it puts the symbol as is in the expansion (within syntax-quote)
17:05mikesomethingor do they execute when they can?
17:05Chousukecompare
17:05chouserbartj: not necessarily, but only useful if you've got more than one thread.
17:05Chousuke,`(let [a 1] ...)
17:05clojurebot(clojure.core/let [sandbox/a 1] ...)
17:05Chousuke,`(let [~'a 1] ...)
17:05clojurebot(clojure.core/let [a 1] ...)
17:05pcavs_oh okay, as opposed to just ~
17:05pcavs_which does what differently?
17:05chousermikesomething: a promise doesn't have anything in it when you create it. It's just an empty box until some other thread delivers to it.
17:05Chousuke,`(let [~a 1] ...) ; doesn't work
17:05clojurebotjava.lang.Exception: Unable to resolve symbol: a in this context
17:05Chousuke,(let [a 'some-symbol] `(let [~a 1] ...)) ; does work
17:05clojurebot(clojure.core/let [some-symbol 1] ...)
17:06mikesomethingso if i put a closure into a promise, what happens?
17:06amalloymikesomething: then...you'll have a promise, with a closure in it
17:06chousermikesomething: when you deref the promise, you'll be given a closure
17:07mikesomethingmaybe i'm not getting it, what's a tiny real-life example of promises
17:07Chousukepcavs_: so basically ~ is a feature of syntax-quote that evaluates the following expression in the local context and uses that in the expansion.
17:07pcavs_,(defmacro [& body] (let [~'results (list 1 2 3)] ~@body))
17:07clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
17:07Chousukepcavs_: evaluating 'a results in just the symbol a which is why ~'a gets around the namespace qualifying mechanish
17:08Chousukemechanism*
17:08pcavs_Chousuke, ahh I see
17:08pcavs_Makes sense.
17:09Chousukepcavs_: you need to use syntax quote before that (let..., otherwise it's just a let, not a data structure :P
17:10chousermikesomething: hm, let's see. there's a section of this book here entitled "when to use promises"
17:10Chousukepcavs_: note though that pulling variables out of thin air is usually not a good idea, so be careful.
17:10pcavs_yeah..what's a better idiom then?
17:10Chousukepcavs_: if you must, make your macro take another argument that the results get bound to
17:11Chousukeso that the macro call looks something like (foo [res] bodyhere)
17:11pcavs_the other variable would need to be syntax symbol quoted though right?
17:11Chousuke(vector is optional but most binding things use vectors so it's idiomatic)
17:11hiredmanmikesomething: if you have thread A doing X and thread B doing Z and Z depends on some but of data from X, Z can do as much as it can in parallel to X and then block until the bit it needs is available
17:12mikesomethingoh ok
17:12hiredmansimilar to using a transfer queue, but single shot
17:12mikesomethingso it's for mutually inclusive threaded operations and prevents deadlock?
17:12Chousukepcavs_: (defmacro foo [[arg] & body] `(let [~arg (list 1 2 3)] ~@body))
17:12hiredmanI dunno about prevents deadlock
17:14hiredmanI also end up using promises to turn void java methods into fns that return something
17:15amalloyhiredman: how do you mean?
17:16hiredmanlike, if you have some set of visitor pattern interfaces
17:17hiredmanso you have VisitorThing ThingYouVisit and ThingYouVisit has a .visit method that returns void and takes a VisitorThing you can reify VisitorThing and have it deliver data to a closed over promise
17:17amalloyi see
17:18hiredmanhttps://github.com/hiredman/agilezen-jdbc/blob/master/src/agilezen_jdbc/core.clj pretty horrendous example usage with a SQL statement parsing library that uses visitors
17:23pcavs_,(defmacro foo [[arg] & body] `(let [~arg (list 1 2 3)] ~@body))
17:23clojurebotDENIED
17:26pcavs_Chousuke: I don't think that works.
17:31tnbdHello, just wanted to ask whether anyone is creating a starter package for the next ai contest http://aichallengebeta.hypertriangle.com/
17:32amalloypcavs_: works fine
17:32amalloy(foo [x] x) yields (1 2 3)
17:35dnolentnbd: doesn't seem like it.
17:36ibdknoxtnbd: I might
17:36pcavs_amalloy: I am stupid. Thanks.
17:36ibdknoxI would definitely like to do it this year
17:36ibdknoxnot sure how busy I'll be though :(
17:42ibdknoxif we wanted to take the easy way out I guess we could wrap the java one...
17:42ibdknoxhttps://github.com/aichallenge/aichallenge/tree/epsilon/ants/dist/starter_bots/java
17:50pcavs_Chousuke , amalloy: Why choose the have [arg] be in a vector? You metnioned it's idiomatic, but why is that the idiomatic decision. Usually there is some underlying reason, just wondering why.
17:51Chousukepcavs_: often times you want more than one binding so a vector if bindings makes sense
17:51amalloypcavs_: compare to common lisp: (let ((x 1) (y 2)) (+ x y))
17:51pcavs_mmhmm, makes sense
17:52amalloythere are a lot of parens: some are for grouping, and some are to call functions (or macros)
17:52amalloyclojure uses vectors for bindings so that lists usually mean "this is code"
17:52amalloy(and it can't use bare symbols for the reason Chousuke gives
17:55hiredman(let x 1 y 2 :in (+ x y))
17:55bsod1I really love vim but vimclojure REPL under vim is too slow, any advices?
17:56amalloyhiredman: fair enough, i suppose
17:56dnolenhiredman: keep that ML stuff outta here!
17:57hiredmanor, get this, no more implicit do
17:57hiredman(let x 1 y 2 (+ x y))
17:57hiredmanmore like cond
18:13derp__I am trying to figure out how to use agents, and I am getting kind of confused
18:13derp__this is my def for an agent: (def a (agent (fn [new-str] (println "Hello, " new-str "!"))))
18:14derp__but when I run (send a "world") I get an error
18:14amalloyderp__: agents hold values, and are sent functions
18:16amalloy&(let [a (agent "test")] (send a (fn [old new] (str old new)) "more") (await a) @a)
18:16sexpbotExecution Timed Out!
18:16amalloythat's wrong. in my repl it prints "testmore" immediately
18:17derp__amalloy: ah, thank you for clearing that up
18:17amalloyderp__: all of clojure's reference types behave that way: hold types, receive functions
18:17amalloyer
18:17amalloyhold values
18:18hiredmanamalloy: sexpbot's threadpools are most likely shutdown
18:18hiredman,(let [a (agent "test")] (send a (fn [old new] (str old new)) "more") (await a) @a)
18:18clojurebot"testmore"
18:20mikesomethingwith lazy-seq can i write tail-recursive functions without regarding to the recursion stack limit of 5000?
18:21amalloyhiredman: oh snap. did someone call shutdown-agents on him? that's mean
18:21derp__amalloy: just to double check, when sending a function to an agent, the current agent value will always be the arg, correct?
18:21derp__the first arg*
18:21dnolenmikesomething: pretty much.
18:21amalloywill always be the *first* arg
18:21hiredmanamalloy: most likely it was swank-clojure
18:22derp__amalloy: thanks
18:22dnolenmikesomething: the main thing that doesn't work with lazy-seqs from I can tell is CPS style code, that requires trampoline.
18:22scottjbetter way to write this? (cond (:completed task) :completed (:canceled task) :canceled (:started task) :started :else :new)
18:23hiredmanscottj: I would added a field like :state to task
18:25amalloy(or (some #(% task) [:completed :canceled :started]) :new)?
18:25scottjhiredman: mostly just interested in better way to write a cond like that.
18:25vagifhello, i wrap an exception in my own and throw it, but when i catch it my wrapper is not there. The stack trace starts from original error
18:25amalloyi guess that's not right
18:25amalloyreplace some with (comp first filter), as so often seems to happen :P
18:25scottjhiredman: in this case I think makes sense to track separately cause task could be started then canceled and I might want to know that
18:26technomancyscottj: there's always reduce
18:27derp__if I have a function that's treated as data (such as '(println "Hello)) how would I turn that into a piece of callable code?
18:28derp__I get (eval '(println "Hello world"))
18:28dnolen,(or (some #(and (% {:completed true}) %) [:completed :canceled :started]) :new)
18:28clojurebot:completed
18:28dnolen(or (some #(and (% {:foo 'bar}) %) [:completed :canceled :started]) :new)
18:28dnolen,(or (some #(and (% {:foo 'bar}) %) [:completed :canceled :started]) :new)
18:28clojurebot:new
18:28derp__but I don't get how I can turn something like (def hello '(println "Hello world!")) can be evalled
18:28derp__into something to be evaluated*
18:29mikesomethingderp
18:29mikesomethingwrap it in a clojure
18:30mikesomething(def hello #(println "Hello world!"))
18:30mikesomething#'user/hello
18:30mikesomethinghello
18:31derp__I thought # was a compile-time macro
18:31amalloyderp__: answer: stop trying to pass around code forms at runtime
18:32amalloyyou can do it, because of eval, but you shouldn't unless you're doing some very low-level stuff like implementing an IDE
18:33hiredmanscottj: I don't see what that has to do with it
18:33amalloyinstead, use macros to construct the forms you want at compile time, or first-class functions to pass around "code snippets" enclosed in functions at runtime
18:33hiredman(defrecord task [state log])
18:33derp__I just think it would be kind of interesting, to make it so that agents are smarter than simple users of functions
18:34ibdknoxderp__: in what way?
18:34amalloyhuh? what feature do you envision becoming possible?
18:36derp__I don't really have a plan, I just want to play around with it and see what's the easiest way of doing something
18:36derp__I mean I am assuming that I'm taking the wrong/long way to accomplish this, but I just thought it would be an interesting piece of behavior to look at
18:37derp__idk
18:43scottjhiredman: fair enough, for now I prefer being able to do (:started task) instead of defining a predicate that looks through the log and see if there was a state :started that's not followed by an undo. but I suspect there are some benefits to your model I'm missing
18:44dnolenderp__: (do (def x '(println "Hello world")) (eval x)), will work. But know that eval won't have access to locals (if you're used to the behavior of JS for example)
18:45dnolenderp__: also eval is crazy slow since it's actually compilation.
18:47derp__dnolen: thanks. But what do you mean eval is slow? I thought the whole point of lisp was to play with the program<->data representations, and eval is the only convert data->program, right?
18:47amalloytechnomancy: your tweet confuses me. didn't we prove last night that that's *not* what's happening?
18:47amalloyderp__: no! *macros* are the best way to convert data to a program
18:48amalloyeval is indeed crazy slow, just like in any other language
18:49gfrlog`(binding [*macros* "lots"] (eval '(println "twelve!")))
18:49derp__amalloy: but macros only run at compile time, right? so no one really plays with that stuff in running programs?
18:49amalloymhm
18:49amalloyif you are writing your program at runtime, you're doing it wrong
18:50technomancyamalloy: I think your gist may have shown that it's more complicated when functions are let-bound
18:50amalloytechnomancy: my conclusion was that it has nothing to do with metadata: the "foo" in (fn foo [x]) is bound to java's "this"
18:51amalloycode<=>data is appealing because it's easy to hook into the compiler: you just write a function that takes some data, returns some other data, and suddenly you've written a piece of the compiler for your program
18:52amalloytechnomancy: so that when you attach metadata to a function f, you get out a new function, with the same class but a different this reference; then it compares whatever you call it on against *itself* instead of the original function
18:52technomancyamalloy: hum... I see
18:53amalloyi'm still not *entirely* sure that's what's going on, though. do you know a good way to test it on something other than meta?
18:53technomancyif that's the case then the 1.3 behaviour is quite strange
18:54amalloytechnomancy: actually i think i am sure. https://gist.github.com/1055630 shows that a function's "name" is returning itself
18:54amalloy(the second part, specifically)
18:56mikesomethingi think a program i wrote in clojure might be damaging my computer :-D too hot too the touch
18:57technomancyamalloy: it's [true false] in 1.3 though
18:57technomancythe plot thickens
18:58dnolenderp__: eval has it uses, but they are limited. macros let you manipulate programs as data just fine.
18:58amalloyyeah. both behaviors seem to make sense to me, so unless someone points out a ticket it's not clear which version has a bug
18:59hugodis it possible to get the type hints from the fields of a deftype?
18:59technomancy(identical? f (m)) ; true in 1.3
19:00dnolenhugod: with reflection I would think.
19:00amalloy*nod*
19:00hiredmanhugod: at runtime?
19:00hugodyes, at runtime
19:00hugodI can't see it via reflection
19:01hiredmanwell, you can get the types of the fields, I believe
19:01hugodwhich is Object
19:01hiredmanreally?
19:01hiredmanHuh
19:01amalloyi know defrecord doesn't support storing anything but Object or primitives
19:02hugod,(bean (first (.getFields (deftype t [^String s]))))
19:02clojurebot{:declaringClass sandbox.t, :class java.lang.reflect.Field, :synthetic false, :enumConstant false, :accessible false, :name "s", :declaredAnnotations #<Annotation[] [Ljava.lang.annotation.Annotation;@6788c4>, :genericType java.lang.Object, :type java.lang.Object, :modifiers 17, ...}
19:02amalloyi wouldn't be surprised to see deftype is the same
19:02hiredmanamalloy: oh, good point
19:03amalloy,(t "test")
19:03clojurebotjava.lang.Exception: Expecting var, but t is mapped to class sandbox.t
19:03amalloy,(t. "test")
19:03clojurebot#<t sandbox.t@d69cff>
19:03technomancyamalloy: what do you call "inner" anyway?
19:03technomancyan internal "anonymous" function name?
19:04amalloytechnomancy: i usually don't call it anything, in words. i might call it a self-reference
19:04amalloythe compiler calls it "thisFn"
19:04amalloyor something similar
19:05hiredmanit is literally the reference to the current object which happens to be a fn
19:05amalloythisName
19:07technomancyhiredman: so now instead of copying f, with-meta just creates a new function that delegates to f?
19:08hiredmantechnomancy: huh?
19:09technomancyI thought you mentioned that last night
19:09technomancywhich is why "inner" never refers to m
19:11hiredmanwhy would it delegate to f?
19:11technomancyclojurebot: optimization is "What a tangled web we weave, when first we practice to optimize."
19:11clojurebotIk begrijp
19:12technomancymaybe I misheard you?
19:12hiredmanyou would just call .clone or whatever
19:14hiredman(actually looks like the compiler just new's up another instance of the fn's class with the metadata)
19:14amalloytechnomancy: AFunction.java looks like it does delegate, and git blame puts that commit in march
19:15amalloyand it *seems* like FnExpr in Compiler.java creates an AFunction, but it's hard to be sure
19:16hiredmanamalloy: but it also generates it's own withMeta method if the Fn has metadata
19:17amalloyhiredman: "it" here refers to what?
19:17hiredmanFnExpr
19:18amalloyoh jeez. i haven't gotten into the bytecode-generation at all yet; so far reading the parse() methods has been enough to satisfy my curiosity
19:18hiredmansomewhere around 4096
19:18hiredmanah, well, bytecode generation is disgusting
19:20amalloyhiredman: but i'm not sure that code is getting executed? it looks like a withMeta function is generated only if there's metadata in the original function declared; the example technomancy and i put together involves adding meta to a function that didn't start with any
19:21hiredmanso AFn and delegation is a fallback
19:22hiredmanAFunction
20:07devnhello all
20:22pmbauer,(reductions * (take 20 (iterate 0 inc)))
20:22clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
20:23gfrlog`,(doc reductions)
20:23clojurebot"([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
20:24gfrlog`pmbauer: ##(iterate inc 0)
20:24sexpbotExecution Timed Out!
20:24gfrlog`not sure why I wanted sexpbot to eval that
20:24gfrlog`but the point is you swapped the args to iterate
20:25gfrlog`on another note, (take 20 (iterate inc 0)) <=> (range 20)
20:27dnolen,(seq (take 20 (iterate inc 0)))
20:27clojurebot(0 1 2 3 4 5 6 7 8 9 ...)
20:28dnolen,(type (seq (take 20 (iterate inc 0))))
20:28clojurebotclojure.lang.Cons
20:28dnolen,(type (seq (range 20)))
20:28clojurebotclojure.lang.ChunkedCons
20:29gfrlog`dnolen: (take 20 (iterate inc 0)) <~> (range 20) ;)
20:30gfrlog`,(= (range 20) (take 20 (iterate inc 0)))
20:30clojurebottrue
20:30gfrlog`that much is true at least :)
20:31pmbauer,*clojure-version*
20:31clojurebot{:major 1, :minor 2, :incremental 0, :qualifier ""}
20:32pmbauer@gfrlog, thanks ... trying out the clojurebot, it's kinda cute
20:33gfrlog`~botsnack
20:33clojurebotthanks; that was delicious. (nom nom nom)
20:37tufflaxhehe
21:03seancorfieldis there a simple way to filter a map so it only contains a specific set of keys? a map intersection sort of function?
21:04technomancy,(doc select-keys)
21:04clojurebot"([map keyseq]); Returns a map containing only those entries in map whose key is in keys"
21:04hiredman,(doc select-keys)
21:04clojurebot"([map keyseq]); Returns a map containing only those entries in map whose key is in keys"
21:04technomancyclojurebot: double double your refreshment
21:04clojurebotTitim gan éirí ort.
21:12seancorfieldtechnomancy: thanx!!!
21:25seancorfieldi don't suppose there's some magic function that allows you to easily rename a single key in a map?
21:26seancorfieldso far i have (merge (dissoc record :old-key) {:new-key (:old-key record)}) which seems ugly
21:28seancorfieldi could also do (conj (dissoc record :old-key) [:new-key (:old-key record)]) which is probably better...?
21:29seancorfield,(doc rename-keys)
21:29clojurebotGabh mo leithscéal?
21:30seancorfield,(doc clojure.set/rename-keys)
21:30clojurebot"([map kmap]); Returns the map with the keys in kmap renamed to the vals in kmap"
21:36amalloyseancorfield: fwiw rename-keys looks like it's rebuilding the whole map from scratch; if you have a very large map and want to just rename one key, the assoc/dissoc approach will be faster
21:38seancorfieldok, good to know, thanx amalloy
21:38seancorfieldit's a very small map so i'm not worried in this case
21:39gfrlog`$findfn 8 -8
21:39sexpbot[clojure.core/unchecked-negate clojure.core/-]
21:47gfrlog`,(take 20 (iterate #(->> % - (+ (-> % int (* 2))) inc (/ 1)) 1))
21:47clojurebot(1 1/2 2 1/3 3/2 2/3 3 1/4 4/3 3/5 ...)
21:48gfrlog`fun fact: ^ that sequence contains all the positive rational numbers with no repeats
21:48amalloygfrlog`: since when are there only twenty of those?
21:48seancorfield:)
21:48gfrlog`since I didn't want to crash clojurebot :P
21:49pdkdoesn't it have safeguards against an infinite seq anyway
21:49gfrlog`,(range)
21:49pdkheck it already truncates the list on its own
21:49clojurebotExecution Timed Out
21:49pdkhmmmm
21:49pdkwonder if you could start connections from it with java connection objects
22:06sunniboquestion: i made a WAR file with compojure, hiccup, ring, ... and deployed to my jetty server. so i can connect to http://myserver.com/mywar. everything works well. but i have a link to my website, like /dosomething. when i test this web app in my computer (with lein ring server) i made <a href="/dosomething"> link and (GET "/dosomething/" ... ) in defroutes and worked well. but when i deploys
22:06sunnibomy WAR to jetty, that link points to http://myserver.com/dosomething/, not http://myserver.com/mywar/dosomething/. how can i handle this problem?
22:11Deranderpdk: clojurebot running on clojurebot
22:11pdkUH OH
22:11pdkcould even make it spawn a second nick
22:12pdkand spam messages to activate the first one!
22:12Deranderthereby creating a third
22:12amalloysunnibo: someone said something about root wars in here the other day
22:13amalloyit fixed the problem you were having
22:14sunniboamalloy, thanks. i'm looking for it
22:30scottjsunnibo: or maybe search context on compojure ml
22:30scottj"context"
22:31sunniboi tried to make a code like <a href="dosomething">... but the generated code always has the prefix '/'. <a href="/dosomething">... i think this is a problem. my css file loaded well, actually.
22:32sunniboscottj: thanks
22:34sunniboa relative anchor link is prohibited? @.@
22:36sunniboor is there any way to get the current URL in my program (with compojure)?
22:40sunnibooh. plz forget my question. i made a couple of stupid mistakes :(
22:52matthias_i'm trying to use break, but it says "java.lang.IllegalStateException: Var swank.core.connection/*current-connection* is unbound.
22:52matthias_" how does that happen?
22:53hugodmatthias_: it only works when the break is on your repl thread
22:56sunnibo(link problem solved) anyway, how can i redirect my page to WAR root? i'm using ring.util.response.redirect. (redirect "/") redirects to my web site's root /. http://myserver.com/ , i want to redirect to http://myserver.com/mywar.
23:04odie5533Who uses Clojure?
23:06hiredmanhttp://clojure02.managed.contegix.com/display/community/Clojure+Success+Stories
23:34devnmatthias_: gauger?
23:47matthias_devn: what?
23:47devnmatthias_: nevermind, I have a friend on IRC who is mathiasx
23:47devnconfusing.:)
23:48devnmatthias_: I was temporarily incredibly proud of him for discussing stacktrace intricacies in clojure
23:49devnI've been kicking him and everyone else I work with to get on the clojure boat for awhile so I thought I'd caught him red-handed
23:49devnAlso, sorry to derail, but the strange loop 2011 lineup looks, in a word, incredible.
23:50devnFantastic lineup. Intensely excited.
23:52matthias_haven;t heard of
23:52devnmatthias_: are you in the US?
23:52matthias_germany
23:53devnwanna come to the states? ;)
23:53matthias_i like how you described my "why wopnt iot work? :'(" as discussing the intricacies :p