#clojure logs

2011-10-07

00:16no_mindRepeating question. Is it possible to have all files under a directory to have same namespace identified by directory path. For eg. all files in path xyz/applications/accounts have same namespace as xyz.applications.accounts . I have tried using compile and lein compile but both throw errors
00:30devninferior lisp is nice enough.
00:30devnfootholds are nice, but they are not requirements.
01:25joshnzHi all. I started playing around with slime/swank and clojure the other night. The first thing I noticed was that the doc function doesn't appear to be loaded. If I lein repl then it's there out of the box. So why the difference?
01:41amalloyjoshnz: it's just not in core; the repl probably loads some other namespaces like clojure.repl
01:41duck1123doc is now in clojure.repl
01:41amalloy,#'doc
01:41clojurebot#'clojure.repl/doc
01:42duck1123either that, or lein is using 1.2 for it's repl. Did you start it in the context of a project for the repl?
01:45joshnzRunning lein repl in the project folder, *clojure-version* reports 1.3 as expected. I can, straight off the bat and in the user ns, call (doc first) all ok
01:46joshnzin the slime repl, *clojure-version* is also 1.3. This is from a jack-in via the same project.
01:46joshnzIt also starts in the user ns, but doc is undefined
01:47duck1123odd. I don't use lein repl, anyway: (use 'clojure.repl) and you're all set
01:47carkthat change is annoying as hell
01:48carkwhile developing, you nbeed to import it in each of your current namespaces
01:48carkor fully qualify it
01:48duck1123or C-c C-d d
01:49carkthat messes my window configuration =P
01:49amalloyfwiw C-c C-d C-d works too; i find it easier than remembering to let go of C-
01:50carkthen you have find-doc
01:50duck1123I need to get in the habit of using it. The only reason I mentioned it was because technomancy mentioned it when this came up earlier
01:51joshnzaccording to here: http://stackoverflow.com/questions/6443922/why-does-repl-treat-clojure-core-doc-as-a-var doc is "used" implicitly in the user ns, which is the behaviour I see from the command line repl, but not via slime. So something must be different in the way the swank repl is created...?
01:52carkin the past, it was "used" implicitely in all namespaces, and it made sense
01:52carkanyways ...can't have all we want all the time =)
01:53duck1123core is big enough. doc can afford to move
01:54carkthat's just an annoyance, nothing to write home about
01:55joshnzI'm not worried about the ns and implicit using or anything, what interests me is that the behaviour between the two repls is different. I would have thought they would have ultimately resolved to same thing. Cheers for the C-c C-d C-d tip, that works better than doc anyways :)
01:57duck1123It probably has something to do with swank not really concerning itself with repls and just acting as an interface, and thus that code doesn't get called
03:37Blktgood morning everyone
04:02ejacksonmorning folks
04:17cemerickejackson: Damn, now you're, what, 9 hours ahead of me?
04:21ejackson9 !
04:22ejacksonyou in SF now ?
04:22ejacksonis
04:22ejackson09:20 here
04:23cemerickfeh, typical!
04:23cemerick;-)
04:23cemerickejackson: yeah, was here for java one
04:24cemerickflying back in 4 hours.
04:24ejacksonoh yeah, how was your talk ?
04:24ejacksonwait.... its 1am there and you're flying in 4 hours...
04:24ejacksonborg !
04:25cemerickyeah
04:25cemerickThis has been a rough trip re: the actual traveling.
04:25cemerickThe talk went well.
04:25cemerickNot really my sort of crowd tho. *shrug*
04:26ejacksonhehe, don't worry, the conj is soon.
04:26cemerickI was a little peeved that there was *no* recording of the session at all.
04:26ejacksonreally ? that's a bit amateur hour for such a big conf
04:26cemerickI'm going to do some screencasts very shortly, starting with a reprise of the topic from my talk at the bay area clojure group tonight.
04:26cemerickYeah, I don't know what to say about that.
04:27ejacksoni'll be on the lookout for them, can't get enough tutorials
04:27ejacksonoh,
04:27cemerickClojureScript views in CouchDB, baby. Not sure if that counts as a tutorial, but… :-D
04:28ejackson(probability being what it is, I managed to book myself onto the same plane across the atlantic is christophe, fun)
04:28cemerickright, yes, I saw that :-)
04:28cemericknice serendipity
04:28ejacksonit does make the world go round
04:28cemerickodd that he (they) are going through London?
04:28ejacksonthey, yes.
04:29ejacksoni'm not sure why, usual airline industry madness i'm sure
04:30cemericktell me about it
04:30cemerickwas stuck in Philadelphia overnight on Sunday.
04:30ejacksonhappy days, did you at least get a cheese steak ?
04:30cemerickNot even!
04:30cemerickBarely got a flight out the next day.
04:31cemerickHad to wrangle the customer "service" person to get me on a different airline's flight. Then had to run back and forth between the two, holding their hands so that they'd work together.
04:31cemerickIt was a total cluster.
04:32ejacksonyou guys need some more trains
04:32cemericknot gonna happen
04:32ejacksontwo weeks ago I did a boston,nyc,washington trip, the connecting trains were great
04:32cemerickMaybe for short runs
04:32cemerickyeah, east coast works fine
04:33cemericktrains can't cross country in reasonable time.
04:33cemerick~30 hours, optimistically
04:33clojurebotIt's greek to me.
04:33ejacksonthen you need to shrink the country, only sensible solution
04:33ejacksonairlines are no good
04:34ejacksoni've finally managed to write something based on macros that seems to make sense (after christophe imparted some zen master wisdom to me)
04:35ejacksonits the usual orm-ish malarky but useful
04:53cemerickejackson: Christophe is good at that. :-)
04:54ejacksonhave a good one, catch you soon
05:10skuro,(let [cur *ns* alien (namespace 'alien)] (in-ns alien) (println *ns*) (in-ns cur))
05:11clojurebot#<NullPointerException java.lang.NullPointerException>
05:11skurowhy is that throwing an NPE?
05:22clgvhmm that's strange I changed my project dependency to incanter 1.2.4 but lein deps still copies old 1.2.3 versions of incanter.core 1.2.3 into my lib folder.
05:23clgvah lol incanter 1.2.4 lists the old dependencies in its project.clj :(
06:30MrMcI want to split comma separated values and collect specific fields with nth in Common lisp this is done with a loop in conjuction with collect how is this done in clojure
06:33clgvMrMc: like that ##(let [vs (split "1,2,3,4,5,6,7" #",")] (println (nth vs 0) (nth vs 5)))
06:33lazybotjava.lang.Exception: Unable to resolve symbol: split in this context
06:33clgvMrMc: like that ##(let [vs (clojure.string/split "1,2,3,4,5,6,7" #",")] (println (nth vs 0) (nth vs 5)))
06:33lazybot⇒ 1 6 nil
06:36MrMcclgv:Thats it in principle. Can a get this as a vector or list
06:36clgv&(type (clojure.string/split "1,2,3,4,5,6,7" #","))
06:36lazybot⇒ clojure.lang.PersistentVector
06:36clgvso split returns a vector
06:37MrMcyes
06:38skuro##(let [v (clojure.string/split "1,2,3,4")] (map #(nth v %) [1 3]))
06:38lazybotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: string$split
06:38skuro##(let [v (clojure.string/split "1,2,3,4" #",")] (map #(nth v %) [1 3]))
06:38lazybot⇒ ("2" "4")
06:39clgvthere is 'vec to get a vector from a collection
06:40MrMcskuro:that is what I am looking for
07:33noidiwhat's the preferred way of manipulating fields of records (deriving new records)?
07:33noidimap functions such as assoc and update-in?
07:34ambrosebsI guess so, since records are just maps
07:34ambrosebscan't really go wrong with the map functions
07:35noidiI was just thinking that there might be a better performing way
07:35noidisince records are Java classes
07:36ambrosebsrecords are maps with certain keys optimized
07:36ambrosebsso you get the speed for "free"
07:36ambrosebsAFAIK
07:38noidiok
07:53michaelr525hey
07:54gfredericksmichaelr525: hey
07:58antares_if I have a record in a namespace abc.de that is required as de, how do I address it? de/MyRecord or do I need to import it as a Java class?
07:59gfredericksantares_: import
07:59antares_gfredericks: thank you
07:59gfredericksnp
08:59lnostdalhm, i can't even read from a DB within a clojure transaction?
09:00carktransactions might be retried, woudl you want to pay the cost of a database query on each retry ?
09:01lnostdalto make things simple, sure
09:01lnostdalat least for now
09:02carkwell reading from a daztabase is a side effect
09:03carkbut what's really important is that you shouldn't have to do this
09:03carktransactions should be small and localized
09:04carkby doing a long operation like reading from a database, you increase the risk of a retry
09:04lnostdali'm doing a simple login check in a http request .. other http requests do more complex things and need a outer dosync wrapper .. but i don't want to think about what needs stm and doesn't, so i wrap all http request handlers in an outer dosync
09:05lnostdalperhaps this is wrong .. (heck, i actually want a pessimistic stm, but yeah .. :>)
09:05carkyou're trying to avoid thinking about your concurrency issues
09:05carkthat's a receipe for disaster
09:06lnostdala pessimistic stm? .. it's simpler, no write-skew or anything
09:07carkyou can picture a dosync like a lock, a very elaborate lock which will not lock very often, but still, that's a contention point
09:07carkyou don't want to spend too much time inside your locks
09:10inhortteHello. I'm getting this error: Exception in thread "main" java.lang.IllegalArgumentException: No matching field found: getRoot for class clojure.lang.Var when adding a model with clj-record to a Noir app. Has anyone else encountered this?
09:11antares_inhortte: sounds like clj-record is not 1.3 ready and you are using 1.3
09:11duck1123I have a patch somewhere i think
09:11inhortteI thought it may be that, though when I switch back to 1.2.1, I get an unrelated error.
09:12inhortteduck -> That would be great. :)
09:13duck1123hmm... that's not one of the things I've changed
09:14carklnostdal: usually you want to use stm to "protect" some kind of datastructure(s), you would put the dosyncs on the functions which are the entry points for manipulating those data structures
09:14duck1123I actually didn't have to change much to get clj-record working, is this with running tests?
09:14inhortteNo, this is with attempting to access a model.
09:14carklnostdal: the "http request" layer of your application has nothing to do with stm
09:14lnostdalsure cark .. but i might call several of them, and that'll lead to transactions from other threads being interwoven
09:14duck1123The real issue is getRoot is now getRawRoot
09:15inhortteI did not run the tests. (And I should say that I am new at clojure, by the way)
09:15lnostdala http request handler is the proper granularity i'm after; it does a set of things that must be done atomically
09:15inhortteAh. I can attempt to modify clj-record, I guess.
09:15duck1123inhortte: is it giving you a stacktrace?
09:16inhortteduck -> It is giving me a stacktrace, beginning with the line I first posted.
09:16carklnostdal: it is not the proper granularity if you want to mix dosync with database reads
09:16lnostdalcark, i could do the i/o ,that is db stuff (just read in this case), in an agent .. except i can't use await so it's worthless
09:17inhortteIf the model is not required, then there is no error.
09:17carkall your problems are because you're mixing presentatin layer with business layer
09:18duck1123inhortte: here's the branch I'm using https://github.com/duck1123/clj-record/tree/kronkltd
09:18inhortteSo my guess is that clj-record.core/init-model macro is doing something wrong (not calling getRawRoot, I suppose).
09:18inhortteOK. I'll clone that branch. Thanks, duck.
09:18tudorinhortte: do you use slime when working with noir?
09:19inhorttetudor -> I set up slime earlier, but it would not work using clojure-jack-in.
09:19tudorI'm trying to but it looks like it doesn't load all the libraries so it can't compile my module
09:19inhorttetudor -> I can only get slime working if I run a swank server independently.
09:19tudorthis happens with clojure-jack-in
09:20tudorI was curious if I'm expecting too much from slime, to know of my libraries or if it's just a bug
09:20inhorttetudor -> I've not had any luck with slime not only with my noir project, but ANY project. I can use the repl for random stuff, but not in the project. I have to create my own repl with leim to do that.
09:21tudorinhortte: thanks, that was my experience as well.
09:22duck1123what errors are you guys getting? And are you using the slime from elpa?
09:23inhortteduck -> I'm using the slime from elpa.
09:23inhortteduck -> one moment.
09:24tudorduck1123: I start slime with clojure-jack-in in the project directory. try to compile a random view and get errors like : "don't know what defpartial is", I don't have the exact error message around for reference
09:24tudordefpartial is a macro used in noir, "use"'d in the currently open view
09:24inhorttetudor -> hm. It worked this time.
09:25inhorttetudor -> what steps did you take to compile the view?
09:25inhorttetudor -> once slime was running, that is?
09:25lnostdalcark, ok, yeah, i suppose my request handlers need to do without dosync .. then i need to parse input, do db i/o (read), then call some Model type function/handler which only there wraps everything in a dosync, then write to DB afterwards .. something like that anyway
09:25inhorttetudor -> I want to try it.
09:26duck1123I've never been a big fan of clojure-jack-in. I prefer to keep my apps running in screen
09:27inhortteduck -> this is the first day of my life that I have used clojure-jack-in. It seems to be working now, however, oddly. I dislike when things fix themselves. :)
09:29ejacksonI can never figure out where the output goes with clojure-jack-in, seems to vaporize.
09:29winkhm, is the jetty via "lein run" that slow? 10 concurrent (via siege) on a seemingly simple noir webapp firing ~11 simple sql-queries on a ridiculously small local mysql db (50 datasets), indexes are ok -a nd I get 3-4 sec response times.
09:34tudorinhortte: I'm never sure what keys to use to compile stuff. most of the time I try C-M-x
09:34tudorhow do you guys compile in slime?
09:34duck1123uce C-c C-k, that way you keep the line numbers
09:34tudordo I get the error because of C-M-x?
09:35duck1123possibly if you changed the ns form and forgot to send it
09:35duck1123C-c C-k reloads the whole file
09:35tudorduck1123: thanks, will try that later today
09:36inhorttetudor -> C-M-x complies.
09:36inhorttetudor -> oops. Duck's answer was better. C-c C-k
10:16inhortteI'm pretty sure, after more investigation, that the problem is with clojure.contrib.sql. :(
10:19ejacksoninhortte: you know that's deprecated, yeah ?
10:22inhortteejackson -> nope. What shall I use instead?
10:22ejacksonif you're on 1.3 you should go to clojure.java.jdbc
10:23ejacksonas contrib is being broken up
10:23inhortteOK. I just found that. Thank you, anyway.
10:24ejacksonnp, it caught me out
10:30stuartsierraDoes `*print-dup* true` automatically imply `*print-meta*` true?
10:36TimMc,(binding [*print-meta* false, *print-dup* true] (print ^{:foo :bar} []))
10:36clojurebot^#=(clojure.lang.PersistentArrayMap/create {:foo :bar}) []
10:36TimMc(No idea if I'm testing this the right way.)
10:36TimMc,(binding [*print-meta* true, *print-dup* true] (print ^{:foo :bar} []))
10:36clojurebot^#=(clojure.lang.PersistentArrayMap/create {:foo :bar}) []
10:38gfrederickswhy isn't "^#=(clojure.lang.PersistentArrayMap/create {:foo :bar})" redundant?
10:39gfredericksisn't it the same as #^{:foo :bar}?
10:39gfredericksor something similar
10:49clgvhow can I force leiningen to check clojars again?
10:49gfredericksclgv: rm -rf ~/.m2 ? :)
10:50clgva bit drastic. but I can lookfor the library I intend to update
10:50gfredericksyeah that's what I normally do
10:52clgva builtin parameter would be nice ^^
10:53gfredericksclgv: what kind of use case is not covered by version-bumps and checkouts?
10:53clgvgfredericks: I just did lein deps this morning. but there was an error in the jar that is fixed now. but leiningen didnt check back I guess
10:54gfredericksclgv: if the contents of the jar changed, shouldn't that be a new version?
10:55clgvI dont know any details on how leiningen and clojars work together and if leiningen does check back there everytime
10:56gfredericksis it a SNAPSHOT version?
11:04clgvnot really. error when releasing ;)
11:04clgvbut it's solved now manually^^
11:08bendlashi
11:09bendlasdoes anybody have experience getting packages with native dependencies to run on JDK7?
11:11bendlasI wanted to play around with overtone, but it segfaults on JDK7
11:17wiseenIs ClojureScript missing (case ) statement implementation or I'm I doing something horribly wrong ?
11:21gfredericksdoes anybody know what a "Duplicate method name&signature" on a (defrecord) is likely to mean?
11:22clgvgfredericks: defrecord methods have no extra namespace so it might be possible that you have a function outside the defrecord with the same name and arity
11:22gfredericksoh hmm
11:22clgvor maybe you pull it into the namespace via a :use
11:22gfredericksno wait
11:22gfredericksneither of those are the case
11:22gfredericksI'm doing this in a stripped-down manner now, to debug
11:23raekI hink there can be problems if you have a field and a method with the same name
11:23dnolengfredericks: you're probably defining a method defrecord already defines.
11:23gfredericksaah -- like count!
11:23dnolengfredericks: yup
11:23gfredericksso what do I do if the interface has a method called count?
11:23toxmeisterhey, speaking of defrecords… which protocol do i have to extend/implement to have that record supported by the count & conj functions?
11:24gfrederickstoxmeister: I think you get that automatically
11:24toxmeisterno way, crossover. same question twice.. ;)
11:24toxmeisterwell say my record is just (defrecord polygon [vertices]) and i want count not count the number of fields in the record, but the number of vertices in that field
11:26gfrederickstoxmeister: sounds like that'd be bad form, since you'd be breaking the behavior of IPersistentMap
11:26wiseenCan someone plz check (case 1 1 1 2 2) in ClojureScript REPL just so I know if it's my install problem or is it really not implemented
11:26gfrederickstoxmeister: use deftype if you don't want a map?
11:27toxmeisteri quite like the map, since I might add a few other fields later
11:27PPPaulwhy is there clojure in my javascript?
11:28gfrederickstoxmeister: well it can't be both a map and not a map. The other option is to create a count function in your own namespace, and the callers have to distinguish
11:28dnolenPPPaul: because it's good.
11:28PPPauldoes clojurescript have into?
11:28toxmeisterand re: breaking IPersistentMap, that's exactly why i'd like to implement that functionality myself (count, conj etc.) but have these applied to the vertices field only
11:28PPPaul(into
11:28PPPauli love into
11:28dnolenPPPaul: ClojureScript has pretty much everything you expect from Clojure and then some.
11:28gfrederickstoxmeister: but then your record is no longer a map, because I can assoc onto it but the count stays the same
11:29toxmeistergfredericks: not, if the (count poly) actually returns (count (:vertices poly))
11:30toxmeisterhmm, but i see the point about assoc would be problematic...
11:30toxmeisterokay, will try deftype then and see how i fare… thanks a lot!
11:30gfrederickssure
11:32gfredericksI guess my answers to toxmeister answer my own question as well. Since maps/records have a .count method, I can't implement an interface that has a method by the same name :/
11:41dnolenpattern matching is hard
11:42gfredericksdnolen: with clojure it's easy! have you seen dnolen's pattern matching library?
11:43dnolengfredericks: ha! easy to use, tricky to implement.
11:44dnolenI think I'm down to one last serious correctness bug (knock on wood)
11:46gfredericksfliebel: you give me too much credit. It was just a lame joke.
11:46gfrederickss/credit/the benefit of the doubt/
11:46lazybot<gfredericks> fliebel: you give me too much the benefit of the doubt. It was just a lame joke.
11:47fliebeldnolen: pattern matching is not hard, your view of what good pattern matching is is hard to implement.
11:48dnolenfliebel: heh, it's not "my view", it's the view of 25 years of FP research.
11:51dnolencore.match on the innovation scale is pretty close to zero :) pushing the work into predicate dispatch might have a tiny bit of real novelty.
11:51fliebeldnolen: So what is going on under the hood? Is all the dag magic and openness from the predicate papers in htere?
11:51dnolenfliebel: no openness is my own invention - though it ended up being similar to Racket's implementation.
11:52bsod1is there a clojure REPL with syntax coloring and auto-indentation? like python's ipython
11:52gfredericksdnolen: "multimatches"?
11:52fliebeldnolen: Did you blog about the exception stuff already? That sounded really weird.
11:53wiseenplease please please will someone try (case 1 1 1 2 2) in clojurescript repl, I just want to confirm that what I'm getting isn't because I installed it wrong
11:53dnolenfliebel: no, what's weird about it? just uses exceptions for backtracking, it's been done before in Java applications.
11:53fliebeldnolen: Just that I've never seen it, and don;t know how it works.
11:54gfrederickswiseen: okay okay okay
11:55dnolenfliebel: just create an exception store it in a var. And reuse it.
11:55dnolenwiseen: that doesn't work for me, you should open a ticket in JIRA
11:55gfredericksditto
11:55wiseentnx. was going nuts looking trough the cljs source for implementation of it
11:56dnolenwiseen: actually now that I think about it, you probably shouldn't open a ticket
11:56gfrederickswiseen: (case 1) and (case 1 1 1) seem to fail the same way
11:56dnolenwiseen: case is a JVM specific optimization
11:57dnolenwiseen: there is no comparable constant time switch for JS as far as I know.
11:58gfredericksdnolen: should there at least be a ticket to remove it then?
11:58gfredericksor make it do whatever it was put there to do
11:58wiseenoh ok, but is there any equivalent way to do it ? without (cond (= 1 1) (= 2 2))
11:58gfrederickswiseen: use pattern matching :)
11:59wiseenhmm tried that also got a CLJS error
11:59wiseenwill try more tough :)
12:00dnolengfredericks: what do you mean remove it, it doesn't exist thus the error.
12:01dnolenwiseen: cond works fine.
12:01gfredericksdnolen: oh ha. sorry misunderstood the error then.
12:02gfredericks(defn case [v & pairs] (let [pairs (partition 2 pairs)] (second (first (filter #(= v (first %)) pairs)))))
12:02gfrederickswiseen: ^ make your own?
12:03chouser(condp i = 1 "one" 2 "two")
12:03chousersorry, (condp = i 1 "one" 2 "two")
12:04chouser,(condp = 2 1 "one" 2 "two")
12:04clojurebot"two"
12:04gfrederickschouser: so (def case (partial condp =))? :)
12:05chouseryeah, but that'll actually because differently than clojure's case
12:05gfredericksI bet I have missed many opportunities to use condp :/
12:05gfredericksI can't ever get those years back.
12:05wiseenchouser: nice, tnx !
12:06dnolenwe need a CLJS repl in here.
12:06chouserclojure's case doesn't eval the conditions, and uses literal lists to mean "or"
12:07fliebeldnolen: I still don't get it. You make an exception, and then? reuse = throw? Do you have an example on something to read or google for?
12:07chouser,(case + (+ 1 2) "plus or one or two")
12:07clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching clause: clojure.core$_PLUS_@593f4e>
12:07chouser,(case '+ (+ 1 2) "plus or one or two")
12:07clojurebot"plus or one or two"
12:08dnolenfliebel: http://blogs.oracle.com/jrose/entry/longjumps_considered_inexpensive
12:09chouserdnolen: have you gotten any pushback from Rich on that?
12:09dnolenchouser: pushback on what?
12:09chouserexceptions for flow control
12:10dnolenchouser: Clojure's STM uses the same technique.
12:10chouserhm, ok.
12:10chouserI did the same thing in error-kit and thought I remembered enduring some frowns because of it.
12:11dnolenchouser: I think the idea was using it a real form of non-local control. In core.match, it's an implementation detail.
12:14dnolenchouser: In ClojureScript I throw 0. That's fun.
12:15dnolenprobably should throw a namespaced keyword.
12:46toxmeistersorry to ask so many newbie questions, but am trying to get my head around some defprotocol weirdness(es).. could someone please have a look at this and explain why the exception occurs for the 3-arg func call using the protocol, but works fine using the same arity specs on a normal function?
12:46toxmeisterhttps://gist.github.com/1270747
12:49hiredmantoxmeister: protocols don't do varargs
12:51toxmeisterarrgh! that explains things… would be good if this could be pointed out on: http://clojure.org/Protocols
12:51toxmeisterthanks, hiredman
12:53chouserdnolen: heh
13:18dnolencool! http://ww2.cs.mu.oz.au/~sulzmann/chr/
13:27gtrak`i think maybe the best way to distribute a clojurescript library right now is in single-file form, a la core.clj, building up namespaces as you go, has anyone thought about that kind of stuff?
13:30gtrak`ah, i see there is some talk of jaring up dependencies and using lein
13:40aaelonyHi - I wanted to check out Cheshire with Clojure 1.3, but it seems to clobber the doc function. http://pastie.org/2656615 Do others see this too?
13:41hiredmanaaelony: you need to (use 'clojure.repl) in your new namespace
13:41aaelonyi see. thanks hiredman!
13:49antares_is there a seq function like iterate that stops when the function it is given returns nil?
13:51cark(filter identity (iterate .... ))
13:52carkerr take-while or something
13:52dbushenkodid you guys try storm?
13:53dbushenkoI've just tried to follow the examples and everything I have -- just the errors
13:53cark,(take-while identity [1 nil nil])
13:53aaelonyantares: there is nice blog posting on this (http://blog.malcolmsparks.com/). See "Preventing infinite application".
13:53clojurebot(1)
13:53carkantares_: remember we're working with lazy sequences
13:57antares_cark: I have been about to try take-while, thanks. Sorry, what specifically do you want me to keep in mind?
13:57antares_cark: my broader goal is to turn a generator function that will eventually return nil into a lazy seq
14:00carki was only pointing out that it should stop even though you have an infinite list
14:00carkbut it looks like you know that already =)
14:03antares_cark: yeah, I am not *that* new to FP and lazy evaluation :)
14:33devthi'd like to use (read-string) on some user input, and handle differently if the input was a string or number. how do I check the resulting type of (read-string)?
14:34ibdknox,(doc type)
14:34clojurebot"([x]); Returns the :type metadata of x, or its Class if none"
14:34ibdknox,(doc string?)
14:34clojurebot"([x]); Return true if x is a String"
14:34ibdknox,(doc number?)
14:34clojurebot"([x]); Returns true if x is a Number"
14:35devthah, thanks. i was trying isa? without luck.
14:35hiredmanread-string results in a clojrue datastructure, how do you check the type of anything in clojure?
14:37devth,(string? (read-string "foo"))
14:37clojurebotfalse
14:38hiredmancorrect
14:38devth,(string? (type (read-string "foo")))
14:38clojurebotfalse
14:38devthok, what am i missing?
14:38hiredman,(read-string "foo")
14:38clojurebotfoo
14:38hiredman,(read-string "\"foo\"")
14:38clojurebot"foo"
14:38hiredman,(type (read-string "foo"))
14:38clojurebotclojure.lang.Symbol
14:38hiredman,(type (read-string "\"foo\""))
14:38clojurebotjava.lang.String
14:39hiredmanread-string is just like what happens with clojure source code
14:39hiredmanfoo is a symbol, "foo" is a string
14:39devth(type (read-string "1.0"))
14:39devth,(type (read-string "1.0"))
14:39clojurebotjava.lang.Double
14:39devthi guess that was throwing me off.
14:50cgrayi'm having some trouble with java interop... there is a class with constructor public HangmanGame(String secretWord, int maxWrongGuesses) { ... } and I am doing (def game (HangmanGame. "abbey" 5)) and getting the error Class clojure.lang.Compiler$NewExpr can not access a member of class HangmanGame with modifiers "public"
14:55hiredmancgray: what version of clojure?
14:55cgray1.2
14:57gtrak`dnolen, if only the kinesis had an integrated trackpoint
14:57hiredmancgray: can you pastebin more?
14:57cgrayhiredman: sure, just a sec
14:58amalloycgray: sounds like the HangmanGame class probably isn't itself public
14:58cgrayamalloy: ahh, you're right
15:05cgrayare classes not public by default?
15:06hiredmanthey are not
15:06hiredmanalso you may run into trouble if the class is not in a proper package
15:11amalloyjava's default visibility settings are absurd
15:30michaelr525what is a good windows software for making screencasts?
15:34jcromartieWould it make sense to bang-ify functions like: "uuid!" or "timestamp!"
15:35jcromartiethings that are not pure functions?
15:35jcromartieor what is the definition of "not safe in a STM transaction"
15:35jcromartieI'm going off of http://dev.clojure.org/display/design/Library+Coding+Standards
15:35gfredericksjcromartie: something more specific than impure
15:35gfrederickse.g., clojure.core/send
15:36jcromartiehm ok
15:36jcromartieso something using current time or PRNG is not quite unsafe
15:36jcromartiebut if you retry the transaction, it would get a new value, right?
15:37gfredericksyes. but that's fine right, in this particular case?
15:37jcromartieprobably
15:37gfredericksI'm not too familiar with the issue, beyond what I've already said
15:46todunBrand new to Clojure. Looking for a tutorial that will walk me through from installation to basic syntax to practice problems(or group of tutorials). Any tips are welcome!
15:48gfrederickstodun: 4clojure.com is not exactly a tutorial but you might find it helpful
15:50dnolentodun: if you're just starting out, I recommend looking into clooj first.
15:50dnolentodun: unless you already have a dev environment you'd like to continue using.
15:51todungfredericks: dnolen thanks. when I google clooj, I get github repo
15:53droidboihi
15:54dnolentodun: yup, there's a download link on the repo.
15:55gfredericksdroidboi: hi
15:55todundnolen: ok. I was thinking of working from the CLI using emacs.
15:55amalloytodun: yeah, 4clojure will help you learn the language. not really the "mechanics" like installation, though. it's a pure-browser solution, though, that can help you get your feet wet without having to install stuff
15:56dnolentodun: then you have an environment that you want to continue using - http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
15:58todunamalloy: ok thanks.
15:58todundnolen: yes indeed.
15:59todunwill read up and come back with my questions. thanks all.
16:02jcromartieI wonder if depending heavily on refs is bad API design?
16:02jcromartieit starts to feel very stateful
16:02jcromartielike, to have most of your functions depend on certain refs
16:02jcromartieI guess I could pass the ref
16:03jcromartiethat would be better
16:03stuarthallowayor its value
16:03jcromartieah yes
16:03jcromartieI'm just not sure what to call them :)
16:03jcromartieI have two main refs: logins and organizations
16:04jcromartiethat's basically the state of my system
16:04jcromartieall non-loign data lives under an organization
16:04stuarthallowaywhy don't the functions take one state and return another
16:04jcromartieyeah that's probably a better idea
16:04jcromartieand write them at the organization level
16:04jcromartiethe organization itself may be a huge data structure (various values may have a million elements or more)
16:05jcromartiebut that's not really a problem
16:05jcromartieuntil I start printing things :)
16:05sridwhat is the best way to dispatch to functions based on a value? for eg. I have foo, bar, baz functions. I also have the similarly-named function in a different module. whenever I invoke foo, I want to pick the module dynamically based on a command-line argument.
16:06srid(in python, i normally lookup func/modjules dynamically based on name)
16:06ibdknoxsrid, multimethods?
16:06dbushenkodo you guys have any examples of storm-projects except storm-starter?
16:11tdrgabiI started slime with clojure-jack-in from a noir project. try to compile a view and I get: "error: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class noir.core__init"
16:11tdrgabican we compile noir files from slime?
16:12ibdknoxgfredericks, really? I didn't know that either
16:12gfredericksibdknox: and to think I was considering assembling a record by hand.
16:13gfredericksnow to figure out if there's a factory for initializing a record with nils somewhere...
16:13ibdknoxtdrgabi: noir isn't any different than other Clojure libs, but I don't use emacs, so I can't help you much :(
16:16gfredericksibdknox: what do you use?
16:18ibdknoxgfredericks, VIM
16:18gfredericks:)
16:19ibdknoxI keep trying to learn emacs, but working at 10% efficiency for a while is a hard barrier for me to get over
16:24RaynesI'm currently using a mutant mix of Emacs and Vim.
16:24cgrayviper-mode is a nice hit of methadone
16:25RaynesI'm an Emacs user, mostly. Just thought I'd give Vim a go. I like it, but I'm not sure it can really give me what Emacs gives me.
16:25ibdknoxcgray, I found no reason to use emacs with viper over just normal vim, you lose paredit, which seems like the most useful part
16:26michaelr525cgray: ಠ_ಠ
16:27cgrayibdknox: emacs has paredit
16:27Raynesibdknox: Vim has paredit too. I guess it isn't quite as sophisticated, but it does everything I needed.
16:28mcstardoes anybody have a clue as to why nothing show up on an incanter graph for me?
16:30amalloymcstar: given only that information, i don't think anyone in the world could help
16:31mcstari tried running incanter from clojure/cake, and from its distribution too
16:31mcstari use the (view) call, a window comes up, but its completely blank
16:31mcstar(view (function-plot sin -1 1))
16:31mcstarfor exmaple
16:32mcstarim using sun's jre
16:32mcstar+linux
16:32mcstari dont know what else could be relevant, help me out, i answer your question
16:35gfredericksdoes anybody know if there's anything that does the inverse of clojure.core/bean? Else I'll be writing my own...
16:51ibdknoxmcstar, put a gist up with some simple code and maybe someone can help
16:51mcstaribdknox: there nothing to put up, its the simplest example from any incanter tutorial
16:53amalloygfredericks: writing your own? good luck with that
16:54gfredericksamalloy: thanks, I'm halfway done :) at least according to my own requirements. Not a strict interpretation of what I asked for.
16:55stuartsierragfredericks: people have done it, search the list/IRC archives
16:55stuartsierraAlthough it won't work in the general case.
16:56gfredericksstuartsierra: My case is I have an interface that has getters/setters with standard names, and I want to convert a map to a proxy object that implements the interface
16:57gfredericksI seem to be getting into macro trouble though :/
16:58stuartsierraTry writing out what you want by hand.
16:59gfredericksstuartsierra: you mean for a specific interface?
16:59stuartsierrayes
16:59gfredericksfor my own sake or to communicate to IRC what I want?
16:59stuarthallowaystuartsierra: just the man I am looking for!
16:59stuartsierrauh oh
16:59stuarthallowayplease check to see if I just cut alpha1
17:00ibdknoxrun
17:00ibdknoxrun fast
17:00gfredericksstuart fight!
17:00stuarthallowayand if I didn't please do so
17:00stuarthallowaythe release build (#314) vanished from the Hudson UI. Totally weird
17:01stuartsierrastuarthalloway: You did not.
17:01stuarthallowaycan you try it, and see if you can do better?
17:01stuartsierrahttp://build.clojure.org/view/Clojure/job/clojure/314/console
17:01stuarthallowaypretty please?
17:01stuartsierra" [INFO] Failed to create assembly: Error adding file to archive: /var/lib/hudson/jobs/clojure/workspace/changes.txt isn't a file."
17:02stuartsierraThe build expects to find a file named changes.txt
17:02stuartsierraThat file got renamed to changes.md
17:02stuartsierraIt just needs to be changed in src/assembly/distribution.xml
17:02stuarthallowayOK, I can do that
17:02stuarthallowaythanks
17:03stuartsierranp
17:03gfredericks no more macro trouble; can use init-proxy fn instead of proxy macro.
17:03amalloygfredericks: if you have an interface, and want to implement it in terms of a map (i guess a ref of a map, for setters?), that's possible, and probably not even that hard
17:03stuartsierragfredericks: By the way, my suggestion of writing stuff by hand was a general trick for designing macros.
17:03amalloyit's the general case that's impmossible
17:04stuartsierraIn general, the general case is impossible
17:04gfredericksby "general case" you mean arbitrary objects that aren't so bean-like?
17:04gfrederickss/objects/classes
17:04lazybot<gfredericks> by "general case" you mean arbitrary classes that aren't so bean-like?
17:05amalloygfredericks: doesn't even matter if they're bean-like; i mean not having a known class, or not having a known set of methods
17:05gfredericksoh oh of course
17:05gfredericksI was assuming the class/interface was an extra argument
17:05gfrederickssorry
17:05gfredericksyes, clearly impossible :)
17:05amalloyalso, using proxy for this makes me a bit sick. why not just use reify? you have an interface to implement, not a class to extend
17:06gfredericksamalloy: because I don't know what reify does, so it didn't occur to me :)
17:07amalloy(as-interface m [:name] MyInterface) => (let [data (ref m)] (reify MyInterface (getName [this] (:name @data)) (setName [this x] (dosync (alter data assoc :name x)))))
17:09amalloyfor extra credit you can use reflection on MyInterface to derive the list of field names, but having them be explicitly passed is easier and imo simpler
17:09gfredericksamalloy: I already wrote the reflective function to take an interface and derive method names
17:09gfredericksbut reify being a macro seems to make this harder
17:09gfredericksunless I make a def for each interface I want to use, rather than a general function of maps/interfaces
17:10amalloyproxy is a macro too, though?
17:10gfredericksyeah, I had the same problem there, and was digging into the proxy src to see how to do it with lower-level functions
17:10hiredmanugh
17:11gfrederickshiredman: I asked for help, I'm not asserting that I have great ideas
17:12amalloygfredericks: it sounds like you've done the hard work; making it work with reify instead is a small change
17:13gfredericksamalloy: I did the reflective work. Didn't solve the macro problem. Reify wants the interface-names and method-names at compile time, when I'm trying to supply them at runtime
17:13gfredericksI think...
17:13amalloyi don't believe you. you must know the interface name at compile time, or proxy wouldn't work
17:14gfredericksamalloy: so if I write my thing as a macro, then I'm accepting a symbol to refer to the interface. Do I resolve that symbol somehow?
17:15amalloy*nod* just like proxy does, i think
17:16amalloy(or, if not, then reify certainly does)
17:16gfredericksyeah, I just thought to look at how reify does it
17:16amalloyi mean, i guess there's a special form for that, reify*
17:16amalloyso it may be the compiler doing the resolution, but either way it's passed a symbol and has to turn it into a class at some point
17:16hiredmanamalloy: I believe he was looking at proxy, but proxy doesn't work
17:17amalloyhiredman: they should both work, right? proxy is uglier but viable?
17:17gfrederickshiredman: I was, but amalloy pointed out reify, which I wasn't familiar with, so I'm looking at that now
17:17hiredmannot if he wants runtime code generation
17:17amalloyi don't think he actually does
17:17hiredmanyou don't have to do resolution or anything at all
17:18hiredmanjust emit (reify SomeInterfaceName some-methods)
17:18gfrederickshiredman: how do I know what methods?
17:18amalloyhiredman: right. which is how the version i proposed would work
17:18amalloyhe wants to inspect the interface and magically determine the methods to emit
17:18hiredmangfredericks: you said you did reflective stuff?
17:18gfrederickshiredman: yeah, already got that; a function that takes an interface and returns a map of method-name info
17:19hiredman,(-> String .getMethods)
17:19clojurebot#<Method[] [Ljava.lang.reflect.Method;@849bd>
17:19amalloybut at compile time; just saving his users from typing in stuff
17:19amalloywhich, as i mentioned above, i think is a misfeature that isn't really worth doing
17:19hiredmangfredericks: so you write a macro that uses that function to generate the call to reify
17:19gfrederickshiredman: and the macro has to resolve the interface name
17:20hiredmangfredericks: why?
17:20gfrederickshiredman: else it's just a symbol.
17:20hiredmanfor the function?
17:20gfredericksyeah
17:20hiredman,(resolve 'String)
17:20clojurebotjava.lang.String
17:20hiredmanthats how you do it
17:20gfredericksare there complications when the macro is in one ns and the call is in another?
17:21hiredmanresolve is relative to the value of *ns* when resolve is called
17:21gfredericksI guess I can try this out pretty easily...
17:21hiredmanwhich will be the current ns, not the one where the macro is defined
17:21gfredericksoh
17:22hiredmanyeah, try it out, stop making problems up, you will hit plenty of real ones as you code
17:22gfredericksso if the calling ns has imported the interface name, and is using the short name, then resolve won't work?
17:22hiredmanit will
17:22hiredman(import 'clojure.lang.RT)
17:22hiredman,(import 'clojure.lang.RT)
17:22clojurebotclojure.lang.RT
17:22hiredman,(resolve 'RT)
17:22clojurebotclojure.lang.RT
17:23bartjhi, is there any clojure library to find
17:23gfrederickshiredman: I mean when the calling ns imports, but the ns defining the macro doesn't
17:23bartjpositions of HTML elements as rendered by Webkit, etc.
17:24amalloygfredericks: just try it. it's super-easy to test that
17:24hiredmangfredericks: I already tried to explain that it would work, and obviously failed, so just try it
17:25jcrossley3hi - is it possible to define a "once" test fixture for *all* the namespaces i'm running tests for?
17:26stuartsierrano
17:26stuartsierrasorry about that
17:27jcrossley3stuartsierra: would it be difficult to implement?
17:27stuartsierrayes
17:29jcrossley3stuartsierra: really? :)
17:29stuartsierraThe way clojure.test is written right now, yes
17:30jcrossley3stuartsierra: is it a common request? do most people work around it using test-ns-hook or something?
17:31stuartsierrayou're the first :)
17:31stuartsierrathat I know of
17:31stuartsierraI think people work around it by writing their own test drivers.
17:32amalloywhen it's time for me to run tests, i call stuartsierra and have him run the once-hooks for me
17:32stuartsierraHuh, just like the Clojure release process.
17:32technomancyjcrossley3: nah, it's not uncommon.
17:33stuartsierraI'll take a patch, just don't have time to do it.
17:33jcrossley3technomancy: any common solutions?
17:34hugodstuartsierra: would a patch for http://dev.clojure.org/jira/browse/CLJ-840 be likely to get applied?
17:34technomancyjcrossley3: some people write a hook for leiningen.test/form-for-testing-namespaces
17:34technomancynot the cleanest, but it works
17:34stuartsierrahugod: maybe
17:36hugodzi has an initScript parameter that gets called before running tests
17:36stuartsierraTest setup/teardown is almost always messy, no matter how you do it.
17:36stuartsierrahugod: just put a comment on CLJ-840
17:37hugodstuartsierra: a comment about?
17:37stuartsierraI mean, I put a comment there
18:00aaelonyI'm likely misunderstanding something. I'm seeking only to output when values equal "Profile" for a particular key. I believe I need filter for this, but first I sought to grab one row to test it. I see the key/value pair I want in this row, but the = function returns false rather than true as I expect. Just to investigate further, if I do (= "Profile" "Profile") I also get false, so I am surprised. Any help appreciated... http://pastie.org/265790
18:05arkhtroll?
18:05clojurebotaccording to troll lore living beings move backwards through time
18:06hiredman~botsnack
18:06clojurebotThanks, but I prefer chocolate
18:06hiredmanclojurebot: jerk
18:06clojurebotExcuse me?
18:06hiredmanclojurebot: you heard me
18:06clojurebothiredman: I'm just giving you a second chance
18:06hiredmanclojurebot: why I oughtta!
18:06clojurebotTitim gan éirí ort.
18:08lpetitthe IRC version of SIRI !
18:09ibdknoxlol
18:13sridthis way of looping through a structure to find something looks complicated, https://gist.github.com/1271458 - can it be simplified?
18:13sridthe argument to loop, especially
18:14amalloyblurrrrgh
18:14amalloycan't you just use filter to get out the thing you want, and then call calculatesomething on it?
18:14sridwhy filter? i'm looking for that *one* item, not a subset of items
18:14amalloy(first (filter...))
18:15amalloy&(inc (first (filter even? (range 11 20 3))))
18:15lazybot⇒ 15
18:16amalloy&(* 2 (first (filter #{17} (range 11 20 3)))) ;; just that one item
18:16lazybot⇒ 34
18:18sridamalloy: ok that works
18:19sridhere's the final version: https://gist.github.com/1271472
18:28tsdhHi. I have a seq like [:a [1 2] :b [4 5]] and want to calculate a seq of maps like [{:a 1 :b 4} {:a 1 :b 5} {:a 2 :b 4} {:a 2 :b 5}]. How do I do so?
18:30tsdhBasically I have some kind of binding vector at runtime and want to do something like `for': create a seq of bindings where each binding is represented as a map.
18:32amalloytsdh: i think you want `combinations` (which is in contrib somewhere) and `zipmap`
18:32amalloyor i guess it's less like combinations and more like cartesian product
18:33amalloyie, take a/b out entirely till you have [[1 2] [4 5]], compute the cartesian product, and then reintroduce a/b with a zipmap
18:34tsdhamalloy: Ok, I'll have a look.
18:38tsdhamalloy: Cool, cartesian-product does the trick. :-)
18:40tsdhamalloy: Mission completed: (map #(zipmap [:a :b] %) (cartesian-product [1 2 3] [4 5 6]))
18:40amalloyyep
18:40tsdh:-)
20:18cgrayhow do i replace the nth element of a vector?
20:20amalloy&(doc assoc)
20:20lazybot⇒ "([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)."
20:20cgraycool, thanks. I thought that was only for maps
20:46rimmjobis there a good book on understanding jvm internals?
20:46rimmjobeverything i find is about java lang :<
20:47rimmjobnvm i found http://www.amazon.com/Java-Virtual-Machine-Specification-2nd/dp/0201432943/ref=cm_lmf_tit_17
21:12khaliGhttp://www.h3rald.com/articles/10-programming-languages/ <- i like how only one of the cool language has examples of apps written in it
21:19amalloykhaliG: i have to wonder which one you think that is? i see examples for squeak, clojure, and erlang at least
21:21khaliGamalloy, i was thinking Erlang