#clojure logs

2009-09-22

00:01interferonis the a function somefunc s.t. (somefunc fn {:a 4, :b 5}} => {:a (fn 4), :b (fn 5)} ?
00:01interferonlike a map for maps
00:13mikehincheyinterferon: try destructuring in a map, like (map (fn [[k v]] {k (my-fn v)}) {...})
00:14mikehincheyalso, you need (into {} ...) around that
01:11tomojI've always wondered about that
01:11tomojis it efficient to build single-pair maps and (into {} ..) them?
01:12tomojseems intuitively to me that it would not be such a good thing to create a new map for every single pair
01:27mikehincheya vector would also work for the pair
03:05Fossihi
03:07mikehincheyhi
03:39LauJensenGood morning gents
03:42RomanRoegood morning
04:58AWizzArd~max people
04:58clojurebotmax people is 171
05:00jdzi guess i'm the only one annoyed by this
05:00jdzyou know you can communicate directly to the bot, right?
05:34LauJensenjdz: Calm down my friend, life is too short :)
05:34jdzi'm not upset, i'm annoyed :)
05:37eevar2jdz: some of us are pack animals. helps to know we're not alone ;)
05:39licoresseI know I can do (println (first (rest (rest ((vec sample-complex-structure) i))))) in a much simpler way
05:39licoresseCan someone point me in a direction?
05:42cgrandlicoresse ->
05:43licoresseah :)
05:43licoresse,->
05:43clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/->
05:43cgrand(-> i (vec sample-complex-structure) rest rest first println )
05:44licoressethanks a lot!!
05:44cgrand"rest rest first" can be "nnext first" or simply (nth 2)
05:48eevar2rest rest could also be written as (drop 2 seq)
05:50licoressebut I cannot do this: (doseq [i (range (count sample-complex-structure))]
05:50licoresse (-> (i (vec sample-complex-structure)) rest rest first println)
05:52ayalGood morning. I was wondering if someone ever implemented logging while maintaining a pure functional approach (- no atoms, no print etc). We were thinking about a crazy solution where every *single* function recieves a "log-object" and returns its return value with a metadata of the "log-object" on it. An optional way of doing it is changing defn in main.clj or some other crazy macro-based approaches. This seems a little too much
05:54eevar2I'd go with java.util.logging
05:55cgrandlicoresse: (let [sds [[:a :b :c] [:d :e :f :g]]] (doseq [i (range (count sds))] (-> ((vec sds) i) rest rest first println)))
05:55cgrandbut why not get rid of this index? (indexes are bad)
05:56cgrand(let [sds [[:a :b :c] [:d :e :f :g]]] (doseq [item sds] (println (nth item 2))))
05:56licoresseyes, I was thinking about that too, (!)
05:57licoresseI like this last one much better
05:57licoressethx
05:59ayaleevar2: We know how to log generally. However there is always a problem with two threads logging at the same time for example.
05:59ayaleevar2: The logs of two threads running at the same time would get interleaved, which is a problem.
06:06licoresseI think I understand this now, I feel great!
06:09Chousukeayal: maybe you could use a thread-local logging agent :/
06:10ayalChousuke: Yes, we though of that but I'm not sure how to create thread-local variables. Can I use vars? How do I then update them?
06:11mccraigayal: what do you need to do with the logs that makes it a problem for different threads logging to be interleaved ?
06:12Chousukeayal: you could also send a thread identifier with each logger event and have the agent just use that for sorting I guess
06:14ayalmccraig: We are writing a google wave robot. Robots run in the context of events - each event gets sent to the robot and the robot responds with operations. So we'd like to be able to see logs in the context of each event seperately.
06:14ayalChousuke: That seems like a good solution, albeit somewhat too technical and hacky. What do people do in other FP languages? This seems like a general issue.
06:15Chousukehmmh.
06:16ChousukeI wouldn
06:16Chousukewouldn't worry too much
06:16Chousukea simple logging call doesn't make your functions impure as far as your program logic is concerned
06:16mccraigayal: we use thread and context ids for our distributed logging : thread log sequence can then be recovered from a file with grep, or a logger can use the id as a database key
06:16Chousukeit's just logging. it doesn't change the way your program behaves.
06:18ayalmccraig, Chousuke: Thank you. I guess we will use the thread filtering approach for now.
06:19ayalSo.. How do you get the thread identifier? :P
06:19ChousukeI suppose the Thread class has somethinf :)
06:20ayalChousuke: Are you really not Chouser?
06:20ChousukeI am me :P
06:21ayalThank you all, have a nice day!
06:21licoressehm
06:23licoresseI found (map #(-> % (nth 2)) sample-complex-structure) equally nice to work with, since I don't really need the sideeffect
06:25Chousukewhy the ->?
06:25Chousuke#(nth % 2)
06:26licoresseoh
06:27licoresseno, that does not work with the structure
06:27Chousukehuh. but it's equivalent :/
06:28Chousuke,(macroexpand '(-> x (nth 2))
06:28clojurebotEOF while reading
06:28Chousuke,(macroexpand '(-> x (nth 2)))
06:28clojurebot(nth x 2)
06:29licoresseI'm sure you know this, but it is trying to cast a PresistentList to a IFn if I leave out ->
06:29Chousukedon't just leave out the ->
06:30ChousukeI mean #(-> % (nth 2)) -> #(nth % 2)
06:30licoresseokay...
06:31Chousukethat ought to work, because they're exactly identical as far as the compiler is concerned :)
06:32Chousukebut I'll go get something to eat now. later
06:34cow-orkerChousuke: "it's just logging. it doesn't change the way your program behaves." <- that's a dangerous assumption! :)
06:35licoresseChousuke: yes, I see your point now...
06:40jdzdotimes instead of doseq?
06:40jdzbut then i'd just use map
06:40jdzor rather, (doseq [x sample-complex-structure] (-> x rest rest first println)
06:40jdz)
06:40jdzi'd say logging is sideeffecting by nature
06:40jdzi don't know the details, but if the whole logging record is not performed in a single system call then logs from different threads might be interleaved, right?
06:46eevar2any logging api worth using should be thread safe
07:06JomyootIt would be great if I can readily convert clojure structures into Ruby structures without going through JSON
07:10tomojJRuby?
07:10tomojor what? I don't get it
07:11Jomyootconvert { :a 0 :b 1} into { :a => 0, :b => 1}
08:00crioshi
08:02jonvvhi does anyone have time to discuss thread local bindings that get "lost" by the use of lazy sequences?
08:04cgrandjonvv: you have to capture and restore them
08:05rhickeyjonvv: just grab them into a let before creating the lazy seq. Putting code that uses vars inside the closure is the problem
08:06rhickeyif your lazy seq function calls code that in turn uses vars, then you'll have to explicitly bind them
08:10rhickeypatches 169 and 170 will provide helpers for grabbing bindings
08:10rhickeyhttps://www.assembla.com/spaces/clojure/tickets/169
08:10rhickeyhttps://www.assembla.com/spaces/clojure/tickets/170
08:11jonvvok.. but if i want to make any 'system-wide' (rather than fairly targeted, localized use) of var bindings.. i'd have to be capturing and rebinding absolutely all over the place? why is it useful for lazy sequences *not* to *always* grab and rebind the threadlocals?
08:12jonvv(ie. what's a use case for lazy calculations to be done later on in an effectively random 'context'?
08:14rhickeyjonvv: if you are using vars inside a lazy sequence, directly or indirectly, those are like side-effects (i.e. non-local) and must be treated similarly. The overhead for capturing the dynamic context for every lazy seq op would be extreme, and would effectively render dynamics non-dynamic
08:15rhickeythere is a fundamental tension between laziness and dynamic scope
08:15rhickeycombine with extreme caution
08:26ayal,(contains? '(1 2) 1)
08:26clojurebotfalse
08:26ayalwhy?
08:28jonvvok.. thanks.. when i first met clojure last year (coming from VB.net) i thought the thread local bindings solved some problems quite neatly.. and the use of them for *in*, *out*, etc seemed to encourage their (potentially) 'system-wide' use for certain things.. and i was thinking of using them (as suggested a couple of times on the group) for switching between more than one simultaneously available low level implementations of "interfa
08:31jonvvhi ayal.. i know the answer to that..
08:32jonvvcontains only works on.. Associative, IPersistentSet, Map, + Strings and Arrays when used with an integer.. otherwise returns false!
08:33ayaljonvv: oh ok weird. thanks.
08:33jonvv(some #{1} '(1 2)) returns 1 (ie. a true value since not nil)
08:34Chouserayal: if you have a collection that you'll use mainly to see if it contains things, try using a set instead of a list.
08:34ayalChouser: you're right but we get it from an external API
08:35ayaljonvv: Thank you, that'll do.
08:35Chouserayal: the external API prefers to provide a PersistentList vs. a PersistentHashSet?
08:36cow-orker...but sometimes you have a list (eg - code) ... it is strange, seen from a user perspective, that it doesn't work with a list.
08:36jonvvayal: (contains? (into #{} '(1 2)) 1)
08:36Chouser,(contains? (set '(1 2)) `)
08:36clojurebotUnmatched delimiter: )
08:36Chouser,(contains? (set '(1 2)) 1)
08:36clojurebottrue
08:37Chouser,(.contains '(1 2) 1)
08:37clojurebottrue
08:37Chouserthere are ways. :-)
08:38Chousercow-orker: the idea is that generally only things the collection can do fast have direct functions available. Doing 'contains' on a list is O(n), so it doesn't support 'contains?' directly.
08:38ChouserThough 'nth' seems to stretch that rule a bit.
08:40drewrhttp://www.artima.com/forums/flat.jsp?forum=226&amp;thread=268948
08:40rhickeyChouser: yes, nth gets a break it probably shouldn't, r at least there should be a guaranteed-fast indexed lookup
08:43ChouserWhen I do positional destructuring, it's almost always on a vector, I think.
08:43rhickeydrewr: yeah, the discussion there has been quite disappointing
08:43ChouserActually, I hardly ever use lists except when writing macro-related code.
08:44rhickeyChouser: yeah, vectors rule everywhere else
08:45cow-orkerI see... a good reason, but not very ducky... I mean, performance is not always the issue, clearity and elegance are important too. Anyway - a writeup wrt internals, lookup speed O(?) ++ would be useful :-)
08:46rhickey,(doc nth)
08:46clojurebot"([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."
08:50ChouserI almost wonder if some readers thought you meant that fixing the Date object would solve the time problem.
08:50rhickeyChouser: heh
08:52Chouserwhoa. paste.lisp.org pastes expire!?
08:52Chouserjcall is gone
08:52drewrshouldn't by default
08:53ChouserI'm pretty sure this used to be jcall: http://paste.lisp.org/display/67182
08:54drewrmy delicious agrees
08:55Chouserhttp://clojure-log.n01se.net/date/2008-07-23.html#15:02
08:58Chouserway past time to put that in contrib, apparently. java-utils?
09:02rhickeyChouser: the problem with jcall is, some people come to Clojure expecting a string-based duck-typing system. That's not what Clojure is about. > 90% of the time they shouldn't be using jcall, but if it were there they would happily use it and never ask the questions that help them understand how Clojure works. Then they will complain about jcall being slow...
09:17cow-orkerwould it make sense for RT-contains to throw an exception instead of returning F (last line in method) ?
09:17Chouserrhickey: adding warnings in the jcall docstring wouldn't be sufficient?
09:18rhickeyChouser: warning, do not use this :)
09:18Chouserexactly!
09:19rhickeyI'd rather see it live in a FAQ than the library
09:21Jomyootwhat is THE json library for clojure?
09:23ChouserJomyoot: I think there are two
09:24Jomyootis the contrib one good?
09:24Jomyootcannot find documentation
09:24Chouserthat's about par for contrib. :-)
09:26Jomyoothow would I find doc for clojure.contrib.json.read
09:27Jomyootsorry i am stupid
09:27Jomyootfound it
09:31Jomyoothow would I change all {"a" 1 "b" 2} to {:a 1 :b 2}?
09:32ChouserJomyoot: didn't I answer that for you yesterday?
09:33Jomyootsomething with zipmap
09:33Jomyootright?
09:33Chouseryes
09:33Jomyooti thought it was related question
09:33Chouserhttp://clojure-log.n01se.net/date/2009-09-21.html#09:38a
09:33eevar2Jomyoot: i know I said _don't_
09:33Jomyootyep
09:33JomyootI prefer to use (:a hash) than (hash "a")
09:33Jomyootwhen accessting
09:34Jomyootaccessing
09:34Jomyootit's easier to read
09:35eevar2how large is said hash?
09:37eevar2or nm, i don't care
09:52drewrhow do I force expansion of a symbol in a macro?
09:53drewre.g., (defmacro foo [args] `(do ~@(map ... args)))
09:54drewr(let [bar [1 2 3 ...]] (foo bar)) will complain about args being a symbol
09:55Chouserdrewr: the value of bar there isn't known until runtime. you probably need to generate a call to map instead of trying to execute the map at compile time
09:55Chousuke*sight*
09:55Chousuke-t
09:55Chouser(defmacro foo [args] `(map ... ~args))
09:55ChousukeI took a course for GUI programming and since the assignment is in Qt I hoped I could do it without Windows
09:55ChousukeI was wrong,
09:55Chousukethey distribute the program as a windows DLL and we have to write an UI for it...
09:56ChousukeI don't even have a windows licence :(
09:58ChouserChousuke: probably not worth messing with wine. :-/
09:59drewrChouser: hm, you're right, but the reason I'm mapping at compile time is to generate a dynamic list of (.foo ...) method calls in a doto
09:59Chousukeso now I can either drop the course or get a Windows environment set up somehow
09:59drewrChouser: virtualbox or qemu?
09:59drewrwhoops, that was for Chousuke
09:59ChousukeI'm definitely not going to pay for a full windows licence though.
09:59criosmaybe a trivial question. What is a "cell" in your context?
10:00Chousukedrewr: you must pass the vector as a literal to the macro
10:01drewrI guess I just need to use a function
10:01drewrthe fn is ugly though
10:02Chouseryou either have to have the vector at compile time (pass it in directly, generate non-reflective code at compile time) or not have the vector until runtime and do reflective calls.
10:06drewrcan I do the reflective calls in clojure?
10:06Chousersure
10:07Chouserwell, what do you mean? You can do anything in clojure. :-)
10:07drewrheh
10:07drewrare they uglier than the fn version?
10:07Chouseryou're passing in a vector of method names, or ...?
10:08drewrlet me paste a full example
10:08Chouseryes please.
10:13lisppaste8drewr pasted "seq expansion from macro arg" at http://paste.lisp.org/display/87499
10:13drewrwell that doesn't work
10:14drewrguess jcall isn't lost forever :-)
10:14drewrhttp://gist.github.com/191109
10:23Chouserdrewr: you're going to have several functions that look like make-options, or you're just trying to clean up that one?
10:24drewrjust that one for now, though I do see a pattern there that's worth generalizing
10:25Jomyootwhy does read-json parse {"action": "save", "id": 37296, "model": "story"} into {model story, id 37296, action save}
10:25JomyootI am using the contrib read-json
10:25Jomyootis it wrong?
10:25Jomyootit looks wrong to me
10:25Jomyoot[
10:25Fossilooks good to me, what's looking wrong to you?
10:26JomyootI am not expecting the comma
10:26Fossithe comma is optional in clojure
10:26hiredman
10:27Fossiit's like whitespace
10:27Jomyootduh
10:27hiredman,'{a b c d}
10:27clojurebot{a b, c d}
10:27hiredmanthe comma is an artifact of printing out the map
10:28Jomyootok
10:30Jomyoot,(map #({:a %}) [ {:a 1} {:a 2}])
10:30clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap
10:32Jomyoot,(hash-map :a 1 :b 2)
10:32clojurebot{:a 1, :b 2}
10:32hiredman#({:a %}) => (fn [x] ({:a x}))
10:38Jomyootclojure is the only langue where i feel smarter everyday using it
10:39cgrandclojure enlarges your iq :-)
10:39drewrJomyoot: it's the first *practical* language to have that effect on me
10:40drewrplenty of stuff out there can stretch you
10:40Chousukemaking the comma whitespace was an interesting decision. :)
10:42cgrandChousuke: I don't know, cause it's now my #1 error when wrtiting in other languages
10:42Chousukemost lisp people will probably go "wait, what?", while people coming from other languages will be grateful that they don't get errors if they accidentally type it :P
10:42tmountainI think it's nice for readability when representing a data structure
10:42hiredmancgrand: me too, that and missing returns
10:43Chousuketmountain: yeah.
10:43cgrandyeah that one too
10:43hiredmanI love the coma as whitespace
10:43tmountaingreat for maps
10:43Chousukeit's not actual *syntax*. it's like indentation.
10:43Chouseror pairs in vectors
10:46djpowellWould core benefit from a 're-split' function, that basically does pattern.split(s)? (for parsing tab-separated files and stuff)
10:48Chouserdjpowell: why not just call pattern.split(s) ?
10:49hiredmanString's .split takes a string regex also
10:49djpowellYeah, I am doing: (seq (.split #"\t" s)).
10:49Chousermost things that take seqs will call seq for you
10:50djpowellyeah, but arrays don't have nice string representations
10:50djpowellhiredman: the regexp version is probably better, cause then you can use an interned regexp
10:51Chouserthere's also split in str-utils and str-utils2
10:52djpowellChouser: Oh ok. I'm a bit shy about using contrib cause I'm never sure what state it is in.
10:53Chouserhas it bitten you?
10:55djpowellNo not yet. There is some great stuff in there, but for what I'm doing it hasn't really been worth the effort of discovering it.
10:56djpowellseqs rock. I'm just working on reading a directory of tab-separated files into the same format as I get from resultset-seq, to test my heavily interweaved java/clojure project.
11:02drewrdjpowell: I share your frustration with contrib, but you can lock into your build a version that has working parts you need
11:06stuartsierraWhat would make contrib palatable?
11:06djpowelldrewr: yeah, it isn't really a problem for me yet. It would be nicer if we had something a bit more CPANish, but I'm not in a hurry yet.
11:40steganohi guys having read this blog http://bestinclass.wordpress.com/2009/09/17/scala-vs-clojure-round-2-concurrency/ its not very clear if clojure would be a good choice for distributed computing ... obviously I don't know much about clojure but I do understand the Actor model that Scala has adopted from the Erlang world ....
11:41steganoso the question is does clojure support distributed computing as easily as Erlang's actor based paradigm ??
11:42rhickeystegano: no, distribution is not built into Clojure. OTOH, you have a wealth of non-built-in options, i.e. JMS, AMQP, etc
11:43stuartsierraHadoop, Terracotta, ...
11:43criosmaybe stegano do you mean "parallel" distributed computing?
11:43rhickeyJGroups, GridGain, NetKernel
11:46steganorhickey: thanks for those pointers .... so I would assume that distribution is not built into clojure bcoz of the jvm limitations right ? ... and that means clojure like other jvm languages wouldn't be able to take advantage of multiple cpu's ....
11:46stuartsierrano, no!
11:46stuartsierraThe JVM uses multiple CPUs in a single machine just fine.
11:46steganowell that may not be true ... but certainly a cluster would be very difficult to build
11:46steganostuartsierra: i mean you are right.... sorry for that oversight
11:47rhickeystegano: http://www.gridgain.com/
11:47steganocrios: yes I mean parallel distributed computing
11:47stuartsierraParallel distributed computing is always hard.
11:48steganostuartsierra: except that erlang makes it some what easier
11:48albinoHow do you bootstrap erlang onto multiple machines?
11:49Chouserdoes erlang force or encourage you to handle node and communication failures even when just using mutliple local cores?
11:49drewrstegano: erlang makes serialization trivial, and forces you to pass messages, but you can do both in clojure
11:50drewrChouser: both
11:50rhickeyChouser: yes, the local case is exactly the same as the distributed
11:50drewra process is a process is a process
11:50Chouserhm
11:51steganodrewr: i am sure I can do the same in clojure too on a local node ... but is there any additional complexity to deal when dealing with remote nodes
11:51stegano?
11:51steganodrewr: as rhickey just said the local case is same as distributed case in Erlang
11:51albinojust the complexity of putting grid gain agents on multiple machines?
11:51rhickeywhich means reading data == sendMeTheData(you, me), then blockWaitingFor(you)
11:53rhickeyIMO most applications are better served using a higher-level construct like message queues. Note, e.g. the #1 application of Erlang outside of telcomm is to write message queues (RabbitMQ, ejabberd)
11:53drewrstegano: my point is that with clojure the local case is easier and the distributed case can be as elegant
11:53rhickeyErlang is great plumbing for that
11:54drewrit also has great binary splitting for implementing certain protocols
11:55steganodrewr: how do you mean in clojure the distributed case can be as elegant ? do you mean by using GridGrain's
11:55rhickeybut managing webs of directly interconnected distributed objects is tricky. Message queues add useful indirection, durability, manageability etc
11:56drewrstegano: it's not baked into the language like it is with erlang, but there are plenty of ways to pass messages robustly (see rhickey's ongoing comments)
11:57rhickeyWriting a message queue? use Erlang. Writing an ordinary application? use a message queue.
11:59danlarkinrhickey: +1
12:01ChouserI need to understand better what a message queue system provides and how an application is meant to interact with it.
12:04stuartsierraChouser: try the Amazon SQS docs -- don't know how that compares with libs like JMS, but it's very easy to follow.
12:04Chouserstuartsierra: ok, thanks.
12:05tmountainis there a more idiomatic way to do this? (= clojure.lang.Ref (class my-var))
12:06hiredman,(doc instance?)
12:06clojurebot"([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"
12:06Chousertmountain: not exactly that, but (instance? clojure.lang.Ref my-var) is close
12:07tmountainok, but there's nothing equivalent to (ref? ...)
12:09ChouserI don't think so
13:37winterstreamHi everyone. I'm trying to create a plugin for a program (Cytoscape, if it matters). I'm using AOT compilation to generate a minimal plugin class, but it fails to load. Could Cytoscape be loading plugins in a way which causes trouble with Clojure generated classes, or is my mistake likely elsewhere? (I've been struggling with this for 2 days).
13:39Chouserwinterstream: so you get any kind or exception or stack trace?
13:39Chouserdo you?
13:40winterstreamChouser: I can only see NoClassDefFound in Cytoscape's error window. I compiled it from source and should probably put a breakpoint in at its plugin loading code to see what's going wrong.
13:40Chouserthat is the kind of error one would expect when classloaders start to get in each others' way, though other things can cause it too.
13:44winterstreamChouser: Thanks. I'm going to hook Cytoscape to jSwat to see if I can identify the problem. Another question: if I distribute a jar containing Clojure compiled classes, where should clojure.jar be placed? Can jars be nested? Sorry - I realize that this is really a non-Clojure question, but it is something to worry about with Clojure code.
13:46ChouserI believe you can nest jars, and have the outer jar specify the inner one as part of the classpath using the outer's manifest file.
13:46Chouserbut I've never done it.
13:47ChouserI always just unpack all the jars into a common dir, then pack them up into a single .jar
13:48stuartsierraI think nesting jars requires special classloaders
13:48winterstreamI'm quickly checking if that's causing my issues.
13:52winterstreamUg. It was as simple as that - I just had to unpack clojure.jar and place its contents into my jar.
13:52hiredmanhttp://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4648386 <-- "Simplify deployment and versioning by embedding JAR files within each other"
13:52winterstreamThanks Chouser & stuartsierra.
13:52winterstreamThanks hiredman, I'll check that out.
13:53winterstreamOh wait, I see
13:53winterstream:/
13:53winterstreamOh well. It's not too bad taking the extra step.
13:53hiredmanhttp://one-jar.sourceforge.net/
15:52lisppaste8hamza pasted "rss concatanation" at http://paste.lisp.org/display/87523
15:53hamza`hey guys i am trying to create an rss feed but i can't figure out how to add inner-test functions output after the desc tag?
15:54stuartsierrahamza`: you can return data structures from the xml-inner-test, don't call (prxml...) again
15:55hamza`i am going to call inner-test multiple times is it ok to concat the resulting vector for each item in list?
15:56stuartsierraSure, just return a list.
15:56stuartsierraIf prxml sees a list in its arguments, it recursively prxml's each element of the list
15:56hamza`kk thank you
15:57stuartsierrawelcome
16:16prospero_are there plans to let you add metadata to anonymous functions?
16:20technomancyprospero_: there's a ticket for it
16:20technomancyprospero_: have you seen the workaround with proxy?
16:35prospero_technomancy: no, I haven't. link?
16:35technomancyprospero_: not sure off the top of my head; try searching the mailing list for: proxy fn metadata
17:04hiredmanclojurebot: ticket search Fn metadata
17:04clojurebot("#140: Single :tag for type hints conflates value's type with type of return value from an invoke" "#12: GC Issue 8:\t:default as keyword arg to defmulti")
17:04hiredman:|
17:06hiredmanclojurebot: ticket #94
17:06clojurebot{:url http://tinyurl.com/mgjunh, :summary "GC Issue 90: Support metadata on fns", :status :new, :priority :normal, :created-on "2009-06-17T20:43:34+00:00"}
17:07hiredman"milestone set to Release 1.1"
17:51jensliIs there a shorter way to do:
17:51jensli,(apply concat '((1 2)(3 4)))
17:51clojurebot(1 2 3 4)
17:51jensli?
17:51stuartsierrathat's pretty short
17:52stuartsierrabut c.c.seq-utils/flatten might work
17:53jenslik, thanks.
17:54stuartsierrahttp://stuartsierra.com/2009/09/22/its-about-the-platform
17:54jenslithe standart lib is big enough for me for a while
17:59Chouserno memory leaks in java?
18:00Chouseroh, he's gone.
18:01jensliJava leaks in a more controled manner.
18:02hiredmanthat article is timely
18:02hiredmanplog post
18:02hiredmanblog
18:02hiredmanwhatever, man
18:22hamza`hey guys how can turn a string to a keywork "platform" -> :platform?
18:23LauJensen,(keyword "platform")
18:23clojurebot:platform
18:23hamza`thx
18:23LauJensennp
18:29jensliI dont seem to be able to do this: (defn create-obj [class-sym] (new class-sym))
18:29jensliDo I have to use reflection for this? Create an object of a class passed as an argument.
18:30hiredman,(new (Class/forName "java.lang.Object"))
18:30clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: (Class/forName "java.lang.Object")
18:30hiredmanwhee
18:30hiredmanyeah, you need to use reflection
18:32jensliok, thanks, hrm, then I have to learn some new stuff...
18:32clojurebotnew Class(x) is (Class. x)
18:33hamza`why is this causing an exception?
18:33hamza`,(with-meta "atest" {:layout true})
18:33clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IObj
18:33hiredman
18:33hiredmana String is not an IObj
18:34hamza`so i can't store meta for a string that i am returning from a function?
18:34hiredmanany string
18:34technomancyhamza`: that's right; unfortunately Java doesn't let you subclass strings to add features.
18:34hiredmanclojure strings are java.lang.String strings
18:35technomancy"If God had wanted strings to have features, he would have built them into the JDK!"
18:35technomancyaccording to Sun, at least.
18:35hamza`kk got it thx i'll stick to maps :(
18:36hiredmanyou could always proxy CharSequence and IObj
19:43hamza`is there a native clojure way to cast "12" to 12?
19:43hamza`or do i resort to java?
19:46Makoryu, (read "12")
19:46clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.io.PushbackReader
19:46MakoryuDang
19:46technomancy,(int "12")
19:46clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character
19:49dnolen,(.parseInt "12")
19:49clojurebotjava.lang.IllegalArgumentException: No matching field found: parseInt for class java.lang.String
19:49dnolenheh
19:49hamza`,(Integer. "12")
19:49clojurebot12
19:49hamza`worked
19:49Chousukeit's Integer/parseInt anyway
19:49dnolenthere you go, just saw that.
19:53rhickey,(read-string "12")
19:53clojurebot12
20:03Chouser,(read-string "#=(println \"watchout\")")
20:03clojurebotwatchout
21:02khorahello
21:03khorahow do I setup acquamacs for clojure?
21:16khoraI'd like to be able to install Acquamacs and its support for Clojure, is this a recommended setup?
21:16hiredman~emacs
21:16clojurebotemacs is best configured for Clojure with instructions at http://technomancy.us/126
21:16Chouserkhora: I believe that's what Rich Hickey uses, though he doesn't use slime.
21:16khoraChouser: what's slime?
21:18khorahiredman: thanks. Will those instructions work for aquamacs too?
21:19Chouserit's an advanced mechanism for emacs to interact with a running lisp. I don't use it either. :-)
21:20khoraChouser: oh ok. So all I need is Aquamacs itself, and clojure-mode?
21:24khora~textmate
21:24clojurebotExcuse me?
21:24khoralol
21:25hiredman~google clojure textmate bundle
21:25clojurebotFirst, out of 3860 results is:
21:25clojurebotANN: Clojure Textmate Bundle 0.1 | Educate. Liberate.
21:25clojurebothttp://nullstyle.com/2008/11/09/ann-clojure-textmate-bundle-01/
21:29dnolenkhora: http://bc.tech.coop/blog/081023.html, bill clementson's tips are also very helpful.
21:33hiredmanexcept all the urls are outdated
22:44blcooleyHi, I am trying to figure out an idiomatic way to accumulate a sequence, kind of like reduce. An example would be (accumulate + '(1 2 3 4)) yielding (1 3 6 10).
22:44blcooleyMy first attempt was (defn accumulate [f coll] (for [ind (range 1 (inc (count coll)))] (reduce f (take ind coll))))
22:45blcooleybut this obviously calls f needlessly
22:46blcooleySo I wrote a recursive version: http://gist.github.com/191620
22:46blcooleyFeels like I am missing something, though. Any tips?
22:47Chouserblcooley: seq-utils reductions
22:47blcooleyChouser: thanks
22:48Chouser,(reductions + [1 2 3 4])
22:48clojurebot(1 3 6 10)
22:48blcooleyexactly what I was looking for. guess i have some studying to do. :)
22:49hiredman http://video.google.com/videoplay?docid=-8860158196198824415# Growing a Language -- Guy Steele
22:50Chouserhiredman: I've watched that. Fantastic.
22:51hiredmanyeah, it's great
22:51hiredmanI wanted clojurebot to delicious it
22:53savanniHey, all. I don't have any questions at the moment, but I'm just letting you know that I am here. I started playing Clojure today.
22:55durka42savanni: welcome
22:56durka42be careful, i hear the boss at the end is a bitch
22:56savanniThe boss at the end?
22:57hiredman~laugh
22:57clojurebotNo entiendo
22:57savanniOh. I didn't even realize my grammer failure!
22:57savannigrammar.
22:57hiredman~laugh is <reply>ha ha
22:57clojurebotAck. Ack.
22:57hiredmanclojurebot: it's funny, laugh
22:57clojurebotThe most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' (I found it!) but 'That's funny ...' -- Asimov
22:57hiredmanbah!
23:00savanniAnyway, I started doing this because I've gotten frustrated trying to figure out how to create a clisp *program*... something I could easily launch from the command line or run as a CGI. And because some co-workers are interested.
23:01hiredmanthe jvm's start up time sort of nixs cgi most of the time
23:01durka42you could teach apache how to use a nailgun
23:02hiredman~laugh
23:02clojurebotha ha
23:02savanniWell, theoretically, I should be able to do something crazy with Apache. Like mod_java or tomcat or something.
23:02savanniOr just use the java-implemented web server.
23:03hiredmansure
23:03savanniOr forget CGI and use Swing. :)
23:03Chouserthe world is your oyster.
23:05durka42(identical? World/getGlobalWorld (.oyster savanni))
23:05savanninil
23:06hiredman(.getWorld SingletonMatrixFactoryObject)
23:06durka42RuntimeException: too many design patterns in: SingletonMatrixFactoryObject
23:07rlbClevernessOverflow...
23:09durka42break c-c-c-combo;
23:09savanniC-c
23:11savanniCuriosity point... does clojure support conditions and restarts?
23:11durka42there is chouser's clojure.contrib.error-kit
23:12savannik. I'm not even sure it matters because I haven't programmed enough lisp to use them yet.
23:49killy971is there a known bug concerning maps not being able to store more than 8 key/value associations ?
23:49killy971transient ones
23:50technomancykilly971: array maps become hash-maps when they have more than 8 entries
23:51killy971so how should I do_
23:51killy971?
23:52technomancythey should function the same way
23:52danlarkinone becomes the other
23:52danlarkinthe class is not important
23:53danlarkinfree your mind!
23:53killy971of course
23:54killy971but the problem is that if I execute in the REPL the following 3 lines
23:54killy971(def a (transient {}))
23:54killy971(map #(assoc! a % %) (range 10))
23:54killy971(count (keys (persistent! a)))
23:54hiredman:(
23:54killy971the result is 8
23:54killy971not 10 :/
23:54hiredmanhave you read the docs for transient?
23:55hiredmanyou need to pass the output of transient around still
23:55hiredman,(doc transient)
23:55clojurebotNo entiendo
23:55hiredmanbah
23:55hiredmananyway, a. don't def transients
23:56hiredmanb. you need to pass around the result of assoc!, etc
23:56danlarkinkilly971: you're trying to shoehorn state in here... incorrectly
23:56killy971yup
23:56killy971well
23:57hiredmanso don't do those things
23:57killy971I would like
23:57killy971so
23:57hiredmanwhy would you want to do a bad thing?
23:57killy971is there a nice way to do dynamic programming without adding useless parameter to my functions ?
23:58danlarkinkilly971: you have the wrong mindset
23:59hiredmanhttp://en.wikipedia.org/wiki/Dynamic_programming <-- this kind of dynamic programming?