#clojure logs

2011-09-06

00:02mindbender1please why do I keep getting this error message on ccw with eclipse on my first hello.clj file
00:02mindbender1=> (hello "you")
00:02mindbender1#<CompilerException java.lang.Exception: Unable to resolve symbol: hello in this context (NO_SOURCE_FILE:1)>
00:07mindbender1please help
00:07user317so is hello a symbol?
00:09seancorfield_mindbender1: did you load the file into the REPL and then switch the REPL to that namespace? (two steps)
00:12user317whats the difference between using :use in your namespace and calling use, ie (use 'lamina.core) seems to work but :use 'lamina.core doesn't
00:12user317:use in your namespace for files in your project, and (use <lib>) for external deps?
00:13brehautuser317: (use …) is mostly only useful in the repl, and (:use …) in your ns for project specific libs or deps
00:19user317so (ns myns :use 'foobar) is the same as (ns myns); (use 'foobar)?
00:20brehaut(ns myns (:use foobar)) is
00:21michaelr525hey
00:21brehautor perhaps (ns myns (:use [foobar]))
00:21brehauti forget if the vector is optional on :use forms
00:23brehautyeah the vector should be optional according to (doc require)
00:23mindbender1seancorfield_: the tutorial I was following didn't point that out please can you point out the directions for me
01:05user317anyway to get around leins slow startup time? when i run it in interactive mode it hangs on any compiler errors
01:36user317_how do i set a java class's field name? i am new to java, does it have automatic getter/setter functions for members?
01:56tomoj&(->> #(rand) (repeatedly 2) #() (repeatedly 3))
01:56lazybot⇒ ((0.19066336225889235 0.46004763443354735) (0.40565071223177274 0.48848509803591755) (0.20556681440024904 0.037729850401373))
01:56tomoj:/
01:57pmbaueruser317_: no automatic setters.
01:57pmbauerIf there is method "setFoo" on object of class Bar, you can call it: (.setFoo myBar aFoo)
03:17robermannciao muffetta :)
03:24michaelr525hello!
03:31khaliGhi michaelr525
03:34humourousis it possible to view the source of multimethods through the repl?
03:37ibdknoxhttp://news.ycombinator.com/item?id=2964419
03:37ibdknoxthis keeps coming up
03:38khaliGibdknox, why does it?
03:39ibdknoxMy argument would be that no one is purely focused on improving the overall experience of using Clojure
03:39ibdknoxclojure/core is improving the language and trying to expand its reach
03:41ibdknoxbut ClojureScript is perfect example of not focusing on the experience of using the language
03:43ibdknoxkhaliG: so people can't get started or they get stuck
03:50khaliGibdknox, you're referring to the "Set up" point in the article?
03:50ibdknoxkhaliG: the two main points people bring up about clojure are errors and documentation
03:51ibdknoxthe last bay area clojure group was basically a long rant about those two things
03:52ibdknoxevery article talks about those two issues when going over the practicality of clojure
03:52khaliGibdknox, i'm fairly new to clojure myself and can relate to that somewhat - but I think the stacktraces aren't too bad, you get good at reading them
03:52ibdknoxkhaliG: I agree, but you shouldn't have to ;)
03:54khaliGibdknox, has someone articulated how they should be technically better?
03:55ibdknoxkhaliG: it's a well known problem that has been discussed a great deal
03:56khaliGibdknox, ah sorry i'm not familiar with those exchanges - would be interesting to see how they propose things need to be improved
03:56ibdknoxkhaliG: sorry, that wasn't meant to be dismissive at all, I was just saying that it's something that the "right people" know about :)
03:57ibdknoxand solutions have been discussed
03:57khaliGgotcha
03:57pyrmorning
03:58ibdknoxIt comes down to someone needing to own the experience of writing a clojure app from end to end
04:09thorwilhmm, i didn't see the documentation to be that lacking. however, error messages are about the only thing where i see clojure as a step down from python
04:09ibdknoxthorwil: some of the documentation is pretty obtuse if you don't already have a firm grasp of functional programming
04:10ibdknoxstill
04:10ibdknoxcompare clojure.org to ruby-lang.org
04:10ibdknoxdocumentation isn't just API docs, it's also things like "Ruby in twenty minutes..."
04:11thorwilice brick vs campfire :)
04:12khaliGit does lead to the question whether clojure is suitable as a first language? maybe it isnt?
04:12ibdknoxkhaliG: I don't buy that :)
04:12TheMoonMasterI wouldn't give someone clojure as their first language. :P
04:14ordnungswidrig1I'd recommend scheme as a first language. the tight integration with java is distracting.
04:14TheMoonMasterYeah, my main thought would be Java interop confusing them.
04:14ibdknoxeh, to just start programming, you don't need any of the Java stuff
04:14ibdknoxwhen you start with python
04:15ibdknoxor any other language, you rarely do things that interact with the host
04:15ordnungswidrig1ibdknox: but java shines through everywhere in clojure. e.g. at stack traces, error messages and so on
04:15ordnungswidrig1I think scheme would be nicer
04:15TheMoonMasterI'd throw Ruby or Python at someone interested in general programming.
04:15ibdknoxordnungswidrig1: those are solvable problems I think, but yes, in its current state
04:16thorwili guess it's hard to compete with racket for a scheme and an introduction to programming
04:16ordnungswidrig1ibdknox: yes, when there is cinc, then clojure will be nicer as a first lang
04:17ibdknoxanyways guys, I've ranted enough for one night :)
04:17ibdknoxg'nite!
04:17khaliGibdknox, night
04:19khaliGordnungswidrig1, so would you say you need to know Java first?
04:19ordnungswidrig1khaliG: not, necessarily
05:04michaelr525hey wunki
05:04michaelr525why are you connecting from amazon machine?
05:11wunkimichaelr525: I installed a bouncer on the free instance you can get from AWS
05:18michaelr525cool
05:18michaelr525free instance..
05:18michaelr525where is that?
05:24wunkimichaelr525: you get one free EC2 micro instance when you sign up for AWS
05:34bendlasGood day, folks!
05:35bendlasI just wondered: Is there a way to intern the same Var in two different namespaces?
05:35bendlasi.e. is there a way to intern an existing var object in a namespace?
05:42raekbendlas: don't think so, but you can always refer the var
05:43raekbut that doen't allow other namespace to refer the refered var
05:45bendlasraek: that would have been my use case
05:45bendlasa transitional aid in refactoring
05:45bendlasbut I can imagine, that it would open the door to too much dynamic-binding wierdness
05:46bendlasthanks, anyway
05:47raekyeah, something like that would make it possible to rename a namespace and keep the old one for backward compatibility
05:48raekbut afaik there is no obvious way to do that
05:50raekthere is 'immigrate' from old contrib, but it creates new vars. so if you update vars in the one namespace that change won't propagate into the other
05:50bendlasack
05:51bendlasthe real solution will be a proper refactoring tool
05:53mindbender1greetings
06:29clgvIs there already a hierachical clustering algorithm implemented in clojure? I didn't find anything in incanter.
06:34mindbender1
06:56scottjclgv: maybe infer
06:56clgvscottj: which lib is that?
06:57clgvhttps://github.com/getwoven/infer?
06:57clojureboteg, https://github.com/clojure/tools.logging is the new version of clojure.contrib.logging
06:58scottjclgv: yeah
07:04wunkican someone help me how to supply a function with extra parameters when a condition is met. For example: https://gist.github.com/5075886377eb27feaeed
07:04wunkithus, if condition x, also add these parameters to the function call.
07:05ordnungswidrig1(apply f arg1 arg2 arg3 (if (condition [arg4 arg5] []))
07:06ordnungswidrig1wunki: sth like that?
07:08wunkiordnungswidrig1: let me try that
07:09wunkiordnungswidrig1: passing [] to the function causes it crash, wrong amount of arguments
07:09kzarI've messed up the recursion in this little function somehow, any ideas? http://paste.lisp.org/display/124505 (It's running off forever even if I do (take 5...))
07:09wunkiI think I need an if, or else do nothing, don't return nil also
07:11Chousukekzar: that lazy-seq is pointless. recur is not lazy.
07:11ordnungswidrigwunki: you'll need sth like (apply validate letter [:title...] ... [:body...] (if (:reply letty) [[:reply objectid?...] [:reply...]] []))
07:13kzarChousuke: Ah right, I'll go read about lazy-seq methinks
07:14Chousuke(defn reductions [f init coll] (lazy-seq (let [res (f init (first coll))] (cons res (reductions f res (rest coll))))))
07:15Chousukehm, that probably fails at the end of the reductions
07:15Chousukeyour job to fix it :)
07:16Chousukethe point being, usually you don't want to use recur if you want a lazy seq
07:17Chousukeyou just use regular recursion, which is made non-stack-growing by the laziness of lazy-seq
07:39wunkiordnungswidrig: I wasn't able to make it work.
07:40ordnungswidrigwunki: gist your code
07:40wunkihttps://gist.github.com/2c86bec2f2249d69c4ed
07:40wunkiI stripped apply again, to start clean
07:42ordnungswidrigwunki: https://gist.github.com/a9da42cfda88499f47f6
07:42ordnungswidrigwunki: this should work
07:42wunkiordnungswidrig: trying it right now
07:43ordnungswidrig,(apply println :foo :bar (if true [[:baz :qux]] []))
07:43clojurebot:foo :bar [:baz :qux]
07:51wunkiordnungswidrig: checks don't seem to work anymore. I'm now always getting `null` returned
07:59mccraigare there functions for manipulating file-paths anywhere in core/contrib : something like ruby's File.dir/basename/dirname/expand_path/join ?
07:59kzarChousuke: Gotya, got it working :) http://paste.lisp.org/display/124505#1
08:05raekmccraig: clojure.java.io/file
08:06raekif you pass it multiple string or File arguments, it will join them with the serparator of the platorm
08:06raekit returns a java.io.File instance, which has methods for more advanced stuff
08:07mccraigraek: ah, ok… and then use e.g java.io.File.getCanonicalPath for expand_path
08:07raekyeah
08:07mccraigraek: thx
08:07raekthe file function basically just wraps the constructor of File, which is a pain to use
08:08raek(you can only join two segments)
08:42wunkiordnungswidrig: excuse me, it was some other code that caused the error. Thank you for your help, it worked!
08:43ordnungswidrigwunki: I'm glad I could help
08:53khaliGi've got a png image i use as an icon - is there a clojury way of referring to it from code?
08:55ordnungswidrigkhaliG: you can load it from the class path using getResourceAsStream
08:56khaliGordnungswidrig, so where shall i store it in my lein project - in src? or somewhere else?
08:56raekkhaliG: put it on the classpath (e.g. in resources/, which leiningen adds to the classpath automatically) and use clojure.java.io/resource to get a handle to it
08:56raeksrc/ works too, but it can be nice to separate these things
08:56khaliGso in $PROJECT/resources raek?
08:56raekyes
08:57khaliGok thanks
08:57raekif that dir did not exist when you started clojure, you might need to restart it
08:57khaliGyeah i've got no such directory :/
08:57khaliGi was about to create it by hand
08:58raekyes, you have to do that
08:58khaliGok understood
08:58raek(resource "foo/bar/file.png") will access $PROJECT/resources/foo/bar/file.png
08:58khaliGexcellent, that's very nice and neat :)
08:59raekin the string you give to resource, always use forward slashes as separators and don't include one in the beginning of the string
09:01raekkhaliG: also, you can give the thing you get from the resource call directly to the constructor of ImageIcon
09:01johnbendi
09:03khaliGraek, that worked beautifully. I need to take a closure look at clojure.lang.io to see what other goodies lie there
09:06gtraka closure look? lol
09:07Wild_Catstupid question: why does get not work on lists when nth works on vectors?
09:08gtrakget is associative, vectors are also associative from ints to vals, I don't think lists are associative
09:08bpsmWild_Cat: "get" is supposed to imply O(1), efficient random access, while nth implies sequential O(n) cost.
09:09Wild_Catbpsm: does nth have O(n) cost on vectors as well?
09:09gtrak,(get ['a 'b 'c 'd] 1)
09:09clojurebotb
09:09gtrak,(get '('a 'b 'c 'd) 1)
09:09clojurebotnil
09:10gtrak,(nth '('a 'b 'c 'd) 1)
09:10clojurebot(quote b)
09:10gtrak,(nth ['a 'b 'c 'd] 1)
09:10clojurebotb
09:10bpsmI expect that nth will have O(n) cost on vectors as well (though clojure could special-case it, I don't think it does.)
09:10johnbendiwhat the best site for clojure business-related open source projects?
09:11gtrakbpsm, why wouldn't it special case it?
09:11bpsmbecause that just muddies the waters when you want to communicate get is O(1), nth is O(n).
09:11gtrakclojure always tends practical
09:12gtrakO(1) doesn't muddy the O(n) waters, it dilutes them :-)
09:12gtrakand big-o is always worst case
09:12chousernth doesn't promise fast access in general, but does provide it on vectors.
09:14bpsmYup. I just found that out too by reading the definition of nth in https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java It special cases for things that implement Indexed (like Vector).
09:15Wild_CatI see. Thanks for the info.
09:16Wild_CatI'm not convinced of the usefulness of having separate get and nth functions, but at least I see the reasoning behind it.
09:16gtrakin fact Indexed only has an nth and a count() method
09:16gtrakWild_Cat, get works on maps
09:16gtraknth on a map gives you an entry I believe
09:16Wild_Catgtrak: sure. What I mean is, why not just have get work on all collections and get rid of nth entirely?
09:17gtrak,(nth {:a 1 :b 2 :c 3} 1)
09:17clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap>
09:17Wild_CatI come from an OO background -- code to the interface, not the implementation, and performance characteristics are an implementation artifact ;)
09:17gtrakah, it just fails, I think get and nth are conceptually different, the same argument is, why have vectors when a vector is just a map of ints to vals?
09:17gtrakjust use maps instead
09:17Wild_Catgtrak: because maps are unordered.
09:18Wild_Catand because maps may be sparse
09:18gtrakyou can have a non-sparse ordered map if you like
09:18Wild_Catgtrak: yeah, it's called a vector :p
09:18manutterwait, get and nth do different things, don't they?
09:19gtrakthey only do the same thing on vectors
09:19gtrakwhich makes sense
09:19manutterget == "look up a value in a map (associative array) with an optional default value if the key is not found"
09:19manutternth == "retrieve an item in a list based on position"
09:19manutterright?
09:19clojurebotto be fair I dunno that I've ever had code out right rejected, it just sits in jira or assembla or where ever, or if I ask if there is any interest (before writing any code) I get told to go write alioth benchmarks
09:20manutterbotsmack
09:20gtrakWild_Cat, I think many of clojure guys come from OO background :-). At some point it's worth drawing a line, and they draw it at performance guarantees. Sometimes you want a map, sometimes you want a vector.
09:21gtrakthe abstraction for both is called collection
09:21mprenticegtrak: vectors and maps are different data structures with different characteristics, appropriate in different situations
09:21Wild_Catgtrak: like I said, I understand the reasoning. I don't agree with it, but I understand it ;)
09:21gtrakWild_Cat, I think you *should* agree with it :-)
09:21gtraknot to be dogmatic
09:22Wild_Catgtrak: well, my point of comparison here is Java's own LinkedList and ArrayList
09:22Wild_Catwhich both support the List interface.
09:22Wild_Catbut widely different performance characteristics.
09:22gtrakthere's a common interface if that's what you need
09:23mprenticegtrak: oops sorry, i think i jumped in talking to the wrong person :P
09:23gtrakmprentice, yes, I agreed with what you said
09:23Wild_Catgtrak: still, what I get of all this is that get shouldn't be used on vectors either. If you want a list interface use nth, and if you want a map interface use get.
09:23Wild_Cat(that way vectors and linked lists can be swapped out for each other at will without needing to rewrite the code that accesses them)
09:24gtrakWild_Cat, you can still swap out vectors and linked lists, though you might have to run seq on the vector
09:25gtrakhttp://clojure.org/sequences
09:25mprenticei usually treat vectors as tuples. i haven't done any performance sensitive stuff so that list performance is a problem.
09:25Wild_Catgtrak: whereas if you avoid get altogether you don't have to do anything other than replace the list with a vector (or the opposite) where it's instantiated
09:26Wild_Catof course, if you find out a map is what you really needed you're screwed, but IME it's more common to swap lists/vectors than vectors/maps or lists/maps.
09:26Wild_Cat(then again, ME doesn't include any actual Clojure work, so...)
09:26gtrakWild_Cat, ... they're all trees anyway
09:26Wild_CatGod is a hash map ;)
09:27gtrakanyways, you should probably check out Rich Hickey's seqs video: http://blip.tv/clojure/clojure-sequences-740581
09:28Wild_Catgtrak: will do. Cheers.
09:30jweisshow is "tail position" defined? I'm returning a vector literal, and i'm calling recur inside the literal. but the compiler doesn't think that's the tail position.
09:31gtrakjweiss, if you want an accumulator, make an extra binding in the loop
09:31gtraklike (loop [out [] input start] or something
09:32jweissgtrak: i don't think i want an accumulator. i'm turning a list of trace log statements into nested vectors: http://fpaste.org/QXoo/
09:34gtrakjweiss, well that's not the tail position because it has to keep track of the prior stack frame to be able to build it up, if you can refactor it to use assoc-in, it'll work
09:35jweissgtrak: i am not seeing how assoc-in helps, it's not a map, it's a vector
09:36gtrakit's how you update nested structures more easily
09:36mprenticegtrak: i'm not familiar with assoc-in, but it sounds interesting. can you point me to some examples?
09:36gtrakvectors are maps of ints to vals
09:36jweissgtrak: ah ok i see what you are saying, i can accumlulate the vector and insert where necessary
09:37gtrakhttp://clojuredocs.org/clojure_core/clojure.core/assoc-in
09:39gtraklooks like it won't automatically create the nested vector for you, it works best on maps
09:39gtrak(assoc-in {} [:bob :bob2] :bob3)
09:39gtrak,(assoc-in {} [:bob :bob2] :bob3)
09:39clojurebot{:bob {:bob2 :bob3}}
09:40gtrak,(assoc-in [] [:bob :bob2] :bob3)
09:40clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>
09:40jweissgtrak: i think i don't even need recur, since i'm processing trace logs, if the fn call depth didn't blow the stack, my processing the log won't either.
09:40gtrak,(assoc-in [] [0 1] :bob3)
09:40clojurebot[{1 :bob3}]
09:40gtrakjweiss, might as well do it iteratively if you can
09:40chouserright. currently to use assoc-in on vectors you need the vectors to exist already
09:40gtrakyou don't want a time-bomb
09:40chouser,(assoc-in [[]] [0 1] :bob3)
09:40clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
09:41chouser,(assoc-in [[:x0 :x1]] [0 1] :bob3)
09:41clojurebot[[:x0 :bob3]]
09:41chouserthere has been talk (but no action afaik) on an assoc-in-like thing that lets you specify how to create new collections
09:43mprenticegtrak: ahh i see. assoc-in seems related to a zipper, so you can pass in a path and do a deep udpate
09:43mprenticegtrak: super nifty!
09:43gtrakassoc-in is cool stuff, try to write that in java
09:45mprenticejweiss: this might be hopelessly dated, but i would have fn processor take an accumulator param
09:45jweissmprentice: that would seem to make the fucntion a lot more complex, since I'd also have to keep track of the current insertion point
09:46jweissseems like using recursion is what would make this a lot simpler
09:46mprenticejweiss: ah yeah i'm taking a closer look at the structure of what you're building
09:48jweissmprentice: here's the same paste with the input i'm going to give it added: http://fpaste.org/Qm4S/
09:48gtrakjweiss, I assure you, any recursive algorithm can be made iterative :-)
09:49jweissgtrak: i'm aware of that :)
09:49jweisshttp://fpaste.org/ybT2/
09:50mprenticeiteration with immutable trees is the situation zippers were made for. clojure.contrib.zip-filter.xml
09:50mprenticehttp://richhickey.github.com/clojure-contrib/zip-filter-api.html
09:51jweissmprentice: yeah, i tried that first, but zipper docs are not clear on how i'm supposed to turn a leaf node into a branch and add a child
09:51jweissappend-child just complains about child on a leaf node
09:52mprenticewould it be terrible advice to do it recursively and leave a note to do it iteratively with a zipper? :P
09:53mprentice;; TODO: iterate with zipper for log file > 100KB
09:54jweissmprentice: i don't think recursive could ever blow the stack, just by virtue of the data i'm giving it - it's stack data. if it was > maxdepth, the stack would have blown while creating the data before this fn could ever see it
09:54jweissbut yeah i DID try to use zippers first
09:55mprenticejweiss: i learned how to use xml zippers because i was dealing with big-ish xml files :P
09:55jweissmprentice: were you creating xml or parsing it
09:56mprenticejweiss: converting from one xml format to another
09:56mprenticejweiss: the sort of thing xslt is supposed to solve but always makes me want to tear my eyeballs out whenever i have to use any programming logic
09:56jweissmprentice: do you have an example you could point me to
09:56chouserIf you're sure the data is small enough, a recursive solution is almost always prettier in Clojure than an iterative solution, especially if that requires manual use of zippers.
09:57mprenticechouser: indeed
09:57mprenticejweiss: lemme see
09:58gtrakyou could probably do tail recursion if you save off the data for later in a bunch of closures
09:58chouserI've been doing a lot of small tree rewriting at work recently and although seq-tree, walk, and zippers are all alluring, in the end a plain ol' recursive function ends up being succinct, flexible, and fast.
09:58chouserer, tree-seq
10:00mprenticechouser: i used walk a few months ago. if you have to update values inside an xml tree, it's soooo good.
10:01chouseryep
10:01mprenticejweiss: i have a file that walks through an xml tree and prints it out in a .dot file. i dunno how useful it is if you're not familiar with the input xml it's using.
10:01jweisschouser: i ended up here because i'm writing a log file, and writing logs as a tree structure is bad because you can't know when to close open tags (or braces). so i elected to write the logs as a flat structure with the depth as one field in each entry. now i am trying to convert back to a tree
10:02jweiss(after the file has been closed)
10:02chouserI didn't mean to detract from any of those. They each are very powerful in their place. Walk is expecially good with "mixed" trees of various clojure stuctures (maps, vectors, etc.)
10:03chouserjweiss: ah, so converting a sequence back into a tree.
10:03chouserI wrote a function for just such a situation, specifically to convert a sequence of XML SAX events into a DOM-like tree.
10:04chouserI haven't documented it properly. It deserves a talk or blog post.
10:04mprenticei also solved a very similar problem
10:04mprenticewhere dependencies came in in any order, but had to be output in a specific order
10:06mprenticejweiss: i would go the recursive route with a note
10:06jweissmprentice: that's what i'm trying now :)
10:06chouserNot sure if seq-tree would be convinient when the input includes depth rather than up/down events: http://bit.ly/o8ArdK
10:06mprenticejweiss: so when it breaks later, you or someone else can shake your fist and say "damn you lazy asshole!"
10:07jweissmprentice: i'm pretty sure it's safe to use recursion here. as long as someone doesn't try to use this function to process some other kind of data, which i don't see ever happening :)
10:08jweisschouser: it also has up/down events, i probably don't even need the depth, i just have a boolean which is whether the line is for a fn entry or exit
10:09jweissseq-tree might do what i want - looking
10:09mprenticejweiss: famous last words. "nobody will ever need more than 64K of stack..."
10:09jweissmprentice: but my data is traced fn calls
10:09jweisshow can processing them blow the stack but didn't blow the stack when the trace was run?
10:10chouserdifferent JVM settings? :-/
10:10jweisschouser: yeah, that is true
10:10jweissok ok you guys win
10:11mprenticejweiss: i was advocating expediency! i was just also pointing out that it could potentially cause difficulties later
10:11chouserI agree with mprentice :-)
10:12chouserrecursive is good! If your log parser blows up they can tweak their JVM settings and it'll work.
10:12khaliG(.darker (java.awt.Color. 100)) works as expected in the repl; but the same line in code gives Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.IllegalArgumentException: No matching field found: lighter for class java.awt.Color - any ideas?
10:13gtrakmaybe we can create a stackless clojure
10:13gtrakjweiss get on it
10:13jweisschouser: i'm not sure seq-tree would work, since i don't have any "node events", just enter/exit subtree
10:14jweissi guess i could pre-proccess the data to make it have node events
10:15khaliGoh i see, i was actually calling .lighter on nil - my mistake, nevermind
10:16chouserjweiss: if you either give up on seq-tree or manage to make it work, I'd be curious to see how far you get. seq-tree was written specifically for XML, but I'd like it to be as general as possible.
10:22chouserjweiss: your enter subtree event has all the details you would want for the subtree?
10:25jweisschouser: no, my events are just fn enter and fn exit (the former has the fn name and args, the latter the return value)
10:26jweissso basically the enter has half the node info, the exit has the other half
10:27chouserhm.
10:28jweisswell, i'm not sure what a node is in this case, i suppose a node can be either the fn call or the return value
10:28jweissin which case each entry is either [enter-subtree node] or [node exit-subtree]
10:29chouser,(seq-tree #(when (not= %1 :up) (vector %1 %2)) #{:up} identity [:a :b :up :c :d])
10:29clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: seq-tree in this context, compiling:(NO_SOURCE_PATH:0)>
10:29chouseroh, heh.
10:30chouseranyway, that has the down-event data in each node without pre-processing the seq
10:30jweisschouser: cool i'll give that a shot
10:30jweissthanks
10:30chouserbut it's missing data from up events
10:32chousera key requirement for seq-tree was to be as lazy as possible. requiring the exit event of a subtree in order to return the subtree pretty well defeats that
10:32chouserbut that doesn't mean it could work. hm..
10:34chouseryeah, seq-tree doesn't allow for the existence of any useful data in exit events. a weakness.
10:35jweisschouser: i control the data being produced here, so i could easily change it - what do you recommend?
10:36jweissmy only restriction is i can only write to the data on fn call/exit
10:36jweissso i could write [enter node] and then [node exit] ?
10:37juhu_chapahi folks, i am a beginner. i have been reading some clojure code and sometimes i have found "->" and a do not understand how is used, somebody can help me?
10:37jweissjuhu_chapa: yeah that was pretty mindbending for me too when i first started
10:38jweissimagine your forms as those russian nested dolls. using -> lets you put the dolls side by side, and it'll automatically nest them all for you
10:39jweisshttp://revolutioniz.com/revolutioniz/wp-content/uploads/2010/04/russian_dolls.jpg
10:39jweissalthough that image is sort of backward, in clojure you'd put your smallest doll first
10:40chouserjweiss: possibly. Your best solution might still be your own recursive function. But I'd like to better understand the problem space of converting seqs to trees.
10:40chouserjweiss: Having data in the exit event makes perfect sense for your problem space, so I'm trying to think about how seq-tree could accomodate that.
10:47gtrakjuhu_chapa, http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/
10:48gtrakthere's also a ->> that threads into the last spot
10:49gtrak,(-> 4 (conj 6) str)
10:49clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IPersistentCollection>
10:50chouser[4]
10:51jkkramersrid: prompted by your question a couple days ago about finding all projects that depend on X, i built this: http://clojuresphere.herokuapp.com/
10:51gtrak,(-> [] (conj 4))
10:51clojurebot[4]
10:52gtrak,(->> 4 (conj []))
10:52clojurebot[4]
10:52gtrak,(conj [] 4)
10:52clojurebot[4]
10:52gtrakget it?
10:52chouserjweiss: (seq-tree #(when (symbol? %) {:name %1 :exit (:x (last %2)) :kids (drop-last %2)}) #{'up} identity (mapcat #(if (= 'up %) [(meta %) %] [%]) '[a b ^{:x :foo} up c d up up ^{:x :last} up]))
10:53chouserThat uses mapcat to preprocess the event stream, putting a special node event before each exit event, which the 'parent' fn then extracts.
10:53chouserclumsy. seq-tree should provide the exit event to the parent function somehow.
10:54jweisschouser: nice, only problem with that i can foresee is it would read my whole log into memory
10:54Mike|homeWhy doesn't Clojure perform tail call optimization at compile time like Scala does?
10:55juhu_chapathank you very much to all
10:55chouserjweiss: yep. to process the first node, it would read to the exit event of that first node.
10:55gtrakMike|home, recur will error at compile-time if it's not in tail position, that's better than doing it implicitly, no?
10:55jweisschouser: i'm not sure that the solution i come up with won't end up doing that too, though :)
10:55chouserjweiss: after that, since it's a lazy seq, that first node could get GCed, but each whole node will be in memory
10:56Mike|homeDo Scala people envy that feature, gtrak?
10:56gtrakwho cares? :-)
10:56Mike|homeHahaha. Thanks. Question answered :)
10:56chouserMike|home: It seems to me there is already plenty of confusion about what "tail position" means.
10:57jweissyeah i asked about that an hour ago :)
10:57chouserClojure's approach means when you're wrong you get a clean error that says you were wrong about tail position.
10:57chouser(and we all know how much Clojure concentrates on clean error messages. :-P)
10:57Mike|homechouser: I agree, that does help the developer an awful lot.
10:57Mike|homeHaha
10:57jweissapparently [1 2 (recur a b)] is not tail position because the overall vector is evaluated last, not the recur?
10:58chouserIf Clojure converted tail-position recursive calls into 'recurs', when you're wrong you would get a runtime error, but only on sufficiently large data.
10:58chouserI wonder how much Scala code has stack overflows waiting to happen...
10:59Mike|homeHahaha, I never thought of that, chouser
10:59chouserjweiss: right. "tail" in this case doesn't mean "syntactically last"
11:00jweisschouser: yeah that's what is confusing about "tail" since it sounds rather spatial to me, when really it's temporal
11:00chouserhm. maybe.
11:04chouserOnly expressions which may wholly be returned by a form are in the tail position of that form.
11:05chouserso in (let [a b, c d] e f g), only g is in the tail position
11:05chouserbecause none of b, d, e, nor f will be returned by the let
11:05jweisschouser: ah so that is why literals are different
11:05jweisssince what's returned is the entire literal
11:05chouserright
11:06jweissmaybe we should call it "return position" :)
11:07chouserso in (fn [a b] (prn :hi) (+ 1 2 3)) the call to + is in the tail position, but none of its args are.
11:07cemerickanyone know what an "intrinsic predicate" is?
11:09chousercemerick: "Identity of relation may, *of course*, be taken to indicate an intrinsic predicate which the terms have in common" -- Bertrand Russell
11:09chousercemerick: in other words, I have absolutely no clue.
11:09cemerickmmm, right
11:09cemerickSo, something between Russell and https://github.com/clojure/clojure/commit/e92978783e1ba7ac0e2617fdabfed576209d7fa4
11:09cemerickapproximately :-P
11:10chouserha!
11:13chousercemerick: http://java.comsci.us/etymology/type/intrinsic.html
11:14chousersynonym for "primitive type" I think
11:14cemerickMust have been introduced to improve clarity.
11:14chouserheh
11:15cemerickIn any case, not knowing my ASM as comprehensively as I probably should, I've no idea what that code does.
11:16chouserThat table is fascinating. It looks like it may be replacing calls to various static methods with special JVM opcodes
11:17cemerickOh, not having to go through c.l.Numbers for stuff like shifts, I think…
11:17cemerickright
11:17chouserhad no idea that was in there.
11:17cemerickcommitted yesterday (!)
11:18hugodmust be a bugfix then ;)
11:21chouserheh
11:25juhu_chapaguys, here with another beginner question: i am using the function read-properties from the contrib: (read-properties file-able)
11:25juhu_chapaafter that how can i read the properties?
11:25juhu_chapawhere are they?
11:26technomancyjkkramer: I've totally been wanting to build that for a while now
11:26technomancydid you base it on the clojars sql dumps?
11:26jkkramertechnomancy: me too. finally got around to it yesterday
11:27jkkramertechnomancy: rsync -av clojars.org::clojars clojars
11:27technomancyslick
11:27jkkrameri wasn't sure how to get sql dumps, which would've probably been a lot less to download
11:28technomancyI wonder if that could be integrated into clojars at some point
11:28jkkrameri was wondering the same
11:28chouserclojars scares me
11:28technomancyhttp://meshy.org/~ato/clojars-test-data.sql.gz
11:28jkkrameris clojars under community control?
11:28technomancychouser: as a codebase or as a service?
11:28jkkramertechnomancy: is that kept up to date?
11:28chouserservice. I know nothing of its codebase
11:29technomancyjkkramer: so far it's been _ato, but he's pretty open to having others help out. nobody's really taken him up on it so far though
11:30technomancychouser: the SPOFiness?
11:30jkkramermy first thought was to make a clojars patch, but there are so many forks & branches, i wasn't sure where to start
11:30chouserthe unsigned, first-in-wins, namespace clashiness
11:31cemerickits use as a personal sandbox…
11:31cemerickwe've been through all this before, though
11:31coopernursejuhu_chapa: read-properties returns a java.util.Properties object that you can reference
11:32pjstadigchouser: why does it have to be unsigned?
11:32juhu_chapa:O
11:32thorwiljkkramer: http://clojuresphere.herokuapp.com/ is remarkably well laid out :)
11:32coopernurseeg: (def p (read-properties "/tmp/foo.properties"))
11:32juhu_chapais really simple
11:32juhu_chapathanks coopernurse
11:32coopernurse(.getProperty p "my prop")
11:33technomancyjkkramer: does your site just check :dependencies or is it :dev as well?
11:33jkkramerthorwil: thanks
11:34jkkramertechnomancy: both. the data is separated in the underlying store, but displayed combined
11:34jkkrameri wasn't sure off-hand how i wanted to provide a UI filter
11:35technomancyyeah, it's not a straightforward problem
11:35jkkramermaybe just a site-wide toggle in the header or something
11:36technomancycould also probably use a "see all" truncation widget
11:37technomancyjkkramer: part of the reason we don't have more people hacking on clojars is that it's hard to set up with nailgun and the separate user account. hiredman has a branch to make all that go away
11:37cemerickpjstadig: Are there any signed artifacts in clojars?
11:38pjstadigcemerick: is there any reason they can't be signed?
11:38technomancysigning is the easy part; it's building up the web of trust that I wouldn't know how to do
11:39pjstadigthe internet is pretty crazy out there
11:39pjstadigyou can't even be sure the website you're visiting is the one you want
11:39pjstadigyou have to be responsible
11:39technomancymaybe we could outsource that to diginotar
11:40technomancythey've got some pretty cheap certs these days =)
11:40cemerickpjstadig: No, but that's not really the point.
11:40chouserI don't know that things in clojars *can't* be signed.
11:40cemerickAs onerous as central's policies are, requiring all artifacts to be signed is unabashedly good.
11:41ejacksonooh ooh..... flights to get to the conj have dropped dramatically
11:41ejacksonit might even be possible :D
11:41chouserbut what scares me is if I release a project with deps that are resolved by pulling code from clojars, it seems quite likely that someone using my lib could get exploit code from who know whom via clojars. Maybe there's something I'm unaware of that prevents that. I hope so.
11:42technomancycemerick: so the point is not that it's coming from someone you trust, but that the artifact was signed by the same key as the one that signed earlier releases?
11:42cemericktechnomancy: Right, you have a *shot* at determining legitimacy.
11:43cemerickejackson: gotta be there :-D
11:43technomancyit certainly would help in the event of a compromised server or the like
11:44chouserof course if we could depend on SHA-1's instead of maven coordinates, signing would be a lot less important -- ie, only an issue at dev time.
11:44technomancyI wonder if it would be feasible to add that kind of requirement mid-stream as it were
11:44ejacksonyeah, if I come around early for the training I save 1,500 GBP on flights, which is nutso, so I just might
11:44technomancywe do have access to the scp outputstream, so we can insert any kind of deprecation warning
11:44technomancyand once we separate releases and snapshots, the policy would probably only need to apply to releases
11:45pjstadigcemerick: all I'm saying is that jar signing is ostensibly a solution to this problem, so complain about jar signing, and not clojars
11:46pjstadigif you want to know whether you can trust a message (or jar) that comes through an untrusted channel, then use signing
11:47cemerickpjstadig: It's clojars' policies that are problematic. If people aren't signing artifacts as a matter of course (which no one will do unless required by the accepting repository), then there's no point.
11:47chouserpjstadig: but it's also a culture. a maven plugin that checkes for signed jars, plus use of it (including I suppose all the signatures I trust) in a lib I release still won't do any good if the deps I need aren't signed.
11:47chouserer right, what cemerick said.
11:47cemerickI can't very well lobby authors of my dependencies to practice good hygiene.
11:48pjstadigright, which means you have to be careful and specify to your build system that you only want signed jars
11:48pjstadigthat's orthogonal to the clojars policy
11:49pjstadigit would be nice if every website used SSL and had a trust chain that went back to a CA i trusted, but somehow we manage to survive
11:52cemerickThat's fine, if you are OK with never using clojars. If clojars doesn't require signed jars, then it will never contain signed jars.
11:52pjstadigcemerick: why can't you lobby the authors of your deps? if people don't know that they should be signing jars, then how will they know?
11:52cemerickHopefully, deploying to central will become nearly as trivial as deploying to clojars soon.
11:53pjstadigchouser: i don't think that its as bad as you think, once someone claims an groupId on clojars no one else can push to it AFAIK
11:53chouserjweiss: actually, there may be a conflict between seq-tree providing access to the exit event from the parent fn and the ability to provide sufficient laziness.
11:54technomancywe've had a couple of instances where a misclaimed groupid has been reinstated to its rightful owner through manual intervention.
11:54cemerickpjstadig: Sorry, that's just absurd. Even the smallest of my (deliverable) projects involves transitive dependencies on dozens of libraries from different projects/authors.
11:55jweisschouser: i could see that being the case. i'm still trying to write my own recursive fn
11:55technomancydespite it being a technical solution to a cultural problem, I think if the tools made it easy we should consider requiring signed releases
11:56pjstadigcemerick: i don't see how it is productive to complain about a problem, then not be willing to work to fix it
11:56pjstadigbesides just getting everyone to sign jars is only the first step
11:56pjstadigjust because you know its the same person pushing versions doesn't mean you can trust them
11:56pjstadigand even people you can trust can introduce nasty bugs
11:56technomancyyeah, it's necessary but not sufficient =\
11:56pjstadigit's just not as simple as you make it seem, cemerick
11:57jkkramertechnomancy: are the clojars code changes being discussed on a mailing list, or ad hoc on IRC and such?
11:57jkkramerre nailgun & such, not signing
11:58technomancyjkkramer: there's a maintainers list: http://groups.google.com/group/clojars-maintainers
11:58technomancythough I don't know if the scp changes are being discussed there yet; currently it's just a hiredman project
11:58jkkramerah, there it is. didn't turn up via google
11:58technomancythough I am quite curious about it too
11:58technomancyjkkramer: maybe a different colored background for dev deps?
11:59jkkramertechnomancy: good idea
12:01cemerickpjstadig: The start of "fixing it" is a policy change IMO. Policy changes through discussion, debate, and convincing others. It's not like I can submit a pull request for such things.
12:08sridjkkramer: looks like irccloud ate my responses to your message. did you get them?
12:08jkkramersrid: no
12:09sridah ok. i like the UI, pretty simple. i'm trying to set it up locally and `lein run -m clojuresphere.preprocess` raises java.lang.NullPointerException
12:10juhu_chapaguys, where can i find documentation to run a clojure app in the command line?
12:11jkkramersrid: the actual preprocessing steps are in a comment in preprocess.clj. haven't turned it into a runnable thing yet, since they are still a bit messy
12:11manutterjuhu_chapa: are you using leiningen?
12:11jkkramersrid: note that you'll need to download a hefty amount of data to do it - more than a gig from clojars, and thousands of github calls
12:12hugodanyone know where strint is in 1.3?
12:12sridjkkramer: how long would that take on average? and is the 'update' faster for the github calls?
12:13technomancyjkkramer: how much did you find that was available only via github and not clojars?
12:13cemerickhugod: "where"? Still in old contrib, AFAIK.
12:13cemerickI think it was OK'd for transition, but I haven't gotten to it.
12:13technomancyI'm surprised you implemented both sources already for a project that's a day old =)
12:14cemerickInsofar as Rich et al. have said that it's not likely to make it into core, I may just continue development of it outside of the contrib process.
12:14hugodcemerick: ok, it was listed under core.incubator on the library names page
12:15cemerickoh really?
12:15jkkramersrid: 15-30 mins maybe. updates are still slow, since there's no easy way to find out which repos changed. i would be reluctant to run the github fetching more than once a day or so, to avoid hitting rate limits
12:15juhu_chapamanutter: no, i am using enclojure.
12:16cemerickhuh, lookit that
12:16manutterHmm, enclojure, I've never built a standalone jar with that...
12:17jkkramertechnomancy: Raynes' github api helped: just searched for "clojure" with language "clojure"...which leaves some repos out, like clojure itself (written mostly in java)
12:17cemerickhugod: I'll have to see what's up there. IIRC, you had some ideas for strint improvement, correct?
12:17Raynesjkkramer: Oh cool, you made use of that?
12:17RaynesI was wondering if anybody else on the planet ever would.
12:18manutterjuhu_chapa: the basic idea is to build a standalone jar file that includes all the libs/jars that your clojure code depends on (including the clojure jar itself)
12:18jkkramertechnomancy: i haven't run a "difference" query yet to check which exist on one but not the other. there were way more projects on clojars, but that may be because it includes all past versions
12:18technomancyjkkramer: naturally
12:18jkkramerRaynes: http://clojuresphere.herokuapp.com/clj-github :)
12:18manutterjuhu_chapa: but I'm not sure what the specifics would be
12:18technomancyjkkramer: end-user applications don't necessarily end up on clojars, so there is that
12:19jkkramertechnomancy: right. only open source
12:19hugodcemerick: pallet added some stuff on top to do runtime interpolation - I'll probably just copy the code into pallet.common along with all the other contrib stuff used in pallet that isn't in the new contrib.
12:19jkkramermaybe i should say "graph of the open source Clojure ecosystem"
12:19hugodcemerick: longer term, I might just switch to using one of the mustache libs
12:19squidzwhat's so good at paredit?
12:19cemerickhugod: using eval?
12:20Raynesjkkramer: Since someone is actually using it, I'll give it a once over this weekend and see if I can't update/fix any nastiness.
12:20hugodcemerick: yes
12:20jkkramerRaynes: worked fine for my modest needs
12:22Raynesjkkramer: Am I right in that every API function requires a auth argument? That could probably be remedied.
12:23sridjkkramer: would be nice to sort the 'Dependents' list itself by their number of dependents. enlive has 63 dependents, and I was most interested in the popular dependents.
12:23RaynesIt's kind of pointless, given that not everything requires authentication. Hence your very empty github-auth map.
12:23jkkramerRaynes: i didn't use auth -- just gave {} as the argument. seemed to work fine
12:23jkkramerright
12:24RaynesAlso, I guess I need to go over my gist stuff, since it was written before the gist API was documented.
12:24jkkramersrid: yeah, i will probably do that. or privde options for sort criteria: most-dependents, last-updated, alphabetical, etc
12:24RaynesAnyways, this is a lovely website.
12:24RaynesHappy to have helped.
12:25jkkramerthanks, it saved me a good chunk of time :)
12:27sridwill take a look at clojuresphere when i get back home, and contribute something. good way to learn clojure.
12:27juhu_chapamanutter: i have installed lein, could you describe please the process of creating a jar?
12:28manutterjuhu_chapa: ah, that's an easy one: "lein jar" will create a jar with just your app code in it, and "lein uberjar" will create a standalone jar that you can run with "java -jar whatever-you-called-your.jar"
12:30jkkramertechnomancy: 1384 distinct artifact ids for github projects, 879 of which do not exist on clojars. 1641 ids for clojars, 1136 of which do not exist on github. 505 that exist in both.
12:31juhu_chapamanutter: i have created myproject/src directory and i wrote there a helloworld.clj, can you post me a project.clj using clojure 1.2.1 and contrib 1.2?
12:32manutterjuhu_chapa: if you create your project with "lein new myproject" it will set you up with the right project.clj file automatically
12:34juhu_chapamanutter: ohh, let me see.
12:35sridi did not realize that i can host more than one app in heroku for free. thought the free 1 dyno == 1 app.
12:36sridthis makes heroku irresistibly for hobby projects
12:36sridirresistibly attractive*
12:38juhu_chapamanutter: project creation succeded, there is a core.clj in src, what is the purpose of that file?
12:38manutterThat is the default source code file, you'd normally put your "hello world" code in there
12:39manutterbut you can delete it if you don't like it, and put your code in a different file if you put a :main def in your project.clj
12:40manutterThere's a lot of leiningen documentation in the example project.clj file (https://github.com/technomancy/leiningen/blob/master/sample.project.clj)
12:41juhu_chapamanutter: really simple, thank you for your help.
12:41manutteranytime
12:49jkkramersrid: i had the same realization recently. the cedar stack is relatively unrestricted (300+ MB ram, threads, etc). not much persistent storage, though
12:51gtraksrid, someone's been trying to persuade me to do that, any advantages over a local jetty for development?
12:53sridgtrak: ?
12:54gtraksrid, to check out heroku i mean
12:54sridhmm, for development I use jetty via 'lein ring server'. heroku is only for deployment.
12:55sridand deploying clojure to heroku is pretty easy. mostly just need a single-line file `Procfile`
12:55gtraksrid, so you can show off some stuff I guess, but can you really do anything substantial without storage and db?
12:56sridheroku does provide postgresql database (and mongo and others via external addons). only 5MB is free. i don't know about storage; i can probably live without it.
13:05juhu_chapamanutter: i am getting the following error: Exception in thread "main" java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0), what i have missed?
13:05juhu_chapathis when i run: lein compile inside the project dir
13:06manutterCan you post your source code in a gist (gist.github.com)?
13:06manutterI don't think you need to do lein compile, by the way-- lein uberjar will create the standalone for you
13:09gtrakdoes lein uberjar do AOT on everything?
13:10juhu_chapamanutter: git clone git://gist.github.com/1198232.git gist-1198232
13:10manuttergtrak: I don't think it needs to, does it? Uberjar will include clojure, which will compile the scripts dynamically (I think)
13:11amalloyit compiles whatever you say needs to be compiled
13:12amalloyjuhu_chapa: a few minutes ago you were asking how to create a project/jar; that's a very strong indicator that you don't need to compile anything
13:14manutterjuhu_chapa: I don't think you need (:gen-class) in your namespace, and it might be messing you up. You can just run your hello-world code as straight clojure
13:14manutter(from within the jar)
13:14juhu_chapaamalloy: i am trying to break my OOP mindset.
13:15manutterI don't think the (read-properties) should be a problem, but that would be the second thing I would comment out if it were still crashing
13:15amalloymanutter: first thing i'd do. that's unlikely to work
13:15manutterbut I'd start by commenting out the :gen-class line and then running lein uberjar
13:16amalloy(defn properties [] (read-properties ...)), and then use (properties) instead of just properties
13:17manutteramalloy: you're doing that because properties might change at runtime, I'm thinking?
13:17amalloyno, because you can't really define the properties at compiletime it's not an object that can be embedded into java code
13:18amalloyhm. my - key seems to be broken? i left out two of them in that
13:19amalloymanutter: a java program that wanted to do the same would have to look like: class Foo { static { properties = ...}} - that's happening when the app starts up, not when you compile it
13:19amalloyyou can't just put Some Random Object into the bytecode; you have to include the code to create the object instead
13:20manutteramalloy: ah, ok, I wouldn't have expected that (due to my Java inexperience) but I can see it now that you explain it.
13:22manutterWhen I try (read-properties) at the repl, it gives me a file-not-found error for "app.properties" -- sounds like it's actually looking for a config file to parse.
13:22amalloywell yes
13:22manuttermaybe I should look up the docs on that puppy :)
13:22gtrakmanutter, try putting it in the resources dir in your leiningen project
13:22amalloyeh, just an empty file will be a legal .properties file
13:23manuttergtrak: I'm not the one that's using it, I'm just trying to help juhu_chapa figure out the exception he's getting on lein compile
13:24manutter,(doc clojure.contrib.java-utils/read-properties)
13:24clojurebotPardon?
13:24manutterclojurebot: :P
13:24clojurebotPardon?
13:24amalloymanutter: you can also probably repro if you replace (read-properties "foo") with (java.util.Properties.)
13:25gtrakamalloy, so all the things in an ns are compiled to a static initializer block? what determines the order classes are loaded?
13:25amalloy(a) no, i'm pretty sure that's not how it works, and (b) i dunno
13:26gtrakah ok, I'm trying to get an intuition for that stuff, but maybe it's best just to dig in
13:26amalloymostly, you should only put functions at the top level, is the answer
13:27amalloyor clojure objects, which i guess can be embedded because they can be shimmed in with pr-str/read? i'm not sure about that. but you can't put arbitrary java objects at the top level if you want to AOT-compile stuff
13:28juhu_chapaguys i commented out the :gen-class line and the read-properties line and i am still getting the no source error
13:34manutterjuhu_chapa: what are you typing on the command line? Just "lein compile"?
13:36manutterjuhu_chapa: the No Source message just means that the error is not located in a source file
13:36manutteri.e. before it gets to your program code in other words
13:38manutterjuhu_chapa: it's also possible that you have more than one Clojure jar in your classpath, or some other java lib dependency problem
13:41juhu_chapayeah: lein compile or lein uberjar throws the same error
13:41juhu_chapais there a java version issue with clojure? i am using openjdk7
13:42amalloyuhhhh i don't know if 7 is working
13:42amalloyi think it probably is, but i'm not sure
13:45chouser7 is being added to the test matrix. Haven't seen any results yet.
13:47pjstadigthere's no problem with java7
13:47pjstadignot that I've seen
13:48manutterpjstadig: sun java7 or open java7?
13:48pjstadigwhat's the diff
13:49amalloywell, they're different :P
13:49amalloyeg, cljs doesn't work on openjdk because the compiler is depending on some internal undocumented class
13:50amalloyor, at least, that was the state of things for a while after cljs was announced. maybe someone's fixed that; the point is they're not the same
13:50pjstadigyeah i'm not talking about clojurescript i'm talking about clojure
13:53arohnerpjstadig: openjdk doesn't contain a bunch of stuff due to licensing
13:53technomancyarohner: that was true of 6 (mostly font rendering libs) but I don't think it's true of 7
13:54arohnertechnomancy: interesting. Did they get the licenses sorted out, or drop the features? I seem to recall some sound & graphics libs as well
13:55technomancyI don't know for sure; I think headius might.
13:56juhu_chapaguys, the problem was openjdk7.
13:56juhu_chapanow i am using sun jdk 6
13:56juhu_chapai all works
13:58juhu_chapaby the way the :gen-class is needed in order to generate the class inside the jar. after run lein uberjar, just typed: java -jar myjar.
14:05headiusopenjdk is 100% open source now
14:06headiusthe IcedTea replacements for the proprietary bits were merged in some time ago, I believe
14:13manutterjuhu_chapa: Ah, you need the :gen-class to compile the -main function, I forgot about that, sorry!
14:13gtrakI'm noticing it's too easy to reinvent stuff when there are elegant ways to do something. I'd love to see a use-case wiki feature added to clojuredocs, anyone thought about anything like that?
14:14manuttergtrak: the hard part is figuring out how to classify the use cases so you can find the one that matches what you want to do (or *think* you want to do, which isn't always the same thing ;)
14:15gtrakyou can get pretty far with text search, but I see what you're saying
14:26gtrakI have a question about 'separate' in this code: https://github.com/amalloy/useful/blob/develop/src/useful/seq.clj
14:26gtrakis using a for lazier than doseq? also, does the vec call defer evaluation?
14:27hiredmandoseq is not lazy at all
14:27amalloyuh. a for is entirely different from doseq
14:27amalloyin that doseq doesn't return any results
14:27hiredmanan vec builds a vector, so obviously not lazy at all
14:27hiredmanand
14:27gtrakit builds a lazilypersistentvector, does that have any implications?
14:28amalloyno. but i never really understood LPV, so if anyone knows feel free to jump in and tell me about that
14:28hiredmanvectors are not lazy
14:29chouserLPV doesn't really exist anymore
14:29hiredmanit just has static methods for creating pvecs
14:30chouserIt used to be a collection type, before transients I believe.
14:30chouserBut I'm not sure it ever would have had anything to do with this question.
14:31hiredmanthe only things that are lazy are sequences constructed using lazy-seq
14:31chouser'separate' there is not in any way lazy, and couldn't be written using doseq without using some kind of mutable object.
14:31chousergtrak: ^^^
14:33chouserit could have been written with loop/recur, which might be more effecient.
14:35gtrakmore generally, how do you reason about how lazy something is?
14:35hiredmanI just said
14:35hiredmanthe only things that are lazy are sequences constructed using lazy-seq
14:35gtrakmap does that too, yes?
14:36hiredmanwhy don't you check?
14:36hiredman(type (map ...))
14:36gtrakset a man on fire and he'll be warm the rest of his life
14:37gtrak,(type (map identity []))
14:37clojurebotclojure.lang.LazySeq
14:37amalloychouser: i think you're misreading the implementation of separate; it eagerly produces two sequences, both of which are (mostly) lazy
14:38chouseramalloy: ah, indeed. thanks for the correction.
14:39amalloysay, chouser, has any version of data.xml been actually released?
14:39amalloyit would be nice to have a 1.3-compatible replacement for prxml: 4clojure could finally get off 1.2.x
14:40gtrakso ok, the for creates a lazy seq, does running vec trigger the evaluation of it, whihc returns two lazy seqs (from the map calls)?
14:40gtrakthat's what it looks like to me
14:41hiredmanI do feeling like burning things down this morning
14:41Rayneshiredman: I can give you a list of things I'd like to see burned down.
14:45amalloygtrak: yes
14:47gtrakamalloy, coolio
14:48chouseramalloy: no, none released. I was supposed to look at that this weekend.
14:48chouserplayed portal-2 instead.
14:48amalloyhah. wholeheartedly excused
14:48amalloygtrak: you probably should look at the official https://github.com/flatland/useful rather than my fork. actually, my fork probably shouldn't exist
14:49chouseramalloy: I need to look at how we're handling comment, cdata, etc. elements, and glance at my todo list
14:49chouserthen it's just docs. We're really pretty close.
14:50gtrakamalloy, yea, I was just curious and I saw an implementation of separate, followed it down the rabbit hole since a couple of folks I know were arguing about it
14:50amalloygreat
14:51gtrakI also found out about group-by through that discussion
14:52arohnerhas anyone gotten swank running over heroku?
15:09amalloychouser: well, let me know when you pick a format for representing comments and such; i'll probably want to add a sexp/prxml-ish conversion to that format
15:13chouseramalloy: ok. It was gread that prxml supported them -- I don't want it to be a regression moving to data.xml
15:13chousergreat
15:15amalloyyeah, agreed. i wonder how you can do it with tag/attr/content - in theory you could just use a namespaced-keyword for the tag, but if you want namespaces to correspond to xmlns declarations, then...i dunno, metadata somewhere?
15:18chouseryeah, not sure yet.
15:24arohnerhas anyone got postgres working on heroku?
15:28lobotomyhmm, i finished my chess problem solver, and tried to make it multithreaded. run the first round separately, make an agent for each case on the first round, run all the agents recursively from their different starting points
15:28technomancyarohner: abedra wrote an article on it; it's in their official docs
15:28lobotomyis this a good way do to that?
15:28arohnertechnomancy: yeah, I'm having trouble connecting to the DB
15:28arohnerI think I'm doing what the docs say, and it isn't working.
15:28lobotomyif it is, how can i make it actually work? :) my code seems to simply hang after a while
15:31mprenticelobotomy: the chess problem space is huge. that approach will have too many threads.
15:31gtraklobotomy, you do know chess is pretty hard to compute fully, yes?
15:31gtrakmprentice, agents use a thread-pool
15:32lobotomyyeah, but i'm only making one agent per each choice of square on the _first_ round
15:32mprenticegtrak: oh, well, too many agents anyway
15:32gtrakyea
15:32gtraklobotomy, well you make an agent... then you send work to it
15:32lobotomyin my example there's one queen and 2-3 of each other piece (but no pawns); so it's basically 64 agents. each agent puts the queen on a different square and then recurses with the rest
15:33lobotomygtrak, as i said, i did that but then it hangs after 2836 solutions
15:34gtraklobotomy, using send or send-off?
15:34lobotomysend
15:34gtrakhmm, well you can use visualvm to get a stack trace
15:34lobotomythinking maybe i should somehow ensure there's at most say 2-3 agents running at the same time?
15:34gtraklobotomy, I'm not sure 1 agent per square is a good mapping
15:35lobotomyis this doable easily with some core function or something, or should i keep track manually?
15:35lobotomyme neither, but it's the simplest one, so i just tried that :)
15:35hiredmansomething to keep in mind is sends and send-offs inside an agent action don't run until the action is completed
15:36lobotomyguess i should put the squares in a list and feed the first n squares of the list to n agents at a time, or something
15:38lobotomybut why does it hang after a handful of solutions?
15:38robermannhello. which is the default javadoc site for clojure's Java classes?
15:38gtraklobotomy, to characterize the hang, you need a thread dump
15:38lobotomyif there's too many agents, i'd hope it would crash instead, or give some indication of the too-maniness
15:39lobotomygtrak, fair enough. so this suddenly became complicated ;p
15:39lobotomywill check that out later, cheers
15:39gtrakgenerally how concurrency goes
15:42amalloyrobermann: there's not a lot of javadoc for those
15:44amalloyand it's fairly rare that you'd need any. what are you looking for?
15:48robermannjust trying to understand why (def aaa {:a 'a :a 'nnn } ) fail :) - well I know because fails, but I was thinking to check PersistentHashMap's javadoc
15:49hiredmanrobermann: what do you mean fails?
15:49robermann,(def aaa {:a 'a :a 'nnn } )
15:49clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Duplicate key: :a>
15:49robermannthe duplicate key
15:49hiredmanrobermann: and?
15:50hiredmanseems like the reason it failed is pretty obvious
15:51lobotomyi think he's asking where that's documented
15:51robermannyes it is obvious :) but I was checking if the corresponding Javadoc documents it
15:51robermannshould be http://pacific.mpi-cbg.de/javadoc/clojure/lang/PersistentArrayMap.html#createWithCheck%28java.lang.Object[]%29 ?
15:52robermannnow I'm forcing to be in Java-mode
15:53robermannmaybe it is a stupid expectation, but I was thinking that putting a key in a map should override an already existing one
15:54robermannas it is in java maps
15:54cemerickrobermann: They do.
15:54raekassoc does that. you only get the exception for literals
15:54hiredmanrobermann: it will, but for literals it is generally considered a mistake, so it throws an error
15:54cemerick,(assoc {:a 5} :a 6)
15:54clojurebot{:a 6}
15:56robermanncool! yes it is generally a mistake, and I was just trying it. So is this check executed only on literals?
15:56cemerickexactly
15:56cemericksame with sets
15:56cemerick,#{5 5}
15:56clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Duplicate key: 5>
15:57robermannyes, sets are quite obviuos for me
15:57cemerickwell, a map's keys are a set, so the same semantics should apply :-)
15:58robermannyes but in Java you override a key value, you don't get blocked in the insertion
15:59cemerickrobermann: The same thing happens with assoc (see above). Java doesn't have map or set literals, so it doesn't need to contend with what to do in that circumstance.
16:01TimMc,#{5 (+ 1 4)}
16:01clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: 5>
16:02robermannyes. I was inquiring if this check of not duplicity ( https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentArrayMap.java#L67 ) is documented in javadoc
16:02TimMcset literals, not literals of sets
16:02TimMcs/of/in/
16:02lazybot<TimMc> set literals, not literals in sets
16:02cemerickRight, it's all values by the time the corresponding data structure is being built
16:04cemerickrobermann: Probably not.
16:04TimMccemerick: So, safer to do ##(set [5 (+ 1 4)])
16:04lazybot⇒ #{5}
16:04cemericksafer?
16:05cemerickoh, I see what you mean
16:05TimMcYeah, if you are using a set literal that is not made of literal values.
16:05robermannok thanks
16:06TimMcSounds like that could really bite someone.
16:06cemerickSeems like a strange thing to worry about. If you end up getting an error you don't expect, then you probably aren't clear on what the offending expression is doing.
16:06TimMcWell, it isn't my place to surmise what use someone might have for sets.
16:07cemerickJust working around it by using `set` seems counterproductive. That's why the literals have that guard to begin with.
16:07TimMcThat guard is intentional?
16:08cemerickPreventing the duplicate values in literal sets or keys of literal maps? Yes, certainly.
16:08TimMcOh, I see -- it is in Clojure.
16:08robermanncemerick: when I have an error in Java, the first thing I do is to check its javadoc
16:08TimMcI think it makes perfect sense in ,aps.
16:08TimMc*maps
16:09cemerickrobermann: Are you using the Clojure data structures from Java?
16:09TimMc,(doc #{}) :-P
16:09clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Symbol>
16:10TimMcWhere is the canonical definition for behavior of literals?
16:11cemerickOfficial documentation, anyway: http://clojure.org/reader
16:11amalloy&(doc read-string)
16:11lazybot⇒ "([s]); Reads one object from the string s"
16:11cemerickamalloy: smartass :-P
16:11robermanncemerick: no, I'm studying clojure, and knowing that its core is written in Java I was checking its javadoc
16:11TimMcheh
16:11cemerickrobermann: ah; you'll find it to be very thin indeed :-)
16:11amalloycemerick: a real smartass would have used $source read-string
16:11amalloybut this way i get to make the point that it's not really documented, so maybe you're right
16:12TimMcamalloy: You're just a fake smartass?
16:12cemerickThere's a lot in the reader that isn't formally documented.
16:13cemerickTimMc: As am I, on both counts.
16:13TimMcI'm choosing to blame the weather for the latter.
16:14robermannmaybe you could write an "internals clojure" book ! I should be one of your readers :D
16:15jkkrameri've been bitten by this: ##(apply hash-map [:foo "bar" :foo "baz"])
16:15lazybotjava.lang.IllegalArgumentException: Duplicate key: :foo
16:15cemerickrobermann: We cover some of the undocumented bits in the book. Hardly "internals", but certainly some of the niceties (2r11, etc)
16:15jkkrameryou can partition it up into vector pairs, but that's more typing
16:16robermannwhich book?
16:17cemerickrobermann: http://oreilly.com/catalog/0636920013754/
16:17TimMcI suppose the workaround there is ##(into (hash-map) [[:foo "bar"] [:foo "baz"]])
16:17lazybot⇒ {:foo "baz"}
16:17chouser2r11 is documented
16:18robermanncool I bookmarked it!
16:18TimMc,2r11e10
16:18clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: For input string: "11e10">
16:18cemerickchouser: look at that, it is! I don't think it was when I wrote that part in the book.
16:18chouserheh
16:18TimMcHrmph, I can never keep number literal formats straight.
16:19chouser2r11 is also detailed on page 22 of http://joyofclojure.com/ :-)
16:20cemerickTimMc: That'd be a long binary string, but in any case, you can't use an explicit radix for decimals.
16:21TimMc,2r11
16:21clojurebot3
16:21TimMc,2r1.1
16:21clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 2r1.1>
16:22TimMcI see. And e notation turns it into a float?
16:23TimMcWait, no -- I *was* imagining 1e9 notation in Clojure.
16:27robermannah they are binary literals
16:28cemerick,36r9
16:28clojurebot9
16:28TimMcn-ary literals
16:28cemerickwhoops
16:28cemerick,36r9z
16:28clojurebot359
16:28kwertiianyone have any experiences (good or bad) using CouchDB or Mongo as the backend persistent data store to a Clojure app?
16:29cemerickBoth are commonly used.
16:30kwertiicemerick: but are they good or bad? common doesn't mean good..
16:31robermannchouser: by the way I discovered the "key duplicated error" when trying your "(str (build-move :from "e2" :to "e4"))" example (pag 205)
16:31cemerickkwertii: I mean, both data stores are used commonly with good results. Whether you prefer one or the other isn't related to Clojure; there are quality client libs for both.
16:31kwertiicemerick: ok, cool, thanks
16:31cemerickI prefer couch, but for reasons entirely unrelated to Clojure.
16:31ibdknoxredis!
16:32robermannchouser: I tryied a (build-move :from "e2" :from "fake" :to "e4") move to see if what would happen
16:32cemerickEr, perhaps not entirely true -- I think there are a number of relevant parallels between the broad philosophies behind couch and Clojure.
16:33kwertiicemerick: the Mongo project's "couch vs mongo" page essentially says directly that the only reason to pick Mongo is if you need ultra-high performance at the expense of robustness
16:33cemerickkwertii: link?
16:34kwertiicemerick: http://www.mongodb.org/display/DOCS/Comparing+Mongo+DB+and+Couch+DB (ok, not directly, but that's what I got out of it at a glance)
16:35kwertii"if we had very high performance requirements we would use Mongo... for a problem with very high update rates, we would use Mongo... in contrast to the above, couch is better when lots of snapshotting is a requirement"
16:35chouserrobermann: interesting.
16:35cemerickkwertii: That interpretation is probably not generous enough, but I won't argue with it.
16:35kwertii"Philosophically, Mongo is very oriented toward performance, at the expense of features that would impede performance. "
16:36chouserand it's written in C++, so you know it's balzing fast.
16:36kwertii"Problems requiring high update rates of objects are a great fit"
16:36chouserI meant blazing, but either will do.
16:36scgilardione of those provocative faux typos...
16:37chouserwe use mongo at work and are happy with it, afaik.
16:37cemerickCouch is moving towards an easily partitionable backend as well. BigCouch does that already today.
16:38kwertiicemerick: it seems (at a glance, haven't looked into it in depth) that if your application doesn't absolutely require the latest realtime data at every instant, you can use Couch replication to scale
16:39cemerickkwertii: True enough, and that's what bigcouch does. Rolling your own partitioning scheme is not fun, tho.
16:40kwertiimy other question for those of you who are doing this.. it occurred to me that I can set a watch on a ref to a map or a record, update the map anywhere as a normal Clojure map, and rely on that watch to propagate the changes to the DB. is this reasonable?
16:40TimMcchouser: C++ isn't a cure-all for performance, of course. I remember the professor posting performance results by language for a semester project, and C++ came in dead last, with Python and Java in the lead. :-)
16:41chouserTimMc: I'm totally trolling. Feel free to read as much sarcasm into my statement as you'd like.
16:41chouserC++ apps are fast, except when they're not.
16:41technomancywhat are you talking about; c++ is totally balzing fast
16:41TimMcchouser: Wasn't entirely sure.
16:41cemerickkwertii: very, yes. Functioning as a write-behind log, in that case.
16:42arohnerkwertii: as long as you're ok with losing data sometimes
16:42TimMcchouser: It does tend to have a fast startup time. :-P
16:42arohnerlike on shutdown or quick power-off
16:42chouserTimMc: indeed
16:43kwertiicemerick: how do you handle the reverse case, changes in the DB that need to be propagated to the application? I haven't looked into Couch enough to know whether it has the concept of triggers. I imagine you could fire off a notice to your Clojure app saying "update record x" if it does, or periodically expire data structures somehow if it doesn't
16:43TimMcThat's an interesting use-case for metadata.
16:43technomancycemerick: best freudian slip I've seen in a while
16:44cemerickkwertii: look in the couch wiki for info on the _changes feed
16:44TimMctechnomancy: While reading out loud the other day I accidentally said "penetrate the thong" (throng)
16:45TimMcThat was the best I've done in a while.
16:45kwertiiarohner: yeah, that's not ideal, of course, but making it more robust is a diminishing-returns problem.. you could never re-use the map and reload it from the DB every time, I suppose, at a huge performance hit that's probably not worth it unless you're trading stocks in realtime or something like that, in which case you'd have practically unlimited resources for hardware anyway
16:45technomancythis is even better since it's an example of the speed/consistency trade-off
16:45kwertiicemerick: so it can do that.. cool, thanks
16:46cemerickkwertii: yeah, you can abuse couch as a message queue pretty easily
16:47kwertiicemerick: ideally I'd like an AllegroCache like solution where the db is fused transparently to the data structures
16:48cemerickkwertii: Of course, people have spent lifetimes pursuing that.
16:48kwertiiheh
16:48kwertiiand for only the price of a new sports car plus a warrant for your firstborn child, Franz will sell it to you (in CL only)
16:49cemerickPlus a new sports car each year, of course.
16:50robermannbye
16:52hiredmankwertii: those kind of solutions tend to be in the cache space, not the db space, inifinispan provides a more or less transparent shared concurrent hashmap
17:05acagle``/
17:16jweissis there a way to read from an input stream and write to a file without using the verbose java way with the byte array or similar?
17:17amalloyjweiss: clojure.java.io/copy
17:18jweissamalloy: aha, thanks
17:26hiredman~clojure
17:26clojurebotclojure is the bestest programming language available.
17:26hiredman~clojure
17:26clojurebotclojure is cheating
17:26hiredman~botsnack
17:26clojurebotThanks, but I prefer chocolate
17:26hugoddo dynamic vars inherit thread specific bindings in 1.3?
17:29hiredmanhugod: only via send, send-off, and possible future and pmap
17:30hiredmanonly if you create or send work to the thread via some clojure mechanism
17:30hiredmanhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L1885
17:31michaelr525anyone knows whether amazon is charging for the requests when uploading files to s3 from ec2 in the same region? I know they don't charge for data transfer..
17:31hugodhiredman: thanks
17:40hugodwriting library code that works on 1.2 and 1.3 is "interesting"
17:51cemerickmichaelr525: all transfer in is free
17:52michaelr525hmm
17:52michaelr525I'm asking about ec2->s3
17:53michaelr525Not home->s3
17:55michaelr525that's what written on their site: "There is no Data Transfer charge for data transferred between Amazon EC2 and Amazon S3 within the same Region"
17:55michaelr525But nothing like this is written regarding requests
17:55cemerickmichaelr525: Scroll down to "data transfer pricing" http://aws.amazon.com/s3/pricing/
17:56cemerickoh, per *request* pricing you mean
17:56michaelr525yep
17:56cemerickThe per-request pricing applies no matter where you're operating from AFAIK.
17:57michaelr525that's what I thought, just wanted to make sure.
17:57sridwhat is the buzz-word replacement for saying "clojure". eg: instead of I saying "here is a clojure-based sample app demonstrating our enterprise feature XYZ" I want to say it without frightening folks using the word "clojure". perhaps, i could include the word JVM or even Java as these are enterprise-friendly.
17:58amalloys/clojure-based/<intentionally left blank>
17:58amalloyseems like if you don't want to mention clojure there's not much need to put any words in that space at all
17:58ziltiMaybe "JVM-based functional sample app"?
17:58sridone alternative, yes. but I want to capitalize on this somehow :-)
17:59amalloy"sample app we wrote in five minutes instead of five weeks"
17:59hiredmanyou want to capitalize on clojure without saying clojure?
17:59ziltiHaha nice
17:59hiredmansounds dumb
17:59sridzilti: the word 'java' is missing though. (folks may not understand what 'jvm' means)
17:59cemerick"Here's our app. It runs on Java."
17:59amalloyjust tell them about this cool language that's a great replacement for java, Erujolc
18:00sridi have mentioned clojure several times in our meetings, and the response like "meh".
18:00amalloythen, months later, when you unveil clojure, they will be astonished
18:00ziltiAnother reason for maybe not studying computer sciences: You'll have to convince some dumb businessmen knowing nothing but economy theories.
18:00ziltis/convince/convince all your life
18:00lazybot<zilti> Another reason for maybe not studying computer sciences: You'll have to convince all your life some dumb businessmen knowing nothing but economy theories.
18:01ziltiNice bot
18:01coopernursesrid: so is the real issue that you need a way to sell the use of clojure to your org? or something else?
18:03sridcoopernurse: i am using clojure (in a sample app) to demonstrate a feature X. when I message it, people respond positively to "X" but respond with a "meh" to clojure part. just wondering if I can change that somehow. i'd probably go with "java/jvm based sample app"
18:03sridclojure is not used for anything else, btw. it is just a silly infatuation of mine.
18:14coopernursesrid: gotcha. if it's not critical that they buy off on clojure, then I agree with "jvm based sample app" is good.
18:14kwertiiI'd say "Java virtual machine based," since they probably won't know what a JVM is, but they've very likely been exposed to a decade and a half of marketing for Java
18:15coopernurseif you want to convert "meh" to "wow!" then I guess you'd have to show them benefits that they care about (not sure if the meh folks are dev or biz)
18:16kwertiior, as suggested, leave out that detail altogether -- if there's not some specific reason why they would care about what language it's in (e.g. they're a huge, deeply invested Microsoft partner), they probably won't care
18:16coopernurseright, if it's all sufficiently irrelevant, then I suppose you can just say "look at my demo of feature X"
18:51ShreeMulayhey everyone. I've got a question regarding the usage of "include-css" from hiccup.page-helpers in my web development project. Where do I actually place that folder in context of my leiningen prroject?
18:53ibdknoxShreeMulay: depends on how you set up your resources route
18:54ibdknoxShreeMulay: if you're using noir, anywhere inside of resources/public/ would work, though it's usually best practice to do something like resources/public/css/
20:28aaelonyI have a future named m1. If I do @m1, I see the future and the data I want to extract. How can I extract the data though? e.g. (#<core$future_call$reify__5382@71d382ab: ["2110401" "426"]> #<core$future_call$reify__5382@7527e2ee: ["2110402" "425"]>)
20:28aaelonyI'd like to extract the vectors inside the future
20:29aaelonyany help appreciated
20:29hiredmanyou have a future inside some other derefable thing
20:30aaelonynot sure what you mean.
20:30hiredman,(let [x (future (future 1))] (Thread/sleep 5000) @x)
20:30clojurebot#<core$future_call$reify__5733@54a99b: 1>
20:31hiredman,(let [x (atom (future 1))] (Thread/sleep 5000) @x)
20:31clojurebot#<core$future_call$reify__5733@10a35db: 1>
20:31aaelonyI did this to create it:
20:31hiredmanyou are nesting things and not derefing enough to denest
20:31aaelony(def m1 (future (get-metric-timeseries "Users" [testfile testfile2])))
20:31hiredmanwhat does get-metric-timeseries with out the future result in?
20:31aaelonythis will go get metric "Users" in all the test files
20:32aaelonywhich I want to happen asynchronously since I have many metrics.
20:32hiredmanI don't care what it is, what is the result type?
20:32aaelony(class m1)
20:32aaelonyclojure.core$future_call$reify__5382
20:32hiredmanno
20:32clojurebotExcuse me?
20:33aaelonynot sure what you mean.
20:33hiredman(type (get-metric-timeseries "Users" [testfile testfile2]))
20:33hiredmanaaelony: I am not sure if you can be helped then
20:33aaelonyclojure.lang.LazySeq
20:34hiredman(map type (get-metric-timeseries "Users" [testfile testfile2]))
20:34hiredmanyou are creating a future with contains a lazy sequence of futures
20:34aaelony(clojure.core$future_call$reify__5382 clojure.core$future_call$reify__5382)
20:35hiredmaneach level of future will need to be deref'ed
20:36aaelonyI see.
20:37aaelonySuppose I want to look inside N files for a particular key as a future, and I want the future to return a sequence of all the values it found for that key.
20:37aaelonyI will want one future for each key.
20:40aaelonyThe irony is that the future I have contains exactly what I am looking for, it's just buried in there.
20:41aaelonythx anyways, I'll tinker away
20:47humourousis (apply conj [1 2] [3 4]) better than (vec (concat [1 2] [3 4])) to get a vector form concatenation? (or something else?)
20:48brehaut,(into [1 2] [3 4])
20:48clojurebot[1 2 3 4]
20:51humourousthank you
21:17devn,(map #(apply str (repeat % "q")) (range 0 10))
21:17clojurebot("" "q" "qq" "qqq" "qqqq" ...)
21:17devnbetter way to write that?
21:19devn,(set *print-length* 20)
21:19clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$set>
21:19hiredman,(iterate str "q")
21:19clojurebot("q" "q" "q" "q" "q" ...)
21:19hiredmanhmmm
21:19hiredman,(iterate (partial str "q"))
21:19clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$iterate>
21:19hiredman,(iterate (partial str "q") "")
21:19clojurebot("" "q" "qq" "qqq" "qqqq" ...)
21:19brehaut,(let [qs (apply str (repeat 10 "q"))] (map #(.substring qs 0 %) (range 10)))
21:19clojurebot("" "q" "qq" "qqq" "qqqq" ...)
21:19devn,(set! *print-length* 20)
21:19clojurebot20
21:20brehaut(for a different value of better)
21:20devnbrehaut: a bit too declarative, no?
21:20hiredman,(iterate (partial str "q") "")
21:20clojurebot("" "q" "qq" "qqq" "qqqq" ...)
21:20devnah-ha!
21:20devnbeautiful
21:20devnthanks hiredman
21:20bhenry1nice
21:20brehautdevn: hiredmans is better, but i think the substring is more space efficient for large ns
21:20devnbrehaut: i should really only be going to about 6 in general
21:20devnso tiny is preferred
21:21devnit's for JFugue -- (q)uarter note
21:22devnhiredman: i've actually never seen partial and iterate used like that -- really cool
21:22Tcepsa,(map #(
21:22clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
21:23devnthere must be at least 50 ways to write it...
21:23devnat least...
21:24Tcepsa,(map #(apply str (take % (repeat "q"))) (range 0 10))
21:24clojurebot("" "q" "qq" "qqq" "qqqq" ...)
21:24Tcepsafor yet another ;-)
21:24gfrlogdevn: http://twitter.com/#!/DEVOPS_BORAT/status/109622560559333376
21:24devn?
21:24devnbahaha
21:25devn"I work on new language call Quattro. If want to do any thing, is exactly 4 way of do it."
21:25gfrlog:)
21:25devngfrlog: <3
21:26devnobvious now given hiredman's solution, just another way of writing it:
21:26devn,(iterate #(str "q" %) "")
21:26clojurebot("" "q" "qq" "qqq" "qqqq" ...)
21:26devnperhaps a bit much in the syntax department, though -- doesn't really give you anything...
21:26Tcepsa(though looking more closely, I'm pretty sure mine is just a more verbose version of the original ~wry grin~)
21:27devn:)
21:27devnI have no doubt -- but there seems to be a limit to amount of shaving before all you're left with is a brittle twig
21:27brehautor at least a very cold yak
21:27devnexpressive but small -- hiredman's seems quite good in that department
21:28devnhaha
21:28devndinner time! then back to annoying my girlfriend with algorithmically generated muzak! :)
21:28devnbbiab
21:29Tcepsadevn: Is the code available anywhere? That sounds like something I would enjoy looking at.
21:29devnTcepsa: it's really nothing special but yes I'll put it up this evening
21:30devnIt's just doing some really rudimentary part-writing techniques
21:30Tcepsadevn: Thanks! I've tinkered with JFugue a little but never really got anywhere...
21:30devnto generate a simple progression and then play some passing tones with it in a sort of constrained "must-be-a-kind-of-melody" way
21:30TcepsaNeat
21:31devnTcepsa: I keep getting stuck at building small first and then trying to build a nice abstraction
21:31devnthey all end up feeling too constrained or too random to be expressive
21:32devnlike (generate-layer (with-instrument :kalimba (generate-notes 16)))
21:32Tcepsa"Oh hey, if I make this a protocol then I could...!"
21:32devnor somesuch kind of thing
21:32devnI don't have a nice sequencer-level abstraction which I think is the key
21:32devnneed a nice way to sequence parts...
21:32Tcepsa:key :F#
21:33TcepsaAhhh, yeah, that makes sense
21:33devnon the nth note of layer 1, play from the 3rd to the 7th note of layer 2's first part
21:33devnand repeat it 10 times
21:33devnthat ends up very verbose and not magical enough
21:33TcepsaHmmm...
21:33devnbut i suppose this is why composition is hard :)
21:34devnthe other thing i really desire is a way to "capture" a sequence in order to train
21:34devnsupervised learning with midi sequences
21:35devnanyway, gotta run, Tcepsa drop me a private message and ill ping you a link to the github or at the very least a gist of some ideas
21:35TcepsaOh I definitely want to chat more with you later; that is something else I have been noodling on
21:35devnTcepsa: :) we should pair! i'll bother you later. ciao
21:36TcepsaBye!
21:52jhicknerHello good sirs. In ClojureScript, is there a way to console.log a clojure datatype in such a way that you can see the contents, like at the repl? A standard console.log of a vector displays as 'cljs.core.Vector' or similar.
21:55alandipertjhickner: (js/console.log (.strobj my-obj))
21:55alandipertjhickner: it's a nasty impl. dependent way, and i've only used it with maps... but it might work
21:55jhicknerok thanks I'll give it a try
21:58alandipertor rather, (.log js/console (.strobj my-obj))
21:59jhicknerit looks like it works for maps only. vectors and lists are translated to undefined in js
21:59jhicknerlooks like it's time for a pretty-print util function
22:01alandipertah, there's (.array my-vec)
22:02alandipertsee also http://groups.google.com/group/clojure/browse_thread/thread/eba1454e1984bee0 and https://gist.github.com/1141054 and http://dev.clojure.org/jira/browse/CLJS-37 (whew)
22:05alandipertjhickner: any luck?
22:06jhickner.strobj works for maps, and it looks like .array works for vectors
22:08jhicknernice, Kevin's functions at the end of that discussion look like a good start
22:08jhicknerthanks @alandipert!
22:09alandipertnp
22:12solussdwhat common interface do vector and list share? How can I tell if something is a indexed sorted thing?
22:12gfrlogsequential?
22:12gfrlog,(map sequential? [[] #{} {} '() ""])
22:12clojurebot(true false false true false)
22:13solussdthat'll do nicely
22:19donpdonpi have a software package with a project.clj - how do i compile/build the project?
22:20coopernursedonpdonp: do you have lein installed? then you can do: lein run or lein jar
22:20alandipertdonpdonp: https://github.com/technomancy/leiningen
22:20donpdonpcoopernurse, alandipert: got it, thx!!
22:42solussdhmm, can't apply a Record. (apply MyRecord. [args])
22:44brehautsolussd: classes arent functions / ifns
22:44amalloymore specifically, neither are constructors
22:44solussdyeah… (apply make-myRecord [args]). :D
22:48TimMc,(sequential? nil)
22:48clojurebotfalse
22:48TimMc,(sequential? (seq [1]))
22:48clojurebottrue
22:50solussdrecords just don't feel right… they feel OOPy
22:50amalloyyesss if you don't have a clear reason don't use them
22:51solussdthey exist pretty much soley to implement protocols, right?
22:51brehautthey are also faster than maps if you have a constant set of keys
22:52amalloyyes, what brehaut said. a constant and *known-at-compile-time* set of keys
22:52solussdI have a couple protocols that I need to implement for data stored in maps, but not for all maps, so now I have records
22:52solussdyeah, these are maps with certain keys
22:52solussdthey'd be structs if I were still allowed to use them. :D
22:52solussdI like protocols though. I like how they're inside out from protocols in other languages
22:52amalloysolussd: but if (apply MyRecord. args) worked, it wouldn't be performant, which is one reason it doesn't exist
22:53sridjkkramer: so any idea on the null pointer exception when running preprocess.clj? the stacktrace doesn't tell me the .clj/line information.
22:53brehautsolussd: an important distinction between records and OO is that a) they never implement data hiding, inheritance, recieve message and are not namespaces for methods
22:53solussdyep. That's what I like. I like how clojure encourages implementation to live in functions not class hierarchies
22:54solussdand if I want to share implementation I can do it w/ protocols + extend
22:54amalloyusually when people want to do crazy stuff like (apply MyRecord. args) or (into (MyRecord. nil nil nil) m), they're just using records for fun and to make their lives harder
22:55solussdamalloy: I didn't really want to do it, just noticed it didn't work.
22:55jkkramersrid: well, there's no -main fn in that ns. for now i interactively eval the parts in the commented-out area to refresh the project graph
22:56TcepsaRecords: kinda-sorta analogous to "pure" JavaBeans?
22:56solussdrecord fields are immutable, right? I guess I haven't tried to set! one yet
22:57solussdI like to think of them as maps I can have implement protocols, and nothing more.
22:57sridjkkramer: got it; running fetch-all-repos now
22:57sridah, it dumped json to stdout
22:58amalloysolussd: they are immutable, yeah. if you use deftype instead you can ask for mutable fields if you want
22:58solussdi don't. :)
22:58jkkramersrid: see the commented parts at the end. each def/defn in that area is a cumulative step
23:00jkkramerthat may not work out well :)
23:00sridjkkramer: isn't the idea to execute all of the sexps in the (comment block?
23:01jkkramersrid: yes, but there's one broken project entry that i edit out by hand; that's mentioned by not included
23:02sridclojure-slick-rogue
23:02jkkramerright
23:02sridperhaps I should filter it out from - what - `github-projects` list?
23:02jkkramerthat works
23:03sridbtw, how long is this supposed to take? 15 mins, right?
23:03jkkramerthe problem is really with my limited project parser
23:03jkkramerfetching the repos is quick. fetching the project.clj/pom.xml files form github takes a while...didn't time it
23:04jkkramer15-30 mins i think
23:04srid'fetching the repos' == cloning the git repo?
23:04sridok, just project names.
23:05srid"/Users/tin/src/clj/clojuresphere/clojars/" <-- hmm. i need to rsync clojars first, it seems
23:05jkkramerit does actually pull down the latest github push date, so future updates could take that into account
23:05jkkrameryes
23:07sridjkkramer: are the .jar files really required? (else, i can skip them for faster rsync?)
23:08jkkramersrid: they are not. my rsync-fu is weak so i just grabbed everything
23:10srid "- *.jar" ... runs much faster now.
23:11sridclojars has static metadata, what a relief -- in pypi (python) one has to use xmlrpc
23:11brehautxmlrpc is the pits
23:11amalloybrehaut: i hear it's a necessary evil
23:12brehautsadly
23:12amalloy~rimshot
23:12clojurebotPardon?
23:12amalloysigh
23:12brehautno snack for the bot today
23:14amalloyclojurebot: rimshot is <reply> Badum, *ching*
23:14clojurebotAck. Ack.
23:16brehautid be curious how much evil has been propogated due to python having xmlrpc support in the stdlib
23:20sridpython had worse problems. one has to run a script to get metadata such as project dependencies (that's what I do for pypm). this is being addressed recently. http://tarekziade.wordpress.com/2009/09/12/static-metadata-for-distutils/
23:21solussdhow do you check if a instance of a record is of a given record type?
23:22brehaut,(instance? String "abc")
23:22clojurebottrue
23:23solussdthx, kept trying to use isa?
23:23solussdkeep forgetting, record == class
23:30sridheh. writing back to clojure source (project_graph.clj.gz) instead of using a database.
23:32brehautsrid are you importing the resulting file or just reading it?
23:34sridnot me, jkkramer's project (clojuresphere) .. and it seems to (read ...) it
23:34sridi wonder why i'm running preprocess.clj at all, when it is already in git.
23:34jhicknerok, so after some screwing around, this seems to work pretty well for converting clj nested datastructures to js: https://gist.github.com/1199700
23:36jhicknerat least for maps and sequentials. it doesn't handle sets yet
23:36brehautjhickner: any reason you wouldnt just use a json lib?
23:37jhicknerthis would be for passing structures to js functions
23:37jhicknerfunctions that take object or array args, for instance
23:38jkkramersrid: cool. sorry for the goose chase, i thought maybe you wanted cutting-edge project data or something
23:38sridi only had to define default PORT.
23:39sridi wonder why you are not using 'lein ring server'? it auto restarts the server on file changes.
23:39jkkrameri use swank, which can pick up changes after just evaling forms
23:39amalloyjhickner: this is not a unique thing to want to do. someone has surely already written this library; i think that's brehaut's point
23:40jhicknerI agree, I've been looking.
23:40brehautamalloy: once again making sense of my gibberish
23:40brehautclojure.contrib.json and clj-json are the two main candidates i recall
23:40amalloybrehaut: this seems to be a cljs context
23:41amalloyand i don't think those really work for cljs
23:41sridjkkramer: is the plan to eventually integrate it to clojars?
23:41brehautoh right
23:44user317_is there a way to add a local .jar file as a project dependency
23:45jkkramersrid: i'd like to yeah
23:47amalloyuser317_: the mechanism starts with (1) Realize "oh wait, I didn't really want to do that"
23:47user317_well, i depend on this jar file thats released by interactive brokers
23:47user317_not sure how to get around it, i cant really add it to a public repository
23:48technomancyuser317_: if you are a solo developer you can get away with mvn install:install-file, if you are on a team then you need to set up an archiva or nexus server
23:48user317_technomancy: i am han solo :)
23:49user317_technomancy: i take mvn is a maven thing?
23:49technomancyuser317_: just add it to project.clj and run lein deps; it'll spit out an error message containing the mvn invocation that will put it in your local repo
23:52user317_technomancy: i am a little slow :) do i add "mvn install:jtsclient.jar" to the :dependencies vector in project.clj?
23:52technomancyuser317_: no, just add it as if it were yet another jar on clojars
23:53technomancy[mygroup/myid "1.0.0"]