#clojure logs

2010-06-29

01:13itistoday,(map #(.toString %) (seq (.listFiles (File. ".") (reify FilenameFilter (accept [f s] (not (.startsWith s ".")))))))
01:13clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: File
01:14itistoday,(map #(.toString %) (seq (.listFiles (java.io.File. ".") (reify java.io.FilenameFilter (accept [f s] (not (.startsWith s ".")))))))
01:14clojurebotjava.lang.IllegalArgumentException: Can't define method not in interfaces: accept
01:14itistodayok, why does that happen?
01:14itistodayit works with proxy
01:15itistodayhere's a simpler version:
01:15itistoday,(seq (.list (java.io.File. ".") (reify java.io.FilenameFilter (accept [f s] (not (.startsWith s "."))))))
01:15clojurebotjava.lang.IllegalArgumentException: Can't define method not in interfaces: accept
01:15itistoday,(seq (.list (java.io.File. ".") (proxy [java.io.FilenameFilter] [] (accept [f s] (not (.startsWith s "."))))))
01:15clojurebotjava.lang.RuntimeException: java.lang.IllegalStateException: Var null/null is unbound.
01:16itistodaywell, the proxy version works on my machine, clojurebot probably blocks file access
01:17itistoday,reify
01:17clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/reify
01:17itistoday,(doc reify)
01:17clojurebot"([& opts+specs]); reify is a macro with the following structure: (reify options* specs*) Currently there are no options. Each spec consists of the protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Methods should be supplied for all methods of the desired protocol(s) and interface(s). You can also define overrides for methods of Object. Note that a
02:23LauJensenMorning all
02:26LauJensen,(seq (.list (java.io.File. ".") (reify java.io.FilenameFilter (accept [_ f s] (not (.startsWith s "."))))))
02:26clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission . read)
02:26LauJensen$mail itistoday You forgot the explicit this argument: (seq (.list (java.io.File. ".") (reify java.io.FilenameFilter (accept [_ f s] (not (.startsWith s "."))))))
02:26sexpbotMessage saved.
09:01jfieldsis there a way to make a function globally available? Say I want to make fnil (http://groups.google.com/group/clojure/msg/f251cfd9baab440a) available everywhere without putting a :use in every namespace, how would I do that?
09:07chouserjfields: patch clojure.core
09:11lpetitjfields: or place it in your own clojure.patch namespace, and bootstrap your clojure.patch namespace early in your project. Then from everywhere you can access it via normal fully qualified namespace resolution: clojure.patch/fnil . This will have the added benefit of being able to easily spot where you introduced such "patches".
09:12jfieldsthanks chouser and lpetit
09:12lpetitchouser: is it too late to make comments on early chapters of your book ?
09:12chouserlpetit: not at all
09:14lpetitchouser: I've just read chapter 2, and some things made me uneasy. I'll try to review it again (didn't take notes, was on the car during traffic jams) and share my thoughts with you.
09:14lpetituneasy may not be the appropriate term.
09:14chouserlpetit: that would be great, thanks!
09:15lpetitHTH
09:17jfieldslpetit, is there a blog entry or something you can point me at that shows how to " bootstrap your clojure.patch namespace early in your project"
09:18lpetitjfields: :/
09:18jfieldsI'll take that as a no :)
09:19lpetitjfields: do you have some "entry point namespace" already ? :/
09:19jfieldsI'm not using lein, I'm just starting a simple app from ant
09:19jfieldsyes, i do
09:20lpetitjfields: then maybe just placing a (:refer 'clojure.patch) in the top of this "entry point namespace" should suffice
09:21jfieldslpetit, cool, I'll look into :refer, I haven't ever seen that before. thanks.
09:22chouserif foo.bar/my-global is acceptible for getting to it from everywhere, you should be able to add -i foo.bar to your clojure.main command-line to get it loaded early enough
09:22lpetitjfields: refer is in charge of "loading" the namespace in the clojure environment, while keeping the current namespace intact (not creating any new mapping)
09:22lpetitchouser: yes !
09:24jfieldsokay, thanks lpetit and chouser, I'll try that stuff out.
09:24chouserrefer only bring in vars of namespaces that have already been loaded
09:26rhickey,(clojure-version)
09:26clojurebot"1.2.0-master-SNAPSHOT"
09:26rhickey(doc fnil)
09:26clojurebot"([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched."
09:29shooverchouser: look at my agent thread instead. it's much easier
09:30lpetitjfields: my bad. As chouser pointed out, it's not refer you must just, but just plain old require
09:30shooverchouser: and by easier, I mean I want your opinion
09:31lpetits/must just/must use/g
09:31sexpbotlpetit: Format is sed [-<user name>] s/<regexp>/<replacement>/ Try $help sed
09:31lpetits/must just/must use/
09:31sexpbots/must use/must use/g
09:31lpetitgrmlml
09:31chousershoover: shorter but stickier :-)
09:32shooverchouser: that's debatable, but I take your point
09:32chousershoover: thanks for reminding me aobout it though. I read it but didn't have the time to look into it before.
09:33shooverchouser: no problem
09:34chouserok, I'm thinking it's unintentional. The action has failed, so I can't think of any problem with now doing a send.
09:35shooverI figured. It was mentioned in the wiki, but then so was "not a promise of a feature..."
09:37shooverIt get stickier when I realize my handler fn has the wrong number of arguments and that gets eaten too. I suppose that train has to stop somewhere, though, and I can't expect that to bubble up
09:39chouseryeah, unfortunately errors in error handlers have to be explicitly ignored.
09:42chouserok, I think I have a fix.
09:43shooverthat's better than an opinion! I'll take it!
09:43chouserrhickey: do you agree that sends should be allowed from agent error handlers?
09:43chouserthe current behavior is to collect them as "nested" sends in the agent, and the silently throw them away.
09:44rhickeychouser: dunno, I'm always reluctant to see people try to use agents instead of queues
09:45rhickeybut not a real reason to prohibit
09:48rhickeychouser: but you have to be extremely careful not to open a reentrancy hole in trying to support them
09:50chouseroh. ugh, you're right.
09:50shooverrhickey: in the queue setup you would have a queue in a ref and some other thread actively pulling from the queue?
09:50chouserno, wait I'm not seeing the race yet.
09:52chousershoover: probably a blocking queue that the error-handler pushes on
09:53rhickeyshoover: no, use a regular concurrent queue or message queue
09:53chousershoover: and one or more threads sitting blocked on popping from the queue
09:53shooverright, but with just agents you don't need the sitting blocked thing
09:54chouserrhickey: so I've got a naive patch here, which if it has a race I'm not seeing it. May I make a ticket? Against 1.2?
09:54dsophmm how to define a service in compojure 0.0.4 similar to (defservice?
09:54rhickeychouser: sure, thanks
09:58yacinhow can i access a file, inside a 'lein uberjar' jar from within clojure?
10:04pjstadigI'm getting a OOME PermGen space
10:04pjstadigmy hunch is because of a (eval (read-string "...")) that I'm doing
10:05dsopyacin: there is something like URL url = this.getClass().getResource("/hello.jpg"); in java, so you have to use this in clojure code I guess
10:05pjstadigis that an incorrect hunch?
10:06pjstadigin a cursory glance at the compiler i didn't see it generating any classes in the code path i'm taking
10:07Chousukepjstadig: eval generates a class dynamically IIRC. did you enable class garbage collection?
10:07pjstadigChousuke: how do i do that?
10:07Chousukenot sure. it's some -XX option to the JVM
10:08pjstadighmm
10:08Chousukeor -X I suppose
10:08Chousukehm
10:09chousershoover: http://www.assembla.com/spaces/clojure/tickets/390
10:09shooverchouser: thanks for getting into it
10:09Chousukechouser: you know more about permgen errors than I do, right? :P
10:09pjstadighttp://bit.ly/cAdF5t made me think that PermGen shouldn't be so much an issue...but there is no mention of eval
10:10pjstadigi had assumed that eval generates classes, but like i said i couldn't see it doing that in the path i take through the compiler
10:10chouserChousuke: maybe not :-/
10:11chouserpjstadig: eval will create at least one class, but I think it does so with a separate classloader
10:11chouserthis means that once let go of all references to the object(s) in the eval, that class and its classloader will be GC'd
10:12pjstadigright
10:12rhickeychouser: that patch is unlikely to fly unless accompanied by a thorough analysis of its impact, else you are just putting that on the committer
10:13chouserrhickey: ok
10:13pjstadigi'm read-string'ing a call to a function, then evaling that, and i'm not holding on to any reference that i know of
10:20rhickeypjstadig: what does the string look like?
10:21pjstadig"(the-function-im-calling #=(clojure.lang.PersistentArrayMap/create {:some "keywords" :and "strings}))"
10:22pjstadigif i try to recreate it on a smaller scale I get a "GC overhead limit exceeded" OOME instead of a permgen
10:30rhickeypjstadig: got a gist of that?
10:31pjstadighttps://gist.github.com/a977b8acde92665683b1
10:32rhickeypjstadig: not the string, the smaller scale test that gives you OOME
10:33pjstadigoh hehe
10:33pjstadigsure
10:33Chousukepjstadig: that's not a proper string either :P you didn't escape the quotes and one is missing
10:33pjstadigsheesh! tough crowd :)
10:37pjstadighttps://gist.github.com/9185dca57057102d765a
10:38pjstadigi'm running this on a jvm with a 20mb
10:38pjstadigso as not to take forever to fail
11:00hugodis the lack of a : in the ns import clause in clojure.contrib.find-namespaces deliberate?
11:01rhickeypjstadig: how long does it take to fail for you?
11:02pjstadigrhickey: hmm...i didn't time it exactly, but it feels like no more than 5-10 minutes
11:07rhickeypjstadig: ok, I see it here
11:24arohnerI'm trying to daemonize a clojure process on OSX, and I'm getting this exception:
11:24arohnerclojure.lang.Compiler$CompilerException: java.lang.InternalError: Can't start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application's Info.plist or on the command line (core.clj:19)
11:25arohnerdoes anyone have a decent explanation for what's going on?
11:36pjstadigrhickey: does it even make sense to think that eval is generating classes, thus leading to the PermGen? or is that a totally erroneous idea?
11:38rhickeypjstadig: you can be running out of memory due to another leak, not sure PermGen is driving the leakage
11:39pjstadigso it may not even be clojure...could be some other component?
11:40pjstadigbut isn't the PermGen a fixed space that shouldn't be affected by other heap partitions? or is it more dynamic?
11:50arohneranother clojure daemon question. The apache-commons-daemon library says to not spawn threads while the JVM has root privileges. When are the clojure thread pools created?
11:52arohnerin Agent.java, there's a line final public static ExecutorService pooledExecutor = executors.newFixedThreadPool(...). Does that spawn new threads when it runs?
11:58hiredmanarohner: clojure doesn't run as root unless you run the jvm as root
11:59arohnerhiredman: right. but when starting a daemon that needs to write a pid in say, /var/run, commons daemon says start the JVM as root, then it will drop privileges
11:59hiredmanthe jvm does not have any ability to fork as a different user or switch users
11:59arohnerbut apache commons daemon does
12:00hiredmanit does trickery
12:00hiredmanbut it does not do that
12:00arohnerhiredman: doesn't do what? drop privileges?
12:01hiredmanhttp://commons.apache.org/daemon/jsvc.html#How_jsvc_works
12:02hiredmanick
12:13danlarkinarohner: might just be easier to have a bash script fork/exec into you
12:13danlarkinthen it's easy to trap signals, close file descriptors, etc
12:14arohnerdanlarkin: I'm already most of the way into http://github.com/arohner/lein-daemon
12:14arohnerdanlarkin: doesn't the commons daemon library handle most of that?
12:15danlarkinarohner: never used it... probablyy it does. But if I were going to write clojure code intended for daemonizing I'd deal with the messy bits in shell and leave java blissfully unaware
12:16danlarkinor use daemontools or something
12:17danlarkinwhich is time-tested rock solid
12:17danlarkinwho knows about this apache commons daemonizer thing
12:35ckirkendallarhoner: did you try -Djava.awt.headless=true, I believe the issue has to do with AWT needing to communicate in xwindows on mac.
13:51Licenserfogus: you're there
13:58arkhdefn: ping
14:12jcromartiepong
14:18bhenryif i do (with-connection db
14:18bhenry  (with-query-results rs ["select * from blogs"]
14:18bhenry    ; rs will be a sequence of maps,
14:18bhenry    ; one for each record in the result set.
14:18bhenry    (dorun (map #(println (:title %)) rs))))
14:18bhenryfrom http://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples how can i get rs into something i can use later instead of only having the side effects of println in the dorun?
14:18clojurebotPONG!
14:19thorstadtbhenry: yes, you should be able to do a doall, doseq, etc.
14:20thorstadtas long as you force the evaluation completely before you are outside of with-query-results
14:20bhenrynice thanks.
14:24bhenry(doall rs) worked wonderfully
14:25thorstadtawesome, glad to help :-)
14:31hugoddefrecord seems to get very confused by (require ... :reload-all)
14:38BMephWhat do folks here use for an editor?
14:39chouseremacs, vim, various IDEs
14:41mtopolnikhi
14:42mtopolnika noob here, let me introduce myself
14:42mtopolniki work in zagreb, croatia for a firm that uses clojure in production
14:42mtopolnikone of the lucky few around here :)
14:43mtopolniki would like to know if there's a way in clojure to call a java method by name that is not known in advance
14:44lancepantzman, i would love to go to croatia
14:44lancepantzlooks like a beautiful place
14:44mtopolniksomething like (eval (list (symbol ".setTime") (java.util.Date.) 23423424))
14:44chousermtopolnik: there is
14:45mtopolniklancepantz: it's lovely here, true :) at the seaside, as well as in the mountains
14:45ckirkendallBMeph: eclipse counterclockwise
14:45chousermtopolnik: one way is to use clojure.lang.Reflector, but eval can perform better if you can cache its results
14:45mtopolnikthe above code will fail because an object cannot be embedded in code
14:46qbg,(clojure.lang.Reflector/invokeInstanceMethod "123" "length")
14:46clojurebotjava.lang.IllegalArgumentException: No matching method: invokeInstanceMethod
14:47chouserthat is, if the same method will be called multiple times, you can build a function on-the-fly (costing some time) that will call the method, but then subsequent calls through that generated function will be very fast.
14:47qbg,(clojure.lang.Reflector/invokeInstanceMethod "123" "length" nil)
14:47clojurebotjava.lang.NullPointerException
14:47qbg,(clojure.lang.Reflector/invokeInstanceMethod "123" "length" (make-array 0))
14:47clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$make-array
14:47jkkramer,(clojure.lang.Reflector/invokeInstanceMember "123" "length")
14:47clojurebot3
14:48qbg,(clojure.lang.Reflector/invokeInstanceMethod "123" "length" (to-array nil))
14:48clojurebot3
14:48mtopolniki need this to transform a clojure map into java beans, so there will be no repeated calls
14:48mtopolnikbut speed is not a high priority here
14:48mtopolnikthanks, I think this will do it for me
14:49mtopolnikright now i have a solution that uses java reflection api
14:49mtopolnikit's not as elegant as this
14:49chouser,(let [d (java.util.Date.)] (clojure.lang.Reflector/invokeInstanceMethod d "setTime" (to-array [23423424])) d)
14:49clojurebot#<Date Wed Dec 31 22:30:23 PST 1969>
14:50mtopolnikso, Reflector needs an array of method args?
14:50chouserthis is probably about 30 or 40 times slower than calling through a regular function
14:50mtopolnikjust like java reflection
14:50chousermtopolnik: yes
14:51mtopolnikso, using java reflection would probably be speedier
14:51mtopolnikbut i don't think this is a major factor, really
14:51chouseronly slightly speedier, if at all.
14:51mtopolniki'm calling out to axis2
14:51chouserthat's just how slow Java reflection is in my experience.
14:52mtopolnikmaking a soap call will surely dwarf any time spent preparing the java bean for the call
14:53chouser:-)
14:53mtopolnikusing Reflector is simpler because i dont' need to know the exact arg type of the method
14:53mtopolnikright now i deduce that by examining the getter
14:53mtopolnikobviously, that's even slower code
14:54chouserwell, that's probably what Reflector is doing for you
14:54mtopolnikyes, and what i expected a form like ((symbol ".setTime") d 23234) to do
14:55chouserbut of course that doesn't work
14:55mtopolniksure
14:55chouserbecause .setTime is not a real function, it's a reader macro that expands to (. d setTime 23234), and . is a special form
14:56mtopolnikit cannot be made to work even with eval
14:56Chousukehmm
14:56Chousuke,'(.foo)
14:56clojurebotjava.lang.IllegalArgumentException: Malformed member expression, expecting (.member target ...)
14:56chouserthat's not quite true
14:56mtopolnikeither form would be fine for me
14:56mtopolnik(. method) or (.method)
14:57mtopolnikbut i couldn't make either work
14:57chouserreflection is probably faster than using eval to generate the call and then calling it.
14:57mtopolnikyou can make eval understand the (.method) part
14:57chouseryes
14:57mtopolnikbut i cannot refer to an object in a form given to eval
14:57chouserright, you'd have to pass that in
14:57mtopolnikexcept if it's a global symbol
14:57Chousukechouser: looks like .foo is not a reader macro
14:58Chousukepretty weird.
14:58Licenserchouser: are you the second JoC guy?
14:58Chousukeor did I just test it wrong.
14:58chouser,`(.valueOf 5)
14:58clojurebot(.valueOf 5)
14:58chouserhm
14:58chouserLicenser: yep
14:58ChousukeI suppose the compiler checks for those
14:58Chousukeso clojure has an infinite number of special forms ;P
14:59Chousukewell, except java method names probably have some limits
14:59chouseroh right, not quite a reader macro
14:59chouser,(macroexpand `(.valueOf 5))
14:59clojurebot(. 5 valueOf)
14:59chouserit's expanded after reader macros but before regular macros. :-)
14:59chouseror something
15:00mtopolnikrelated to this, here's what i was playing with:
15:00Licenserchouser: I#ve a very very big wish for you :)
15:00mtopolnikuser> (eval (list (fn [] 1)))
15:00mtopolnik1
15:00mtopolnikuser> (let [b 1] (eval (list (fn [] b))))
15:00mtopolnik; Evaluation aborted.
15:00mtopolnik; No matching ctor found for class user$eval__10973$fn__10975
15:00mtopolnikuser> (let [b (fn [] 1)] (eval (list b)))
15:00mtopolnik1
15:00mtopolnikuser> (defn bb [] (let [b (fn [] 1)] (eval (list b))))
15:00mtopolnik#'user/bb
15:00mtopolnikuser> (bb)
15:00mtopolnik; Evaluation aborted
15:00mtopolnik; java.lang.ClassNotFoundException: user$bb__10946$b__10948
15:00Licensercan you convice the pdf compiling guys to make the pdf indexed with a TOC so that I can use it on an iPad nicely?
15:01mtopolnikfrom these examples i can see that there's a problem with eval and lambdas
15:01mtopolnikthey don't get on eval's classpath
15:01mtopolnikand i wanted to use a lambda to encapsulate my objects
15:02chouser(let [m ".setTime" d (java.util.Date.)] ((eval `(fn [a# b#] (~(symbol m) a# b#))) d 23423424) d)
15:03chouserLicenser: your MEAP doesn't have an expandable outline? I'm pretty sure mine does.
15:03technomancychouser: the review copy doesn't
15:03Licenser*hecks on the computer*
15:04mtopolnikchouser: wow, that's some pretty nice code!
15:05chousertechnomancy: :-(
15:05Licenserchouser: I didn't computer but not on the iPad I'm not sure what the differences are but I know it works on the iPad since i got it for other pdf's (non books)
15:05technomancychouser: reviewers can tough it out. =)
15:05mtopolnikso you use eval only to produce the lambda!
15:05technomancyI got it all concatenated and loaded into my kindle easily enough.
15:06chousermtopolnik: yes. Add some type hints and that lambda will call the method without any runtime reflection, making if very fast
15:06mtopolnikthanks, chouser, i think this is a winner!
15:06chouser`(fn [^java.util.Date a# b#] ...)
15:07mtopolniki won't be able to do that as my code will walk through a map and generate java setter calls from that
15:07chousermtopolnik: but note if you just throw away the lambda returned by eval each time, it's likely much slower (and more likely to have PermGen issues) than if you just use Reflector.
15:07mtopolnikso i don't know the types
15:07mtopolnikhm... PermGen issues would be a problem
15:08chouseroh. well, then I'd probably recommend Reflector. Without type hints, the code eval generates just calls into Reflector anyway.
15:08mtopolniki would create a permgen mem leak?
15:08chousernot necessarily
15:09mtopolnikreflector is a nice solution, too
15:41bigwavejakeI want to add a lein plugin to my project, but I don't want the version from clojars. I've downloaded a forked version of the project and done a lein install. What do I need to add to my project to get the plugin to work?
15:57arohnerbigwavejake: change the version in the forked version to be different form the clojars one
15:57arohnerbigwavejake: then update your project.clj to point at your unique version
15:58arohnertechnomancy: I wrote http://github.com/drewr/lein-daemon , which I'm pretty happy with, except that the plugin ships with code that needs to run at runtime. I can split it into two projects, or list the dependency twice, once in :dependencies, once in :dev-dependencies (ick). Is there another way?
16:01technomancyarohner: I can't think of another way, sorry. =\
16:01technomancyarohner: oh... you might be able to use classifiers for that
16:01arohnertechnomancy: classifiers?
16:01technomancyit's a feature that was recently added... I am not even really sure what it's for, but you could read up on them in the mvn docs.
16:02technomancyI think it's for publishing things like test-jars as separate artifacts.
16:03lancepantzarohner: i ran into the same issue, ended up adding it in both deps and dev deps
16:05arohnerhah, actually, I wrote http://github.com/arohner/lein-daemon, not http://github.com/drewr/lein-daemon
16:05LauJensenhehe :)
16:05LauJensenarohner: to tell them apart you could rename your repo to 'leinjure'
16:06arohnerLauJensen: it's cool, they're the same project. drewr forked from me, I was just checking out what the diff was
16:06LauJensenah ok... even still... :)
16:09drewrlol
16:11drewrarohner: no diff yet, but looks like something I'll be trying, which means I'll most likely be submitting patches ;-)
16:11arohnerdrewr: cool, bring it on :-)
16:11arohnerdrewr: I have the same feeling. I tend to patch every project I use
16:59pjstadigrhickey: i've figured out my problem
17:00pjstadigit's because keywords are never GC'ed
17:01AWizzArdpjstadig: who keeps a reference to them?
17:01pjstadigKeyword.table
17:01AWizzArdoho
17:02AWizzArdpjstadig: maybe it would be good enough if it just kept the last N keywords?
17:04pjstadigor perhaps use weakrefs
17:04seoushiI'm looking for a way to use a generated vector with let. for example "(let (vec x 1 y 2) (+ x y)) => 3". is there a function I can use?
17:06serp_perhaps a macro could help you
17:06seoushiI've been trying but can't get it to work right
17:06hiredmanspeaking of keywords
17:06hiredmanhttp://groups.google.com/group/clojure-dev/msg/a5b527caa63ab3c0
17:07pjstadigcool!
17:11kotarakHow can I reach some op of clojars?
17:14vasily_pupkinhi
17:14technomancykotarak: I think it involves a flight to Australia at this point. =\
17:14vasily_pupkini just started learning clojure (and jvm)
17:14technomancynext time I see _ato around I am going to have to talk him into giving someone else the keys to clojars
17:15vasily_pupkini try to use java library for XMPP - smack
17:15kotaraktechnomancy: :( Someone hijacked vimclojure there. Not very nice. And _ato is going submarine...
17:15technomancyouch
17:15vasily_pupkinsome classes loaded ok - org.jivesoftware.smack.XMPPException, etc, but main XMPPConnection fails with [Thrown class java.lang.NoClassDefFoundError]
17:15vasily_pupkin
17:16kotarakThis "everyone can push arbitrarily "fixed" (read: broken) variants" sucks.
17:16vasily_pupkinit placed in the same jar, and TAB key shoes it in slime repl
17:16vasily_pupkinwtf? :]
17:16AWizzArdkotarak: oh :(
17:17technomancykotarak: it's not bad if ops are responsive; the alternative of "wait weeks for your group-id to get approved" is much worse IMO.
17:19kotaraktechnomancy: yeah. I'm actually in favor of easily getting group-id's (with the right of prior art so-to-say for established projects). I'm just not keen of seeing 6 different vimclojure (all not from me), which are "fixed" in various ways. I somehow don't get this "fork me" stuff.
17:19technomancykotarak: it does seem to be used an awful lot more than it should.
17:20thorstadtseoushi: a very hackish macro that will only work with basically the example you gave is: (defmacro contrived-let [vecx & body] `(let [~@(rest vecx)] ~@body))
17:20technomancyI don't understand why you'd push a fork unless you tried to get your fixes upstream and they were unresponsive.
17:21thorstadtseoushi: i can't think of a reason to use anything like this, ever, though
17:21kotaraktechnomancy: my suspicion is, that they use clojars as "local repo". I haven't provided an SNAPSHOT for 2.2, yet.
17:22seoushithorstadt: thanks. I still don't understand macros all that well. Is there somewhere that describes all the special symbols? for example I don't really know what @ means, and I think ~ means use the value from the param
17:22thorstadtseoushi: http://clojure.org/reader
17:23thorstadtabout half way down
17:23thorstadt~@ means expand the evaluated contents of this list here
17:23clojurebot@ , {a b c]
17:24seoushithanks
17:24thorstadt'~' just means evaluate (unquote)
17:25vasily_pupkinhm
17:25thorstadtif you were to modify this macro to use '~' instead of '~@' it would end up looking like (let [(x 1 y 2)] ...)
17:26vasily_pupkinlooks like clojure couldn't load class with anonymous subclass
17:26thorstadtwhereas ~@ 'splices' the evaluated form into your expansion
17:28thorstadtseoushi: so (defmacro my-let [vecx & body] `(let ~(vec (rest vecx)) ~@body)) would also work
17:31seoushithanks much. The only thing I don't really understand is the "rest" function, I would think it would jsut chop off the first element.
17:31thorstadtit does
17:31thorstadtit's a terrible example
17:31thorstadtit doesn't actually evaluate the vector
17:31thorstadtthe first element is 'vec'
17:33thorstadt,(rest '(vec x 1 y 2))
17:33clojurebot(x 1 y 2)
17:33seoushioh.. I see now, it's cutting off the first of the thing I passed in, not the evaluated version
17:33thorstadtcorrect
17:33thorstadtthe problem here is that in order to evaluate (vec x 1 y 2) x and y have to have meaning
17:34thorstadt,(vec 'x 1 'y 2)
17:34clojurebotjava.lang.IllegalArgumentException: Wrong number of args (4) passed to: core$vec
17:34seoushiright
17:36thorstadtor rather
17:36thorstadt(vec '(x 1 y 2))
17:36thorstadt,(vec '(x 1 y 2))
17:36clojurebot[x 1 y 2]
17:37thorstadtif you wanted to actually evaluate the form
17:37thorstadtyou could do this:
17:37thorstadt(defmacro my-let [vecx & body] `(let ~(eval vecx) ~@body))
17:38seoushiI actually did try something like that
17:38thorstadtso that (my-let (vec '(x 1 y 2)) (+ x y)) would work
17:38seoushibut the stuff in there was unbound so it failed
17:38seoushiah
17:39thorstadtwell vec takes a sequence as a parameter
17:39thorstadtyou said (vec x 1 y 2)
17:39thorstadtwhen really its (vec '(x 1 y 2))
17:39seoushiI meant to say vector the first time
17:39seoushibut yeah
17:40thorstadtthe macro doesn't care about the variables, it sees them as symbols
17:40thorstadtthat's why my-let would work
18:15Guest63257hello, I'm developing an application with swing and wanted to develop some component. So I started to write a function but I quickly came to the point where the parent needs to know about the current data of the component so I need a way that the parent can ask the component. But if I want to introduce a function I need something it can be called on so my original function that creates the component needs to return a map or something like
18:15Guest63257that. But from that point on I have something that looks very object oriented so I wonder if there's a more clojuresque way? I hope you understand my problem.
18:23chouserreturning a map of data is perfectly acceptible.
18:23chouserthough it's still worth trying to keep mutable objects separate from immutable data.
18:28Guest63257that would make lots of mutable objects in a larger swing application. It would result in namespaces containing one function which serves as a constructor and other functions just being normal member functions. It's not easy for me to separate the functional part then.
19:02wolfjbhello, been reading en.wikibooks.org/wiki/Learning_Clojure, where can I find more information about defmulti/defmethod? I'd like to know how to make defmethod accept a type rather than a value
19:02wolfjbie generically accept a string or a specific kind of struct and perform some operation on that
19:03wolfjb(defmulti dosomething (fn [v] v))
19:03wolfjb(defmethod dosomething 'string?? ...; do something cool with the string)
19:06Guest63257something like (defmulti dosomething type) (defmethod dosomething java.lang.String [v] ...) ?
19:06wolfjbyes
19:07wolfjbdoes that syntax work?
19:07Guest63257yes.
19:07Guest63257,(doc type)
19:07clojurebot"([x]); Returns the :type metadata of x, or its Class if none"
19:07Guest63257,(type "some string")
19:07clojurebotjava.lang.String
19:10wolfjbawesome!
19:10wolfjbthanks
21:06rhickeyawesome: http://info.azulsystems.com/rs/azulsystems/images/zing_product_brocha4.pdf
21:12danlarkinawful laptop-on-clouds graphic aside, yeah that is _super_ awesome
21:12rhickeyyet another benefit of being on the JVM
21:14danlarkincolor me interested. I wonder how this'll integrate with existing cloud deployments
21:27hiredmandanlarkin: it sounds like amazon would have to offer it, or at least you would need a zing ami or something
21:29danlarkinhrmph
21:30hiredmanI'm seeing stuff like
21:30hiredmanReflection warning, /Users/hiredman/amontillado/src/amontillado/core.clj:27 - call to contains can'\
21:30hiredmant be resolved.
21:31hiredmanwhere 27 is a defrecord
21:31itistodayso i made a mistake, i did this in the repl: (def *warn-on-reflection* true)
21:31itistodaybut that refers to the user namespace
21:31itistodayapparently i need to set clojure.core/*warn-on-reflection*
21:31itistodayso that brings the question: how do i undefine a var?
21:31hiredman(ns-unmap *ns* '*warn-on-reflection*)
21:32itistodayhiredman: thanks!
21:32itistoday$mail
21:32hiredmanthat does not undefine a var, but it removes the mapping from the namespace
21:32hiredmanas payment I demand that you never publicly use $mail again
21:33itistodayhmm.. the bot told me to
21:33itistodayis it /$mail?
21:33hiredmanprivmsg it
21:33hiredmanor ignore it
21:33danlarkinugh
21:33danlarkinthe. worst.
21:34itistodayhow do i send a mail/message to someone that's not online?
21:34itistoday(I promise not to publicly do it :-p)
21:35itistodaysexpbot won't respond to 'help' :-\
21:35danlarkinirc does not have that capability
21:35hiredmanI suggest you send them an email
21:35itistoday... i got a message that way
21:35itistodayfrom sexpbot, so obviously there's a way to do it
21:37itistodayhiredman: i don't have their email... and they didn't have mine. just got a message once i signed on from the bot saying i had mail. which is cool, only problem is i don't know how to reply
21:40danlarkinsend them a text message
21:46itistodayi think i figured it out
21:46itistodayhaha, yes!
21:52itistodayah the power of google and opensource software. i looked up the code for sexpbot, and to send someone a message when they're offline, pm the bot with: $mail <nick> <msg>
21:53itistodaymake sure not to send anything private, as it's really fucking insecure
21:58Raynesitistoday: sexpbot responds to $help <command-name>
21:59itistodayRaynes: but it doesn't respond to $help
21:59RaynesCan't say the command docs are excessively helpful though.
21:59itistodayactually, it does, but it explicitly says it can't help you! :-p
21:59RaynesIndeed. I need to give it a better reply.
21:59itistodayhow am i supposed to ask for help if i don't know the commands?
22:00itistodayif the input is not one of the commands it should present a list of available commands.
22:00itistodayRaynes: but really neat bot btw!
22:01RaynesYou can get a list of commands with $dumpcmds. I actually started on some stuff to generate a list of commands I could put online with docs rather than dump a raw list of commands every time, but I haven't got around to it yet.
22:01RaynesThanks. :)
22:19itistodaywhere is set! defined?
22:19itistodayi can use it but can't find it in the api docs...
22:20itistodayhmm... found it: http://clojure.org/vars#set
22:23trptcolincan anyone verify that scp to clojars.org is working for them right now? i'm getting "Permission denied (publickey)", but i've checked and re-checked my key several times...
22:25itistodaycemerick: of course you are :-)
22:25itistodaycemerick: at least i appreciate it :-)
22:25trptcolinah, nm - weird pasting issue on my part
22:26itistodaycemerick: then again, that might not be much comfort?but, if there's no pushback, well, you know what they say about silence being viewed as condoning
22:26cemerickitistoday: as long as someone is getting something out of it :-)
22:27cemerickI'm not bothered by much, but anything approaching "go away if you're not 133t enough" irks me.
22:27cemerickOK, just flat out pisses me off. ;-)
22:28itistodaycemerick: btw, i just saw your reply to cageface, nice one. i was going to reply to earlier and bring up a similar point as well, but was too tired, and i avoid writing when i'm too tired (for fear of sounding stupid :-p)
22:29chouserI started a similar response, but postponed it when I realized there was no way I could keep up with the pace of that thread.
22:30cemerickI'm really not trying to be confrontational, but some of this just has to be called.
22:32itistodaybtw, how long does your message take on average to appear on the thread? mine have been taking a while, but recently it's speeded up from ~24 hours to about 30 minutes or so
22:32itistoday(I respond via email)
22:33cemerickIt varies a lot. :-/
22:33itistodayhow google hasn't developed a solution for the spam problem boggles my mind
22:45trptcolinon clojars, is there a trick to getting external libraries copied up there? publishing my project jar worked fine, and scp looks like it copies all jars ok, but afterwards the external jars (org.clojars.trptcolin/*) don't appear to be there.
22:59itistodayIs the only difference between set! and def that def will create a var if it doesn't exist?
23:00technomancyitistoday: set! only works on thread-local bindings
23:00itistodaytechnomancy: ok thanks, but other than that they're the same?
23:01itistoday(that and the fact set! doesn't create a var if it doesn't exist)
23:02technomancyitistoday: the main difference is that you should use def and you shouldn't use set! =)
23:02technomancybut yeah, yours is also technically correct.
23:02technomancythe other difference is you sholud never use def inside a function body; only at the top level.
23:02itistodaytechnomancy: well i came across it because i tried doing this in the repl: (def clojure.core/*warn-on-reflection* true)
23:03itistodayand that gave me this error: java.lang.Exception: Can't create defs outside of current ns (NO_SOURCE_FILE:120)
23:03technomancyoh right; for repl usage set! is ok
23:03technomancyyeah, you can set! fully-qualified or refered vars; that's another difference.
23:04itistodaytechnomancy: not sure what you mean by refered vars. this? (set! *warn-on-reflection* true)
23:04itistodaycause i get: java.lang.Exception: Unable to resolve symbol: *warn-on-reflection* in this context (NO_SOURCE_FILE:121)
23:04technomancyitistoday: refer is the function that makes vars from other namespaces visible in the current ns
23:05technomancyitistoday: sounds like your current namespace is screwed up
23:05itistodaytechnomancy: not screwed up i don't think, just in the repl (namespace user)
23:05technomancyall namespaces have all vars in clojure.core visible by default
23:06itistodayhmm.
23:06itistodayyou're right
23:06itistodayit was screwed up
23:06itistodaymust be a bug in 1.2...
23:06itistodaydon't know how i caused it
23:08technomancyif you create a new ns with in-ns then you don't get clojure.core refered automatically
23:10itistodaytechnomancy: thanks, didn't know that. kinda odd... does a namespace created with 'ns' have them referred?
23:10itistodayit seems too...
23:10itistodaywonder why they did that...
23:11itistoday(made in-ns not autoinclude them like everything else)
23:11phenom_thoughts on clojure vs scala ?
23:13technomancyitistoday: ns does auto-refer; in-ns does not
23:14technomancyphenom_: scala is "a better Java"
23:14itistodaytechnomancy: yeah i discovered that, was wondering why though (why in-ns doesn't)
23:14itistodaytechnomancy: performance?
23:14technomancyitistoday: in-ns is low-level
23:15technomancyns is a macro which expands to a bunch of calls starting with in-ns
23:15itistodaytechnomancy: ah ok.
23:15technomancy,(macroexpand-1 '(ns user))
23:15clojurebot(do (clojure.core/in-ns (quote user)) (clojure.core/with-loading-context (clojure.core/refer (quote clojure.core))))
23:15technomancythere you have it
23:16itistodaypretty simple actually :-)
23:19itistodaythere are no type hints for primitives? only coercion?
23:19itistoday(primitives, not primitive arrays)
23:22itistodaywhy are primitives treated differently?
23:26technomancyitistoday: probably because they're not objects
23:26itistodaytechnomancy: ah... but primitive arrays are objects?
23:26technomancyitistoday: you can have a method signature that's just Object, Object, Object, etc, and it will work fine with any non-primitive you throw at it
23:27technomancyI don't know about arrays.