#clojure logs

2011-02-12

00:00cheezeyi already removed it.
00:00bytecoloranthony__: so in myscript.clj you have (ns myscript (:use my-utils)) ; not really sure if that's correct
00:01bytecolorI haven't loaded a clojure program the way you are attempting
00:01anthony__bytecolor: I've tried several things similar to that, none of them worked
00:03anthony__Is there a function where I can pass it a .clj file and have it eval all of it? Maybe I need to eval the my-utils.clj from the JAR file before trying to use it.
00:06tomojwhat does your myscript.clj actually do?
00:06anthony__Just some defs
00:06bytecolorhrm, I wonder if it's due to the hyphen in my-utils.clj
00:06anthony__Oh, sorry.
00:06anthony__The myscript just calls some of the functions declared in my-utils.clj
00:07tomojI mean, what does it _do_?
00:07tomoji.e. do you have a good reason for dealing with all this bullshit manually?
00:08tomojideally you shouldn't have to worry about the classpath nor type "java" :)
00:08anthony__tomoj: Well, I'll have several (independent) scripts using the functions from my-utils. I could just make separate programs out of each of them, using my-utils as a library. I was just curious if it was possible to avoid that and just run them as scripts.
00:09tomojhmm.. my suggestion leads to creating separate projects for each script which all depend on the utils
00:09tomojwhich could be a hassle
00:09anthony__I mean, I could probably throw them into one project, and just take a command-line arg for the script to run.
00:09tomojoh, as you said
00:09tomoj:)
00:09anthony__Which would be nicer.
00:10anthony__I'll mess around with it some more. Maybe the hyphen is messing something up, like bytecolor said
00:10bytecolorwait, wait, I want to know *why* it wont work ;)
00:10tomojwell, you should never have hyphens in a .clj filename
00:11anthony__bytecolor: lol, me too. I need to grab something to eat, but I'll be back with some more messing around. I might be just doing something stupidly wrong.
00:11tomojalways replace with underscores
00:11bytecolortomoj: nod, that bit me on the ares for a while until I figured it out
00:11bytecolorthat's why I thought it may be a problem in anthony__'s example
00:12tomojhave we seen the error yet?
00:12bytecolorwhy no! we haven't
00:13tomojblind men with an elephant, eh?
00:15anthony__Sorry, here's the error:
00:15anthony__Exception in thread "main" java.lang.Exception: Unable to resolve symbol: myutils in this context (myscript.clj:1)
00:15anthony__(I changed it to myutils)
00:15tomoj:D
00:15tomojthat error looks rather mundane
00:16anthony__Exactly. That's why I'm worried I'm missing something trivial.
00:16tomojperhaps you're missing a require or use in myscript.clj?
00:17anthony__tomoj: I wasn't missing it, but I think I had it typed wrong. Seems to be working now. Must've been the hyphen originally.
00:19tomoj(require 'foo.bar.baz-bang) will look for foo/bar/baz_bang.clj on the classpath
00:25anthony__tomoj: Amen. The problem with Clojure is that it makes me hate writing Java more and more each day.
00:25anthony__I was happy living in ignorance before.
00:26tomojit's a strange situation
00:28bytecolorI think any time you start writing lisp, you have to step your game up. But, you'll be a much better programmer for having done so.
00:28tomojI guess it helps if you were a java programmer already
00:28tomojthen it just looks like you get to escape much of the madness
00:28brehautbytecolor: that applies to any language that differs from the paradigms you know
00:31anthony__tomoj: Exactly. It's wonderful coming from Java.
00:31bytecolorbrehaut: well, I don't know. I dont think any other language has made me re-evaluate my thought process more than lisp. Take clojure. The immutability has really tossed me a curve ball. But, I've never used a purely functional language such as haskell.
00:32bytecolorwell, after typing that, yes I can agree with you
00:32greghthe "functional" thought process hit me when I did some nontrivial stuff in xslt (of all things) years ago
00:32brehautheh :)
00:32tomojbytecolor: in which other languages have you dabbled?
00:32bytecolorcommon lisp, scheme, python, c++
00:33tomojso, lisps vs python and c++?
00:33bytecolornod, I'll concede that my view is quite limited
00:34tomojthe "are we there yet?" talk by rich includes a part about how most popular languages are practically the same
00:35brehauta logical language and haskell should be on everyones list to learn IMO
00:35tomojand that the main differences are programmer sensibilites
00:35tomojif we're going to have religious wars, maybe programmer sensibilities aren't such a bad thing to war about
00:36cheezeyso if a ns exists in (find-namespaces-on-classpath), how can i use one? for example clojure.core is in there..
00:36cheezeyi dunno i think im just being frustrated at this point ;_;
00:37tomojbut it's not awfully surprising to me for someone who's learned several popular languages very well to never have their head screwed around
00:39tomojbrehaut: what would be your recommendation for a logical language?
00:39brehauteeck kinda hard. prolog is very available and its hte canonical example
00:39amalloytomoj: prolog is the canonical one
00:39tomojmy dabble there was probably not long enough for head-screwing
00:40brehautbut clause ordering and cuts require you to understand the procedural evaluation for even some simple programs
00:40brehautmy dabble with miniKanren over summer was promising as a good first pass
00:40bytecolortomoj: makes two of us, I've played around with it, but not written anything worth mention
00:41bytecoloralthough I'd still like to implement prolog in clojure, as in paip
00:41brehautbrain bending programs can be _very_ short in prolog ;)
00:41bytecolorbrehaut: I have The Seasoned Schemer on my desk (collecting dust :/)
00:42brehautive only go the little schemer
00:42brehautive pondered getting the seasoned and reasoned schemers
00:44brehauttomoj ask dnolen, hes neck deep in logical programming
00:46bytecolorI'd like to see hicky and co do a rewrite of paip in clojure. That would be one eye-opening book, imo. I tried doing a one-to-one port to clojure, but some of the functions just do so much mutating it's just not practical unless evertying is an atom, ref, etc.
00:46tomojshoot, "clojure nomic"
00:46tomojhas results now
00:47tomojthe only result looks totally fucking bogus though
00:47brehaut'nomic' ?
00:48tomojer, talk of prolog reminded me of my attempts to write a code nomic in prolog. I've been yearning for a clojure one for quite a while
00:49tomojthis appears to be the only clojure source file in the only so-called clojure nomic I can find: https://gist.github.com/1de0bec2aafc936d39b3 O_o
00:50tomojignoring all the .clj files which appear to be dependencies checked in to the repo for some reason
00:51amalloytomoj: funny you should mention nomics and xslts. i wrote a nomic that was mainly a couple xml files, and several xslts to render them in different ways
00:51bytecolorso is mutation in the let vector abuse, or good form?
00:52brehautbytecolor: do you mean shadowing prior bindings?
00:52brehaut(let [a 1 a 2 a 3] ...) frinstance?
00:52bytecolorusing prior binding to *set* subsequent bindings
00:52bytecolorI guess *set* would be bind, as in local binding
00:53brehautthere are probably better tools for a lot of cases
00:53tomojI accept it occasionally
00:53tomoj
00:53bytecolorclojure let is actually common lisp let*, no?
00:53bytecolorwell, leaving destructing aside
00:54tomojwhether it's abuse really depends I guess
00:54bytecolorclojure destructuring is pretty cool, imo
00:54brehautits not abuse; if it were it wouldnt be allowed
00:54tomojit certainly can be abused
00:55brehauti think its more of a code smell though
00:55bytecolorhey, I ran across a problem where I tried to destructure a binding form, but it crapped out. I found *old* post where someone had written a macro to do this, but has it not been implemented in the core?
00:57bytecolorsomething simple like (binding [[x y] [0 1]] [x y]), but (let ...) will work
00:58tomoj"binding form" :)
00:58bytecolorwhere x and y had been def'ed prior
00:59tomojis it easy for you to explain why that would be useful?
00:59tomojI can't think of an example
01:00bytecolorwell, actually I was converting koza's genetic programming kernel to clojure
01:00tomojamalloy: hmm. so how do you play that nomic?
01:01bytecolora map of 11 bits
01:01amalloytomoj: email, and iirc manual editing of the xml files for new rules
01:01amalloyit never really got off the ground
01:01tomojunfortunately that seems to usually be the case
01:02bytecolorso, destructuring a binding is out
01:02tomojmap of 11 bits? like {0 true 1 false ... 10 true} ?
01:03bytecolortomoj: basically, yes
01:03bytecolortomoj: it was another one-to-one port, probably much better ways to do it in clojure
01:03bytecolorporting from common lisp code
01:06bytecolorin the kernel, EVAL is used heavily in the fitness evaluation function, and it is god-all-mighty slow. I ended up progromatically writing the fitness funciton to c++, compiling, evaluating, and returing a clojure vector to shell-out/sh.
01:07tomojwow
01:07bytecolorbut I aint mad. I rockets through the population.
01:08tomojthat reminds me of my thoughts about macroexpanding a neural network topology into code that directly evaluates it. unfortunately that seems to be terribly evil and the class size limit makes it probably doomed
01:10bytecolordepending on the complexity of macro expansions, they can generate enormous amounts of code
01:10tomojalso unfortunately, I'm sure any sane neural network code I write in clojure will be _slow_
01:11tomojright, but too enormous and you just get an exception at compile time :(
01:11bytecolorI don't have a book on neural networks. I'll put that on the todo list ;)
01:20Deranderbytecolor: I just got my second. I'm excited.
01:23bytecolortomoj: are the exceptions due to a blown stack?
01:23bytecolori.e. not being able to recur in the tail position?
01:23tomojno, functions get compiled into classes. classes (or methods in classes?) have a size limit
01:24bytecolorhrm, so it's a java.lang limit?
01:24tomojthat is you will get the same error if you try to write an enormously long java method
01:24tomojright
01:24amalloytomoj: the world would be a better place if that limit were about a hundred lines
01:26tomojlines don't exist at this level
01:26amalloyi know
01:26amalloyit's my fantasy, though, so i nominate them
01:26brehautthere is nothing like 1500 lines of VBS class initializer to bring one to tears
01:26tomojbut, yes, agreed :)
01:27amalloyon a related note, i love how easy it is to write short functions in clojure. in java, c, or php, it always seems so easy to just make the method ten lines longer than break it up
01:27bytecolorholy sheet, 1500 lines of vbs *anything* ;)
01:28tomojthere was a blog post a while back, something like "clojure is faster than assembly"
01:29bytecolorwhat I've found interesting about clojure is the lack of C/C++ continue and break. I just don't think like that any more.
01:29tomojI didn't understand it but the idea stuck with me, macroexpanding into super-fast code
01:29tomojtwo hands: it sucks that the size limit cripples you here, but I guess you shouldn't be doing that anyway
01:30brehauttomoj: theres some really intersting work in haskell supercompilers going on that can do some incredibly whole-program optimisations
01:31tomojis a supercompiler something different than a really good compiler?
01:31Scriptorbrehaut: like with jhc?
01:31brehautdont know about jhc, yhc was the one i had heard most about
01:32amalloymacroexpanding into actual code is so passe. just expand into the desired output like with C++ template programming
01:32brehauttomoj: basicly the compiler does graph transformations on the whole program
01:33brehautit is capable of finding hidden state machines that the programmer may not have been aware of
01:33bytecolorc++ template compilation times are just not that great. look at boost. compilations times are horrible, but run times are white-knuckle fast.
01:34bytecolorgreat for an end user, not so great for a programmer.
01:34brehauti understand that if you run a supercompiler you have to suffer similar long compile time ;)
01:34tomojat least you can run the subcompiler and still get a working program?
01:34brehautyup
01:36brehautGHC has a pretty intereting local rewriting optimisation sub system too http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/rewrite-rules.html
01:37bytecolorbrehaut: are you writing any clojure core or contrib code?
01:38brehautbytecolor: hell no
01:38brehautyou dont want that
01:39bytecolorahahah, well I was thinking it wouldn't be a bad idea to have a haskell programmer's point of view
01:39brehautit already does ;)
01:39brehautand im a dabbler, im not fluent
01:39bytecolorI just have to learn haskell to see that.
01:39tomojif I ever understand anything conal says I guess I can die happy
01:40bytecolorhaskell syntax just seems so chaotic to me and I can't figure out why.
01:41brehauttomoj: hah yes indeed
01:41replacabytecolor: haskell syntax is juat radically different from what you get in other languages. You have to immerse yourself in it and then it can be beautiful
01:41replacathough, tastes vary
01:42brehautbytecolor: the answer is threefold a) you havent grasped its whitespace rules b) you havent grasped the effects of pervasive curried functions, c) the type system is wickedly expressive
01:42tomojisn't there (here of all places) also something to be said for minimal syntax?
01:42bytecolorreplaca: I will admit I'm curry ignorant
01:43brehautaside from the type notations i think haskell is pretty minimal syntax wise
01:43bytecolorer brehaut
01:43tomojhaskell's may be minimal compared to blub, but compared to a lisp?
01:43replacabytecolor: like lisp, you don't feel it until you've lived in it for a while (and really *tried* to live the way it wants you to live)
01:43bytecolornot compared to common lisp, it isn't
01:45replacahaskell's syntax isn't so minimal, but it feels very terse when you write it (and therefore un-blub-like)
01:45bytecolorparentheses -> the next atom may be a function, hallelujah!
01:45tomojterse? really? :P
01:45brehautreplaca: all the weight in haskells syntax comes at the type system though
01:47bytecolorseems as though clojure tries to emulate haskell's functional notation, although clojure's is limited by arity
01:47brehautreally?
01:47bytecolorwell, from my limited knowledge
01:48amalloybrehaut: (update-in foo [a b c] assoc-in :k 1 :j 2)
01:48amalloyfeels more like haskell than clojure
01:48bytecolorare a, b and c keys?
01:48amalloyyeah
01:48replacabrehaut: mostly. Haskell gets stuff that looks like syntax from funny named functions
01:49tomojamalloy: that particular example has always felt rather strange to me
01:50tomojnever thought much about why
01:50amalloytomoj: same for swap!, alter, etc
01:51bytecolorI've been using the shite out of swap!, but only because I dont grok the higher mutators
01:51tomojI guess I always feel like the flattening will break something
01:52tomojI imagine in haskell you could pretty easily nest that deeper
01:53bytecolorswap! is synchronous, correct? No other thread is running that will try to change the first arg to swap!
01:53bytecolornow when you get into refs, it get's umm... interesting.
01:53brehauti think that would look something like updateIn foo [a b c] $ updateIn [(K, 1), (J, 2)]
01:55bytecolortomoj: *why* is the greatest question ever asked ;)
01:55tomojbytecolor: they might try, only one will succeed
01:55amalloyonly one at a time, anyway
01:57bytecolorso, slap me if you will, but from a layman's point of view, clojure is a language that, to be of interest, requires many, many cores.
01:58amalloybytecolor: or a desire to not have the zillions of programming errors mutation causes
01:58tomoji
01:59bytecoloramalloy: nod, and that come from an individual writing the lock code that "knows what the hell he's doing", i.e. hickey
02:01bytecolorI've seen a couple other names that have a background in multi-core programming, joy of clojure comes to mind. Are cores going to follow memory?
02:01brehautits not just knowing where to put the locks, but having done the work to determine good models to implement at all
02:02bytecolorbrehaut: I'm such a n00b in multi-threading. I really am. But that *has* to be the next step.
02:02brehautim confused
02:03bytecolorWe have enourmous amount of memory, but it's all being piped through a bottle-neck.
02:03bytecolora single processor, or 4, or 8
02:03brehauti think messages got out of order
02:04bytecolorahahaha
02:06bytecolorI saw a podcast. I found it through searching clojure. Steele's Fortress maybe? It was fantastic. No so much as how to divide a problem up into threads, but how to combine the results of those threads into a useable data structure.
02:08amalloybytecolor: i think you are focusing too much on concurrency. it's nice, but it's not the only benefit of immutability, which in turn is not the only nice clojure feature'
02:09bytecoloramalloy: It's all new an shiny to me ;)
02:10semperos_it stays shiny
02:11brehautthe funny thing about immutability is it starts off seeming like its definately going to make life harder, where in reality there is a huge huge realm of problems where its the exact opposite
02:13tomojpersonally I hardly ever use clojure's concurrency features and I still love it
02:13brehautlikewise
02:13brehautmost common thing for me is to use pmap i think :P
02:14brehautits a lazy mans fork-join :P
02:14semperos_for me, having the concurrency semantics makes me think about state very critically
02:15amalloybrehaut: and for me the most common concurrency feature is "start a thread to do this expensive operation the user asked for, then get back to interacting"
02:15brehautamalloy: i havent done any gui programinning in clj since 08
02:16amalloybrehaut: who said gui?
02:16bytecolorbut the mind accepts parellel data. sound, sight, touch, etc. It processes that data and produces a thougt. It does *not* produce an output, it produces a thought. What is that thought? Is it a cache of ideas?
02:16brehauts/g// ?
02:16amalloyit happens to be sexpbot most of the time :P
02:16brehautah haha
02:16brehautim mostly doing web stuff
02:16amalloy"message just came in, get to work"
02:16bytecolorahaha, havent't heard a bot muse in a while
02:17tomojbytecolor: can you have a thought that has no effect whatsoever on your behavior?
02:17amalloyyeah i really need to learn ring. it sounds like it must be so easy to write webapps
02:17bytecolortomoj: yes
02:17brehautamalloy: do you know how to write a function that accepts a map and returns a map?
02:18amalloybrehaut: man, i almost didn't realize you were talking about ring
02:18brehauthah
02:18amalloyi was like, yes, you write "identity"
02:18bytecolortomoj: it's a state, but it's one of many
02:18semperos_I found moustache to be a nice place to start with ring
02:18brehautclassic
02:18brehautthats an illegal ringhandler btw ;)
02:18tomojbytecolor: a thought is a state, you think?
02:18bytecolorwtf is moustache?
02:18brehautthe only other thing for ring is (future (start-jetty {:port 8000}))
02:18semperos_micro web framework
02:18bytecolortomoj: ahahaha
02:19amalloybytecolor: we'll explains when you're older
02:19semperos_consists of one macro :)
02:19semperos_it's a nice way to deal with Ring
02:19semperos_and ring's features
02:19semperos_and actually get something done
02:19brehautsemperos: thats unfair to both moustache and ring
02:19amalloybrehaut: (def handler (constantly {:response-code 500 :body "Not implemented yet"}))
02:19semperos_brehaut: how so?
02:19brehautamalloy: perfect
02:19brehautsemperos_: well you are still writing ring handlers and middleware even if you are using moustache
02:20amalloyout of curiosity how close was i on the keyword names?
02:20bytecolortomoj: philosophy and programming are not disjoint
02:20brehaut:response-code is :status
02:20semperos_brehaut: right, that's why I like it
02:20semperos_it provides a nice way to combine everything
02:20semperos_but there's no "magic" over ring, you just get it with benefits
02:21brehautsemperos_: i agree; but i would personally encourage anyone starting out to start with ring first
02:21tomojbytecolor: sure, which is one of the things that attracted me to clojure, I think. rich talking about whitehead and all
02:21semperos_brehaut: fair enough
02:21tomojbut my obsession for phil of mind doesn't belong here unfortunately :(
02:21bytecolortomoj: I've been meaning to read whitehead, haven't gotten around to it yet, alas.
02:23tomojstart with ring then switch to aleph :P
02:25bytecolorphilosophy *does* have a place in programming, it will become more apparent in subsequent generations.
02:26tomojhave you seen the "are we there yet" talk yet?
02:26tomojif not, do so
02:26brehauti hate applescript
02:26bytecolorhrm, I think I have, there-fore I must have.
02:29bytecolorI tried to learn nurb surfaces from apple-script once. it was actually a really good description. I just didn't posses the brain cells to grok it.
02:31brehauti am going to be social. ttyl
02:31bytecolorI wonder what egotistical bastard would use the name grok.
02:31bytecolorlater brehaut
02:32tomojwhat, you checked whether 'grok' was a registered nick?
02:33bytecolorna, just wondering. I'll bet there are some out there that would use it.
02:34bytecolorand the say part: they would not have a clue wtf grok means
02:35tomojnow I worry I don't have a clue either
02:36bytecolordidn't hickey used to idle in here?
02:37tomojmaybe too many people said clojure was awesome
02:38bytecolorthen again, maybe his ego got too large, because clojure just isn't that awesome. Not when you look at users. I'm not knocking clojure, I'm knocking the creator.
02:40greghwait, are you saying clojure users aren't awesome?
02:41semperos_I don't think you'll find any Rich Hickey worshippers in here, but Rich is a seriously intelligent individual who has created something of profound value and given it to the community
02:41semperos_and from the many videos I've watched of him, he is surprisingly devoid of ego
02:43tomojbytecolor: for context, I was referring to his disdain for the word "awesome"
02:45tomojs/referring/alluding/ ?
02:45amalloylol
02:45bytecolorsemperos_: I'm not questioning hickey's intelligence, I've watched enough vids to convince me that the man is quite intelligent. My only query... Why do the creators always leave? Simple question. I think it deserves a simple answer. And if money is a part of the answer, then I am dissapoint.
02:46semperos_bytecolor: in what way has he left?
02:46tomojer, you deserve the kiss of course, but I imagine you don't want it :)
02:46amalloytomoj: i think that wouldn't have triggered him anyway, before my change. if anything came after the trailing slash he didn't parse it
02:46amalloys/change/GENIUS IMPROVEMENT/ ?
02:46tomojunfortunately I would've been too dumb to remember that
02:48tomojdunno about rich, but I wish I had the discipline not to type M-x freenode
02:49semperos_bytecolor: if you just mean the irc channel, then I agree with tomoj, wish I had the discipline :)
02:50rata_hi
02:51semperos_howdy
02:51bytecolorclojure?
02:51clojurebotclojure is not scheme
02:52bytecolormuahahaha, but it is, it uses ? as predicates, and that is a "good thing"
02:52bytecolorit uses ! for in-place mutators, an that is a good god damn thing
02:54tomojdoesn't ruby (with middling consistency) do both of those?
02:55bytecolorscheme did not survive to the next generation because it had big tits, it survivec because it produced the correct result.
02:55bytecolorfuck ruby
02:55bytecolorI mean really, fuck ruby
02:56bytecolorwhat the fuck has ruby done for me lately?
02:58tomojdid you buy AAPL?
02:58RaynesStop with the f-bombs, man. You're offending the little old lady in all of us.
02:58bytecolorRaynes: ok, I can do that
02:58tomojthe little old lady in me is a vulgar cunt
02:59amalloytomoj: swearing with style since 19...something
03:00tomojdamn less-than-111-year-old whippersnappers
03:00bytecolorraise your hand if scheme rawks
03:00bytecolor!
03:02bytecolorok, so there are a lot of conservatives among us, and thats ok.
03:07bytecolorWhat really bugs the fuck out of me is syntax. simple syntax. Do you mutate? put a fucking ! on the end of your symbol. are you a predicate? put a fucking ? on the end of your symbol. These are scheme idea. They are not bad ideas. They are sound ideas. Adopt them. Clojure alomost does. Clojure almost has it right.
03:07tomojalmost?
03:08bytecolor! and ? are epic in lisp programs.
03:11rata_bytecolor: I like scheme too and I find it's cool (but I don't know the subtleties of what the rocks expression means, so I don't know if it rocks)
03:13bytecolorfucking is an adjective, do you remember adjective from 6th grade?
03:13rata_the only thing I think they got wrong was to not make strings be sequences... the sequence abstraction is very powerful
03:14tomojdo you often seq strings?
03:14rata_tomoj: yes, why the question?
03:15rata_bytecolor: whom are you aiming that question?
03:16bytecolorif you'll look at, ok the string lib is a piece of shit. it really is. just try to find it.
03:16bytecolorrata_: the future
03:16tomojrata_: just curious
03:16tomojthat strings are seqable seems occasionally useful to me, not fundamental
03:19rata_for me it's a pity that in scheme you can't use map, reduce (fold*) and the whole sequence library on strings
03:19anthony__This is probably a really stupid question, but is print okay to use in a transaction? (will it only print to *out* if the transaction is successful?) I'm guessing it isn't, but I don't have a really good way to test it...
03:20rata_anthony__: the transaction can be retried many times, so the printing will be done many times too
03:20rata_if that doesn't annoy you, it's ok
03:21anthony__rata_: Thanks -- that's what I expected. I didn't know if maybe it was buffered until the end of the transaction (seems impossible), or if it went straight to *out*
03:21bytecoloranthony__: the repl will lie to you. try (count foo...))
03:22anthony__bytecolor: I'm not quite sure what you mean.
03:24bytecolorthe repl shows the printed output in the result of a map
03:25bytecolorthat's fucked up
03:25bytecolormap, print, return the output
03:26anthony__Oh, gotcha. Yeah.
03:27bytecolorit's not part of the output, but it *displays* as part of the output.
03:27bytecolorthat's fucked up
03:28bytecolorfucked-up=invalid-output, for those that read too much of the bible
04:28thorwilhi! i'm trying out appengine-magic. "lein appengine-new" fails with "That's not a task".
04:28thorwilany tips on troubleshooting that?
04:40thorwilnm, seems i'm reading impaired and mixed up :dependencies and :dev-dependencies :)
04:51hiredmank
06:52CozeyHow can I replace some jar referenced in project.clj (i use cake) with my own version of this jar (I'm fixing a bug, and want to use my build until the issue is fixed upstream)
06:54raekCozey: with leiningen, you can use the checkouts feature
06:55RaynesCake has that feature as well, but that isn't what he looking for in this case.
06:55raekI guess it could also be possible to install an updated jar in your local maven repo (~/.m2) somehow
06:55CozeyI never figured out how to menage my own m2 repo
06:55Cozeymanage*
06:56RaynesCozey: You can just build the jar and, if you aren't going to be putting your project into production, just do 'cake install' to install it in your local repository. Otherwise, you can modify the other project's project.clj to qualify the project name with your own clojars groupId and then push your own version to clojars and use that.
06:56raekwell, you already have one. maybe it's called a "cache" rather than "repo"
06:57Cozeyi now, it sits in ~/.m2, but i played with maven once trying to install something and got into a dependency hell of some kind
06:57Cozeyfrom that time i respect maven, but I don't fancy getting too much into it, if i can use it indirectly via cake or lein
06:58Cozeyclojars is a good idea - it would keep the setup almost as is
06:59raekcake/lein install should be like pushing to a "local clojars", if it works the way I think
07:00Cozeywill try
07:01Cozeyis any of cake/lein getting better then the other?
07:01Cozeyor is it a religious question?
07:02raekthis post helped me understand why there are two at all: http://blog.fogus.me/2010/11/30/take-6-justin-balthrop/
07:03raekI currently use lein, but I have a very strong feeling that if someone would do a "alias lein=cake", I would not notice
07:04raek(99% of the time, I only use the new, deps, repl and swank commands)
07:17Cozeycake chose me by luck.
07:30fbru02hey guys morning ! what is the key for bringing up slime buffer in emacs?
07:31CozeyI'm not sure if there is one by default. I had to bind slime-repl to ^c r
07:31Cozey(add-hook 'clojure-mode-hook
07:31Cozey '(lambda () (global-set-key (kbd "^c r") 'slime-repl)))
07:32fbru02Cozey: thanks I will try that
10:34pdkis there an apt repository with up to date clojure/clojure-contrib in it
11:20pppaulanyone know a site that explains how to use reduce?
11:20fliebelpppaul: More extensively than ##(doc reduce)?
11:20sexpbot⟹ "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well... http://gist.github.com/823850
11:21clojurebot#<RuntimeException java.lang.RuntimeException: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated>
11:21pppauli read that already
11:21pppauli want some examples, and the ones on clojuredocs suck
11:22fliebelhmmm...
11:22Vinzentpppaul, htdp.org
11:22fliebelhttps://github.com/search?type=Code&amp;language=clojure&amp;q=reduce&amp;repo=&amp;langOverride=&amp;x=8&amp;y=18&amp;start_value=1
11:23pdk(reduce + 1 2 3 4) is equivalent to (+ (+ (+ 1 2) 3) 4)
11:23pppaulok
11:23pppaulthat makes a bit more sense
11:23pdkin this case it assumes that + takes 2 arguments
11:23pdkit does (+ 1 2) first
11:24pdkthen calls + with the result of the first addition and 3
11:24pdkthen calls + with THAT result and 4
11:24pdkuntil reaching the end of the list
11:24pppaul(reduce (fn [i1 i2] (+ i1 i2)) 1 2 3 4 5) is the same?
11:24pdknaturally reduce expects the function you give it to take 2 arguments
11:25pdkshould be
11:25fliebelreduce iterates over a list, calling the function with the previous result and the next item.
11:25pppaulso, my problem, i guess, was that i was giving reduce a seq
11:25pppaulshould i use apply in this case?
11:26pdkif the fn you're trying to apply to the seq only takes 2 args
11:26fliebelpppaul: As far as I know redce *does* take a seq, and nothing but a seq.
11:26pppauloh
11:26pdk(doc reduce)
11:26pdkcmon bot
11:26pdk##(doc reduce)
11:26sexpbot⟹ "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well... http://gist.github.com/823855
11:26pdkyeah
11:26pppaul(reduce (fn [i1 i2] (+ i1 i2)) '(1 2 3 4 5)) then?
11:26pdkso that example above shouldve been (reduce + [1 2 3 4])
11:27fliebel&(reduce (fn [i1 i2] (+ i1 i2)) '(1 2 3 4 5))
11:27sexpbot⟹ 15
11:27clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the re
11:28pppauli'm trying to reduce a hash-map to a string
11:28pppaul(reduce #(str (:name %2) "\n" %1) myhashmap)
11:28fliebelpppaul: Almost!
11:29pppaul(reduce #(str (:name %2) "\n" (:name %1)) myhashmap) makes a string of 1 item
11:29fliebel&(reduce irc://irc.freenode.net:6667/#(str (:name (key %)) "\n"  (val %)) {:a 1 :b 2)
11:29sexpbotjava.lang.Exception: Unmatched delimiter: )
11:29pppaulso, i'm not sure what i'm doing wrong
11:30pppaulhmm
11:30jkruegerpppaul: your version assumes that the reduce fn takes two arguments, while it only takes one
11:30pppaul&(reduce (str (:name (key %)) "\n"  (val %)) {:a 1 :b 2})
11:30sexpbotjava.lang.Exception: Unable to resolve symbol: str� in this context
11:30pdkwhen you use % within a #() function
11:30fliebel&(reduce #(str %1 (:name (key %2)) "\n" (val %2)) "" {:a 1 :b 2})
11:30sexpbot⟹ "\n1\n2"
11:30pdkevery time you use % it refers to the same first argument
11:31pppaul...
11:31jkruegerpppaul: forget what i said. it was rubish...
11:31pppauli'm using %1 and %2
11:31pppaulgah! reduce!
11:32pppaul&(reduce (str (:name (key %)) "\n"  (val %)) {:a 1 :b 2})
11:32sexpbotjava.lang.Exception: Unable to resolve symbol: str� in this context
11:32pppaul&(reduce #(str (:name (key %)) "\n"  (val %)) {:a 1 :b 2})
11:32sexpbotjava.lang.Exception: Unable to resolve symbol: str� in this context
11:32pdk%(reduce str {1 2 3 4 5 6})
11:32pdk&(reduce str {1 2 3 4 5 6})
11:32sexpbot⟹ "[1 2][3 4][5 6]"
11:32pppaul...
11:33fliebel&(reduce (fn [i [k v]] (str i k \newline v)) "" {:a 1 :b 2})
11:33sexpbot⟹ ":a\n1:b\n2"
11:33pppaulhmmm
11:33pdkwe're just pulling stuff out our asses now :p
11:33pppaullol
11:33jkruegerfliebel: that's more obvious :)
11:33pppaulmaybe i should just use map and string/join
11:34fliebelpppaul: If you know how destructuring works, you can see that I str the previous/initial value i to the k and v of the map. Iterating over a map returns pairs.
11:34pppauli really want to know how to use reduce, though
11:34pppauli'm iterating over a seq
11:34pppaula seq of maps
11:35pppaul(:name %) works
11:35pdkkeyword args can be used as functions themselves if their argument is a map
11:35pppaulok, how about this, i'll write the code using map + string/join, and then maybe you guys can tell me how to make it a reduce
11:35pdkso instead of #(:name %) you could just stick name in there
11:35pdker :name
11:35pppaulcool
11:36fliebelpppaul: In that case, you where almost there, just add the initial value to the str.
11:37pppaul(->> *s360accounts-salutation-errors*
11:37pppaul (map :name ,,,)
11:37pppaul (string/join "\n")
11:37pppaul println)
11:38mfexhi all, any ideas why I can't do a Thread/sleep in a lein repl?
11:38pppauluse swank?
11:38companion_cube,(reduce (comp (partial str "\n") (partial :name)) {1 2 3 4})
11:38clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$partial
11:39companion_cube,(reduce (comp (partial str "\n") :name) {1 2 3 4})
11:39clojurebot"\n[3 4]"
11:39companion_cubeerr
11:39pppaul,(reduce (comp (partial str "\n") :a) ({:a 1} {:a 2}))
11:39clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to keyword: :a
11:39pppaul:(
11:40pppaul,(reduce (comp (partial str "\n") :a) '({:a 1} {:a 2}))
11:40clojurebot"\n1"
11:40clgvlol. can't you describe in words what you want to do?
11:40fliebelpppaul: Try juxt
11:40pppaul,(reduce (juxt (partial str "\n") :a) '({:a 1} {:a 2}))
11:40clojurebot["\n{:a 1}{:a 2}" 1]
11:40companion_cubethe seek of the holy one-liner...
11:40pppauli thought my above code was pretty clear, though
11:40pppaulis it not?
11:41pppaulget a list of names from a list of hash-maps, interleave with newlines, make into a string
11:41fliebel&(reduce #(str %1 "\n" (:a %2)) "" [{:a 1} {:a 2}])
11:41sexpbot⟹ "\n1\n2"
11:41pppaul:D
11:41pppaulsuccess!
11:42pppaulthanks a lot
11:42clgvlol k ;)
11:43pppaul&(reduce #(str %1 "\n" (:a %2)) "" [{:a 1} {:a 2}{:a 2}{:a 2}])
11:43sexpbot⟹ "\n1\n2\n2\n2"
11:44fliebel&(apply str (interpose \newline (map :a [{:a 2} {:a 5} {:a 2} {:a 5} {:a 2} {:a 5}])))
11:44sexpbot⟹ "2\n5\n2\n5\n2\n5"
11:45fliebelI think str was one of the few things where using apply in a case like this makes sense. + does reduce internally anyway, for example.
11:46fliebelBut then string/join makes even more sense.
11:46incandenza&(reduce #(str %1 (name (key %2)) " " (val %2) "\n") "" {:a 1 :b 2})
11:46sexpbot⟹ "a 1\nb 2\n"
11:49clgv&(str-join \newline (map :a [{:a 2} {:a 5} {:a 2} {:a 5} {:a 2} {:a 5}]))
11:49sexpbotjava.lang.Exception: Unable to resolve symbol: str-join in this context
11:50clgv&(clojure.contrib.str-utils/str-join \newline (map :a [{:a 2} {:a 5} {:a 2} {:a 5} {:a 2} {:a 5}]))
11:50sexpbot⟹ "2\n5\n2\n5\n2\n5"
11:50clgvfliebel: thats even shorter ;)
11:51fliebelclgv: See the solution pppaul provided using clojure.string/join
11:51clgvah kk ;)
11:57pppaul:)
12:08pdki love you ubuntu
12:08pdk>gem install cake
12:08pdk>cake
12:08fliebelphp?
12:09pdk"cake isn't installed, do sudo apt-get cakephp-scripts
12:09pdkyeah that's the rub
12:09clojurebotmake a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive
12:09pdkclojurebot's developed sentience
12:09pdkand he's got a robo axe to grind in the languages world
12:10fliebelpdk: You can create a custom alias I guess.
12:10fliebelOr use the full path, like real man :P
12:10pdki don't really know where gem and apt put their packages so :p
12:11pppaulwhy would you use cake over lein?
12:11fliebelpdk: Have you tried $which cake?
12:11fliebelpppaul: persistent vm, tasks, and other goodies.
12:11pdksame thing as running cake
12:11pdki managed to get lein installed
12:11pdkthough when i got clojure through apt it was 1.1
12:12pdkand i recall reading something about installing clojure through cake or lein, forget which
12:12pppaulpersistent vm, as in when you turn it off and boot it up again it's the same?
12:12pdkso i figured i could update it that way since i don't know where apt stuck the jars
12:12pdklet alone if contrib installed alright
12:12pppaulwhat's a task?
12:12fliebelpppaul: No, it just stays up inbetween repl sessions.
12:12pppaullein does that
12:12pppaulvia swank
12:12pppaulit's how i'm coding right now
12:13pppaulcommand: lein swank
12:13pppaulwhat's a task?
12:13fliebelpppaul: Read the readme ;) https://github.com/ninjudd/cake#readme
12:13pppaulpff
12:13pppauli did read the cake stuff
12:14fliebelpdk: My cake lives in /opt/local/bin/cake
12:14pdkhell if i could just figure out where it put clojure and then update it id be happy then i'd fuss with lein/cake wars
12:14pdki tried putting it in /bin/cake
12:14pdkthen adding that to $PATH
12:14pdkstill does it
12:14pdksudo chmod +x cake aftward doesn't fix it
12:15fliebelpdk: Hm, so either name it clj-cake, so that it doesn;t tigger the msg, or installke cake-php, and make sure that your cake is on the path first.
12:17pdkhm
12:17pdkdo i just change the name of the folder with cake in it to clj-cake
12:25fliebelpdk: No, the binary.
12:26pdksomething tells me i ended up with the cake source in /bin/cake
12:26pdka folder with project.clj and everything
12:26pdklet's see if i xcopy the lein install approach like the docs say
12:27fliebelpdk: In that case, the actual binary is in /bin/cake/bin/cake, of bin/cake is where the project.clj lives.
12:27pdklove that shit
12:28pdkthere we go
12:28pdkghetto lein style install seems to work
12:28pppaulif i want to print out a string, and save it to a file, is #(comp println (parital spit "file") %) the way to do that?
12:28fliebelghe, if I remember correctly, I settled on using ~/git/cake/bin/cake all the time.
12:28pdkat least now it doesn't piss and moan about missing a server jvm install like it did on 7
12:29pdki dunno what the hell was up with that
12:29fliebelpppaul: juxt
12:29pdkbut apparently i was mising a /server/jvm.dll in the java install dir
12:29pdkwhen there wasn't even a /server subfolder there MY OH MY
12:29pppaulwhen would i use juxt over comp?
12:29fliebelwell...
12:29pdk(doc bindings)
12:29clojurebotExcuse me?
12:30fliebel&((juxt + *) 2 5)
12:30sexpbot⟹ [7 10]
12:30pdkcould always do something like (binding [*out* (java.io.FileWriter. "file")] (println "foo"))
12:30fliebel&((comp println +) 4 5)
12:30sexpbot⟹ 9 nil
12:30pppaulhmm
12:31pppaul(comp f g) = f(g())?
12:31pdkyes
12:31pppaul(juxt f g) = f()g()
12:31pdkrather
12:31fliebelyes
12:32pdk(comp f g) = (fn [% args] (f (apply g args)))
12:32pdkif you call the function produced by (comp f g) with any args
12:32pdkall the args get passed to g
12:32pdkthen the return value of g is passed to f etc
12:32pdkso all but the last function you pass to comp should take 1 argument
12:32pppauli understand that
12:33pppauli just want a function that will let me fork a thread (->>
12:33pppaulso, juxt it is
12:33fliebelHm, I'm thinking about some sort of function tree, or function spreader…
12:34pdk(doc juxt)
12:34clojurebot"([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"
12:35pppaulyup
12:36fliebel&(map #(%1 %2) [reverse inc dec] ["hi" 4 5])
12:36sexpbot⟹ ((\i \h) 5 4)
12:37chouserlazy trees are hard for my poor brain
12:37pppauli get a NPE :(
12:37pppaul((juxt
12:37pppaul (println)
12:37pppaul (partial spit "accounts with salutation fixes to be uploaded.txt")
12:37pppaul ),,,)
12:38pppaulthis is part of a thread (_>>
12:38pppaul(->>
12:39fliebelchouser: What does a lazy tree do?
12:39chouserwell, specifically I mean a lazy tree of a lazy seq
12:40chousertrying to turn a series of events like [a :down b :down c d :up :down e f :up :up] into (a (b (c d) (e f))
12:40chouser...but lazily
12:42fliebelSo, taking c consumes a :down b :down c...
12:46kgrad5_Hello, I am having trouble including clojure-contrib with my repl. I am launching the repl with java -cp path/to/clojure-contrib.jar -jar path/to/clojure.jar however when i try to (use 'clojure.contrib.str-utils) I get a FileNotFoundException. I have tried printing out my ClassPath and clojure-contrib is not on it.
12:46kgrad5_If it matters, I am using clojure 1.2.0 and contrib 1.1.0
12:47TimMckgrad5_: I highly recommend using lein or cake to interact with clojure.
12:47kgrad5_TimMc: thanks, I will go look at those, I am a first timer.
12:47TimMcWith Leiningen, I just run `lein repl` and it Does the Right Thing.
12:47TimMc(lein and cake are both build tools for Clojure)
12:50incandenzafor future reference, though, I think the -jar option overrides all other classpaths (everything is supposed to be in the .jar)
12:50kgrad5_incandenza: ah ok, so what would the proper way be to launch from the cmdline with contrib on the classpath?
12:51TimMckgrad5_: Oh yeah, that's right -- I think for -cp you need a colon-delimited set of directories and jars.
12:51incandenzayou put both in the -cp and then give the name of the class with the repl to run... forgot the exact syntax
12:51kgrad5_clojure.lang.Repl?
12:51clojurebotyou mean clojure.main
12:51raekjava -cp clojure.jar:clojure-contrib.jar:something-else.jar:source-directory/ clojure.main
12:52kgrad5_great! thanks everyone :D
12:52incandenzaright, there you go
12:58TimMckgrad5_: But definitely check out lein/cake.
13:00kgrad5_thanks TimMc, checking out lein right now, still useful to know how to do it properly from the commandline too.
13:00TimMcindeed
13:23chouserwoo! got it. now to make it usable...
13:26fliebelchouser: Can you paste? Or is it private?
13:27chousernot private, but raw
13:27chouserit'll end up in lazy-xml eventually.
13:27fliebelchouser: Neat!
13:28fliebelHow does lazy-xml currently work?
13:28chouserhttps://gist.github.com/823958
13:28chouserlazy-xml currently returns a lazy tree, but someone found that it's a little too eager
13:29chouserit forces the parsing of one sibling beyond what you need, at every level of the tree.
13:29fliebeloh, interesting...
13:30chousersince parsing the next sibling requires parsing the full content of the current node, it makes the laziness essentially useless when there's one node with a very large number of children
13:31fliebelchouser: Isn;t all xml one root node with a lot of children?
13:32fliebelhm, if you'd provide predicates for up and down, it'd be like the inverse of tree-seq.
13:32chouserfliebel: inverse, yes, that's the idea
13:34fliebelAnd you do (rest coll) in a lot of places, why not destructure that? (i know you said this was raw)
13:35fliebeloh, right, *when*-ket
13:37fliebelNo, that would work, right?
13:37fliebel(when-let [[event & nodes] (seq coll)]
13:44chouserdestructing & uses 'next' not 'rest', so it forces another step
13:52fliebelchouser: oh
14:15TimMcamalloy_: I did end up using meta for something: https://github.com/timmc/CS4300-HW3/blob/master/src/timmcHW3/core.clj#L112
14:16clojurebot#<RuntimeException java.lang.RuntimeException: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated>
14:16fliebelhiredman: Clojurebot is doing funny things.
14:17TimMcamalloy_: See the usage on line 271 and the processing code in act! around line 160. Basically, the function specifies some details of how it is to be used.
14:28markskilbeckHi, all. I'd like to pause/sleep for every iteration of a loop, but Thread/sleep doesn't seem to do the job.
14:29markskilbeckAny ideas?
14:33markskilbeckOh. Sleep takes milliseconds.
14:33markskilbeck2 milliseconds ain't a long time :P
14:38markskilbeck,(some zero? [1 2 3])
14:38clojurebotnil
15:01jaskiratmarkskilbeck: (doseq [x (range 10)] (Thread/sleep
15:01jaskirat 1000)(println x)) doesnt work?
15:04julian-bunnies
15:06pppauli agree, but, rabbits
15:06julian-pppaul: Yeah, but we can face those.
15:07julian-I mean, there's nothing we can't face, except for the aforementioned member of the Leporidae family.
15:08pppaulbecause he has no face?
15:08julian-pppaul: http://www.youtube.com/watch?v=cW20AlC0IbA
15:11pppaulit won't play
15:11pppaulthe others will, though
15:12pppauladd block killed it
15:13pppaulsorta funny, the singing is soooooooo bad
15:14pppaulwell, i just missed my bus
16:08rata_hi
16:09Scriptorhey rata_
16:09rata_hi Scriptor
16:14kjeldahlSo, I'm giving up on enlive, about to test fleet. Anybody else have any nice hints for modern supported template solutions for clojure?
16:15rata_kjeldahl: what's the problem with enlive?
16:16rata_when you vec a lazy-seq, does it copy it?
16:16kjeldahlrata_: It caches to agressively. Sometimes (or always) the template I pull in with deftemplate simply refuse to reload. There's a ticket for it pending for more than one year. I do not feel up to the task of solving it myself yet.
16:17kjeldahlrata_: Plus looking at the commit log doesn't exactly scream of being well supported (considering the tickets).
16:18rata_oh ok
16:25chouserkjeldahl: the author has recently become a father. That may or may not be related to support lag. :-)
16:27kjeldahlchouser: He he, I can imagine (I've got two myself, 4 and 6 years old). Thanks for letting me know anyway; maybe I'll try to fix it myself after all...
16:30chouserkjeldahl: well, I'm not suggesting that means you shouldn't find another lib that works better out-of-the-box for you.
16:32LauJensenkjeldahl: Typically when working with Enlive, I just add a wrap-reload middleware to my stack and the templates update on every view
16:34rata_is there a short article (like a cheatsheet) about doing common things with swing?
16:34kjeldahlLauJensen: You stick the templates files themselves in wrap-reload? I already have the clj file where the deftemplate macros gets set up wrapped with wrap-reload, but it still fails to reload my template html files.
16:35LauJensenkjeldahl: (wrap-reload '[myapp.templates]), then keep all templates in that file/namespace. It will suceed unless there's an error in that file in which case it will fail silently
16:36kjeldahlLauJensen: That's what I do also. Either it doesn't work, or somehow stops working over time.
16:36LauJensenAnd you're certain its not an error on your part?
16:37kjeldahlAbsolutely not. But it always work when I restart the server.
16:38LauJensenAh ok. Are you on the latest versions of ring/moustache and enlive?
16:39kjeldahlI do not use moustache. Enlive tag is 1.0.0-SNAPSHOT, and since enlive hasn't been updated for a long time, I guess that's the latest.
16:39anthony__I'm stuck on some java interop. I've created a proxy for j.u.Comparator and implemented the compare method. But, I need to create a field and constructor for it. How do I do that in proxy? (can I?)
16:40ChousukeWhy do you need a proxy for comparator?
16:40Chousuke(doc comparator)
16:40clojurebot"([pred]); Returns an implementation of java.util.Comparator based upon pred."
16:41anthony__Chousuke: Ah man, awesome. Thanks so much
16:42Chousuke(actually any function returning bool should work as is)
16:46kjeldahlWrapping in wrap-reload definitively does not work, this is what I'm doing though: (deftemplate index_t "www/index_t.html" ... ) Whenever I modify index_t.html I have to restart the server. Get's kind of tedious...
16:47LauJensenkjeldahl: I understand. Completely the problem wrap-reload should solve. What if you manually reload the templates namespace/file?
16:48kjeldahlReloading in repl works.
16:49LauJensenSo it sounds like you need to take a closer look at wrap-reload
16:50kjeldahlYou mean you think ring isn't working like it should?
16:50LauJensenIf manual reloading works, then I cant think of another possible point of failure
16:51kjeldahlOk, thanks for the hint.
16:59LauJensenkjeldahl: np. I haven't seen the implementation, but if you make your own middleware as a really naive call to :reload-all, that might work
17:01kjeldahlI believe my problem is some wierd combination of running a server inside repl, reloading inside repl and wrap-reload and family. Sometimes the server also simply stops after I use a :reload-all (which doesn't autostart any server and such). So things _sometimes_ fails, and _sometimes_ work. That's the frustrating part.
17:03LauJensenSounds very frustrating. Would be great if you could exactly pinpoint the problem. I recall it happening to me once, but 9/10 times it just works. I also do webdev with ring/moustache/enlive/clojureql
17:04kjeldahlThanks for the info. I'll share whatever I'm able to figure out.
17:04LauJensenGreat, looking forward to it
17:21kjeldahlOk, I at least found a repeatable failure pattern. 1. load the "core" clj file. 2. call "boot" method (which starts the server using defonce). 3. modify "core" clj file (inside comment is enough). 4. reload "core" clj file with :reload-all. 5. attempting to load page gives an endless 301 redirect loop to /. I may be able to create a minimal testcase and solve it later unless somebody beats me to it.
17:23kjeldahlOh, and the "core" file was also wrapped in wrap-reload...
17:48LauJensenkjeldahl: tried writing a naive reload middleware?
17:59chouserdoes contrib standalone fail to build for anyone else?
18:37arohneris there a library that adds higher level navigation to XML docs parsed by clojure.xml?
18:38arohnerwith fns like "give me the tag with this name"?
18:39brehautarohner: the zip library has xml zipping
18:40brehautand a fantastic xml-> fun
18:40arohnerbrehaut: oh right. I forgot about that, thanks
18:46brehautarohner: clojure.contrib.zip-filter is what i was thinking of
18:47brehautas well as zip
19:28_ViMy program have 2 parts: GUI (Swing) and backend. When user performs action in GUI, it does "(send backend-agent qqq)". What do to if backend wants to callback to GUI (to ask a password, for example)? Block inside qqq while waiting for some reaction from GUI?
19:29brehaut_Vi swing provides a run queue
19:30brehauti think its called Invoke soemthing
19:31_Vibrehaut, What should backend do? Currently there is "(defprotocol BackendInterface ...)" that contains the interface of backend exposed to GUI. What should I add to make backend call back to GUI? (The backend itself should not know about Swing)
19:32brehautthe backend calls SwingUtilities/invokeLater with a Callable or Runnable
19:33brehautan example of a callable or runnable in clojure is anything that implements ifn, eg a function
19:33brehauthttp://download.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#invokeLater(java.lang.Runnable)
19:33_Vibrehaut, Backend wants information (the password) that needs to be returned to library function.
19:34brehautyou make the function you pass to invoke pass that to the agent or thread that is doing the work
19:34_Vibrehaut, GUI -(connect)-> backend. Backend connects to server. Connection procedure (external library) callbacks with "askPassword" inside backend. Backend should callback to GUI.
19:35brehaut_Vi i dont have a magic bullet for you. you have to get the backend to pass a function to the UI thread via InvokeLater to request the password fro mthe user and pass that back to the background thread
19:35_ViOK, trying Invoke and waiting when it completes.
19:35brehautyou certainly can try that
19:44brehaut_Vi you might also want to look at promise and deliver
19:45brehautpromise is a reference type; deliver lets you assign a value to a promise. any time a promise dereferenced before it is delivered it blocks; after delivery it returns the delivered result.
19:45_Vibrehaut, Promise and immediately deliver - looks like no use. The answer is probably just using a modal window: Backend -> Backend-to-GUI-interface -> GUI -> Modal window.
19:46brehaut_Vi you UI implimentations concerns are completely seperate you your foreground/background communication concerns
19:46brehauta modal window is not going to block your background thread
19:47_Vibrehaut, The modal window is going to be called from a background thread.
19:47brehaut(unless you use InvokeAndWait i guess)
19:47brehaut_Vi expect your program to crash then
19:47brehautSwing does not like UI activity occuring on any thread but the AWT event thread
19:48brehaut_Vi http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html#single_thread_rule
19:48_ViMain window sends connect request to backend. (using "send"). Agent starts connecting and requests GUI to show password entry window. It shows modal window (blocking that thread).
19:51_ViYes, actually it will probably be invoke and then wait inside.
19:53brehaut_Vi that wont the password back to the background thread though
19:53gfrlogI just bet myself five dollars that there's an easier way to do this:
19:53gfrlog(eval (list (symbol "clojure.core" "go")))
19:53gfrlogaw crap
19:54gfrlogno wait, I think I can't just do (clojure.core/go) because the actual namespace I'm referring to isn't loaded until runtime
19:54gfrlogso the compiler would complain
19:54gfrlogso I have to use eval...
19:55gfrlogbut I bet (eval #'clojure.core/go) would work, or some similar syntax. thus my question
19:55gfrlog,#'clojure.core/map
19:55clojurebot#'clojure.core/map
19:55gfrlog,(eval #'clojure.core/+)
19:55clojurebotDENIED
19:56hiredmangfrlog: you don't have to use eval
19:56gfrlogeven if it's not loaded until runtime?
19:57hiredmancorrect
19:57gfrloghmm
19:57gfrlogI guess the compiler doesn't complain if it's fully qualified?
19:57hiredmannope
19:58gfrlogthat makes sense -- hadn't thought of that; thanks
19:58_Vibrehaut, Looks like promise/deliver is the answer here. We can invokeLater an object with a promise. When it that delivers, the background thread unblocks.
19:58brehautyes
19:59brehaut_Vi instead of an object, just use a closure
20:00_Vibrehaut, closure is also an object. (Here object means "a thing").
20:01brehaut_Vi its always worth being precise.
20:04gfrloghiredman: got a ClassNotFoundException :-/
20:06gfrlogswitching to (eval '(my.namespace/go)) makes it work
20:07hiredmanyou don't need eval
20:07gfrlogI'm not sure how to do it then; (my.namespace/go) produces the classnotfoundexception
20:08hiredmanso obviously you cannot do it that way
20:08gfrlogokay; so you're saying there is some other way to call the function and it is not eval?
20:11gfrlog,(#'clojure.core/+)
20:11clojurebot0
20:12gfrlogthat one doesn't work either ("Unable to resolve var")
20:16rata_gfrlog: what's the problem?
20:19gfrlognot really a problem anymore. I originally had some ugly code that I've simplified to (eval '(my.namespace/go))
20:19gfrloghiredman was saying that I don't need to use eval, but hasn't said anything further, so I'm not sure what he meant
20:19gfrlogI was just trying other things
20:20raekgfrlog: what would the eval do?
20:20raekor, what do you want to simplify
20:20gfrlogeval calls the function
20:21gfrlogwhich does not get loaded until runtime
20:21gfrlogso simply using (my.namespace/go) causes a classnotfoundexception at compile or load time
20:21raekand you are doing something at compiletime?
20:21gfrlogwell I have the code there and it is being compiled, I think
20:21raekthen you are missing a (:require my.namespace) in your ns form
20:21gfrlogbut the namespace would not be found
20:22gfrlogit is loaded via (load-string)
20:22raekoh
20:22gfrlogafter the program starts
20:22raekbut before you want to call a function from it?
20:22gfrlogright
20:23raekit don't see why eval would make it work if it didn't work without it...
20:23raekif the namespace has been loaded, you should be able to use it
20:23gfrlogI assume it means that the compiler or loader or whatever it is that checks for those things when the code gets loaded would pass over it
20:24rata_what do you load-string?
20:24raekloading happens when you evaluate load-* require and use
20:25gfrlogI load the my.namespace code
20:25raekwhy do you load it from a string?
20:25gfrlogit's not local -- it's obtained via HTTP
20:25rata_that sounds dangerous
20:26gfrloglike security or like code maintainability?
20:26rata_anyway, do you have a (require '...) after load-string? (I'm not sure it's required)
20:26rata_like security
20:26gfrlogah -- that doesn't really bother me, it's just personal
20:26gfrlogno, no require after load-string
20:26raekgfrlog: does the code work when you replace the load-string call with a require with a local file?
20:27raekand how much experience do you have with namespaces, ns, require, etc?
20:28gfrlogI use them all the time, so I think I know them enough for 98% of use cases. Have a hard time describing the plumbing of it though
20:28gfrlogI'll try adding a require at the top
20:29raekI think the problem lies in how you custom loading code works
20:29rata_I'm reading require and it needs the file to be there in the classpath, so that's probably not the solution
20:29gfrlogyou mean I shouldn't use load-string?
20:30raekI don't know how you load-over-http code works, but I'm very sure that wrapping a call using it in an eval shouldn't make something work
20:31gfrlogadding require gets me a totally unrelated error, so I don't think I can conclusively say what that does
20:31raekthe distiction between compile-time and runtime is very blurred in clojure
20:31raekrequire looks for the file on the classpath, so that's not what you'd want for loading code over http
20:31gfrlogso I have a typical source file for the namespace, with a (ns my.namespace) expression at the top
20:32gfrlogI'm just passing it to (load-string) instead of having it in the classpath
20:32gfrlog(after getting it over http of course)
20:32raekso if you have (ns my.namespace) (def x "hello") in that file
20:33raekevaling my.namespace/x after having evaled (load-string the-string) returns "hello"?
20:33gfrlogdepends on what you mean by your first "evaling"
20:34gfrlogif you mean calling eval explicitely, then yes
20:34raeki mean in the repl, or at the top level of a file you are running
20:35gfrlogI haven't tried the repl -- I've been trying this with "lein test"
20:35gfrlogI think I can do repl though
20:36gfrlogokay, so before loading the code, I get a classnotfoundexception of course
20:36hiredmangfrlog: what is the relationship between symbols, the compiler, and vars?
20:37gfrlogI would think that the compiler associates a symbol with a var
20:37gfrlogbut I am fuzzy on these things
20:37gfrlogit resolves a symbol to a var?
20:37gfrlogbased on the context?
20:38rata_gfrlog: and after loading the code?
20:38hiredmanso if you do (clojure.core/+ 1 2), clojure.core/+ is a symbol and the compiler resolves it to a var?
20:39gfrlograta_: that's a good question, I'm not very well set up to try that...
20:39rata_why? you don't have the code string at the repl?
20:40gfrlograta_: I can get it, but there's actually a number of namespaces and I'd have to make sure they're loaded in the right order
20:40gfrloghiredman: I think that's how I would explain it
20:40gfrlog,(symbol "clojure.core" "+")
20:41clojurebotclojure.core/+
20:41hiredmangfrlog: and the compiler would fail to resolve clojure.core/+ to a var if the var didn't exist (the file that created it hadn't been loaded)
20:41rata_gfrlog: but then try with the string example raek gave you
20:42gfrloghiredman: that sounds right
20:42hiredmangfrlog: but you know a var exists at runtime but not compile time, so you cannot rely on the compiler to resolve it for you
20:43gfrloghiredman: right
20:43hiredmanso you ned to _ the var yourself
20:43gfrlog"resolve"
20:44gfrlogso I need a way to refer to a var without a symbol?
20:44hiredmanwhy?
20:44clojurebothttp://clojure.org/rationale
20:44hiredmanclojurebot: stick a sock in it
20:44clojurebotExcuse me?
20:44hiredmanclojurebot: you heard me
20:44clojurebothiredman: I'm just giving you a second chance
20:45hiredmanclojurebot: watch it
20:45clojurebotI don't understand.
20:45gfrloghiredman: should I have filled in the blank with "refer to"?
20:45gfrlog"reference"?
20:45hiredmanno, you were doing fine
20:46gfrlogI guess I just figure if I have a symbol, and I want to resolve it to a var, I use (eval)
20:46hiredmangfrlog: how does the compiler resolve a var?
20:46gfrlogbut I suppose there must be a more specific function for doing that
20:46gfrloghmmm
20:47gfrlogwell it'd have to muck about with all the requires/uses, but since I'm fully qualifying I assume I can skip that part
20:47gfrlogso it would go to the namespace object and ask for it?
20:47gfrlogthis is something I haven't done before, but I've seen the functions for examining the contents of a namespace
20:48gfrlogso it would be in that arena?
20:48hiredmanhave you looked at the docs on vars?
20:48gfrlogresolve the namespace name, get a map of its contents and look up my function?
20:48gfrlog(er, var)
20:48gfrloghiredman: not recently
20:49hiredmanperhaps they would be useful here
20:49brehautthe clojure.org/vars page only mentions the appropriate fun in briefly i think
20:49gfrloghiredman: reading now
20:53gfrlogon first pass I have only learned that I don't know what set! does
20:55brehauthas the implications of interning sunk in yet?
20:56gfrlogbrehaut: interning I understood to mean that successive "def"s of the same symbol will refer to the same var
20:56gfrlogso I suppose not, because I'm not sure how that relates
20:56brehautif i understand where hiredman is going with his socratic method, i think thats important?
20:57gfrlogthe (find-var) method listed in related functions...
20:57gfrlogseems like a way to get a var
20:58gfrlogso I would have to do... ((var-get (find-var 'my.namespace/go)))
20:59gfrlogand that in fact passes my tests
20:59gfrlogwhether or not it's what hiredman was getting at, it sounds like is still uncertain
21:00brehauti could just tell you what my guess is, but that might ruin the larning
21:01rata_yes, I'm trying not to say it too
21:01gfrlogoh my golly
21:01gfrlogokay
21:01gfrlogso I should keep thinking about interning you think?
21:03brehautbased on the text of that page, yes i think so
21:03gfrloglooks like the intern function will do something similar to find-var
21:04gfrlogthat doesn't give us any new functionality though
21:05gfrlogthe interning section of the var page seems straightforward to me
21:05gfrlogI can't see anything hiding there
21:06brehautreread the whole page with what you've understood from there then
21:08brehautmay i also suggest you examine clojure.repl/apropos and clojure.core/find-doc at some point too
21:10gfrlogthe bit before set! seems straightforward too... set! itself is confusing. And I think I have made sense of the non interned vars as well.
21:10gfrlogwill look at the two functions you recommended
21:12gfrlog,(doc mapcat)
21:12clojurebot"([f & colls]); Returns the result of applying concat to the result of applying map to f and colls. Thus function f should return a collection."
21:13gfrlog,(all-ns)
21:13clojurebot(#<Namespace swank.core.threadmap> #<Namespace swank.rpc> #<Namespace dk.bestinclass.clojureql.util> #<Namespace clojure.set> #<Namespace clojure.contrib.seq> #<Namespace clojure.contrib.sql.internal...
21:14gfrlog,(ns-publics (first (all-ns)))
21:14clojurebot{find-thread #'swank.core.threadmap/find-thread, *thread-map-next-id* #'swank.core.threadmap/*thread-map-next-id*, *thread-map* #'swank.core.threadmap/*thread-map*, thread-map-id #'swank.core.threadm...
21:14gfrlogso that is a map of symbols to vars
21:15gfrlogso that's how apropos works
21:15brehautyeah. you can also dir a namespace
21:15brehautwhich gives a seq of all the symbols
21:15gfrlogright; that's what I expected
21:16gfrlogI think these would be the namespacy functions I referred to earlier
21:17brehautim assuming you havent pulled out any more information from the vars page?
21:17brehautoh, dir is also in clojure.repl
21:17gfrlogthis is quite a mysterious process to me
21:18gfrlog,(ns-interns (first (all-ns)))
21:18clojurebot{find-thread #'swank.core.threadmap/find-thread, get-thread-id #'swank.core.threadmap/get-thread-id, *thread-map-next-id* #'swank.core.threadmap/*thread-map-next-id*, *thread-map* #'swank.core.thread...
21:18brehautgfrlog: you are aware that each doc page on clojure.org has prose about the topic, and then at the end a summary of related functions?
21:18gfrlogbrehaut: yes, I believe so...
21:18gfrlogon the var page I read prose about the topic, and at the end I perused the related functions
21:20gfrlogsource code for find-doc is straightforward
21:21gfrlogas clojure.repl/dir
21:21brehautgfrlog: i mentioned those because they are useful tools for crosscutting the all the functions rather than having to dig through api pages
21:23gfrlogthis all seems to conform to my understanding that a namespace maps symbols to vars
21:24brehautso what happens if you try to reference a symbol that isnt in the namespace?
21:25gfrlogwhat does "reference a symbol" mean?
21:25gfrlogyou mean use a free symbol?
21:25gfrloglike eval it?
21:25brehautnot eval it
21:25brehautyou can safely leave eval out of this
21:26brehautif you type
21:26brehautfoo
21:26brehautinto a repl
21:26brehautwithout quoting it
21:26brehautwhat happens?
21:26gfrlogI've always thought that means the repl calls (eval (read-string "foo"))
21:26gfrlog,(read-string "foo")
21:26clojurebotfoo
21:27brehautthose mechanics are unimportant
21:27gfrlog,(eval (read-string "foo"))
21:27clojurebotDENIED
21:27gfrlogokay
21:27gfrlogso then
21:27gfrlogit notes that the symbol is free
21:27gfrlogand looks it up in the current namespace
21:27brehauthow does it note that?
21:27gfrlogoh, well at the repl I guess all symbols are free unless they are letted within the current expression
21:28gfrlogsince we just typed "foo", that's irrelevant
21:28gfrlogno letting going on
21:29gfrlogso it's free, it looks in the current namespace, doesn't find it, and so throws an error
21:30brehautok
21:30brehautso what needs to happen for it to not throw that error
21:37anthony__Why would you use #' for a send-off command instead of just the function name? I'm looking through the ants demo source, and there's code like (send-off *agent* #'evaporation) in several places. Why not (send-off *agent* evaporation) ?
21:37brehautanthony__: it passes the var itself rather than dereferencing the var
21:38anthony__brehaut: Yeah, but I don't understand why it needs to do that. Is it because it's being called within the evaporation function, so evaporation isn't a var yet?
21:38brehaut#' is 'var quote' according to http://clojure.org/reader
21:38brehautanthony__: i recall some of those vars being forward declared
21:39gfrlogbrehaut: I would think either the symbol needs to be bound locally through let, or else exist in the namespace already
21:39brehautgfrlog: correct
21:39brehautso you want it to be in the namespace?
21:40gfrlogwell I don't mind fully qualifying it...
21:40gfrlogI guess we haven't been addressing that point
21:40brehautqualifying it just tells it to look in another namespace right?
21:40gfrlogyes
21:42incandenzaanthony__: for what it's worth, my copy does in fact have just "evaporation" without the #'
21:42gfrlogare we suggesting that I should (def my.namespace/go) before that namespace has been load-stringed?
21:42anthony__incandenza: Ok, cool. Thanks for that. I was just worried that my agent code might be wrong, since I never use that macro.
21:43brehautgfrlog: can you find a way that does declares that a symbol will be bound, before its actually defined?
21:43gfrlogthat's what def does right?
21:43gfrlogso (in-ns my.namespace (def go)) is what I want?
21:44brehauti dont think so
21:44brehautalthough it might still work
21:45gfrlogwell the namespace shouldn't exist yet, right?
21:45gfrlogso I have to at least implicitly create it?
21:46brehauthmm pass
21:47brehauti need to head off anyway.
21:47gfrlog:-P
21:47brehauthiredman may say im completely off base, but look at delcare
21:48gfrlogah yes, I've used that before
21:48gfrlognot across namespaces though
21:48brehautgood luck anyways
21:48gfrlog,(declare hiredman.brehaut/x)
21:48clojurebotDENIED
21:49gfrlogah well. at least I tried.
22:43ossarehevening all