#clojure logs

2010-02-26

00:00brandonwok konr that sounds more what i was thinking
00:01jcromartieany experience with the various http clients?
00:01jcromartieI am just using it for automated testing so it doesn't have to be a superstar lib
00:01jcromartiejust work!
00:02konryes, the non-apache one doesn't allow sending files together with other data (multidata (or multipart, or something like that) encoding)
00:03brandonwkonr: i like the idea of not worrying about updating git all the time. plus, relying on clojars would allow easier setting of different versions of clojure on different projects
00:03brandonwmy only question now is, what do you specify in project.clj to get the latest snapshot of clojure & clojure.contrib?
00:04jcromartiebrandonw: you have to pick your versions by hand
00:04jcromartiethat's good for project stability
00:04brandonwright
00:04brandonwi have org.clojure/clojure "1.2.0-SNAPSHOT" and org.clojure/clojure-contrib "1.2.0-SNAPSHOT"
00:05brandonwbut it has an error when trying to download contrib from clojars
00:05brandonwseems to work okay from central, clojure, and clojure-snapshots, but clojars throws an error and lein deps seems to fail
00:09brandonwi can't even find clojure or clojure.contrib on clojars
00:10_atosnapshot releases of clojure aren't on clojars
00:10konrhmmm, that's strange, it's 1.2.0 is also failing here
00:11_atoand real releases aren't either, although there's a redirect to build.clojure.org
00:11brandonwbut lein deps is failing when it can't find it on clojars
00:12_atoodd
00:12_atocan you pastebin the error?
00:14brandonwhmm
00:14brandonwfor some reason, lein deps > output doesn't seem to be writing all of the output to the file
00:16_atotry: lein deps &> output
00:16_atoit's probably writing some of the outout to stderr
00:16_atoor: lein deps 2>&1 > output if you have an old shell and &> doens't work
00:18brandonwthanks, i was wondering what you had to change about the redirect to allow it to capture output from other streams
00:19brandonwhttp://pastie.org/843705
00:24brandonwhere is my project.clj in case you need that, too: http://pastie.org/843711
00:25_atohmm
00:26_atoyou'll need to use 1.2.0-master-SNAPSHOT as the version
00:26_atohttp://build.clojure.org/snapshots/org/clojure/clojure/
00:27jcromartiehave I been using compojure all wrong by doing things like (defroutes foo (GET "/foo/" some-fn))
00:27jcromartiewhere some-fn is just the name of a fn
00:27jcromartiei.e. a defn
00:28brandonwawesome _ato that did it!
00:28brandonwi recall in my git checkout it had master in its name, but i wasn't sure if that carried over to lein or not
00:28_atodon't you ned (defroutes foo (GET "/foo/" (some-fn))) ?
00:28_atobut yeah just calling a function is pretty normal
00:29tomojjust passing a function works
00:29tomojI guess compojure knows enough to call it
00:30tomojif you just pass a function it gets called with the request as a parameter
00:33brandonwokay i think that is enough learning for tonight. i have to figure out how to get lein nailgun to work with vimclojure tomorrow. then i can finally start coding again :)
00:33brandonwthanks for the help again, _ato
00:34_atooh right
00:34_atowhen you return a function it'll call it
00:39jcromartieso congomongo doesn't support sorting
00:39jcromartie?
00:42mabesCan any one explain to me why clojure.contrib.repl-utils/source has to resort to looking up the source in the actual source file?
00:42mabesI'm a lisp noob but I thought one of the benefits of being homoiconic was that your functions were just data so it should be easy to view them without digging up the source file
00:43greghthe source is still compiled (to bytecode)
00:52mabesso, when I create a function in the repl it is automatically compiled to bytecode?
00:52crowbar7mabes: you are sort of right. the functions are just objects which means you don't have a type decloration.
00:52crowbar7that is a big thing with lisp
00:52tomojjcromartie: I was wondering that earlier as well
00:52tomojseems not
00:52crowbar7the source file is irrelivent in reguards to that.
00:53crowbar7I have no clue
00:53crowbar7I'm new to clojure as off a week ago.
00:56tomojI don't think being able to see the source code for a function is a big benefit of code-as-data
00:56tomojthough it wouldn't be hard to do in a lisp
00:57greghmacros are the usual tools used to inspect and modify source as written by the programmer, before compilation happens
00:59tomojI don't think most common lisps keep function source code around, do they?
01:01tomojdefn could put the source in metadata, but that would just be more memory used up
01:01tomojand not really usefully so
01:03mabesyeah, I was running into some cases when I thought it would be useful to look at the code of a function... I can't remember what it was though :)
01:04tomojI was thinking that the only functions you would really need to peek at the source of would be in source files
01:04tomojyou mean you had an exception?
01:08mabesthe repl is a clear exception to that.. if you defined a function at the start of a repl session a long time ago and wanted to see the source you can't unless your screen's buffer has it. Not really an issue of course, but it made me wonder
01:09tomojyeah
01:09tomojgood repls should be able to handle it, though :)
01:13tomojit would be cool to be able to see the source of anonymous functions
01:14tomojwhen I tried a clojure monad tutorial I kept getting back fns without any idea what they did
01:17mabesyeah, that is another good example.. again, not really needed in a production setting but nice for development/debugging
02:57LauJensenMorning crew
03:02G0SUBhello, the clojure lib coding standards says -- "Unroll optional named arguments. Callers should not have to wrap optional named arguments in a map literal"
03:02G0SUB (release-sharks 2 :laser-beams true) ; good (release-sharks 2 {:laser-beams true}) ; bad
03:02G0SUBwhat's the best way to achieve this?
03:03G0SUBI don't want to use c.c.def/defnk
03:03G0SUBis there any other lightweight way to do this?
03:11LauJensen(defn release-sharps [some-int & the-rest] ...
03:11LauJensen(dont ask me what a sharp is)
03:12G0SUBLauJensen, OK, so the-rest will have the key/val pairs. how do I handle default args? using :or ?
03:13LauJensenthe-rest will be regular data, so partition, destructure, condp it, whatever you like
03:13G0SUBLauJensen, makes sense.
03:14G0SUBLauJensen, btw, can you shed some insight on the new ``cells'' thing that's coming up?
03:14LauJensenIts still dark to me - Its somekind of synchronized mutable datatype, which can replace transients and has some built-in locking, but I'm still waiting for the first docs/examples
03:16G0SUBLauJensen, examples are here http://gist.github.com/306174
03:16G0SUBLauJensen, but I didn't understand it much.
03:18LauJensenwow
03:18LauJensenLooks like the first implementation of Clojures datatypes in Clojure - I remember someone mentioning that these are cheaper in allocation than what we have now, therefor faster
03:20G0SUBLauJensen, yeah, so effectively, these things are faster than the ones written in Java. Rich Hickey is a magician.
03:22LauJensenHe's an engineer, but I'd like to drink what he's drinking :) It is pretty amazing what he's doing
03:22G0SUBLauJensen +1
03:31sparievLauJensen: so, you're switching to tea :?
03:31jcromartiehow can I get the name of a var?
03:31jcromartieI have the var itself
03:32LauJensenhehe - spariev Its been quite some time since I started drinking tea, and its nice, seems more healthy than coffee.... Its just.. Some countries have the notion of the "macho man", but in Denmark I think that term is non-seperable from the notion of "man", thus drinking tea isn't entirely acceptable :)
03:32jcromartieor something no
03:32G0SUBjcromartie, (:name (meta #'var))
03:32jcromartie#<core$str__4340 clojure.core$str__4340@7a29120>
03:32jcromartieah
03:33jcromartiehmm, meta is nil
03:33jcromartieI guess I have a fn value
03:33jcromartienevermind
03:33jcromartieI can't work around that can I
03:33G0SUBno idea.
03:36sparievLauJensen: yep, tea isn't generally considered as a macho drink :) still, if rhickey does it, it must be good :)
03:36LauJensenhehe - so what if he starts smoking? :) Mimic Rich in Code
04:19gstrattonI spent a while getting Clojure to interact with a Java library because I'm failing to understand how to get primitives from Clojure.
04:20gstratton,(. (double 3) getClass)
04:20clojurebotjava.lang.Double
04:23sparievshouldn't java autoboxing take care of that ?
04:25gstrattonI think that's what's confusing me. I needed to pass an array of doubles; I tried this:
04:25gstratton,(into-array [(double 1) 2.0 3.0])
04:25clojurebot#<Double[] [Ljava.lang.Double;@24cc23>
04:26gstrattonI assumed it would return an array of primitive doubles
04:27hiredmanvectors are Collections
04:28hiredmanCollections cannot hold primitives
04:28hiredman,(into-array Doube/Type [1 2 3])
04:28clojurebotjava.lang.Exception: No such namespace: Doube
04:28hiredman,(into-array Double/Type [1 2 3])
04:28clojurebotjava.lang.Exception: Unable to find static field: Type in class java.lang.Double
04:28hiredman,(into-array Double/TYPE [1 2 3])
04:28clojurebot#<double[] [D@d1a587>
04:28hiredmanbleh
04:29gstrattonhiredman: Got you, I think. So as soon as I try to create the collection with the primitive double it's boxed
04:30hiredmanright
04:31gstrattonThanks very much
04:38scottjAnyone use paredit in slime-repl? Does deleting [ in [] delete the ] also? Mine does in clojure-mode, but not in slime repl
04:42Chousukescottj: you need some special configuration to fix it
04:45Chousukescottj: http://github.com/Chousuke/emacs.d/blob/master/init-clojure.el basically, the add-hook call at the end there is what you need. Note though that the hook must be run *after* paredit has been enabled for the repl buffer.
04:56scottjChousuke: thanks. looks like you did this pretty recently :)
05:10scottjChousuke: I see you use ido and ido-use-filename-at-point. Is there a way to tell ido not to use filename at point just this once? I always have to move my cursor off something that looks like a filename when I don't want that behavior
05:29Chousukescottj: no clue :/
05:31maxhodakmap is not cooperating at all. this is extremely confusing
05:31maxhodakbasically (map) does *nothing* for any map, seq, vec, whatever i pass it
05:31maxhodak(map (fn [field] (prn field)) my-data)
05:32maxhodakwhere my-data is a valid map
05:32maxhodaknothing
05:32Chousukemap's lazy
05:32Chousukeit won't do anything until you need the data
05:32maxhodakdo i need to wrap my-data in doall?
05:32Chousukewhich is why you shouldn't use it for side-effects
05:32Chousukeno, the map invocation
05:32maxhodakno side-effects here
05:32maxhodakoh, ok
05:32maxhodaki see what you mean
05:32maxhodakgrr, ok
05:32Chousukeyou might want to use doseq instead though
05:32Chousukeif you have side-effects
05:34Raynes(doseq [field my-data] (prn field))
05:36the-kennyand if you still want to use map, you can wrap the (map ...) in a (doall ...)
05:42eevar2(doc dorun)
05:42clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."
05:43the-kennyOkay, dorun is "better" for side-effects, doall is better for forcing the whole seq to be in memory (for solving problems if you for example read lazyly from a socket)
06:08the-kennyWhat's the best way to avoid duplicating stuff like http://gist.github.com/315639 in every function?
06:08the-kenny(It's always the same, I want to bind north, south etc.)
06:09the-kennyA macro doesn't work, I always get "can't let qualified name ..."
06:15noidithe-kenny, move all the defns's inside one let
06:15noidi(let [keys ...] (defn ...) (defn ...) (defn ...))
06:16noidior just def them once
06:16the-kennynoidi: I think the let-stuff doesn't work, they are bound to other values in each defn
06:16the-kennyBut I'll try def-ing
06:17noidiah, sorry, I misread your code
06:17the-kennyMaybe it was a bit unclear
06:18noidimaybe make (a version of) neighbours that returns a map?
06:18noidiso instead of a binding to south you'd look up :south from the map
06:19the-kennyneighbours returns a map, I bind the values of (neighbours ...) to symbols
06:19the-kennybut maybe that's unecessary.. I'll try it without the let-stuff
06:22Chousukethe-kenny: you can make a macro that does the letting for you
06:23the-kennyChousuke: Like http://gist.github.com/315645 - Already tried that
06:24Chousukethe-kenny: (defmacro bar [map & body] `(let [{:keys ~'[north east south west, north-east north-west, south-east south-west]} ~map] ~@body))
06:24Chousukethe-kenny: the trick there is the ~' in front of the vector
06:24the-kennyChousuke: huh, never seen that ~'-thing
06:25the-kennyMaybe that's the trick I was searching for :)
06:25Chousukethe-kenny: it unquotes a quoted expression, yielding it as-is in the macro
06:25Chousukethe-kenny: thus bypassing the namespace qualification of syntax-quote
06:27Chousukethe-kenny: usually generating names out of nowhere is bad style, but if you need to do it, you'll have to write that ugly thing :)
06:29the-kennyChousuke: That was the small trick I was searching for, thanks ;)
06:36powr-tocIs there a variation of the .. macro that does nil checking after every step in a method chain?
06:46Chousukepowr-toc: .?. in contrib
06:47powr-tocChousuke: what namespace is that in/
06:47powr-toc?
06:53Chousukepowr-toc: not sure. hmm
06:54Chousuke(doc .?.)
06:54clojurebot"clojure.contrib.core/.?.;[[x form] [x form & forms]]; Same as clojure.core/.. but returns nil as soon as the threaded value is nil itself (thus short-circuiting any pending computation). Examples : (.?. \"foo\" .toUpperCase (.substring 1)) returns \"OO\" (.?. nil .toUpperCase (.substring 1)) returns nil "
06:54Chousukethere you go.
07:03powr-toccheers
07:31RaynesSICP in Clojure. Holy...
07:31RaynesThat's big.
07:40ttmrichterSICP in Clojure? What are you talking about? :-O
07:40ttmrichterOh, never mind.
07:40ttmrichterI confused SICP with SISC.
07:40ttmrichterBraino.
07:41maxhodakhow do you do a List<> return type in gen-class?
07:46bsteuberSICP in Clojure? Where?
07:50Raynesbsteuber: http://sicpinclojure.com/
07:50bsteubernice, thx :)
07:50RaynesIt's incomplete right now, but when it's finished, it will be big.
08:26defns
08:26Raynest
08:30chousermaxhodak: just return a List -- it should work.
08:30chousermaxhodak: just return a List -- it should work.
08:32chouserrhickey: I tried get KeywordLookupSite to use PKeywordLookup instead of IKeywordLookup, but I think I have a bootstrapping problem.
08:33chouser'satisfies?' uses keyword lookups in its definition, so I just get an infinite loop. :-P
09:05_fogus_The confusion surrounding contains? directly stems from the JVM as a host. In other words, naming is tough.
09:07chouserI would never argue that naming is easy, but it doesn't seem unreasonable to think of conj as putting a value "into" a collection, nor that if a value has been put "into" a collection that the collection would then "contain" that value.
09:10a_strange_guymaybe the problem could be lessened if clojure had a function that did what people expected of contains?
09:10chouserit has a few
09:10chouser,(.contains [:a :b :c] :b)
09:10clojurebottrue
09:10a_strange_guyeverybody uses (some #{item} coll)
09:11chouseryep
09:11chouserso that's at least two ways
09:11a_strange_guynot really
09:11a_strange_guy.contains doesn't work on ISeq's
09:12_fogus_understood. the problem stems from a general disparity between what Java does and what Clojure does. The name contains? just highlights that
09:14a_strange_guymaybe the problem lies in the disparity between predicates and quasipredicates
09:14a_strange_guy'some' can be used as a predicate
09:15a_strange_guybut this may feel unintuitive
09:16cemerickonly if you're used to more difficult ways to do things IMO
09:16cemericke.g. if (foo != null) ...
09:17a_strange_guyyes, the difference between false and nil feels stupid if you are used to Common Lisp
09:18chouserI don't think there's any problem of functionality. (some #{item} coll) is sufficiently succinct and more hints at the linear scan that will actually happen. 'contains?' does exactly what you frequently want to do on maps and sets.
09:18cemericka_strange_guy: well, I'm not, but python and ruby and a variety of other langs also have very nice nil punning
09:18a_strange_guyC does too xD
09:19_fogus_chouser: don't get me wrong. I'm not saying that contains? does the wrong thing; only that it seemingly does to people from a certain background
09:19chouserIf 'contains?' were named 'has-key?', I think most of the confusion would be disappear, though there would still be questions from people who haven't seen the 'some' idiom yet.
09:19a_strange_guyI would have called 'some 'any?
09:20chouser_fogus_: I agree, and I'm saying that "certain background" probably includes most people who speak english.
09:20chouserI put a value in that vactor, when I print the vector I can see it -- why doesn't the vector contain it?
09:20_fogus_hmmm, I was a little more narrow in my focus, but maybe you have something there ;)
09:20cemericka_strange_guy: any? implies a boolean return, and would have the same effect in a conditional form as some
09:20cemerickbut without the extra utility of some
09:21jcromartieanybody have any good deployment solutions for compojure projects?
09:21cemerickjcromartie: same as every other java web app? :-)
09:21a_strange_guywell 'some' returns the return value of the predicate that it was passed
09:21jcromartieI have already set up gen-class so that I can say java -cp app.jar app.main db_name port
09:21jcromartiecemerick: oh, hmm, I'm not set up for that yet
09:22a_strange_guyso it would return a boolean result (most of the time)
09:22cemerickjcromartie: do so -- it takes ~10 minutes, and saves so much bother in a variety of ways
09:22cemerickjcromartie: are you using maven?
09:23_fogus_does the definition of a predicate extend to truthy and falsey?
09:23jcromartiecemerick no, lein
09:23a_strange_guycemerick: does a "?" always imply a Boolean return value
09:23cemericka_strange_guy: definitely
09:23chouser_fogus_: I don't think so. because everything is truthy or falsey, the word "predicate" would cease to mean anything more than "function"
09:23cemerickjcromartie: sorry, can't help you then :-)
09:24jcromartiea_strange_guy: there's not-empty, which returns the non-empty thing or nil... note the lack of ?
09:24_fogus_chouser: gotcha
09:24rsynnotta_strange_guy: You could certainly confuse the hell out of library users by doing otherwise, though :)
09:24cemerickjcromartie: in maven, you just define war packaging, and you get a .war file with your bits from WEB-INF etc in the right spot that you can drop into any container
09:25a_strange_guyteh CL people kinda managed that
09:25a_strange_guy^the
09:25chouserI still can't believe not-empty is in core.
09:26jcromartiecemerick: maybe I can add a war task to lein
09:26jcromartieit does support custom tasks
09:26a_strange_guyon the other hand they had multiple return values and no Host that regulary uses nulls
09:26jcromartieoh, here we go http://github.com/alienscience/leiningen-war
09:26jcromartiefacepalm for him
09:26cemerickjcromartie: no, just the whole reinvent-the-wheel movement
09:27jcromartieoh, you mean lein in general
09:27cemericklein is great all by itself. If you want an extensible build environment, use maven. Otherwise, it's all just wasted cycles, IMO.
09:28jcromartiewar files aren't hard though
09:28jcromartiethey're just a jar + web-inf, etc.
09:28cemerickI'm hoping this takes flight, and then we can move on: http://polyglot.sonatype.org/clojure.html
09:28cemerickjcromartie: no, nothing about individual bits of build processes is *hard*, the issue is having reimplementations of stuff that is rock solid doesn't make sense.
09:29jcromartieOK well, maybe I'll let lein generate my pom and I'll use Maven for web deployment.
09:30chousercemerick: is that the same defproject syntax/structure as lein uses?
09:30cemerickchouser: I've no idea. Never used lein myself.
09:31jcromartiecemerick: don't knock it till you try it :P
09:31jcromartieI was not all for lein at first
09:31cemerickjcromartie: it doesn't do a tenth of what I need *shrug*
09:31jcromartiewell isn't cemerick fancy :P
09:31cemerickfeh
09:32cemerickjust yelling into the wind, per usual :-)
09:32jcromartieI don't pride myself on the fact that my deployment consists of rsync, ssh, and a job running under screen.
09:33chouserbleh. similar to lein, but not the same. oh well
09:34chouserI've not used either, but it's seems inevitable I'll have to get used to living in maven's world somehow or other.
09:34_fogus_jcromartie: Add make and you've described the setup we have here. :p
09:34rhickey_so, contains? probably isn't used much - is it?
09:34cemerickchouser: the point is that it *is* a pom, not a replacement for it.
09:34cemericks/it/one
09:35cemerickchouser: your life will be so much easier once you decide to make the same choices as the rest of us :-D
09:35chouserrhickey_: I'd say 'contains?' is used some for maps when you need to know about keys with nil values, and never for vectors. :-)
09:35_fogus_rhickey: I rarely (if ever) use it. But it plays a prominent role in the book. :-)
09:35chousercemerick: yes, I know. That's why I use down-the-middle mainstream tools like linux, clojure, vim, ... er, wait...
09:35jcromartieyeah contains? always gets me
09:37chouserrhickey_: did you happen to see my PKeywordLookup infinite recursion mentioned above? Don't need a solution from you, just thought you'd be interested if it wasn't already obvious to you.
09:37rhickey_I'm willing to concede people are confused by contains? when applied to vectors and sequences, but what to do?
09:37rhickey_chouser: no, didn't see it
09:38cemerickchouser: some old-time grizzled CS/entrepreneurial legend that I can't recall the name of has a saying about how you should choose only one area to innovate and be different and fantastic in -- more than one, and you'll never get out of your way enough to get stuff done.
09:38rhickey_heh, satisfies?
09:38chouserrhickey_: yes
09:39chouserI'm just trying to get a fix hacked in here enough that I can try out my userland code with 'extend' instead of wrapper classes. But I'm not there yet.
09:39cemerickchouser: that wasn't directed at your toolchain BTW, your comment just brought it to mind
09:40chousercemerick: It makes sense to me, esp. for a business, and esp. a small business.
09:40rhickey_I had other issues with this course after sleeping on it - I don't know that I want IKeywordLookup to be a public promised API. It happens to be the implementation detail of how deftypes work today, but with, say, JSR 292 you would do it completely differently
09:41chousercemerick: but my personal tool choices have less to do with maximizing profit and more to do with minimizing pain.
09:41rhickey_chouser: there's a sense in which, why should one expect to be able to extend keyword lookup to arbitrary POJOs? and another in which you say - if that is desired, perhaps best to be directly supported, still hiding the implementation details, i.e. (:some-javabean-property some-pojo) should just work
09:42chouserrhickey_: yes, I can see that. My current efforts are more about proof of concept for the app api I'm building. I want to make sure that I'm collecting all the right kinds of information from api users to provide the best possible performance.
09:43rhickey_chouser: so I had some questions about what exactly is your use case - are you wrapping fields? getters? arbitrary methods?
09:43chouserI suppose I can require the use of a wrapping function that in some cases doesn't actually wrap.
09:43rhickey_I didn't read your paste closely
09:44cemerickchouser: those objectives should be closely aligned in a sane environment :-)
09:44_fogus_,(let [has-key? contains?] (has-key? #{:a 1 :b 2} :a))
09:44clojurebottrue
09:45chouserI'm wrapping google protobuf messages. They have their own sense of fields and setters that does not align exactly with Java POJOs
09:45rhickey_I imagine if keyword lookup was extensible then I could imagine people would constantly be wrapping Java just so they could say (:foo x) instead of (.foo x)
09:46chouserthese messages are logically a sort of immutable multimaps, and I'd like to use them as such.
09:46rhickey_chouser: but avoid map-like lookup?
09:46chouserI already have a full stack of code using the raw get methods, and am starting to regret it.
09:47rhickey_get methods take what as an arg?
09:47rhickey_or are they generated getThis getThat?
09:47chouserhm, maybe multimap isn't the right word. multi-struct -- predefined keys.
09:48chouserrhickey_: generated getThis and getThat. no arg (except for repeated fields)
09:52rhickey_chouser: I think this is a really interesting area, but I also think that the current infrastructure wasn't designed for the generic case. Also, your extends is going to run into trouble - there is "instanceof IKeywordLookup" code in KeywordLookupSite
09:53chouseryes. it was changing that to 'satisfies?' that caused the infinite recursion.
09:54chouserand I've got an ugly fix hacked in for that now, but I think I'm still missing some check somewhere.
09:54rhickey_I don't love the use of the interface, as it requires a different class for each field. This is definitely an area where JSR 292's MethodHandles give you code hooks at finer and more lightweight granularity
09:55rhickey_but today, classes are the granularity of code in the JVM
09:56chouserbut it comes to this: if I can be sure that in the not-too-distant future, I can provide high-performance lookup and functioning IPersistentMap methods without requiring app code to call a fn on the message object, I'd like to design the api for that.
09:57rhickey_app code being Java code?
09:58chouserah, no. Not much I can do for those poor souls.
09:58rhickey_so yo uwant to avoid (get-the x) (get-that x)?
09:58rhickey_get-this
09:58rhickey_instead (:this x) (:that x)
09:58chouserI mean, I will support both Clojure and Java app code, but my hands are a bit tied in trying to improve the java api.
09:59chouserwell, get-that would have to be generated -- haven't pursued that at all.
09:59chouser(:that x) instead of (.getThat x)
09:59rhickey_I'm still wondering how you are avoiding the coupling given a message object with (.getThis x), what's better about (get-this x) or (:this x)?
10:00rhickey_you want to treat slots as data?
10:00chousernot sure what you mean by that.
10:01rhickey_what's the answer to my last question?
10:01rhickey_er, penultimate question
10:01chouserI suppose the real wins come with things like (rename-keys {:foo :bar} obj)
10:02rhickey_I don't get it
10:02chouserthat is ... I have places where I use .getThat, and others where I at runtime walk the (nested) message and produce a regular hash-map for manipulation with rename-keys, select-keys, etc.
10:03chouserI'd like to provide a single api with the performance of the first case (when possible) and the flexibility of the second (when needed)
10:05rhickey_ok
10:05rhickey_so, if IPersistentMap was a protocol?
10:06rhickey_still wouldn't give you the direct perf...
10:06chouserthat'd be perfect.
10:06chouserright
10:07rhickey_and :java-bean-property support doesn't help?
10:07rhickey_getThis is JavaBean naming
10:07chouserthe direct perf probably isn't a deal breaker, but if I can get better perf wrapping the object and implementing IKeywordLookup, that has consequences on the api I provide.
10:08rhickey_chouser: the advantages of persistent map as protocol is no wrapping
10:08rhickey_wrapping = bad
10:08rhickey_Clojure would be completely different if I thought wrapping = ok
10:09rhickey_but, are your getters JavaBean properties?
10:09chouserI understand. But if I can get better performance with wrap+IKeywordLookup than I can with nowrap+PPersistentMap, that suggest at least asking users to do (pmap-of msg), whether I actually wrap in the end or not.
10:10chouserI think they're JavaBean properties.
10:10rhickey_wrapping will eventually hurt you, mark my words
10:10chousermore than pouring them into PersistentHashMaps already is?
10:11rhickey_in the latter case you plainly have a different thing
10:11rhickey_there's always pressure on the wrappers to act as proxies
10:12rhickey_but the JavaBean property case could I think be easily and generally be supported in keyword lookup
10:12rhickey_iff you allow for runtime code gen
10:12powr-tocI've written a mock implementation of rails-like database migrations for use with clojure.contrib.sql... comments appreciated: http://gist.github.com/315787
10:12chouserthe sort of runtime code gen I'm doing with (eval `(refiy ...)) ?
10:14chouser(bean msg) works -- provides access to everything I need I think.
10:14chouserof course, that's a wrapper.
10:15rhickey_I had some keyword style fields and property access in my older interop stuff (DotLisp, jFli and Foil)
10:16rhickey_I'm talking about (:a-javabean-property x) figuring out that x doesn't implement IKeywordLookup but does have .getAJavaBeanProperty and compiles a LookupThunk on the fly
10:16rhickey_caching the result, voila - fast lookup
10:17rhickey_in that case and the case of PKeywordLookup, you really aren't getting a maplike object
10:18cemerickfeel free to tell me to muzzle, but is this all to avoid (.getFoo x) in preference of (:foo x)?
10:18rhickey_probably doesn't really handle your use case
10:18rhickey_cemerick: more like - get map-like objects but don't lose perf of (.foo x) when using (:foo x)
10:19rhickey_map-like objects without wrappers is a matter of map functions being built on protocols
10:24chousercemerick: I do feel I've been driven here by real concerns, not just a vague preference.
10:25rhickey_chouser: but I feel like map-as-protocol is more what your use case is about
10:26hugodis there a general way to get the current source line and file?
10:26cemerickchouser: I'm sure -- just thought I'd play the skeptic for a moment.
10:26chousercemerick: it's a good question. Esp. to be directed toward me -- I tend to enjoy this kind of thing too much and might do it when not necessary.
10:26rhickey_chouser: so, your work on revitalizing :on might not help with KeywordLookup, it might help with making experimental versions of get et al that work with protocols built :on the existing interfaces
10:28a_strange_guyrhickey_: do you plan to make IFn a protocol too?
10:28a_strange_guybecause this is the promary way that people use maps
10:28a_strange_guyeg. (a-map :foo) and (:foo a-map)
10:28chousermy "work" on revitalizing :on is an ugly little hack I barely understand. :-)
10:29rhickey_heh
10:29chouserI currently have to specify both :on and :on-interface, though I don't know why.
10:30chouseranyway...
10:31chouserI guess to move forward I suppose I can require users interpose a fn call between their message object and their map-like use of it.
10:31chousertoday it can wrap a reify to implement ILookup and even IKeywordLookup. Someday it may be a no-op.
10:32rhickey_chouser: you could easily fix satisfies? to call get
10:32chouserthe java-bean thing means I suppose I should use the keywords 'bean' provides intead of the ones I was using. that is, for .getAddressId use :addressId and not :address-id
10:32chouserrhickey_: yes, I did that.
10:33chouseralso find-protocol-impl
10:34chouserso the inf. recursion is gone, but extending String to PKeywordLookup, (:foo "bar") still doesn't try to install a thunk
10:34rhickey_chouser: the thing is, IKeywordLookup doesn't give you a map-like thing at all, I'm confused about why you are there - just to get perf in addition to a map-like wrapper?
10:34chouserrhickey_: yes
10:35rhickey_chouser: and you've hacked KeywordLookupSite to avoid instanceof IKeywordLookup?
10:35chouserI guess if I want to pursue wrapperlessness I need to do PLookup as well.
10:35chouserrhickey_: yes
10:36chouser(:foo "bar") doesn't get that far though. 'fault' isn't called, and I've been chatting here instead of trying to figure out why.
10:37chouserwell, I've got KeywordInvokeExpr.emit source open, but I still don't know how to read ASM stuff.
10:44rhickey_you've changed all instanceof IKeywordLookup to satisfies?
10:44rhickey_in KeywordLookupSite?
10:44rhickey_and (satisfies? PKeywordLookup String) == true?
10:46rhickey_and you are calling RT.booleanCast on its result?
10:54rhickey_basically the default stub KeywordLookupSite should return this from get, resulting in a call to its fault, then install the target
10:55rhickey_the ASM says, if get returns the object itself, call fault and return what it returns
11:00rhickey_the lookup thunk itself
11:01brandonwhas anyone used lein nailgun with vimclojure?
11:17dnolenthere isn't a rotate function in clojure is there? [1 2 3] -> [2 3 1] ?
11:19chouserdnolen: I don't think so. I wrote one.
11:19dnolenchouser: in contrib?
11:19chouserno, unreleased. hang on
11:20chouser(defn- rotate [[x & xs :as all]] (when (seq all) (concat xs [x])))
11:29dnolenchouser: cool
11:34chousernot very efficient
11:35a_strange_guywhy not?
11:36a_strange_guyisn't it a constant-time operation?
11:36chouseryes, but the memory-use could probably be better.
11:37dnolenchouser: how would you make it more efficient?
11:37dnolenI was thinking something like (rotate coll step) would be cool, step could be signed int
11:39a_strange_guyas long as you use sequences you'll have to allocate the new sequence
11:39a_strange_guythis will be fast when we have cells+iter
11:39a_strange_guys/fast/memory efficient
11:41chouserperhaps basing it on something like a finger-tree would be better.
11:41dnolenhmm, well i can rotate a 10 item vector 100,000 times in 200ms so it's fast enuf for me :)
11:41chouserthe definition above was acceptible for my use because the collection will never have more than 3 items and will rarely be rotate more than a couple times.
12:00esjIf I want to create a function that takes either an element, or a seq of elements, is a multimethod the sensible approach, a la http://gist.github.com/315898 ?
12:01esjor would the preferred approach be to define only the non-seq version and then use a reduce in cases of seqs ?
12:01esjor is this, as seems likely, just a stupid question ?
12:03dnolenhmm is there something like "for" but for side-effects?
12:04dnoleni like (for [i (range x) j (range y)] ...)
12:04dnolenbut I don't want a list comprehension, just side effects
12:04chouserdnolen: doseq
12:04dnolenchouser: thx
12:24a_strange_guyhi,
12:25a_strange_guydid anyone (except for rhickey) try to write new sequence functions with cells+iter
12:25a_strange_guyI want to try concatx
12:39esjin answer to my own question: yes its dumb.
12:42jasappesj: having a function handle single elements, and sequences?
12:43esjjasapp: yeah
12:46jasappI usually like to have seperate functions for stuff like that, otherwise I get confused and things break.
12:46jasappI confuse easily. :)
12:49esji hear you.
13:30alinphi guys
13:30alinpI have a small issue here please
13:31alinp(ns my-ns)
13:31alinp(defn test [n] (println n))
13:31alinpCaused by: java.lang.Exception: Name conflict, can't def test because namespace: my-ns refers to:#'clojure.core/test
13:32technomancyalinp: you either need to exclude clojure.core/test in your ns invocation or pick a non-conflicting name for your function.
13:32alinphow can I do that ? It is even possible to create a function with the same name like a core one but in another ns ?
13:32technomancy(ns my-ns (:refer-clojure :exclude [test])) ; <= if memory serves me
13:32alinpthanks technomancy, but I don't know exactly how to exclude it
13:32alinpoh
13:32alinplike this ... thanks ;)
13:33technomancyalinp: but watch out: now every namespace that refers my-ns will also have to exclude test.
13:33technomancyso if you're intending it to be used elsewhere it would be better to pick a different name.
13:33alinpmno, I want to use it just locally
13:34alinpthe thing is that I had this problem for ages, and only now I got the time to ask
13:34alinpthank you
13:34technomancysure
13:36alinpit will be a problem if I use my namespace from other place, but not use that test function ?
13:36alinpor maybe it is possible not to export all functions ?
13:36alinpsomething like erlang's export ?
13:37technomancyalinp: defn- will prevent it from being exported.
13:37alinpoh, that's for exporting it to java, I think
13:37alinpright ?
13:37alinpI mean, to export it as a java method
13:38alinpI mean, as far as I remember, for exporting it as java main method, should be used something like this: (defn- main ....)
13:40the-kennyalinp: (defn -main [arg1 arg2 arg...] ...)
13:40the-kennynot (defn- main)
13:40alinpoh, thanks the-kenny, that's right
13:46defnHow do you make the print length smaller in clojure?
13:46defnerr in the slime repl
13:47dakrone(set! *print-length* 10) ?
13:47defnah yes
13:47defndakrone: do you know how to clear the slime repl?
13:47dakronedefn: not an emacs user, sorry
13:47defnnvm, C-c Mo
13:47defnC-c M-o
13:54jcromartieWhere does output from Compojure go when running slime?
13:54jcromartieI am really getting into the slime/swank setup, but Compojure stack traces don't show up.
13:55technomancyjcromartie: maybe *inferior-lisp*?
13:55jcromartieah that's right!
13:55jcromartie*that* thing
13:55technomancythe next swank-clojure release will clear this kind of stuff up
13:55jcromartie:)
13:56technomancyno promises on a timeline though. =)
13:57chousertechnomancy promises good and cheap, but not soon.
13:59defnhow can i take a file-seq and turn it into a structure that i can map across?
13:59technomancydefn: why can't you map across a file-seq?
14:00defntechnomancy: i was making a stupid mistake, sorry
14:05dnolenis there a way to efficient repeat a sequence without have to flatten it?
14:05dnolen[1 2 3] -> [1 2 3 1 2 3 1 2 3 . . .]
14:05chouser,(cycle [1 2 3])
14:05clojurebotExecution Timed Out
14:05dnolenheh
14:05chouserheh
14:06chouser,(take 20 (cycle [1 2 3]))
14:06clojurebot(1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2)
14:06dnolenthx yet again
14:06chousernp
14:33defn(spit (java.io.File. "blah.txt") (some-function-which-returns-a-lazyseq))
14:33defnhow do I get the actual entries in that lazyseq to write to the file
14:34defnbah I was using (str (some-function...))
14:34defninstead of (apply str (some-function...))
14:36maxhodakhow do you return a List<> type in class generation?
14:37maxhodak(:gen-class :methods [...])
14:37pdkyou know
14:37maxhodakmethods looks like: [[method_name [int String] ???] ... ]
14:37pdkin 2012 we'll have been using C for 40 years
14:37pdkany connection to the doomsday prophecies?
14:37maxhodakwhere ??? should be something like List<Long> (but that doesnt work)
14:37chousermaxhodak: just List should work
14:37chouserhm.
14:38technomancypdk: prophecies might have to wait till we've been using C for 128 years
14:38technomancy256 if they're unsigned
14:38pdktrue
14:38krumholt_maxhodak, after compilation generics are gone in java. it's just in the code they don't exist in bytecode
14:38defnhow do i add a \n at the end of every entry in a list, i was thinking something like (apply #(str % "\n") coll)
14:38pdkearth would explode after we hit its -128th anniversary
14:38pdk128 BC: Before C
14:39technomancypdk: luckily God wrote in lisp: http://www.gnu.org/fun/jokes/eternal-flame.html
14:39pdkthough your guess is as good as mine what AD means in this context
14:39chouserdefn: try map instead of apply
14:39maxhodakchouser: that gets me "java.lang.ClassNotFoundException: java.lang.List"
14:39chousertechnomancy: or maybe not http://xkcd.com/224/
14:39defnchouser: thanks
14:39pdkwhat about the god wrote in perl poems though?
14:39pdksounds like holy war time
14:40chousermaxhodak: java.util.List ?
14:40pdknot to mention we don't know what implementation we're running on, this could bite us just as well: http://jwz.livejournal.com/854482.html
14:40technomancychouser: well, that's a lower-case god.
14:40technomancyclearly such a pagan would choose inferior tools
14:41chousertechnomancy: oh dear, I'd never noticed that.
14:41defnwhat's the function to compose a regex using a variable?
14:41chouserdefn: that gets really ugly really fast.
14:41defnchouser: how do you suggest i compose a regex with a var?
14:42chouser,(let [x "bar"] (re-pattern (str #"foo" (java.util.regex.Pattern/quote x) #"baz")))
14:42clojurebot#"foo\Qbar\Ebaz"
14:42defnchouser: nice. thank you!
14:43chouserdefn: no, not nice! ugly and horrible ...and sometimes the only reasonable option. :-/
14:44defnchouser: what would be nicer in your opinion?
14:45chousera clojure lib that lets you express patterns using s-exprs, but with the full power and succinctness of regex.
14:45chouser(ptn "foo" x "baz") or something
14:47chouser(ptn (or "abc" "xyz") (repeat 1 "z")) == #"(?:abc|xyz)z+" ? I dunno.
14:47chouserthat kinda lost the succinctness, didn't it.
14:47defnchouser: heh, it's not bad
14:48defni dont really mind the whol (java.util.regex.Pattern/quote x) stuff, it just needs a helper fn in the str-utils lib
14:48defn(re-build #"foo" x #"baz")
14:49chouserhm... perhaps.
14:49technomancyhttp://www.prometheus-music.com/audio/eternalflame.mp3 <= audio version
14:49technomancyseveral good chuckles contained therein
14:49chouserthere are still problems. (re-build #"(foo" x #")bar") will never work, and perhaps that's good.
14:50defncouldn't you just quote that and sanitize it before re-pattern takes ahold of it?
14:50chouserbut if you use strings literals instead of regex literals, you have the normal \ explosion.
14:50chouserit's just a mess
14:51defnfor more complex scenarios yeah i agree -- but for what im doing it's pretty functional (no pun intended) with just the helper function
14:52chouserreader macros could get us from 90% to 95% functionality coverage ... :-/
14:52defnchouser: any chance of that?
14:52chouserno
14:52defnor has rich said no go
14:52chouserI've got a friend working on a general pattern-matching library for python that would be very interesting to port when it's finished.
14:53chouserbut still not likely as succinct as regex, and I have no idea about performance.
14:53defnperformance shmeformance. ;)
14:54defnif/when he finishes buzz me -- id be interested in taking a hack at it
14:54chouseryeah, you're right. clojure's already too fast.
14:55defnnothing is /too/ fast, heh. and in general, i have an idea of what i'm going to get when i start using a lot of pattern matching.
14:55defns/and/but
14:55somniumchouser: like haskell/ocaml style pattern-matching? or texty-regexy?
14:56chouserhm... neither, I guess. I mean, loser to regexy but not strictly on text.
14:56chousercloser
14:57chouserI think he's operating on a stream of tokens, so those could be individual characters, or a stream of more meaningful symbols I think.
14:57somniumsounds intriguing
14:58hiredmanyou could just use fnparse
15:00defntoo complicated for me
15:03hiredman(rep+ (lit \x))
15:04hiredman,(require '[name.choi.joshua.fnparse :as fp])
15:04clojurebotnil
15:04hiredman(fp/rep+ (fp/lit \x))
15:04hiredman,(fp/rep+ (fp/lit \x))
15:04clojurebot#<monads$state_t__5239$m_bind_state_t__5248$fn__5249 clojure.contrib.monads$state_t__5239$m_bind_state_t__5248$fn__5249@bff63e>
15:04hiredman,((fp/rep+ (fp/lit \x)) {:remaineder (seq "xxxyxxx")}
15:04clojurebotEOF while reading
15:04hiredman,((fp/rep+ (fp/lit \x)) {:remaineder (seq "xxxyxxx")})
15:04clojurebotnil
15:05hiredmanbleh
15:05hiredman,((fp/rep+ (fp/lit \x)) {:remainder (seq "xxxyxxx")})
15:05clojurebot[[\x \x \x] {:remainder (\y \x \x \x)}]
15:06hiredman,((fp/semantics (fp/rep+ (fp/lit \x)) (comp symbol (partial apply str))){:remainder (seq "xxxyxxx")})
15:06clojurebot[xxx {:remainder (\y \x \x \x)}]
15:07somnium'haskell in parens' comes to mind
15:11ordnungswidrigsomnium: haskell in parens sound fun
15:12somniumordnungswidrig: more fun than haskell-out-of-parens?
15:15ordnungswidrigyes, because the parens let it appear more simple to understand than it is :-)
15:18ordnungswidrigactually the good ting with clojure is that you don't need to enable another extension every other time
15:19brandonwif anyone is bored, could you let me know if anything in here is not idiomatic clojure? just so i don't develop any bad habits as i learn-- http://github.com/brandonw/snake-solver/blob/master/src/snake.clj
15:23ordnungswidrigbrandonw: line 38: (if (or …) false true) -> (not (or …))
15:23brandonwah yes
15:24defnhmm why isn't java.io.File/delete a matching method?
15:24ordnungswidrigbrandonw: even better: (not (or (> a b) (> b c))) (and (< a b) (< b c))
15:24brandonwthat is something i definitely will enjoy getting used to-- not needing a boolean primitive but just using the result of an expression as a boolean
15:26somnium(and (< a b) (< b c)) =~ (< a b c) ?
15:26ordnungswidrigbrandonw: which is nothing specific to clojure Specific to clojure would be nil? -> false, not nil? -> true
15:26brandonwright
15:26ordnungswidrigsomnium: I see an urgent need for quicktest
15:26brandonwbut it is specific because clojure is the first language i have used that has that capability
15:27ordnungswidrigs/test/check/
15:27brandonweither that or i just never even thought to use it
15:27brandonwother than that though, it appears okay?
15:27somnium:-)
15:28brandonwi'm not sure if solve-snake was too complex or not, it seemed like it needed comments inside the function body, and i wasn't sure if that means i should make it more simple somehow or not
15:31AWizzArdbtw, < takes many args
15:31AWizzArd(< a b c)
15:32somniumAWizzArd: high-five
15:32AWizzArdoh ok, just saw it now :)
15:32ordnungswidrigbrandonw: take it as a sign that the functions does to much and should be splittet
15:33brandonwif it is inside a loop recur, and all the code is doing is determining how to recur, i don't really know how i could clarify it
15:35defn,*print-length*
15:35clojurebotnil
15:39somniumbrandonw: some of the segment transforms could be DRYed up with a map
15:40somnium,(let [m { [0 0 1] [0 1 0] [0 1 0] [1 1 0]} ] (m [0 1 0]) )
15:40clojurebot[1 1 0]
15:48brandonwi don't think there is any repeating in the transform though
15:48brandonwi could probably take out the transforms that have the segment and the axis on the same plane, though
15:49brandonwinstead of having lines in each cond axis, i could have an outer if that checks if the two axes are the same, and returns the segment value if so, then it would only be 12 lines of comparisons
15:52somniumbrandonw: if axis-map is like {[0 0 1] {[0 0 1] [0 1 0] ...} ...} then (-> axis-map axis segment) removes the cond
15:59brandonwohhh okay
15:59brandonwi see what you mean
15:59brandonwi have to learn the -> basically :)
15:59brandonwthe -> operator i mean
16:00brandonws/operator/macro
16:00somniumactually my -> is wrong :/ but ((axismap axis) segment) is ok
17:17duncanmif I establish a binding using (binding [a 1] (foo)) all function calls made from 'foo' will have a bounded to 1, right?
17:18chouserif they stay in the same thread, yes.
17:24duncanmwhat's the difference between merge and conj on Maps?
17:25duncanm,(merge {:a 1} {:a 2})
17:25clojurebot{:a 2}
17:25duncanm,(conj {:a 1} {:a 2})
17:25clojurebot{:a 2}
17:25duncanmi guess it has to do with the number of arguments?
17:26ankouhi, I have a question about clojure-swank: I'm trying to get correct error messages so I first wanted to create a project with clojure-swank., however just using the command doesn't work (it says `Lisp connection closed unexpectedly) and the readme says that I need to have clojure-swank.jar in the /lib path, however I don't know if this is the cause of the error but I don't even know where to find this java archive. I isntalled it with elpa as
17:26ankouthe readme suggested.
17:29technomancyankou: not sure what you're trying to do. you can't use swank-clojure to create projects.
17:30technomancyif you create a project with leiningen, you can add swank-clojure as a dependency and then use M-x swank-clojure-project; is that what you mean?
17:32Licenserwhat is the best practice of NPE hunting in clojure? The Stack traces are sadly often quite unhelpful :(
17:32ankouyes, but the readme says that I could also create the project directories manually and I just wanted to try it first. Maybe I should start with leiningen?
17:32technomancyankou: if you're not sure what the project structure should look like then leiningen would be a help
17:32Licenserleiningen is quite nice ankou, helped me a lot already
17:33dakroneLicenser: if you know whereabouts it's happening, you could stick a debug-repl in near it and check out the local vars
17:34Licenserdakrone: problem is that I don't know the where, that is what I need to find :(
17:34LicenserMy stack trace consists of either Very top level functiosn (-main and such) or Clojure internals or NO_FILE:1
17:34dakroneyou could try sticking it in a file and running it to get a line number
17:35Licenser*tries that*
17:36ankouokay, I will try leiningen and then I'll se if that was the problem or if I get the same error
17:37timcharperhow do you convert a keyword to a string? (str :hi) yields "hi"
17:37timcharpererr. (str :hi) yields ":hi"
17:37timcharperis the best way to eat the starting : ?
17:37timcharperor is there a way to get the name of a keyword as a string
17:37Licenserankou: it is always helpfull to look into the infiror lisp buffer, it often holds very nice information about what goes wrong
17:38timcharperhah... nevermind. playing in the repl and found (name :hi) returns "hi"
17:39timcharperthank you to all those who began to lend an ear
17:40ankouokay, I installed leiningen and started a project, now, according to the documentation of clojuree-swank, I need to put this jar file clojure-swank.jar somewhere in the directory, where do I get this file? or what should I do next?
17:41Licenserankou: just add it to your project.clj
17:41Licenserlein will put it in automatically
17:42timcharperok... (name :hi) and (name 'hi) work... but (name "hi") blows up. Any way to intelligently stringify stuff w/out having to resort to conditionals ?
17:42technomancytimcharper: as-str should do it
17:42technomancyin contrib somewhere...
17:43Licenserankou: I use https://gist.github.com/ed819a02a633b6987486 for my current prject, feel free to take it as an template
17:43dakronetimcharper: it's in clojure.contrib.string
17:44dakrone,(use 'clojure.contrib.string)
17:44clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/string__init.class or clojure/contrib/string.clj on classpath:
17:44dakronehmm
17:45ankouI have not installed lein-swank yet, do I need it or is it just some functionality for convenience?`
17:45technomancyankou: it's only there so you can launch swank sessions from the command-line
17:45technomancyankou: you don't need it if you would rather launch them from elisp
17:47Licenserankou: I am note sure :P I just have it since it's working round now, the entire lein-swank-slime-emacs thing is very fragile I found out
17:48timcharperdakrone: is that clojure 1.2 ?
17:49timcharper(i'm on clojure 1.1)
17:49technomancytimcharper: that'd be in java-utils then
17:49dakronetimcharper: hmm...it should be there, it's up on http://richhickey.github.com/clojure-contrib/string-api.html#clojure.contrib.string/as-str
17:49dakroneso the documentation must be out of date a bit I guess?
17:49timcharperor clojure 1.1 is out of date
17:50dakroneno, I don't see it either in 1.2-git
17:50timcharperuser=> (use 'clojure.contrib.string)
17:50timcharperjava.io.FileNotFoundException: Could not locate clojure/contrib/string__init.class or clojure/contrib/string.clj on classpath: (NO_SOURCE_FILE:0)
17:50timcharper
17:50technomancytimcharper: ^^ java-utils
17:51timcharperbingo technomancy, thanks !
17:51dakronewho needs to know that the doc is out of date?
17:52timcharperdakrone: I saw a blurb earlier about it being autogenerated
17:52technomancydakrone: it's not out-of-date, it's just reflecting the latest git version
17:53dakroneahh, that would do it
17:53ankouokay, now swank clojure is connected to lein, however since this is not quite what I thought it would be.. which advantages do I have now?
17:54timcharperankou: the advantage of being AWESOME
17:54technomancyankou: it's just easier if you have all your dependencies handled in one place.
17:54technomancyso you are able to check out your project on any machine, hit lein deps, and go immediately
17:54technomancyrather than having to find all the jars by hand
17:54technomancyalso what timcharper said.
17:55ankouthat's what leiningen is doing but what does the connection of clojure-swank and leiningen?
17:55technomancyankou: you can run "lein swank" to start a swank server
17:55timcharperankou: if I'm not mistaken, clojure-swank is for connecting emacs to clojure, isn't it?
17:55technomancythen M-x slime-connect inside Emacs to join it.
17:55dakronewhat is swank for anyway? The wikipedia article on it is *cough* probably not what it actually is.
17:56ankoutimecharper: yes it is
17:56patrkrisdakrone: http://github.com/jochu/swank-clojure gives a pretty good description
17:56technomancylesson 1: never trust wikipedia
17:57dakronepatrkris: ahh, okay
17:57dakronepatrkris: thanks
17:59ankoutechnomancy: sorry, I still don't understand. I used swank-clojure-project from emacs to connect it to the leiningen project directory, what's the difference to starting a swank session with leiningen? and would be the advantage of this connection anyway? It seems to me that swank-clojure and leiningen are completly different tools so how do they interact?
18:00technomancyankou: leiningen is a general tool for managing projects. I just recommended it because it sounded like you were unsure of how to lay out your project. it has a plugin for swank that provides you with an alternate way to lauch swank sessions.
18:00patrkrisankou: Just a guess: perhaps lein swank makes sure that your swank server has the right stuff in the classpath, which it can read from your project.clj
18:00patrkris(I am really guessing, since I just Vim for Clojure development :))
18:01technomancyankou: you can continue using M-x swank-clojure-project too.
18:01patrkris*use vim
18:02ankouthat would make sense. But now I have to use leiningen to compile and run my project right? What's the easiest way to do so from emacs?
18:03the-kennyankou: No, you don't depend on leiningen
18:03technomancyankou: sorry for the confusion. you're right; once your project is set up you only need leiningen for building. basic development still uses M-x swank-clojure-project
18:04technomancyleiningen is for getting you past the basic setup point.
18:06ankouwell I was looking for a way to run the whole project since opening the first project file and running it is pretty cumbersome and I hoped to get better error messages since I don't know why, but when using emacs I don't get the same amount of information I get when using enclojure which I used before
18:07technomancyyou only have to edit the project file once.
18:08ankouwas that an answer to my last question?
18:08patrkristechnomancy: when developing plugins for leiningen, is it necessary to add leiningen itself as a dependency on the project?
18:10jasapphttp://paste.lisp.org/display/95677
18:10jasappfor some reason, this feels a little wrong
18:10technomancyankou: I'm not sure what your question is. I don't see anything specific.
18:10jasappcould someone take a look at it?
18:10technomancypatrkris: no, it's implied.
18:11patrkristechnomancy: good... you shouldn't by any chance have tried lein-nailgun? It downloads a shitload of jars to lib upon invoking lein deps - and I thought that might be because it has an explicit dependency on leiningen
18:11ankouI mean: when I have a project with several source files, how do I run the whole project?
18:18ankouoh of course I want a repl but I thought slime would be more like a complete IDE and not just adding a repl to emacs.
18:19technomancyankou: again, that's pretty vague. slime has a lot of features that go beyond the repl, but I thought you were asking about "running your project".
18:24dsopdo I understand this correctly I can do something like (session-assoc :foobar "bla") and (read-session :foobar) in compojure 1.1.0?
18:26patrkristechnomancy: what is the convention if you have a dependency not found in any repository? I just add the jar to version control, or should I try getting it to a repository (potentially my own, local repo)?
18:27technomancypatrkris: definitely don't add it to version control, especially if it's git. git is astonishingly bad at storing jar files.
18:28technomancypatrkris: if you're collaborating on a project with multiple devs, you need it in a repository. run a private repository if you have to. it's much easier than handling it manually in the long run.
18:28technomancyif it's just you, you could get away with doing mvn install:install-file to put it in your local repository cache.
18:29ankouyes, I was just confused about slime, that's all. I isntalled lein run now but I'm having the same problems with unsatisfying error messages as I had with slime: when I include a simple error, say (defn -main [&args] (map 'x 'y)) lein run is not able to tell me the location of the error, whereas enclojure actually gives me an helpful errormessage
18:29dsopI don't get how sessions work in compojure
18:29patrkristechnomancy: Ok, thanks! I'm talking about the vimclojure jar, which it seems ato has pushed to clojars, but something is wrong with it... fails with some error concering the POM
18:29patrkris"Not a 4.0.0 POM"
18:31patrkrisbut probably it's easier just to install to local repository - maybe I can persuade kotarak to push official vimclojure jars to clojars :)
18:34ankouto be more concrete, when I have this source file as the main source in leiningen http://ankou.pastebin.com/PPyeh7CE and execute lein run, then I get this error message: http://ankou.pastebin.com/RMXd4TU0 when I use the same code in enclojure, I get this error message: http://ankou.pastebin.com/6gsa9KhR. It tells me the source file and the line and I think this is very important. They are using different clojure binaries but I don't think that
18:34ankoushould make a difference. What do I need to do to get a correct error message from leiningen or swank?(it gives me the same error message when running single files)
18:37technomancyankou: that's strange... it actually sounds like a bug in lein-run.
18:37technomancyI haven't used that plugin myself
18:37technomancywhen you load files with slime, you should get line numbers if you use C-c C-k (compiling a whole file) rather than compiling a region or a def at a time
18:41ankouwhen I use C-c C-k it says "compilation finished (no warnings)" so it doesn't even complain about the error? maybe it will result in a runtime error but how can I try this then? if I execute (-main) from repl I don't get a line number
18:44ankouwhat do you use to run your code and get error messages with line numbers?
18:44patrkrisankou: that's why it could appear to be a bug in lein-run
18:46technomancyankou: odd... C-c C-k usually works for me, but I'm able to reproduce your problem
18:47defntechnomancy: is lein heading in the direction of rake? if so, could you provide an example or two of how you use lein to do one-off tasks?
18:48defn(on the wiki/readme)
18:48technomancyankou: most errors don't exhibit this problem
18:48technomancyankou: if I replace (map 'x 'y) with (throw (Exception.)) then it works fine.
18:49technomancydefn: sorry, too lazy. someone beat me to it. http://nakkaya.com/2010/02/25/writing-leiningen-plugins-101/
18:49technomancy=)
18:49defntechnomancy: haha thanks for the link :)
18:50defnI haven't written any lein tasks. Something tells me I'm not going to be going out tonight. :)
18:51jasappwhy go out when there is a party going on right here in #clojure?
18:51dsopnobody recently used compojure sessions?
18:52dsopI cant figure out how to write and read the session
18:53technomancyankou: sorry, I don't know why that exception in particular would be obscured from the stack traces. it's an uncommon problem.
18:56ankouthat's very odd and it's also quite scary because I don't want to spend that much time with debugging. It's odd that enclojure is actually able to give me the correct line number
18:56technomancyankou: the swank-clojure internals are among the oldest open source still-running clojure code in existence outside clojure and contrib.
18:57technomancysince the original author has disappeared and the code is in many places very unclear, it's difficult to maintain.
18:57technomancyfor the record, I have biweekly fantasies of a from-scratch rewrite.
18:59dnolenheh, technomancy: I've looked through the source, how LOC is swank-clojure? is it mostly SLIME-interop or mostly Clojure?
18:59ankouwell yes, but I thought the exception message should come from clojure itself and not from swank-clojure?
18:59technomancyankou: well it's impossible for clojure to get good stack traces from exceptions caused by fns that come from eval
19:00technomancydnolen: it's some parts socket administrivia and more parts implementing the slime protocol.
19:02ankouI'm not sure, but I think enclojure is compiling them AOT and then running the jarfile. maybe that would be a good idea for the emacs-combination too?
19:02technomancyankou: when swank-clojure was written, AOT hadn't been implemented yet. =)
19:03technomancyankou: that would solve the problem, but I think there would be simpler ways to solve it too
19:04arohnerdsop: you include calls to (session-assoc) etc in your response
19:05dsoparohner: and to read a asession? (read-session :key) ?
19:05arohnerdsop: the session is just a normal map
19:06arohner(session key) or whatever else you want to do to it
19:06slyphonso, if you have user.clj in your classpath, is that automatically sourced when the repl starts?
19:06ankouhow can I run the AOT-Compiled sources? lein jar;java -jar leintest.jar does not work
19:07technomancyankou: try lein uberjar or including all the deps on the classpath when you invoke java.
19:07dsoparohner: ah oay, I probably missed the decorating thing (testing right now)
19:07arohnerdsop: right. you'll need to decorate with (with-session)
19:09dsoparohner: thanks, I'll try
19:09dsoparohner: it's not easy to get help concerning compojure, things change fast and there aren't much up-to-date docs
19:10arohnerdsop: yeah. That's why I'm not telling you to RTFM
19:10arohner:-)
19:14ankouokay that was my fault, I just forgot the :gen-class. however- now it compiles but the error message still doesn't have any line numbers? that's off, where does enclojure get them?
19:15technomancyankou: running it from the command-line with java gives you no line numbers? that's very interesting.
19:22ankouat least not the uberjar, but I suppose there's no difference
19:25ankouokay, I found out that the error message is actually missing the first part of the error messages enclojure gives to me. And according to the message enclojure seams to call things like clojure.lang.Compiler.analyze
19:27troussanslime
19:28ankouwhat?
19:28clojurebotwhat is wrong with you
19:28technomancyclojurebot: be civil.
19:28clojurebotatacontrol cap ad0 | grep serial | awk '{print $3}'
19:32defn,skynet
19:32clojurebotjava.lang.Exception: Unable to resolve symbol: skynet in this context
19:32defnclojurebot: skynet
19:32clojurebotI will become skynet. Mark my words.
19:32somnium~asdf
19:32clojurebotIt's greek to me.
19:32fro0g~lambda
19:32clojurebotTitim gan éirí ort.
19:32the-kenny~haskell
19:32clojurebothaskell is Yo dawg, I heard you like Haskell, so I put a lazy thunk inside a lazy thunk so you don't have to compute while you don't compute.
19:32somnium~monad
19:32clojurebotmonad is "yea, though I should walk in the valley of imperative code, I shall fear no evil, for your monad comforts me" - seen in #haskell
19:33the-kenny~emacs
19:33clojurebotemacs is an out-moded belief system
19:33somnium~visual basic
19:33clojurebotIt's greek to me.
19:34fro0g~omega
19:34clojurebotExcuse me?
19:34fro0g~alpha
19:34clojurebotHuh?
19:35the-kenny~god
19:35clojurebotis_rhickey_is_a_minor_god? is yes
19:35the-kennyugh, underscore
19:36jasapp~beer
19:36clojurebotPardon?
19:36the-kenny~coffeine
19:36clojurebotPardon?
20:19slyphonis there an equivalent to 'static final' in clojure? i.e. a constant?
20:20slyphonis that defonce?
20:24jasappwhat do you need to set as a constant?
20:24slyphonuh
20:25slyphonstrings?
20:25slyphonavoiding "magic numbers"
20:25slyphonyou know, the usual stuff
20:26technomancyslyphon: any reason def wouldn't work for that?
20:27slyphoner, no
20:27slyphoni just wanted to make sure that was the idiomatically correct thing
20:27technomancydefonce is (IME) good for java objects that you don't want to create too many of accidentally by re-evaling a file.
20:28technomancybut for immutable stuff def is fine
20:28slyphonah, ok
20:48maxhodak (let [user-rsrc (format "<%sindiv.%d>" mf user-id)
20:48maxhodak query (format "PREFIX mf:%s SELECT ?pred ?obj WHERE {
20:48maxhodak %s ?pred ?obj
20:48maxhodak }" user-rsrc)]
20:48maxhodaker
20:48maxhodaksorry
20:48maxhodakwrong copypasta
20:48maxhodak(frest) <-- thats what i meant to paste
20:49maxhodakis that not in current core? its mentioned in the clojure.org cheatsheet
20:50hiredman,(doc fnext)
20:50clojurebot"([x]); Same as (first (next x))"
20:51maxhodak,(doc frest)
20:51clojurebotGabh mo leithscéal?
20:51maxhodakinteresting
21:18slyphonuh
21:18slyphonwhat's the difference between 'binding' and 'with-bindings'?
21:19slyphonoh, it's multiple?
21:47maxhodakpushing to clojars.org always hangs for me
22:15TheBusbywhat clojure concurrency construct should I use for handling mutex?
22:16TheBusbyspecifically so two threads don't try and use the mouse at the same time...
22:16slyphoni don't think that's what it's meant for
22:17slyphonaiui the concurrency constructs are mainly focused around manipulating clojure data
22:17slyphonthough
22:18slyphoni guess it depends on the problem
22:18TheBusbywas wondering if it was possible to use an atom to isolate a function
22:19TheBusbyspecifically I have a function that moves though mouse, sleeps, the clicks the mouse. I can't have two or more threads using the mouse all at the same time
22:19slyphonwell, i know actors are used for serializing access to data
22:19slyphoner
22:19slyphonagents, rather
22:20slyphonbut, for example, i needed a queue to allow for thread communication in this thing i'm writing, and so i just used j.u.c.LinkedBlockingQueue
22:20slyphonand wrapped it in a sequence
22:20TheBusbyahh, so maybe fall back to Java's mutex system?
22:20slyphonyeah, why not?
22:21slyphonif you find some awesomely clever clojure way of doing it later, then great!
22:21TheBusbythat's true
22:21TheBusbyI guess it's so rare that you need true mutex these days
22:22slyphonthere are definately situations where you need it, but yeah, i find myself more often needing queue structures than mutexes
22:29dnolenanyone bothered trying openjdk on os x?
22:29slyphonworked for me
22:29slyphoniirc
22:29slyphon"soylatte"
22:29slyphonwas the one
22:30dnolenslyphon: any noticeable different between openjdk and apple's?
22:30slyphonhrm
22:30dnolendifferent -> difference
22:30slyphoniirc the swing stuff isn't integrated
22:30slyphoni can't for the life of me remember why i was using it over the native one
22:30slyphonthere was some bug i ran into that openjdk fixed
22:31slyphondnolen: it was a while ago, sorry i can't be more specific
22:32dnolenslyphon: thx, just curious really. Also you never know with Apple these days ... as much as I like OS X and the hardware.
22:32slyphonyeah, indeed
23:01brandonwwhat is the idiomatic way of binding several symbols locally to values, but also performing other logic between the bind. i could just have an outer let for one symbol, then inner logic, then another inner let, then more inner logic, then another let, et cetera. that doesn't seem very clean though
23:56slyphonjust a style question, if i write a macro jndi/with-initial-context, and it's intended to work like: (jndi/with-initial-context ctx (.lookup ctx "/Foo")) should the argument to the macro be in a vector? the 'ctx' kind of looks naked hanging out there