#clojure logs

2010-03-09

00:00technomancyI think the string interpolation macro was <<
00:00technomancyand there was talk of putting into contrib, but I don't know if it made it
00:00hugodthanks for the pointers, I'm looking for something to write system config files...
00:00technomancyhttp://muckandbrass.com/web/display/~cemerick/2009/12/04/String+Interpolation+in+Clojure
00:01slyphontechnomancy: is there a "beginner's guide"?
00:01technomancypersonally I'm biased against fleet since it was released like a couple weeks after fleetdb, which is entirely unrelated
00:01technomancybut that's just me
00:02technomancyslyphon: no, poor docs are definitely the #1 drawback for enlive
00:02slyphontechnomancy: oh, i meant for lein
00:02technomancyslyphon: oh, sure
00:02technomancythere's a screencast on vimeo
00:02slyphoni've never worked w/ java really professionally, so the whole "build thing" is a bit of a mystery
00:02slyphonoh, ok
00:02technomancyclojurebot: the leiningen screencast is on full disclojure: http://vimeo.com/8934942
00:02clojurebotIn Ordnung
00:03technomancyslyphon: it's pretty straightforward, I think
00:04slyphonit's odd, i can't *stand* ruby screencasts, but the clojure ones i don't mind nearly as much
00:06mikemrads: yep, that did the trick :) thanks!
00:10technomancyslyphon: if you think the leiningen readme could be improved I'd be up for suggestions there
00:11slyphonok
00:11technomancyit depends on what you're trying to do, but basic dependencies and creating a jar should be pretty clear from those instructions
00:11slyphonone thing off the bat, it was a little confusing that the 'lein' script you download is the one you use
00:11slyphonit's not an "install script"
00:11technomancyoh, is the wording confusing for that?
00:11slyphoni was a little confused
00:11slyphoni thought i was downloading an install script
00:11slyphoni mean
00:12slyphonkudos!
00:12slyphonthat's really genius
00:12slyphonbut it's unique :)
00:12technomancyheh; yeah, having to download a separate script to install seems lame. =)
00:12slyphon:)
00:14hiredmangah, clojure-opennlp seems to not depend on the actual java nlp jar
00:15hiredmanand I can't find a maven repo with it
00:15hiredmanhorrible
00:19slyphontechnomancy: in that screencast the name of the project is org.clojars.sean_devlin/too-hot, what's with the "/too-hot"?
00:20slyphondoes it relate to the namespace of the project?
00:20slyphonor rather, does it have to?
00:20hiredmanit's just the project name with a namespace
00:20slyphonah, mmkay
00:21technomancyslyphon: org.clojars.sean-devlin is the "groupId"
00:21technomancyone bit of maven terminology that snuck in
00:21technomancybut yeah, it functions like a namespace
00:21technomancyso multiple people can publish their own copies of too-hot
00:21slyphonahh
00:21slyphonok, makes sense
00:21technomancylike how github gems used to be prefixed by usernames
00:21technomancybut actually as a first-class concept
00:21slyphonright on
00:21technomancythat should be explained better in the readme
00:25hiredmantechnomancy: does lein put all the jars in lib/ on the classpath or just the ones that map to dependencies from the project.clj?
00:26slyphonwhere do you look for maven deps?
00:28hiredmanwhat do you mean look?
00:28slyphonwell, you specify dependencies, how/where does maven then go and get those?
00:29hiredmanso lein is not maven, it just uses some of mavens stuff
00:30slyphonuh, ok, more direct qustion then
00:30hiredmanlein (and maven?) make a cached local repo of jars in ~/.m2/
00:30slyphonah
00:30hiredmanwhich is the first place it looks
00:30slyphoni'm using log4j, what do i do so that i don't have to have that checked into my git repo?
00:30hiredmanthen it goes to a online looking
00:31technomancyslyphon: there are centralized maven repos it checks
00:31slyphonmm'kay
00:31technomancyhttp://jarvana.com is a nice search for that
00:31technomancybut it also checks clojars.org and build.clojure.org
00:31slyphonheh, clever
00:31slyphonok
00:32hiredman[log4j "1.1.3"] or something like it
00:32slyphonswank-clojure is available somewhere i take it?
00:35_atohttp://clojars.org/swank-clojure
00:35tomojit would be cool to have leiningen able to register some repositories to search
00:36tomojthen index those locally and provide a lein task for searching
00:38slyphoncan you specify alternate repos?
00:38hiredmanyes
00:38slyphoni have a dependency on jboss' hornetq for a project i'm working on
00:38slyphoni'm sorry that these are all probably really stupid basic questions
00:38hiredmanI'd imagine that would be in maven central
00:38slyphonmm'kay
00:38hiredmanwhich lein checks already
00:39hiredmanrhickey was asking about hornetq many moons ago
00:39slyphonit's good, not quite as fully-cooked as ActiveMQ but *way* less buggy
00:40_atohmmm doesn't show up in jarvana search, but yeah you can add another repository, it's somehint like :repositories [[repo-name http://repo.url/goes/here]]]
00:41slyphonhrm, jarvana and mvnrepository.com both come up blank for org.hornetq
00:41slyphonah
00:41hiredmanit's a map
00:41slyphoncool
00:41slyphonit's a trap!
00:41hiredman{"repo" "url"}
00:42hiredmangah
00:44_atobtw, if anyone ever wants a local copy of the clojars repo, I enabled an rsync daemon the other day: rsync -av clojars.org::clojars clojars-repo
00:47tomojawesome
00:48slyphonwow, holy crap
00:49slyphontechnomancy: you're a genius
00:49hiredmanwhoops
00:49hiredmanhmmm
01:01dakronehiredman: ping?
01:01hiredmandakrone: hello
01:02dakronehiredman: saw your issue, the opennlp stuff doesn't exist in any maven library, do you know of the best way to get it available for for clojure jar?
01:03hiredmanif you can make a pom.xml you can push into to clojars
01:04hiredmangrrr
01:04dakroneokay, I have almost 0 maven experience
01:04dakroneis there an easy way to generate a pom.xml, or are they made by hand?
01:05technomancydakrone: in leiningen you can just do lein pom
01:05technomancyand it'll spit it out
01:05dakronetechnomancy: I thought that was *only* for the clojure project, not for an already existing jar
01:05technomancyoh, right yeah
01:05technomancythat just converts an existing project.clj into a pom.xml
01:06hiredmanbleh
01:06dakroneyea, I have 3 dependencies, 2 of which aren't in maven repos
01:06hiredmanjava.lang.NoClassDefFoundError: opennlp/maxent/TObjectIndexHashMap (NO_SOURCE_FILE:0)
01:06dakronethat'd be the other one
01:06dakronemaxent
01:06hiredmanbut the maxent jar on the classpath has that class in it
01:07dakroneweird
01:07dakronedo you have trove.jar on the classpath?
01:07hiredmanno
01:07dakronethat's the 3rd in lib, you should be able to get it from github
01:07dakroneuntil I fix the dependency stuff
01:07dakroneall 3 of the required jars are in the lib folder
01:07hiredmanit comes in the zip for opennlp
01:08dakroneyea
01:08dakronesame with maxent
01:08hiredmanright, that's where I got the maxent jar that it doesn't seem to be able to find the class in
01:09dakroneadding trove.jar should fix it I think
01:09dakronehrmm... how to fix the dependency stuff :-/
01:10dakronetechnomancy: any way to push uberjars to clojars instead of just the library jar?
01:11hiredmanok, trove fixed it
01:11hiredmanwonderful
01:12dakronecool
01:17dakronehiredman: tomorrow I'll work on creating poms for the missing libraries and push them to clojars, thanks for the heads up about missing them
01:17dakroneI thought doing a lein jar would include everything in lib/
01:19hiredmandakrone: excellent
01:26hiredmanclojurebot: how much wood could a woodchuck chuck if a woodchuck could chuck wood?
01:26clojurebotThat is the one thing Clojure can not do.
01:27hiredmanclojurebot: you are very deep
01:27clojurebotGabh mo leithscéal?
01:28hiredmanclojurebot: what do you think of python?
01:29clojurebotpython is ugly
01:29hiredmanclojurebot: what about scheme?
01:29clojurebotGabh mo leithscéal?
01:29hiredmanhmmm
01:30hiredmanclojurebot: and scala?
01:30clojurebotUnfortunately the standard idiom of consuming an infinite/unbounded resource as a stream can be problematic unless you're really careful -- seen in #scala
01:33zmilathe bot is capable to reason, not only calculate? :)
01:33hiredmanclojurebot: what do you think?
01:33clojurebotPardon?
01:33hiredmanclojurebot: can you reason?
01:33clojurebotReason is, and ought only to be the slave of the passions, and can never preted to any other office than to serve and obey them -- Hume
01:40hiredmanhmmm
01:40hiredmannlp thinks rhickey is an adverb
01:54LauJensenMorning team
02:07nteon_good morning
02:11nteon_whats the best way to go about refactoring things in emacs with slime? I've been cutting and pasting code around, but when i recompile a buffer it gives me errors about unqualified symbols already referring to functions in other namespaces
02:15LauJensenIf they're unqualified chances are that your source file is missing an (ns 'something) declaration
02:16slyphonswank-clojure-1.1.0 isn't available through lein?
02:16slyphontechnomancy: ^^?
02:17nteon_slyphon: I had to install lein as noted in the hacking section on github.
02:18tomojI think swank-clojure 1.1.0 is available..
02:19slyphonyeah?
02:19tomojoh, maybe I built it from source and did 'lein install'
02:19slyphontomoj: how do you do that?
02:20slyphoni have :dev-dependencies [[org.clojure/swank-clojure "1.1.0"]]
02:21slyphonoh, duh
02:21tomojwell, swank-clojure's source project.clj is just [swank-clojure "1.1.0"]
02:21tomojso if you 'lein install' it that's what you'll have
02:21slyphonah
02:21slyphoncool
02:21slyphonthanks
02:23slyphon"Compiling swank.swank"
02:23slyphonthat needs another ".swank" i think
03:08defnso erm...am i crazy or wasn't clojure-contrib 1.2.0 supposed to switch duck-streams to .io?
03:08defnclojure.contrib.duck-streams => clojure.contrib.io
03:08defnbecause AFAICT it is still duck-streams
03:15nteon_defn: its io in git: http://github.com/richhickey/clojure-contrib/tree/master/src/main/clojure/clojure/contrib/
03:15tomojlast build was march 4
03:18defnah
03:19defnive asked this in here a few times but i never really get any further:
03:19defnDoes anyone have any ideas on doing SSL based authentication via https
03:19defnI want to scrape some secure https:// urls and I have not been able to figure out a decent way to do it
03:22tomojthat's a good question
03:23tomojmaybe we can just sub in HttpsUrlConnection?
03:23defnI just don't know java well enough to navigate something I'd have trouble with in a language I actually feel comfortable with
03:24neotykHi *
03:24tomojhave you tried one of the available http options already?
03:24defntomoj: such as?
03:24tomojc.c.http.agent, clojure-http-client
03:24defnive tried a few things but I could not figure out how to get it to use SSL
03:25defnyeah i tried messing with those but I couldn't figure it out
03:25tomojyes, neither of those look like they can do ssl
03:25tomojbut, they both use HttpURLConnection
03:25tomojHttpsURLConnection is a subclass
03:25tomojso, I imagine it wouldn't be too hard to patch these libraries
03:25neotyktomoj: I'm currently building async http client
03:25defnone thing someone suggested was apache-http
03:25defnthere was a port of it to clojure
03:25neotykone that is not based on URLConn
03:25tomojneotyk: great, is it on git yet?
03:25defnbut again i couldnt figure it out
03:25neotykwill be tomorrow
03:25tomojI need a good one
03:26neotykand this one does not use thread per request
03:26tomojhow's it work, then?
03:26defnhttp://github.com/rnewman/clj-apache-http
03:26neotyktomoj: I need good one to, and that's why I'm building this one
03:27tomojdefn: that looks cool
03:27tomojhadn't seen it before
03:27defnyeah apache-http is supposed to be the best
03:27neotykdefn: does it support streaming?
03:27defni frankly have no idea
03:28defnim just not familiar with all of the subtleties to know how to use it
03:28tomojit says it can return a stream
03:28tomojor a Reader
03:28neotykI'm building client that will call your provided function on new each new chunk
03:29defnneotyk: that'd be cool for twitter
03:29defnthe firehose and such
03:29neotykso you can talk to ajax push service, like twitter stream api
03:29neotykdefn: exactly :)
03:29defnive been toying with mining the twitter firehose
03:30defnand that is something ive been looking for -- you can also (per technomancy's suggestion), treat it as a lazyseq in combination with agents
03:30tomojdo you think the new geo-enabled stuff will see more users in the future?
03:30wbruceCan someone give me a quick pointer on how to filter a map? Essentially I'd like to get a map that's a subset of another (where all the keys/values pass a given predicate)
03:30neotyktomoj: I hope so :)
03:31hiredman,(into {} (filter (comp even? val) {:a 1 :b 2 :c 3 :d 4}))
03:31clojurebot{:b 2, :d 4}
03:32hiredmanthere is some other function
03:32hiredmanuh
03:32hiredman,(doc select-keys)
03:32clojurebot"([map keyseq]); Returns a map containing only those entries in map whose key is in keys"
03:32wbruceah, ok
03:32wbruceso use into for a custom predicate
03:32wbruceand select-keys for a key match
03:32wbruce(into + filter, obviously)
03:33wbrucethanks!
03:33tomojhaving to build it into a seq and then back into a map seems unfortunate
03:33tomojor is this optimized away somehow?
03:34hiredmaninto uses transients I believe
03:34hiredmanand seqs are not that expensive
03:34tomojok
03:34tomojand it's just a near constant factor more because you have to walk the entire map anyway
03:41gkoHello: do you use keywords only for hashs or do you use them instead of symbols in "data as code" ?
03:41gko"only for hash maps"
03:43nteon_gko: what do you mean by 'in "data as code"'?
03:43hiredman#{:a :b :c} <- enum
03:44hiredmanyou can user keywords for all kinds of things
03:44gkonteon_: example: (def protocol-encoding '( ... (:transaction-id (:integer 8)) ..)
03:44gkonteon_: or :(def protocol-encoding '( ... (transaction-id (integer 8)) ..)
03:45nteon_gko: personally, in that case, I would use keywords. But I've only been using Clojure for a month, so I'm probably not the one to give a definitive answer :)
03:45hiredmanand I'd use a map
03:46gkonteon_: OK. Thanks. I thought keywords are better too, especially as they print better (no NS).
03:47gkohiredman: yes, definitively. just adapting something from CL.
03:48gkoBy the way, how do you flatten a list in a list or vector outside of a macro ?
03:56gko*smpp-fields*
04:01Chousukegko: you can use flatten from contrib
04:01neotykis it possible to: (let [abc {:a (lazy)}])
04:01neotykand have (lazy) part been executed only when needed?
04:01Chousukeneotyk: use a delay
04:01Chousuke(doc delay)
04:01clojurebot"([& body]); Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with force), and will cache the result and return it on all subsequent force calls."
04:02neotyk(doc force)
04:02clojurebot"([x]); If x is a Delay, returns the (possibly cached) value of its expression, else returns x"
04:02neotykChousuke: thank you
04:02Chousukederef (@) also works on delays :)
04:04nteon_hmm. does atom or ref matter for the 'state' of a gen-class class? Since its the only state, there shouldn't be a need to update anything else in a transaction, or am I missing something?
04:04Chousukewell, you might have a thread synchronously updating the states of several objects. :/
04:05Chousukewhich would need a transaction
04:05neotyk,(def m {:a delay (* 2 2)})
04:05clojurebot3
04:05neotyk,(def m {:a delay (* 2 2)})
04:05clojurebot3
04:05neotykhow come?
04:05Chousukehuh
04:05nteon_Chousuke: good point. might as well use a ref
04:06neotykI get Can't take value of a macro: #'clojure.core/delay
04:06Chousukeyou need some parens :P
04:06Chousukethat map literal is illegal as it is, but that return value from clojurebot is weird :D
04:07neotyk,(def m {:a (delay (* 2 2))})
04:07clojurebotDENIED
04:07Chousukedef doesn't work
04:07neotykbut works :)
04:07Chousukeyou need to use let for stuff in clojurebot
04:09gkoChousuke: flatten: Thanks! Could I have found it (find-doc, ...) before requiring clojure.contrib.seq-utils from the REPL ?
04:12Chousukegko: unfortunately, find-doc doesn't work like that :/
04:13gkoChousuke: :)
04:14gkoChousuke: well, I think it's better it doesn't work like that, as find-doc wouldn't reflect what's currently available from the REPL...
04:40neotyk,(let [m {:a (delay (do (println "Doing") (* 2 2)))}] (println "Before") (println @(m :a)) (println "After"))
04:40clojurebotBefore Doing 4 After
04:40neotykbut
04:40neotyk,(let [m {:a (delay (do (println "Doing") (* 2 2)))}] (println "Before") (println (m :a)) (println "After"))
04:40clojurebotBefore Doing #<Delay@f7d41f: 4> After
04:40Chousukeyou need to deref the delay
04:40Chousukeit's not automatic
04:40neotykso I always need to deref
04:41Chousukeyes.
04:42neotykI was looking for a way to avoid execution of values of map until they are needed
04:42neotykclient provides function that takes map
04:43neotykand was hoping to be able not force client to deref map values
04:44hiredmanproxy or reify or something
04:45neotykwhat is reify?
04:45neotykproxy is for java classes/ifaces\
04:45hiredmana better proxy
04:45neotykhiredman: is it in 1.1?
04:46hiredmanreify one of the map interfaces, mayne just ilookup and have it deref before passing out the value
04:46hiredmanhmm
04:46hiredmanI don't recall
04:48neotykfound it
04:48neotykhttp://kotka.de/projects/clojure/lazy-map.html
04:48neotyklaz map
04:48neotykclojurebot: lazy map is http://kotka.de/projects/clojure/lazy-map.html
04:48clojurebotRoger.
05:14nteon_anyone have any idea on this? http://fpaste.org/XyVC/
05:15nteon_nm
05:55licoresse..
06:06rrc7czI'm having a hard time coming up with a lazy seq of past dates. I've tried something like this: (let [cal (Calendar/getInstance)] (map #(do (.add cal (Calendar/DATE) -1) (.getTime cal)) ---)) but it seems like a kludge
06:06nteon_what do I use to push something onto the end of a vector?
06:07rrc7cznteon_: conj
06:07nteon_rrc7cz: ah! thanks
06:07rrc7cz,(conj [1 2] 3)
06:07clojurebot[1 2 3]
06:07caljunioris :gen-class :extends the only way to use a mixin or can I soemhow achieve this with proxy as well?
06:08caljuniorsomehow
06:12caljunioraccording to clojure.org: "Clojure supports the dynamic creation of objects that implement one or more interfaces and/or extend a class with the proxy macro"
06:13caljuniorI have implemented an interface now I would like to extend a class in the same proxy.
06:15nteon_what is the best way to debug nullpointerexceptions in clojure?
06:25caljuniornteon_: I just write and test all functions one by one in the REPL.
06:25sparievcaljunior: afaik you can just add class name to the list of proxy parameters
06:26caljunioras simple as that?
06:26nteon_caljunior: thats smart. I'm not as disciplined with unit tests as I would like to be
06:26hoeckrrc7cz: (->> (iterate #(doto % (.add (Calendar/DATE) -1)) (Calendar/getInstance)) (map #(.getTime %)) (take 3))
06:27hoeckrrc7cz: maybe only slightly less kludgy
06:27sparievcaljunior: see first example (with java.io.StringReader) here - http://dishevelled.net/Tricky-uses-of-Clojure-gen-class-and-AOT-compilation.html
06:31rrc7czhoeck: I like it a lot better, thanks
06:32caljuniorthanks for the link spariev
06:33sparievnp, it helped me a lot last week ) proxy/gen-class stuff is a bit tricky to understand
06:34triyoI have a list of key-val pairs (:id 123 :name "Bob" :age 29). What would be the best way to merge into a map each key-val pair? I have a set-val function that does individual key-val merger into 'nested' map so wish to call this function for each key-val pair.
06:34sparievtriyo: try zipmap
06:35triyospariev: thx I'll have a look. (First I looked at reduce and it doesn't quite fit.)
06:36spariev,(apply hash-map '(:id 123 :name "Bob" :age 29))
06:36clojurebot{:age 29, :name "Bob", :id 123}
06:37bsteuber,(zipmap '(:id :name :age) '(123 "Bob" 29))
06:37clojurebot{:age 29, :name "Bob", :id 123}
06:37bsteuberthese are the two ways to go, I guess
06:38nteon_this is an interesting error: http://fpaste.org/4NMW/
06:39triyospariev: hmm not what I was after. Sorry I don't I think I explained problem well enough.
06:39nteon_does anyone have any pointers?
06:42AWizzArdnteon_: did you put that into a source file? In that case I think Clojure can give you the line number.
06:44sparievtriyo: ok, maybe you after something like (map #(set-val (first %) (last %)) (partition 2 [:id 123 :name "Bob" :age 29])) ?
06:44triyoI wish to call my function (set-val entity-inst key val) with consecutive key-value pairs that come from a list like so '(:id 123 :name "Bob" :age 29 :email "bob@xxxx.com")
06:44nteon_AWizzArd: I did, and it doesn't. step-fn is a function that is loaded at runtime, but I've verified it returns the correct values (a vector of 2 maps)
06:44triyospariev: my result though needs to be the final map with all updated values.
06:45triyoso not to sure map will work
06:45sparievyou could always wrap it with doall
06:45AWizzArdnteon_: If you are sure you located the problem in this function it would be best to step through it, with a debugger.
06:47hoeck,(apply assoc {:a 1} '(:b 2 :c 3))
06:47clojurebot{:c 3, :b 2, :a 1}
06:47hoecktriyo: ^^
06:47hoeckmaybe you're looking for assoc?
06:47nteon_AWizzArd: thanks.
06:49bsteubertriyo: you could also use (into ...) on the stuff above
06:49bsteuber,(into {:a 5 :d 42} (zimap [:a :b :c] [4 5 6]))
06:49clojurebotjava.lang.Exception: Unable to resolve symbol: zimap in this context
06:49bsteuber,(into {:a 5 :d 42} (zipmap [:a :b :c] [4 5 6]))
06:49clojurebot{:a 4, :d 42, :c 6, :b 5}
06:50bsteuberbut yeah, if you already have a list of alternating keys and vals, assoc is your friend for updates
06:51triyohoeck: my assoc / merge part is already in place in the set-val function. What I am looking for is an accumulator that will call set-val for each key-value pair and return the accumulated (updated) map
06:53hoeckokay, my next guess, you are looking for reduce?
06:53triyoso if I call first (set-val myentity :id 123) I get back {:data {:id {:val 123 :assert nil} :name {:val nil :assert}} :type person}
06:55triyohoeck: yes, I tried reduce but I think I didn't feed in what its looking for correct yet.
06:56hoeckcan you paste your code, and some expected input/output to lisppaste?
06:56AWizzArdtriyo: either you have a map or datastructure that already supports key/value pairs, or you have a sequence that doesn't. When you don't want assoc or into, then just loop/recur over it, and use destructuring.
06:56triyo(reduce (fn [key val] (set-val my-entity key val)) keyvals) .. keyvals is an multi-param argument of a function so is a sequence of key-values
06:56triyobut that of course isnt right
06:57hoeckand what is my-entity?
06:57AWizzArdtriyo: reduce will feed your fn element by element
06:57triyoits a data structure that holds the data-map that set-val know how to extract
06:58hoecktriyo: ahh, wait
06:58AWizzArdDestructuring won't help here if your data comes as a sequence.
06:59hoecktriyo: (reduce (fn [entity [key val]] (set-val entity key val)) my-entity (partition 2 keyvals))
07:00hoeckthis way, set-val is called for all key-value pairs on the updated entity consecutively
07:00triyohoeck: ahh, I see this is what I had in mind a sec ago to feed in my-entity as init val
07:00triyoI'll give it a try
07:00hoeckright
07:07nteon_AWizzArd: my problem with that function, was that it was part of a file that was :gen-class, and the return type of the function was boolean, and ref-state was returning the updated state, which couldn't be cast to boolean
07:07nteon_just fyi
07:08nteon_I didn't give nearly enough context for anyone to help me figure that out
07:08nteon_now its time for bed
07:08nteon_night/morning
07:12triyohoeck: thanks. this seems to do the job, just need to test a few more things thow. Got to go. bye.
07:58caljuniorin follow-up to my earlier question on both implementing an interface extending a class using proxy
07:59caljuniorI use an auto-proxy macro to automatically override all interface methods.
08:00caljuniorThis macro trips me up now I want to extend a class.
08:00caljuniorThe macro is here: http://paste.lisp.org/+2270
08:01caljuniorI get ' java.lang.IncompatibleClassChangeError: Implementing class' exception when I simply add the extended class to the auto-proxy arguments.
08:02caljuniorI got the macro from: http://www.brool.com/index.php/snippet-automatic-proxy-creation-in-clojure
08:05caljuniorLooking for a clever way to add a mixin to this macro.
08:12hoeckcaljunior: what do you mean with "mixin"?
08:12hoeckif its a class you want to extend from, then you should put its name at the front of the interfaces argument of that macro
08:14caljuniorbeautiful
08:14caljuniorworks like a charm. thanks. why is that?
08:15chouserproxy allows you to extend one concrete class and implement any number of interfaces
08:17caljuniorright.
08:17hoeckbecause java has only single inheritance for classes, so the class arg comes first
08:18qedmorning folks
08:19caljuniorhoeck: thanks. wrt mixin http://en.wikipedia.org/wiki/Mixin
08:21hoeckcaljunior: ahh, never heard the term 'mixin' in conjunction with java, now it makes more sense to me
08:32bsteuber,*assert*
08:32clojurebottrue
08:33bsteuber,`*assert*
08:33clojurebotclojure.core/*assert*
09:03chouserrhickey: are you pretty sure you're going to change number handling in Clojure as you've discussed (unboxed literals, no auto-promotion)? But not til after 1.2?
09:03Licenser_What place do you people think clojure will take in the IT world in the future? I am curiouse what people here think, had a long discussion with a friend of mine the other day about this.
09:07fogus,true
09:07clojurebottrue
09:12psykoticyet another macro for "flat" keyword args that i assume everyone else has already made for themselves anyway:
09:12psykotichttp://gist.github.com/326606
09:16psykoticfogus: have any particular use case?
09:16chouserpsykotic: (apply concat (map ...)) is the same as (mapcat ...)
09:17fogusnah, not really. Takes me back
09:17psykoticchouser: thanks
09:18chouser(apply array-map ...) is more common than (apply assoc {} ...), but I can't think of any reason yours is any worse.
09:18psykotici was looking for a function like array-map, so thanks in any case
09:18chouserthere are also hash-map, sorted-map, etc.
09:19psykotic(made those changes to the gist)
09:21psykoticactually, array-map (no apply) will do
09:21chouserah, right
09:21chouser,(let [{:keys [a b] :or {a 1 b 2}} {:a 5}] [a b])
09:21clojurebot[5 2]
09:21chouserthere's also this destructuring feature that might be helpful
09:22psykoticyeah, not a big fan of the repetition
09:25psykoticactually, with more testing, neither apply array-map or array-map are correct
09:25psykoticmy assoc {} does left-to-right merging
09:25psykoticthe array-map version does it the other way, it appears
09:26chouser(defmacro named [kwargs defaults & body] `(let [{:keys [~@(take-nth 2 defaults)] :or ~(apply array-map defaults)} (apply array-map ~kwargs)] ~@body))
09:26psykoticnice. with your suggestion about map bindings, i thought you meant as a replacement for named entirely.
09:27psykotici don't like the 'nesting' of using maps for keyword arguments, it goes against what is otherwise clojure's preference for unnested plist-style
09:27chouseryou're right that others have done similar things, but I've not seen the exact api you're defining. kinda nice.
09:29chouserI suppose the "most standard" is defnk from clojure.contrib.def ...though I don't know that I've ever used it.
09:30psykoticobviously my pref would be for integration with defn but this is a good stop gap and it doesn't offend my aesthetic sensibility too much
09:32psykoticbtw is there an effort underway to improve error messages, etc?
09:33psykoticit's pretty ridiculous right now. it's gotten to the point where i'll probably get off my ass and do it myself, just to scratch my own itch.
09:33chouseras individual error messages are identified as egregious, patches are generally accepted.
09:35psykoticin this case enumerating the good rather than bad message might make for a shorter list. but i'll start keeping a list and see what i can do.
09:36triyoI have a seq of paramters that I need to pass on to a function as a multi param. Signature of function is (myfunc [arg1 & otherargs] ..) . How do I transform my parma list '(1 2 3 4) into 1 2 3 4 so that it can be passed on to my function as multi params?
09:36chouserbe aware that the current compiler's implemention is on its way out, so I don't know how worth while it will be to develop patches for it for things like error messages.
09:37tomojtriyo: apply?
09:37psykoticnoted
09:38Licenser_okay I will try if I can come up with a good sandboxing solution for clojure :) lets see if it works
09:39tomojyou can't turn '(1 2 3 4) into 1 2 3 4, but you can use apply to switch from multi-param to a single seq param
09:41tomojheh, me too hopefully
09:41chouserfogus: yay!
09:41tomojmy boss happened to like clojure so now he says we are a lisp shop, but no one else likes it yet
09:41fogusScala is helping my cause however. ;-)
09:41chouserbe like water. patient. gentle. relentless.
09:42fogusoooo. Very Zen
09:42psykoticexcept when it's stagnant pond water.
09:42chouser:-(
09:43Licenser_,e
09:43clojurebotjava.lang.Exception: Unable to resolve symbol: e in this context
09:43psykoticchouser: an evil macro for your edification, (defmacro eager [[f & xs]] (let [syms-and-xs (zip (repeatedly gensym) xs)] `(let [~@(apply concat syms-and-xs)] (~f ~@(map first syms-and-xs)))))
09:46triyoI have an assertion function I need to run at macro expansion time that is passed in as a macro param. Macro of course sees this assert fn as a list data structure and not function. How do I execute the function? Eval would seem very hackish. Or am I going about this all wrong?
09:46fogusI have a brown-bag coming up showing one of the rhickey Vimeo vids.... any suggestions for a good start? I'm leaning towards the Clj4Java vid
09:46tomojpsykotic: what's the difference between that and apply?
09:47tomojbesides the signature
09:47psykotictomoj: (eager (or true (print "hello")))
09:47tomojoh, I see
09:47psykoticit's simple shallow code walking
09:49chousertriyo: I think eval is the only way to get what you want, which suggest you may indeed be wanting something you shouldn't. :-)
09:50chouserwhat are the args to this assert fn that are available at macroexpand time?
09:52defnhi chouser i lost connection -- i was asking about irc logs earlier
09:52defnchouser: any chance the #clojure irc logs are lying around in non-html format?
09:53psykoticis it true that the latest version of lazyseqs don't evaluate their heads until necessarily?
09:53chouserpsykotic: you're comparing to the old lazy-cons, or something else?
09:53psykoticchouser: i guess the old one
09:54psykoticie is there no longer a 'lazyseq elements may not be forced, but at least they evaluate left to right' guarantee?
09:55chouserlazy-cons evaluated "rest" when you did (first s). With lazy-seq, "rest" is not evaluated until you call (rest s)
09:57chouserhm. is that right?
09:57triyochouser: example -> (:datecreated {:init (java.util.Date.) :assert (fn [date] (instance? java.util.Date date))}) ... if the structure has the :init and :assert keys at macro expansion time, then it needs to apply the assert fn with the init value as arg.
09:58psykoticchouser: right now if i do (first (rest (repeatedly #(do (println "x") 42)))) i get two x's printed, so it forces first (or rather it is forced along with its containing lazy-cons-cell) on the way to the second item
09:58psykoticbut i'm not running the latest build
09:58psykotici was trying to reconcile that with what i read
09:59bsteuberuser> (def x (lazy-seq (cons (do (println :hoho) 42) '())))
09:59triyochouser: more accurately example of defentity macro.... (defentity person (:id) (:age {:assert (fn [id] (integer? id))}) (:datecreated {:init (java.util.Date.) :assert (fn [date] (instance? java.util.Date date))}))
09:59bsteuber#'user/x
09:59bsteuberuser> x
09:59chouseroh, firsts are forced in order, if that's what you're asking.
09:59bsteuber(:hoho
09:59bsteuber42)
09:59psykoticright
09:59psykoticgood, i thought i read that they were now delayed too and only forced on 'first'
09:59chouserthat's always been that way
09:59psykoticwhich would be a bad idea.
10:00psykoticsorry for the dumb questions
10:01chousertriyo: you don't want those asserts run when real values are provided to person?
10:01chouserpsykotic: not a problem.
10:01chousertriyo: ie, at runtime?
10:02triyochouser: I do, you are right. However how should handle init values during the defentity step?
10:03chousertriyo: you want :init evaluated at runtime as well, right? You don't want the date of when that macro was expanded, but rather when the resulting code is run?
10:03triyooh, you right again :)
10:04chouserso you're good -- no eval in sight. :-)
10:04triyohmm, then it is actual runtime, no (evil)
10:04triyo:)
10:06psykoticbtw, this is some code i wrote for fun after reading jshore's post about matrices to the list
10:06psykotichttp://gist.github.com/326672
10:08psykoticthe 'payoff' is the last section
10:08chouserbtw, closures are surprisingly unprotected
10:09psykoticthat's disturbing
10:09chouserhm... did it change again?
10:10chouser,(.x (let [x 42] (fn [] (* x 10))))
10:10clojurebot42
10:10fogusYou mean I can't hide my trade secrets in closures?!
10:10chouserBut that appears to be private again in master
10:11psykoticthat's a good bit exhibitionist
10:11chouserI don't have 1.0 or 1.1 handy to see if they were ever public in an official release
10:12stuartsierraeven if they were private, you could still get them out with reflection, right?
10:13fogusyes
10:13psykoticfor this kind of thing, i'm not too worried
10:13psykoticas long as it isn't flaunting itself
10:14chouserI was surprised the field names were so completely uncorrupted
10:14chouserunmunged
10:15psykoticmunging takes work :)
10:15psykoticeven if it's as simple as prepending a few characters
10:15psykoticheh
10:23chouser,(resolve foo)
10:23clojurebotjava.lang.Exception: Unable to resolve symbol: foo in this context
10:24chouser,(resolve 'foo)
10:24clojurebotnil
10:24chouser,(resolve 'foo.bar)
10:24clojurebotjava.lang.ClassNotFoundException: foo.bar
10:24chousershould that last case really throw an exception instead of just returning nil?
10:29stuartsierraprobably not
10:29hoeckthe ns-resolve doc says "... ,else nil"
10:31hoeckso I would consider the current behaviour a bug
10:34chouseryeah, thanks.
11:27defni dont think i can use a lazy-seq due to my side effects
11:28defni have something like (def foo (file-seq (java.io.File. "path")))
11:29defn(defn parser [arg] (remove (or nil? "") (map #(second (re-split #"regex" %)) (read-lines (str arg)))))
11:29defn(def parsed (map parser (rest foo)))
11:29defnis it possible to turn that into a lazy-seq
11:34S11001001defn: if you're really careful about the side-effects you can still have lazy-seqs
11:35S11001001also, it is already a lazy seq
11:35defnheh yes i just realized that
11:35defnmethinks i got lucky with map
11:39duncanmhmm, when i try to use WITH-OUT-APPEND-WRITER in clojure.contrib.io, i keep on getting the "Cannot change an open stream to append mode." exception
11:40duncanmi'm doing this (with-out-append-writer (append-writer f) (pprint ....)) - is that wrong?
11:43stuartsierrayes
11:43stuartsierrayou don't need the extra append-writer
11:44duncanmahh
11:51cljneohi, question about lein on windows. "lein swank" throws an exception IllegalArgumentException: no matching field found: getCommandLine for class org.apache.tools.ant.taskdefs.Java
12:14dakronetechnomancy: ping
12:14dakronehah
12:59chouserugh. I've got macros that expand into forms that contain macro usages, nested fairly deep.
12:59chouserone of the inner ones is throwing an exception.
13:00chouseroh, worse -- they're not real macros, but :inline fns
13:07brandonwis there a preference of when to use (.split "1;2;3" ";") vs (. "1;2;3" split ";") ?
13:07cemerickbrandonw: always use (.methodname obj args) forms
13:07cemerickthat's just idiomatic -- no difference in the functionality
13:08brandonwso tend towards (.methodname over (. symbol methodname) just because it is closer to clojure's syntax
13:09brandonwexcellent, that is what i had already (inadvertently) started doing
13:11cemerickyeah, it puts the name of the thing you think you're calling in function position
13:12adriancole_hi clojures
13:13adriancole_I'm the jclouds guy, and I'm putting together a blog on backends that are written in clojure
13:13adriancole_if anyone has thoughts to share motivation or otherwise, please email me adrian@jclouds.org
13:13adriancole_I'll cite you in the blog and quote if you are ok with it
13:25cemerickadriancole_: not public yet, but will be very soon :-)
13:28adriancole_cemerick: cool... well love to hear your story when you can talk about it :)
13:28cemerickadriancole_: people generally can't shut me up once I start blabbing :-)
13:28tomswI want to perform some actions in sequence, but I only know when an action has finished via an event or a callback - is there a good way to do this in clojure?
13:29adriancole_adriancole_: heh.. I'll keep that in mind, then :p
13:29chouseryou can either nest the operaions inside the callbacks, each step getting deeper...
13:30chouseror you can use promise/deliver to block the original thread at each call.
13:31tomswchouser: that sounds er promising, I'll check it out (thanks!)
13:41chouserbtw, I'd recommend the former unless you have specific reasons it won't work.
13:48tomswoh. Why? But I'm not doing anything very demanding - mainly waiting to be sure that other threads have finished doing things and fetching bits of information from them, eg an id, some content
13:50chouserI guess it doesn't matter too much. It's just I've occasionally had to refactor code from using promise/deliver to using nested callbacks much more often than the other way around.
13:52hiredmanmaybe you aren't promising enough
13:52tomswthe nesting avoids needing to mutate anything I suppose, thanks to scoping
13:52tomsw
13:52hiredman(repeatedly promise)
13:53hiredman^- why repeatedly shouldn't be deprecable
13:54radswhat is definline used for?
13:55chouserrepeatedly shouldn't be deprecated. replicate should.
13:55chouserrads: convenience macro to define a single thing that can behave either as a macro or a fn, depending on how its used.
13:56radswhen would you need that?
13:56hiredmanchouser: are you sure?
13:57hiredman(that definline defined things can be used as a function)
13:57chouser,(map + [1 2] [3 4])
13:57clojurebot(4 6)
13:57chouseryup
13:57hiredmanis + defined with definline, or is the inline stuff added to the function metadata?
13:57chouseroh. that doesn't actually use definline does it.
13:58hiredmananyway, you are right
13:58chouser(definline plus [a b] `(+ ~a ~b))
13:58radsso it's like a macro that you can pass around like a function?
13:59hiredmanchouser: in my test I called it "add"
13:59chouserhiredman: "add" is a better name. :-)
13:59stuartsierraNo, it should be "plusify"
14:00hiredmanrads: in the right circumstance it will expand the body of the function inline, sort of like a macro, instead of just emiting code to call the function
14:01chouserdefinline is pretty rarely useful in my experience. however I manually do :inline stuff rather often.
14:01chousermore often than I should, no doubt.
14:02radswhat do you gain from it?
14:02radsperformance?
14:02clojurebothttp://clojure.org/java_interop#toc46
14:02chouseryeah
14:02hiredman~botsnack
14:02clojurebotthanks; that was delicious. (nom nom nom)
14:03chouserI've got some fns here that can run as much as 100x faster by doing work at compile time instead of runtime.
14:03radsso I guess it's not something I should worry about unless I'm optimizing
14:03RaynesWhy was doseq named doseq?
14:03hiredmanchouser: neat
14:03chouserbut by using :inline instead of a macro, they can transparenly fall back to the slower code and so users can still map, apply, etc. as needed.
14:04hiredmanRaynes: it does stuff to a seq
14:04chouserI'd be happy to have it renamed to something like dofor
14:04radschouser: would you say it's in the same category as transients? something you don't use until you need the performance?
14:05RaynesI'm in a bit of an argument with a couple of people who are saying Clojure has unclear naming and are using that as an example.
14:05chouserrads: definitely
14:05RaynesI'm not sure I can argue with them at this point. :\
14:05chouserRaynes: 'do' takes a block of code and does it wonce
14:05chouseronce
14:05chouser'doseq' takes a block of code and does it once for each item in the seq
14:06technomancy"do" also indicates side-effects
14:07technomancythough I agree "dofor" might be clearer
14:07alson_kempis clojure-contrib considered stable-ish? I was working on learning clojure yesterday and bumped into a number of broken bits in clojure-contrib...
14:07alson_kemp"a number" -> 2 or 3 or so
14:07stuartsierraBut "do" doesn't support all the extra options of "for"
14:07hiredmanif that is their only example, they are just arguing with you for arguments sake, since any language you care to name as an odd name or two
14:07stuartsierraalson_kemp: *parts* of it are stable, most aren't
14:07brandonwdofor would only be clearer if you come from a background with heavy use of for loops
14:07brandonwit is externally consistent but not internally
14:08brandonwyou can't say dofor 'does something to a for loop'
14:08brandonwit would have to be just called 'for'
14:08chouserdoseq supports a minilanguage nearly identical to for, so having them named similarly would be good I think
14:08cemerickalson_kemp: what specifically did you run into?
14:09alson_kempstuartsierra : are there any docs about which parts are stable or should I expect to get VerifyErrors?
14:09technomancyhiredman: like "static". what on _earth_ posessed them to use that word?
14:09technomancystatic in Java, I should say. it may be used reasonably in other languages.
14:09chouserAt times I get confused which of dorun, doseq, and doall does which and have to think of all three before I can get it straight.
14:09stuartsierraalson_kemp: You should never get VerifyErrors
14:09alson_kempcemerik:
14:09alson_kempuser=> (require 'clojure.contrib.string)
14:09alson_kempjava.lang.VerifyError: class clojure.contrib.string$loading__4925__auto____106 overrides final method meta.()Lclojure/lang/IPersistentMap; (NO_SOURCE_FILE:0)
14:09alson_kemp(eww... pidgin broke up that line...)
14:09stuartsierraalson_kemp: You've got mismatched versions.
14:10stuartsierraIf you're using a Clojure release, use a matching contrib release.
14:10RaynesWhat are the chances of something like that being renamed at this stage in the game? Nil, I suppose.
14:10RaynesWould break pretty much all existing code.
14:10RaynesMomentarily, anyways. :p
14:10chousercould have both names for a while, with a deprecation warning at compile-time on doseq
14:11chouserdunno if rhickey is at all interested in this particular one though
14:11alson_kempstuartsierra: so I should use git & git versions? I'd prefer to stay closer to the bleeding edge while I'm learning (???)
14:11brandonwcouldn't you use for or doseq, if they both have many similarities?
14:11stuartsierraalson_kemp: Clojure master => contrib master; Clojure 1.1 => contrib 1.1
14:12Rayneschouser: Oh, I'm not asking that it be renamed, I was just curious as to how something being renamed would be handled at this point.
14:12alson_kempstuartsierra: got that, but would recommend staying away from head and sticking with 1.1?
14:13stuartsierraalson_kemp: unless you want to play with deftype/defprotocol, yes
14:13Raynes'doseq' /is/ consistent, if not very clear, so I doubt rhickey would want to change it.
14:13radsRaynes: the read metadata macro (^) is being repurposed as the set metadata macro starting in 1.1
14:14radsyou just get a warning in 1.1, but in the future it will change
14:14brandonwi'm still not sure there is even a problem. i came from a background in procedural oop and heavy use of for, and doseq made sense when i first read it
14:14brandonwi read about the do function first, then read the name of the doseq function, and it was pretty clear what it did
14:17RaynesI'm not saying it's a 'problem'.
14:17RaynesBut I can see how it might be a little unclear to the uninitiated.
14:41hugodis there some way of dynamically determining if &env is available in macos?
14:44dakronetechnomancy: congrats on the new job! :)
14:44chouserhugod: hm, interesting.
14:45chouserhugod: all I can think of is to define &env in an outer scope (var or let) to a well-known value like :unavailable
14:45chouserhugod: then in the macro if (= &env :unavailble), you know you don't have it.
14:45hugodchouser: i'll give it a try, thanks
14:46technomancydakrone: oh, I just got added to the commit list; it's not a job. thanks though.
14:56Licenser,(def a)
14:56clojurebotDENIED
14:56hugodchouser: seems to work
14:56rickmodeLet's say I have an in memory cache and a persistent data store in a multi-threaded application. The cache should be guarded using refs (probably one for the overall table and one for each item). How can we keep the in-memory cache consistent with the data store given that side effects such as I/O should not be done dosync? Is the best we can do saving the value of a ref and persisting after the STM transaction?
14:56Licenser,(let [a (def x 1)] 1)
14:56clojurebot1
14:56Licenser,x
14:56clojurebot1
14:57Licenserhiredman: I found a hole in clojurebot
14:59rickmodeIs there another way to use thread-safe data and persistence in idiomatic Clojure?
15:01sproustHi; clj newbie here, trying to setup compiling, having slightly frustrating problems.
15:01sproustHow do I set *compile-path*?
15:01sproustI tried (set! *compile-path* "/a/b/v//d")
15:01hiredmanLicenser: I am not surprised
15:01Licenserhiredman: I also have a fix I think :)
15:02sproustI cannot seem to alter the value of *compile-path*, it evaluates to the same afterwards.
15:02cemerickrickmode: you have to think of your refs within a transaction as a separate database -- from there, the question becomes, how do you keep two databases synchronized.
15:02cemerick?
15:02sproust(I actually use a path that exists, and the path I use _is_ in my classpath)
15:02sproustAny idea?
15:02sproustAlso, this is eval'ed using slime from Emacs.
15:03rickmodecemerick: yes exactly. How do we keep in-memory and persistent state in sync while each has it's own transactions
15:03wbruceLooking to write a macro that defines a function with a given name; running into issues since defn won't work with a keyword or symbol [please forgive the contrived example]: (defmacro makefn [name] `(defn ~name [x] x))
15:03sproust'compile is not happy with a "could not locate" error.
15:03cemerickrickmode: watches are what you fundamentally want.
15:03hiredmanLicenser: feel free to bounce a pm off me about it
15:03Licenserkk
15:03sproust(If this is not a good place for newbie question, please let me know.)
15:04neotykHi *
15:04dnolensproust: it's a great place for newbie question. *compile-path* is usually set with binding i think.
15:04dnolen(binding [*compile-path* ...] ( ... some code ... ))
15:04wbruceobviously (makefn :foo) and (makefn 'foo) don't work here
15:06sproustThx dnolen
15:06sproustThe binding form works.
15:07sproustHowever I still cannot compile; I have a difficult time to diagnose why.
15:07sproustThe directory exists.
15:07sproust'compile still fails with the same error: "Could not locate ..../.../ClassName__init.class on classpath
15:08sproustMaybe I'm not getting how this is supposed to work--searched online a lot, digged through SHalloway's book, still can't find.
15:08cemericksproust: I'd strongly recommend using a build tool like clojure-maven-plugin or lein instead of compiling at the REPL
15:08sproustI have a (ns ... ) directory right above;
15:08sproustI eval that.
15:08sproustThen I try to compile.
15:09sproustIf the code isn't compiled yet, how is it meant to find the files?
15:09dnolensproust: you need your source directory and your classes directory on your classpath, "java -cp src:classes:clojure.jar ...". I agree with cemerick tho.
15:09sproustDo I really have to place the (ns ... :gen-class) in the file in the classpath?
15:09sproustdnolen: I'm doing everything from within Emacs, this is prototyping... I'd like to be able to eval everything.
15:10hoeckwbruce: but (makefn foo) will work
15:10dnolensproust: dynamically changing your classpath is not supported so you can't really do that.
15:10sproustSetting up ant/maven just to create a class (I need to, need to override the constructor) sounds like a lot of effort for such a small thing.
15:10dnolensproust: the otherway around sadly :)
15:10sproustOh I don't want to change it--just want to execute my gen-class.
15:10cemericksproust: well, if you're going to do it more than once, then, nope, it's not :-)
15:11hoeckwbruce: try (macroexpand-1 '(makefn foo)) to see what your macro does
15:11rickmodecemerick: looking at agent watchers... with this is is possible to build a write-behind cache, which may work in most cases. But what happens if the persistence fails? (Perhaps I am not seeing the whole picture here...)
15:11sproustSo... wait a second; if you're just fiddling around with an idea, you can't do it with only eval from emacs?
15:11dnolensproust: you can, but you want to do something special, AOT
15:11sproustAOT?
15:11cemericksproust: you don't need to AOT-compile stuff if you're just fiddling
15:11clojurebotAOT genclass is http://paste.lisp.org/display/70665 and http://clojure-log.n01se.net/date/2008-11-18.html#14:19
15:12dnolensproust: Ahead-Of-Time compilation. Clojure is always compiled.
15:12cemericksproust: clojure code is *always* compiled. The only question is whether stably-named classfiles are generated
15:12cemerickdnolen: I'll get out of your way now. :-)
15:12dnolencemerick: no, the more the merrier :)
15:12wbrucehoeck: ah, true ;-)
15:12cemerickrickmode: If the persistence fails, then you'll have data in memory that won't make it to disk. *shrug*
15:13sproustThx guys.
15:13cemerickSTM is a database, but it's *not* durable.
15:13wbrucehoeck: Fromthis contrived example, I do get the following error, though (due to the parameter): java.lang.Exception: Can't use qualified name as parameter: user/x
15:13sproustI guess I need to find a minimal example somewhere.
15:13hoeckwbruce: right, then just change the x's in your macro to x#
15:13sproustBTW this is one of the few things that isn't explained well anywhere.
15:13cemericksproust: um... http://clojure.org/compilation :-)
15:14hoeckwbruce: and then they expand to symbols with a unique name and without a namespace
15:14sproustThx cemerick; I had seen that page, am just getting enough context now.
15:14sproustTell me, is it possible to use gen-class without compiling?
15:14rickmodecemerick: ya... I think in the end there is an equivalent issue even with raw concurrency and persistence (as with plain java). I could simply invalidate that cache entry upon failure. Further it looks like I can use "await" so a user interface will know of the failure. Thanks!
15:14cemericksproust: to do what?
15:14sproustI was using (proxy) but I need to override the ctor, and it seems impossible.
15:15sproustI'm having to derive from a class and override some methods (typical Java thing) but the ctor needs to be overridden.
15:15sproustThat's it, basically, ; I could not do it, so I tried to use the :gen-class form and now I'm in compilation dilemma state :-)
15:16rickmodecemerick: ah... it's all here in "Programming Clojure" pg. 189 to 191...
15:16cemericksproust: Yeah, I think gen-class is the only option for constructor requirements.
15:17sproustcemerick: great, but does that imply it _must_ get compiled?
15:17sproust(I meant: compiled to files?)
15:17cemerickrickmode: yeah, you've got it about right. STM is by no means a silver bullet for everything, and it does not address durability at all, so all the usual tricks, caveats, and tools apply when you need that.
15:17wbrucehoeck: ah, the gensym thing. thanks
15:17sproustIn other words, is it possible to use (ns ... :gen-class) and then to instantiate that class without compiling?
15:17wbruceI wonder why that's necessary, since x is local
15:17cemericksproust: no, gen-class is a purely AOT-compiled thing.
15:17wbruce(more to learn)
15:18hoeckwbruce: np :)
15:18mabescemerick: I just read your post about using jetty + maven + compojure.. very nice. I'm wondering if you have crossed the production deployment bridge yet.. I've been looking into the options (embedded jetty, glassfish, cargo plugin, etc..) but I'm wondering if you could share any lessons learned
15:18sproustAWESOME. Thanks. I'll put the file in my classpath and try that.
15:18rickmodecemerick: We could also persist first then use STM to update the in-memory store (depends on if write-ahead or write-behind is more appropriate). I suppose an online payment might use write-ahead, while a blog could use write-behand.
15:18hoeckwbruce: its not, you can also use ~'x in this case
15:18cemerickmabes: not quite, but getting very close. I actually don't use that approach anymore -- once we added an enclojure repl server into our webapp, we just load up new code that way instead of having jetty reload.
15:19hoeckwbruce: but you can't have a namespace-qualified symbol as a local
15:19wbrucehoeck: ok, I think that makes sense to me
15:19cemerickrickmode: yup, your degree of durability and consistency can vary depending upon the application.
15:19hoeckwbruce: and `x expands to user/x by default to prevent aliasing
15:19hoeck,`x
15:19clojurebotsandbox/x
15:20hoeckor whatever namespace your macro is in
15:20wbruceright
15:20sproustcemerick: So now the file is found.
15:20sproustBut I want to do interactive development, e.g. C-M-x and rerun, within Emacs.
15:21sproustI suppose you _do_ use (compile) to do this, no?
15:21sproustWhat's your workflow like?
15:21hiredmandakrone: sweet
15:21sproust(i.e. the most "interactive" workflow, for working with :gen-class)
15:21dakronehiredman: just see I fixed the deps thing?
15:21hiredmandakrone: yeah
15:21wbruceDoes anyone have any experience with benchmarking a clojure daemon's footprint on a system? Just looking for any basic idea on the minimum resource consumption I can expect (thinking about writing some system tools)
15:22dakronehiredman: you mentioned using it for clojurebot, what sort of stuff are you planning on doing with it?
15:22hiredmanI'd like clojurebot to be a better conversationalist
15:23cemericksproust: once the generated classfile has been loaded into an environment, you can load the clojure bits that back it up again and again however you like.
15:23cemerickthrough a repl, that is
15:24hiredmanpreviously if you asked clojurebot something and it did not have a direct match it would just sort of jumble up the sentence and try to do matches on random combinations of words from the sentence
15:24dakronehmm, that sounds like a cool thing to work on
15:24hiredmanright now I have clojurebot using nlp to pull out nouns
15:25hiredmanbut nlp things rhickey is an adverb :/
15:25hiredmanthinks
15:25sproustHmm I see; I'm reading that you mean I could just go to the file with the :gen-class in it and C-M-x there and the values will override the ones from the class. Nice. Thanks cemerick.
15:25dakroneyea, unfortunately it isn't trained for things like usernames
15:26cemericksproust: yes, the AOT-compiled class just delegates to whatever is defined in the (dynamically-reloadable) vars in the associated namespace.
15:28Licenserhmm we talked yesterday about sandboxing, so I took some effort in starting a library, so far it looks quite niceish (for a start of cause) so I ran into a not so nice situation if I 'extract' the funections from '(fn [b] (+ b 1)) I get (fn* b + b) - any idas how I can distinguish between fn*, + (which are actual funections) and b which is not?
15:28hoeckwbruce: jvisualvm is a good tool to measure the memory footprint of a java/clojure program
15:29hoeckwbruce: and it is included in the sun jdk
15:29wbrucehoeck: thanks (again) :-)
15:29hoeckwbruce: np again, just sharing some experience :)
15:30hiredmandakrone: I don't know much (anything) about opennlp or really nlp at all, do you have any adivce for a starting point?
15:31duncanmcan someone teach me how to use clojure.contrib.probabilities.random-number?
15:32dakronehiredman: unfortunately, the documentation is really poor for a lot of it, http://alias-i.com/lingpipe/demos/tutorial/read-me.html has a lot of tutorials on the sort of stuff you can do with it, but it's for a different library altogether
15:32dakroneif you are interested in the kinds of things you can do with NLP
15:33hiredmanit's a start
15:33StartsWithK,(loop [a 1] (case a 1 (recur 2)))
15:33clojurebotjava.lang.Exception: Unable to resolve symbol: case in this context
15:34hiredmanLicenser: it's like writing an interpreter, you have a set of special forms, fn* being one of them
15:34chouserStartsWithK: yeah, there's a thing with recur in case at the moment
15:34chouserStartsWithK: http://www.assembla.com/spaces/clojure/tickets/258
15:35StartsWithKchouser, then i can only wait :)
15:36Licenserhiredman: I know, fn* and + are note an issue
15:36Licenserthe issue is the 'b' since in the list it does not distinguise from + or fn*
15:38sproustI'm having troubles with the cwd.
15:38hiredmanwelcome to java
15:38sproustIs there a way to change the slime cwd from within Emacs?
15:38sproustI tried changing the user.dir system property.
15:38sproustDoesn't work.
15:38dnolensproust: there's no way to do it.
15:38hiredmanjava doesn't really have the concept of a cwd
15:38The-Kennysproust: I think the JVM doesn't allows this
15:38sproustI mean, the property gets changed, but the effect is not there.
15:39sproustjava doesn't have a concept of cwd? It runs in a UNIX process, doesn't it?
15:39sproustYou gotta be kidding me...
15:39Licenserwhat is cwd?
15:39The-KennyLicenser: current working directory
15:39sproustLicenser: current working directory
15:39Licensercookie weilding demons?
15:39Licenserah okay
15:39raekhmm, slime does not recognize my ns declaration (it has doc and author metadata)... how to fix?
15:39hiredmansproust: the jvm doesn't expose that though
15:39sprousthiredman: that's brilliant.
15:40hiredman*shrug*
15:40sproustSo... forget relative pathnames?
15:40sproustHow do Java programmers do?
15:40chouserthey're just relative to where the jvm was started
15:40sproustAllright, I guess I'm veering off topic, I'll go dig in Google.
15:40hoeckLicenser: if its the first element of a list, then its a function
15:40hiredmanyou have a working directory
15:40Licenserhmm not nessesarily
15:40dnolensproust: nope. this is why things like lein and maven are popular. cwd works if you start the REPL in _that_ directory. you can't change it tho.
15:40hiredmanit's just not the "current" working directory because it doesn't change
15:40Licenserwell yes but not only
15:40hoeckLicenser: if its the second element in a list where the first one is apply, its a function
15:41hoeckyes, that gets complicated soon
15:41hiredmanhoeck: but then you need to know every higher order function in advance
15:41Licensercan'T go by that for example: (let [good-fn bad-fn] (good-fn "rm -rf /"))
15:41hoecklike looking for (.invoke (fn ...))
15:41hiredmanLicenser: if it's in the whitelist, it's a function
15:41hoeckLicenser: do not put bad-fn on the whitelist?
15:42Licenserhoeck: then I'd had to put any (not yet used symbol) on the whitenod
15:42hoeckand write wrapper-functions for the semi-bad ones like symbol, in-ns ..
15:42Licenser(let [a b] ...) b and a has to be in the white list
15:43Licenserthat is a real problem for whitelists
15:43Licenserwhitelists are a real problem it seems
15:44Licensersince either I've to be able to distinguise between things that are functions and things that are not or I'll have trouble with bindings
15:44Licenserof cause I could let out let, but then there's the problem that you can't let stuff
15:45sproustdnolen: do you know how to tell SLIME to start from a specific dir?
15:45sproustdnolen: never mind if it's not at the TOYH, I'll dig.
15:45dnolensproust: I use lein. You can also use maven. If you use lein you can do with this "lein swank".
15:45Licenserhmm one way would be to filter out things that are removed but that's trickyish
15:46dnolenthis starts a REPL on 4005, you can connect from Emacs with M-x slime-connect, and use the defaults.
15:46hiredmanLicenser: you have to replace let to a call to my-let
15:47Licenserhmm I don't quite understand hiredman o.O
15:47hoeckLicenser: but if there is no reference to bad-fn( because its not on the whitelist), then you don't have to find all function calls and filter them with (not bad-fn?)
15:47hoeckor am I wrong, did I miss something?
15:47Licenserwell whitelist as in everything in there is OK, everything not not. so if bad-fn isn't in there it fails
15:48rickmodednolen: I have the same directory issue using swank-clojure-project. The current directory seems to be a bit random. Sometimes its the directory of the project, and sometimes not (I haven't figured out why). Using lein swank works solidly though.
15:49hiredmanyou replace any calls to things you want to allow, but can't trust you replace with calls to wrappers
15:49hoeckLicenser: right, the whitelist would be probably 75% of clojure.core, and some wrappers to maybe-bad but necessary functions
15:49hiredmanand some special forms
15:50sproustdnolen: thanks. Sounds like a lot of technology. I like it simple. I killed all my inferior/superior repl's, M-x cd MYDIRECTORY, then M-x slime, and it worked.
15:50hiredmanswaping out special forms may get tricky
15:50sproustI guess SLIME inherits the directory of its parent process, in this case Emacs.
15:50sproustI hope this is recorded somewhere, will be useful to others!
15:50dnolensproust: nice! good to now.
15:51hoeckhiredman: which special forms have to be swapped out?
15:51sproust"How to change the slime current working directory (cwd)." There. That should get Google hooked up.
15:51hiredmanhoeck: well we were talking about let
15:51bsteuberhiredman: didn't you recently try to have M-x slime use the new clojure version?
15:51Licenserhiredman: I am note exactly sure why I should wrap anything it does not interfeers with problems like a not being defined
15:51hoeckdef?
15:51sproust:-)
15:51clojurebotdeftype is see datatype
15:51neotykis lazy map the way to do lazy maps and why it is not in clojars?
15:51hiredmanbsteuber: sorry I wasn't paying attention to your thread, whats going on?
15:52sproustIT WORKS. I'm so excited. I'm going to liberate a large codebase of questionable java with Clojure! Yeah!!
15:52bsteuberhiredman: don't worry, that's been the start of it =)
15:52hiredmanI grapped the swank-clojure src, and jared it up without compiling it
15:52hiredmanand then makde the jars in .swank-clojure symbolic links to whatever
15:53sproustWhoah... it generates _many_ .class files...
15:53hiredmansure
15:53bsteuberhiredman: thx, I'll try that
15:53neotykclojurebot: lazy map
15:53clojurebotlazy map is http://kotka.de/projects/clojure/lazy-map.html
15:53Scriptoris there any advantage to having the & and the parameter following it be separate in the params vector? why not just do &other_params ?
15:53neotykis that lazy map a way to do lazy maps?
15:54The-KennyLooks like this page is a bit outdated, as it mentions lazy-cons
15:54hiredmanyeah
15:54hiredmanit's old
15:55hiredmanneotyk: you can just use proxy or similar
15:55hoeckneotyk: it is, though its not really 1.2-ish, it was written in the ancient clojure-1.0 days, or even before
15:56Licenser*hrm*
15:57hiredmanLicenser: it may just be easier to write an actually interpreter
15:57Licenserhiredman: I fear you might be right, which is scaryish
15:58hiredmana lisp interpreter in lisp is not hard
15:59Licenser__gnaw disconnect
15:59hiredmana lisp interpreter in lisp is not hard
15:59hiredmanit's maybe a single multimethod?
15:59Licenser__+c :Waves
16:00sproustIs there a way to access the 'this' pointer from within a constructor?
16:00sproust(Using gen-class)
16:01hiredmanI didn't think you could generate a constructor using gen-class
16:02neotykhiredman, hoeck would using proxy be more 1.2-ish?
16:02sprousthiredman: isn't it just the :init optional arg?
16:02sproustThat's what I'm using; it calls it.
16:02cemerickhiredman: I believe the ctor is fixed; the :init is a post-ctor init hook.
16:02hiredmanneotyk: 1.2 ish would be reify or deftype
16:03hoeckneotyk: deftype would be the #1 option for implementing it
16:03hoecknowadays
16:03hiredmansproust: have you looked at post-init?
16:03sprousthiredman: will do right away.
16:04sproust(frantically juggling google, emacs and xchat)
16:04hoeckneotyk: but its safe to use, its in no-way deprecated and you use it mostly through the normal map interfaces (it inherits from APersistentMap)
16:04neotykis it known that if in java you have package local class with public methods and you use class that is public that subclasses previous one you have problems in clojure 1.1 with accessing public method of packege local class?
16:05triyocan it be that a LazySeq elements cannot be fully realized using something like doall? But for example first and last functions work?
16:05neotykhoeck: and that is exaclty hat i want, normal map interface, only lazy
16:05neotyks/hat/what/
16:05hiredmanneotyk: if you put a hint in the right place it should work
16:06neotykhiredman: do tell
16:06hoeckright, you won't even notize if lazymap changed its implementation from gen-class to deftype except for the build-process :)
16:06hiredmanwell, as long has you have an interface you can hint with
16:07hiredmanneotyk: I forget exactly, but this (or similar arising from the same issue) has come up
16:07sprousthiredman: :post-init works, but I had to kill and restart my slime.
16:07sproustNo amount of evaluation or compiling made a difference.
16:08sproustKill process, restart, and voila.
16:08hiredmansproust: you will have to restart the jvm anytime you compile
16:08sproustOh...
16:08hiredman(so don't)
16:08sproustI see.
16:08sproustThis is VERY useful information.
16:08sproustSomeone, somewhere, should write a compendium of this. Maybe I'll start a text file.
16:09hiredmanbecause compilation generates a stable classname, and java doesn't have built in class reloading
16:09hiredmansproust: you can change implementations of methods on the fly though
16:09sproustGreat.
16:09hiredmanbut changes to :gen-class options, and additional methods, that kind of stuff will need a recompile
16:10neotykhiredman: thanks, so I will not bother with reporting it
16:10hiredmanI forget what the resolution was, I think it might have just been a limitation of reflection
16:11sproustAllright, another one: -init does not take a this ptr; -post-init does. I have another method, it doesn't. How do I access the this ptr from that method?
16:11sproustThe "implicitness of this" seems very different between proxy and gen-class.
16:12chouser-init doesn't take a this because the object doesn't exist yet at that point.
16:13hiredmansproust: the first argument to the functions implementing a method is this
16:13sproustAaaah never mind I got it.
16:13sproust(My bad; I happened to have a single arg.)
16:13hiredmanI wouldn't go hog wiled on gen-class though
16:13hiredmanwild
16:15sproust(println) invokes .toString() automatiaclly; is there another function to avoid this, e.g. like __repr__ in Python?
16:15hiredmangen-class is the most painful corner of clojure you can wedge yourself into without much benefit
16:15hiredmansproust: what do you want to be printed?
16:15neotykdon't know how to hint it
16:16neotyk(let [rb (RequestBuilder. RequestType/GET)] (.setUrl rb "url"))
16:16sproustI'm asking, because I noticed that getting one of the base Java class' properties when I print them I get an empty string, and was expecting it would expose them as atoms.
16:16sproust... which it does: I can (set!) on them, but then I expected #<Atom: ... >
16:16neotykRequestBuilder inherits from RequestBuilderBase that is package local
16:16hiredmansproust: you have to wrap it in an atom
16:16hiredmanset! does not work on atoms
16:16neotykand I get Can't call public method of non-public class: public com.ning.http.client.RequestBuilderBase com.ning.http.client.RequestBuilderBase.setUrl(java.lang.String)
16:17duncanmi have a list like this [[x1 y1] [x2 y2] ....] and i want to make that into a double [][], what's the right call?
16:17neotykhow do I hint it?
16:17hiredmanneotyk: you have to find a suitable interface or superclass with that method
16:17sproustWhat's the proper method of modifying the base class' property?
16:17sproust(set!) ?
16:17sproustit's a var I guess...
16:17hiredmanno
16:17hiredmanit's a field
16:18neotykRequestBuilder extends RequestBuilderBase
16:18neotykRB i spublic
16:18neotykRBB is package local
16:18neotykwhat is suitable superclass?
16:18hiredmananything above RequestBuilderBase?
16:19neotyklike (let [rb (RequestBuilder. RequestType/GET)]
16:19neotykRB is above
16:19hiredmanno, I mean in the class hierarchy
16:20neotykwhy clojure tries to access RBB.setUrl directly ?
16:20neotykpublic class RequestBuilder extends RequestBuilderBase
16:20neotykabstract class RequestBuilderBase
16:21neotykhas setUrl method
16:21neotykabstract class RequestBuilderBase has public setUrl method
16:23hiredmanuh
16:23sprousthiredman: I'm looking everywhere for a field... set! seems to work, but SH's book says it's evil; I print the type, says it's a java.lang.String (when I access it via (.fieldName this)). Is there a guide somewhere for accessing java properties?
16:23hiredmanwhoever wrote RequestBuilderBase doesn't understand genercs
16:24hiredmansproust: if you look at the gen-class examples they usually put an atom in the field
16:24hiredmanthat type is the runtime type of the field
16:24hiredmanthe field can hold any Object
16:25triyoI have (throw (AssertionError. (str "errors: " errors))) which outputs errors: clojure.lang.LazySeq@79be0545. If I print errors seq outside of the throw call, it prints fine.Do I have to do something special here?
16:26sprousthiredman: but if I replace the field, won't the java code that uses this barf out when it tries to use the java.lang.String interface?
16:26hiredmantriyo: the .toString method on lazy-seqs returns a string like that, and str calls t.toString
16:26hiredmansproust: that depends on the field
16:27neotykhiredman: very unlikely, but still my problem stands as it was
16:27hiredmanI was assuming you were talking about the .state field
16:27hiredmanneotyk: the code is full of "(T)this" with @SuppressWarnings("unchecked")
16:28triyohiredman: ahh, so its the str thats calling .toString on each param. Thanks.
16:28hiredmanyou can't cast wtih java generics
16:28hiredmantriyo: you need to use pr-str
16:28neotykhiredman: ok, how about my error :)
16:28triyo,(doc pr-str)
16:28clojurebot"([& xs]); pr to a string, returning it"
16:29hiredmanneotyk: very sketchy (I know this doesn't help, but I noticed while trying to find the javadocs)
16:30neotykclojurebot: where do you keep history?
16:30clojurebotPardon?
16:30neotykclojurebot: what is brain?
16:30clojurebotbrain dump is http://clj.thelastcitadel.com/clojurebot
16:30hiredmanclojurebot: please give us logs
16:30clojurebotlogs is http://clojure-log.n01se.net/
16:30neotykthans
16:30neotykthanks
16:31sproustIs there a way to invoke the superclass' method from a method in a gen-class?
16:31bsteuberhiredman: I updated slime's clojure in a different way
16:31bsteuberI've used (setq swank-clojure-classpath (list "path/to/clojure.jar" ...)) in my .emacs
16:31bsteuberthat seems to do the job
16:33hiredmanbsteuber: I would watch out because your AOT compiled swank might not be binary compatible with version of clojure other than what it was built with
16:33hiredmansproust: :expose or maybe :expose-methods
16:33hiredmansproust: checkout the api docs for gen-class
16:34sprousthiredman: thanks; I'll print that, a lot of the secrets seem to be in there.
16:35bsteuberhiredman: thx for the warning, I have to watch out when things go wrong
16:36bsteuberbut also with non-compiled jar's you might prefer swank-clojure-classpath over symlinks I guess
16:37raekanyone have a solution for slime not understanding ns declarations with metadata?
16:37hiredmanbsteuber: well the issue is the clojure part of swank
16:37hiredmanraek: what do you mean?
16:38technomancyraek: hugod just committed a fix for that a few days ago; try the latest git version
16:38raekif i write the ns decl as (ns #^{...} foo), slime still does not change namespace when evaluating the file
16:38raektechnomancy: ah, thanks! I will check it out
16:39technomancyraek: also be aware that you don't need to use that syntax just to add a docstring
16:39technomancyjust putting a string after the ns name will make it a docstring
16:39raekah, ok
16:39technomancyyou only need that syntax if you want arbitrary metadata
16:39technomancylittle-known fact!
16:39raekthat would solve my current problem
16:40bsteubertechnomancy: is this a new feature? because I think I've tried it before without success
16:40raekI added author info, but that is not crucial now, since i'm the only one working on it
16:40technomancybsteuber: quite new
16:40bsteuberi see
16:40technomancyyeah, author metadata can be gotten from git
16:40raekis it in slime or in swank-clojure?
16:41technomancyraek: swank-clojure.el
16:41hugodi didn't realise either, until after fixing swank-clojure
16:41bsteuberbtw. is there a reason why def doesn't allow docstrings?
16:42tomswsorry, more newbie questions - what is the best way to poll something until it changes? At the moment I'm using a separate thread that repeatedly sleeps until the has changed, then calls a callback. But I think it sucks
16:42arohnerbsteuber: check out clojure.contrib.def
16:43chousertomsw: polling in general kinda sucks. are you sure you need to?
16:43bsteuberarohner: I know about that, but I dislike defvar's docstring are after the value
16:43hiredmanneotyk: actually there is some skepticism in ##java that the code in question will actually compile
16:43bsteuberI already hated this in CL :)
16:44Licenserhmm nicer
16:44neotykhiredman: not only it does compile it also runs
16:44bsteuberbut still I wonder why it can't be added to core/def
16:44hiredman(def #^{:doc "foo"} a 1)
16:45bsteuberhiredman: sure, but I'd prefer (def a "foo" 1)
16:46tomswchouser: i'm scripting a Java (Eclipse RCP) application, a lot of things I'm waiting for are closed boxes
16:48StartsWithKcase can't match a value of enum?
16:48bsteuberso if noone has a good reason why simple docstring can't be added to def, I'll file a ticket
16:48miltondsilvaisn't there a fn to return the diff between seqs?
16:49hiredmanStartsWithK: has to be a literal
16:49miltondsilvaI know there is one for sets.. but why not for all seqs?
16:49chouserStartsWithK: I've seen that, yes.
16:49Licenserwhat is the best way to say 'every second element from an seq'?
16:50chouser,(take-nth 2 (range 10))
16:50clojurebot(0 2 4 6 8)
16:50Licenserweeh!
16:50Licenserthanks
16:50tomswchouser: so to cut a long story short the most reliable way I have of knowing if my automation script can start performing actions on something is to check the cursor. So maybe my problem isn't not knowing how to poll...
16:51hiredman:(
16:51hiredmanbusy loops
16:52hiredman,(doc while)
16:52clojurebot"([test & body]); Repeatedly executes body while test expression is true. Presumes some side-effect will cause test to become false/nil. Returns nil"
16:52chouseror a thread-pool-scheduling thing
16:53dakroneis there a 2-way map data structure where I can do something like (:foo {:foo "blah"}) => "blah" *and* (get {:foo "blah"} "blah") => :foo ?
16:53alson_kempis clojurescript dead? Or just lying fallow?
16:54chouseralson_kemp: hibernating until clojure-in-clojure is done
16:58triyoin emacs my clojure-mode tabbed-indentation are looking huge. How do you guys deal with this, if at all?
16:58triyosome that is
17:02bsteubertriyo: while some things could be nicer, I'm quite happy with clojure-mode as it is - especially toghether with paredit
17:02bsteuberoh, it is about tabs? I use spaces everywhere
17:03triyoI see, I'll need to experiment a bit.
17:04bsteuberso does clojure-mode insert tabs? or do you have code from other editors?
17:05powr-tocmiltondsilva: Just turn your seq into a set... (intersection (set seq-a) (set seq-b))
17:05triyoI actually think its spaces its just I guess where I'm braking lines and my lists are getting deep so it goes quite far to the right with a massive whitespace on the left.
17:06miltondsilvapowr-toc: but what if they are nested?
17:06triyoits starting to look silly
17:06bsteuberyou mean like
17:06bsteuber(some-long-name x
17:06bsteuber y)
17:06bsteuber?
17:06powr-tocmiltondsilva: then use tree-seq
17:07bsteubermiltondsilva: what kind of diff algorithm do you want? something tricky for versioning?
17:08miltondsilvano I have something like ((6 8) (2 8) ...) and then something like ((1 2) (6 8)...) and want to return ((2 8) (1 2) ..)
17:09triyobsteuber: yes, exactly
17:09hiredmanmiltondsilva: you can't do that lazily
17:09hiredmanspeak of the devil
17:09bsteuber:)
17:11miltondsilvahiredman: hmmm... I'm extremely inexperienced with the lazy-seq concept.. but how did you reached such a conclusion so quickly?
17:12powr-tocmiltondsilva: are they nested at the same depth, or is it a tree?
17:12hiredmanmiltondsilva: you'd have to walk all of sequence a before you could determine that an element of sequence b was in it
17:12miltondsilvapowr-toc: nested at the same level
17:12Licenserwoohoo!
17:12LicenserI think I got it!
17:12bsteuber,(clojure.set/difference (set '((6 8) (2 8))) (set '((1 2) (6 8))))
17:12clojurebot#{(2 8)}
17:12bsteuberyou could start from here
17:13powr-tocmiltondsilva: then just map ehash-set over the sequence and intersect
17:14bsteubertriyo: I played with my line-breaking style and now I'm quite okay
17:14Licenserbsteuber, hiredman if you'd like to take a peak here is what I came up with for the problem of extracting functions
17:15miltondsilvabsteuber: ohh... thanks, I was having some troubles doing that.. they werent at the same level and I hadn't noticed
17:15triyobsteuber: think I'm gonna have to do some playing around too.
17:16bsteuberlicenser: nice, I'm studying your code right now
17:16Licenser:)
17:18Licenserhmm little bugs still in there :(
17:20Licenserthere we go, fixed
17:21bsteuberlicenser:I guess fn-seq should also skip maps, not just vectors - right?
17:22Licenserhmm hmm?
17:22Licenserfn-seq?
17:22Licenserbut on a nother note, you're quite right, I forgot to handle maps and vectros
17:23bsteuberline 15:
17:23bsteuber(filter #(and (ifn? %) (not (vector? %))) (s-seq form)))
17:24bsteuberso you skip vectors but not maps - but I guess it doesn't matter as they are never equal to your functions :)
17:25hiredman,(doc fn?)
17:25clojurebot"([x]); Returns true if x implements Fn, i.e. is an object created via fn."
17:25bsteuberoh, ic
17:25bsteuberso why is there a check to vector? then?
17:25hiredmanifn? and fn? are no the same
17:26bsteuberoh, now I get it
17:26bsteuberso it's (filter ifn? (s-seq form))
17:28Licenserhiredman, bsteuber http://gist.github.com/327199 <-is the new code
17:28Licenserthe tree-seq does not work, you don't have enough controle over the matter
17:30Licenser,{1 1}
17:30clojurebot{1 1}
17:30Licenser,{1 (def y 1)}
17:30clojurebotDENIED
17:31Licenserah nice :)
18:07neotykhow do I comment on issue in assembla?
18:09hiredmanI believe you have to send in a CA
18:10neotykeven to comment?
18:10neotykboy oh boy
18:11hiredmanfrom what I understand you have to be a member of the space comment
18:11hiredmanto
18:11hiredmanand to be a member you need a CA
18:11neotykwill have to sign another CA than
18:11hiredmanI could be wrong, I haven't used assembla much
18:12neotyk#259 should be linked with #126 as example
18:15hiredmandone
18:15mabeswhat is the recommended way to have/use custom exceptions? I created one with gen-class but according to this, now year old, post that may not be the best route: http://groups.google.com/group/clojure/browse_thread/thread/fae67b5494578baf/006579290248352c?lnk=gst&amp;q=custom+exception#006579290248352c
18:15mabeswould deftype be a better way of dealing with custom exceptions now?
18:15ChousukeIf assembla doesn't allow watchers to comment, then I suppose you need to bring it up on the group.
18:16S11001001mabes: I'm a fan of clojure.contrib.condition
18:16Chousukemabes: I don't think deftype even allows defining exceptions. :/
18:16Chousukemabes: I think the most clojurey solution would simply be not to throw any custom exceptions :P
18:17mabesChousuke: as long as you implement Throwable I would think you would be okay (I haven't done anything with deftype though so I don't know what I'm talking about)
18:17Chousukemabes: is Throwable an interface though? :/
18:17_atoit's a class
18:17mabesah
18:19mabesChousuke: what would the clojurey solution be like exactly? I started down the path of having hash maps returned with the key :errors but the control flow was becoming unruly
18:20hiredmanmabes: why do you need to throw a custom exception though?
18:22mabeshiredman: it may not be the best solution so I'm open to alternatives.. right now I have something that validates some data (coming from a web API), transforms it, and the processes it. If anything goes wrong in the validating or transforming I want to give back helpful messages to the client.
18:23hiredmanok, and why does that need custom exceptions?
18:23hiredman,(.getMessage (Exception. "such and such failed"))
18:23clojurebot"such and such failed"
18:23neotykhiredman: thank you
18:24mabessure, but what if I want to have more custom data that doesn't make sense to stuff it in the string.. i.e. the HTTP response code
18:25hiredmanmabes: well that is sepperate from the concern of showing a message to users
18:25ChousukeI don't like the proliferation of exception types. hm...
18:26hiredmangetting different http responses is hardly an exceptional situation
18:26ChousukeThere should be a ClojureException which can hold a map of arbitrary data :P
18:26mabesAlso, the issue with doing a blanket catch of just Exception is that I may be catching unintended errors. I prefer that any unexpected exceptions bubble up where I have another middleware catching those and handling them appropriately (logging and sending alerts)
18:26Licensergood night my lispy friends!
18:27hiredman*shrug*
18:27Chousukereturning a map of {:error foo} from the functions is not necessarily a bad approach if you manage to structure the error checking in a way that makes sense.
18:27dakronegood evening Licenser
18:27mabeshiredman: agreed WRT it not being an exceptional situation.. I have been going back and forth. When I try using normal flow control it just seems messier.
18:28hiredmanmabes: use trampolines and pass and error handling function
18:28hiredmanan
18:28Licenserhiredman: and thank you for all your advice :)
18:28hiredmanLicenser: thank you for catching that hole in de-fang
18:29Licenser^^
18:29hiredmanpass an error
18:29Chousukemaybe instead of explicit error checking you could simply code up some monadic structure that allows you compose functions so that error cases are handled properly :P
18:29mabesdo you know of some code (i.e. on github) that uses that approach so I can get a better idea of how that would work?
18:30hiredmannot really, trampoline doesn't seem to be used often
18:30mabesok, so it seems like the best/standrd approach would be to have the functions return a map with :error in it then.. correct?
18:30hiredmanare you familiar with trampolines?
18:30hiredman:/
18:31mabesno, I remember reading about them in stuart's book but I haven't used them
18:32hiredmanclojurebot: tco is <reply>yes please
18:32clojurebotAck. Ack.
18:32hiredmanclojurebot: do you want tco?
18:32clojurebotyes please
18:32Chousukemabes: in a way, a parse error is a valid result from a parser so I think yes :P
18:34mabesChousuke: I guess the angst I'm feeling is that in Java that parse error would be in the form of an exception. That may be more of a result of it's static typing though..
18:42zkimQuick question: In the following snippet: http://clojure.pastebin.com/uQf5JnsE I'm trying to get the varargs passed through to my-func-1 without being wrapped in a list a second time. Can anybody help me out on how to accomplish this?
18:50jsanderszkim: You can do it with a macro http://clojure.pastebin.com/EVfnT3pQ - might be a better way, but that way works
18:51zkimjsanders: thanks, will do
18:59jsandersquestion: what is a good way to define a function with a dynamic name, in a string for instance
18:59jsandersI have this macro - #
18:59jsanders(defmacro defn-with-str [name args & body] `(defn ~(symbol name) ~args ~@body))
19:00jsanderswhich works, if the first argument is a literal string
19:00jsandersbut not if it is a symbol that is defined to be a string
19:00jsandershttp://clojure.pastebin.com/YKwTGpph
19:21arohnerjsanders: you'll have to control evaluation in your macro
19:24jsandersright, but I can't seem to figure out how to do so
19:24arohneryou'll probably want something like (defmacro defn-with-expr [expr args & body] (let [val expr] `(defn ~val ~args ~@body))
19:24arohnernote that the let is before the `, so the part inside the let is evaluated at compile time
19:24arohnerand then the output is stuck in the defn call
19:25arohnerif you want it to be evaluated at run time, you'll have to generate a let statement:
19:27jsandersyeah i went down the let route a bit, but it gives the same results, although i must say i don't understand why
19:27jsanders,(defmacro defn-with-expr [expr args & body] (let [val expr] `(defn ~val ~args ~@body)))
19:27clojurebotDENIED
19:28jsandersoh, oops
19:29jsandersit seems that the let should evaluate expr first, but it does not seem to
19:30arohneroh right, the macro doesn't evaluate its arguments. so the let has to be generated
19:32jsandersright but then it is too late - because I need the the value of (symbol expr) at expansion time, so the let can't be generated
19:35arohnerthis works, but it's icky:
19:35arohner(let [val (eval expr)] (assert (symbol? val)) `(defn ~val ~args ~@body))
19:36jsandersit's not *so* icky
19:37jsandersand it does have the whole "working" thing going for it
19:37jsandersis there no better way for macros to force evaluation of their arguments than a direct call to eval
19:40arohnerputting the arguments in a let is the typical way to do it
19:40arohnerI have another idea, one sec
19:41jsandersok - btw, that failed in the case of a string - but this works for what i was going for
19:41jsanders(defmacro defn-with-expr [expr args & body] (let [val (symbol (eval expr))] (assert (symbol? val)) `(defn ~val ~args ~@body)))
22:32slyphonanyone used "cascade"?
22:56nteonso lein is broken for me, and google pointed me at this (identical) paste: http://pastebin.com/HN9HJ0Aq
22:56tomojnteon: I saw that the other day
22:56tomojor something like it
22:57tomojwhat's in your project.clj?
22:57tomojand have you tried 'lein clean && lein deps'
22:57nteontomoj: doesn't seem to matter; happens in my home directory and my lein project clone just typing 'lein'
22:57nteontomoj: ^
22:58nteontomoj: ah, I think cleaning out maven fixed something similar for me the other day, I will try that
22:58tomojoh, hmm
22:58tomojthat is odd
22:59nteontomoj: yea, that fixed it
22:59tomojwhat'd you do exactly?
22:59tomojremove stuff from your ~/.m2 ?
22:59nteontomoj: cd ~/.m2/repository; rm -rf *
23:00nteonthen
23:00nteonlein-stable self-install
23:00tomojodd, wonder what the problem was
23:02nteontomoj: lein for me is symlinked to the bin/lein in my clone of the lein repo, that lein is suppose to pull all its deps from its lib folder. having that work after deleting the jars in the m2 repo suggests it was pulling stuff from the maven repository and clashing, somehow
23:02nteonthats my best guess
23:04nteonah ha!
23:04nteonI can reproduce.
23:05tomojis that a bug, then?
23:07nteonhaving clojure 1.1.0 in maven (but not 1.1.0-master-SNAPSHOT) causes lein to break
23:08tomojhmm
23:08tomojonly on edge lein?
23:09tomojI just removed 1.1.0-master-SNAPSHOT, now I have 1.1.0 and 1.2.0-master-SNAPSHOT, but 'lein help' from my homedir works fine
23:09tomojbut I'm using stable lein
23:16nteontomoj: maybe it was having both 1.1.0 and 1.1.0-master-SNAPSHOT
23:17kylesmithis anyone successfully using leiningen for native dependencies?
23:17tomojbut, that was working too :)
23:18tomojkylesmith: there's a plugin for that
23:18schizmgr
23:18tomojkylesmith: see for example http://wiki.github.com/ztellman/penumbra/getting-started
23:18schizm[20:17:51][wf:.../projects/vimclojure]> java -cp ../clojure/clojure-1.1.0/clojure.jar:../clojure/clojure-contrib-1.1.0/clojure-contrib.jar:build/vimclojure.jar com.martiansoftwar
23:18schizme.NGServer 127.0.0.1
23:18kylesmithyes, I have the plugin, and it downloaded all the files perfectly, but it didn't put them on java.library.path
23:18schizmit can never find the com/martiansoftware/NGServer with that
23:18schizmyet all of those jars are there
23:19tomojkylesmith: ah, hmm
23:19nteontomoj: doesn't work with 1.1.0 and not -master-SNAPSHOT. so whatever reason, my setup is dieffferent from yours :)
23:19tomojkylesmith: you ran lein native-deps?
23:19kylesmithtomoj: yep
23:19tomojit seemed to work fine for me for penumbra, with lein swank. dunno anything about it, really, though, sorry
23:20psykoticdoes the #(... % ...) syntax support varargs? i.e. i want the equivalent of (fn [& args] ...)
23:21schizmwoah, trippy...if I just include the vimclojure.jar it works, if I include any of the clojure.jars it fails
23:21schizm'works' as in I assume it won't when firing it up in VIM
23:21schizmanyone have vimclojure in cygwin/windows working?
23:22tomojthat sounds like fun
23:22schizm:)
23:22tomojpsykotic: I don't think so.. how would you refer to them?
23:22tomoj#(... %args ...) ?
23:22psykotictomoj: or some other % symbol
23:22tomojinteresting idea
23:23tomojaha
23:23tomoj,'#(%&)
23:23clojurebot(fn* [& rest__4221] (rest__4221))
23:24tomojnever knew that
23:24psykoticnice
23:24kylesmithtomoj: I figured it out. I had [[native-deps "1.0.0"]] under the regular dependencies, rather than dev dependencies. Perhaps that should give an error message?
23:24tomojkylesmith: perhaps :)
23:24tomojI have no idea how it works
23:24psykotic,(#(+ %&) 1 2 3)
23:24clojurebotjava.lang.ClassCastException
23:24psykotic,(#(apply + %&) 1 2 3)
23:24clojurebot6
23:24psykoticthere we go
23:25psykotic,(#(do [%1 %&]) 1 2 3)
23:25clojurebot[1 (2 3)]
23:25kylesmithokay, next library: does clojuratica work with leiningen yet?
23:25tomojoh wow
23:25tomojthat do trick is neat
23:25tomojnot sure whether I like it
23:26tomojI usually resort to fn at that point
23:26psykoticwell, the alternative is fn. you can't do "bare" #
23:26tomojyeah, it's neat
23:27psykoticeven with this, i think i still prefer my $ alias for partial, since i don't have to spell out apply when i'm partial-ing with multiple arguments remaining
23:28psykotice.g. ($ + 2 3) vs #(apply + [2 3] %&)
23:29psykotici'm doing some things where i'm using -> for a pipeline, and all the functions in the pipeline are partially applied, so spelling out 'partial' constantly is making the code extremely ugly
23:30tomojthat sounds strange
23:30psykoticit's for monads
23:30schizmso noone has done vimclojure in windows?
23:30schizmthat makes me sad
23:30tomojyou mean like (-> foo (partial x y z)) ?
23:30psykoticmaybe i'll find a better way to write it, but i'd rather not build special syntax
23:30schizmI just want to try clojure out :(
23:30clojurebotClojure ranked #21 on 8/14/2009
23:30tomojthat looks weird
23:30psykotictomoj: yes, except the pipeline is generally much longer, etc
23:31psykoticusing the $ makes the name of the function that does the work more visible
23:31tomojso, the partially applied functions return more functions?
23:31psykoticalso, it's reminiscent of haskell's $
23:31psykoticno
23:31savannischizm: I have done vimclojure, but not anything advanced and not on Windows.
23:31psykotica partially applied function is itself a function awaiting the remaining arguments before it invokes the original
23:31tomojpsykotic: my confusion is that, in (-> foo (partial x y z)), it seems to me that this is not (x y z foo), but (foo x y z)
23:31schizmsavanni: tks
23:32schizmcan't get the damn vim leader to fire anything off, just fails
23:32schizmsigh
23:32tomojer, (partial foo x y z) I suppose
23:33savannischizm: "fire anything off"? Are you referring to the Nailgun system?
23:33tomojso in (-> foo (partial x y z) (partial a b c)), you've got (partial (partial foo x y z) a b c)
23:33tomojwhich looks... strange to me
23:33schizmsavanni: the leader simply takes me into the mode s puts me in, (leader-sr)
23:33psykoticyeah i think you're right
23:33schizmie. nothing happens
23:33psykoticanyway, thanks for the %& tip, looks like you learned about that too :)
23:33schizmit's unfortunate this has to be so difficult :/
23:34tomojschizm: yep :(
23:34psykotictomoj: btw, i think what i wanted was ->>
23:34tomojbut, the reason it's easy for me is because people have put in work making it easy for my platform :)
23:34tomojpsykotic: ah, that makes more sense to me
23:34psykoticthis why i won't need partial application
23:34psykotic*way
23:34psykotic->> is SO close to being like haskell's do notation
23:35savannihuh... I actually don't know what the leader is. But I only have syntax hilighting, rainbow parenthesis, and indent working.
23:35psykoticall it needs is support for :let for binding intermediate function call results to names
23:35savanniAnd all of that is on Linux.
23:35schizmsavanni: the vim leader, for special modes
23:35schizmusually \, mine is remapped to ,
23:35savanni*OH*
23:35schizmala: Open a REPL within Vim by typing \sr (or <local-leader>sr; the default local leader is the back slash )
23:38schizmsavanni: rainbow matching, etc all works
23:38schizmit's the REPL within VIM That I kinda wanted
23:40savanniYeah, I can't help with that. I never actually tried to make it work.
23:58psykoticis there a good reason for why the seq function isn't a multimethod that defaults to the current behavior for collections but otherwise allows, say, class-based dispatching, so you don't have to called all those class-specific *-seq functions for java classes?