#clojure logs

2011-07-19

00:00amalloy&(re-seq #"(.)((?!\1).)" "aacbb")
00:00lazybot⇒ (["ac" "a" "c"])
00:00amalloy&(re-seq #"(.)((?!\1).)" "aaccbb")
00:00lazybot⇒ (["ac" "a" "c"] ["cb" "c" "b"])
00:07methodsamalloy: yea the backrefs did work
00:09amalloyyes, i can see that
00:12methodswoo ! I added it to my bot..
00:14methodsI know it's not clojure (yet) :] https://gist.github.com/6f71751ce21b6296ce37
01:01brehautcan anyone think of a better way of implementing (defn pivot [p xs] (loop [prior [] [h & r] xs] (if (p h) [prior h r] (recur (conj prior h) r))))
01:02brehauteg (pivot {#1,2,3} [4 5 3 6]) => [4 5] 3 (6)
01:02amalloybrehaut: sounds like a split-with
01:02brehautamalloy: almost but not quite
01:03brehautat least, if it is i havent worked out a nice way yet
01:03amalloy(defn pivot [p xs] (let [[prior [h & r]] (split-with p xs)] [prior h r]))
01:03amalloyprobably (complement p)
01:06brehautamalloy: excellent
01:06brehauthmm. no not quite
01:06brehaut (pivot #{1,2,3} [4]) => [(4) nil nil] but should be [nil nil (4)]
01:07amalloyi think your impl yields the same thing?
01:07brehautif it does it broken too then ;)
01:07brehauthah
01:07brehautno mine recurses indefinately at that point
01:07amalloyisn't 4 before the pivot? i don't see how you can claim it's after
01:08amalloyif the pivot is nowhere
01:08brehauthmm pivot is a bad name
01:08brehautbecause you are correct if its actually a pivot
01:09brehauti think i am too tired to write this code properly; ignore me
01:18grantmanybody ever seen the error "can't eval locals"?
01:19grantmim trying to teach myself macros by just jumping in... its kinda confusing
01:20grantmsay i do (defmacro simple [x] (eval x))
01:20amalloygrantm: good policy. not familiar with the error, but gist up a macro and a stack trace (if you can get one; sometimes it's hard with macros) and i'll have a looksie
01:20grantmheh, i can do that too
01:20grantmalthough its just one more line :)
01:21amalloygrantm: on the wholel, anytime you use eval (especially in macros), huge blaring alarm sirens should go off in whatever room you're in. sometimes it's good, but...
01:21amalloy*whole
01:21grantmhttps://gist.github.com/1091372
01:21grantmhaha
01:21grantmalright, i'll keep that in mind
01:21grantmlet me explain what i was trying to do
01:22grantmand maybe you can tell me a better idea :)
01:22grantmim trying to make a simple lispy templating language, just for fun
01:22grantmi want something like (html (body "yay")) to return "<html><body>yay</body></html>"
01:23grantmthat means that html is a function that wraps it's args with html... and similarly with basically any other tag function... so i figured i could make a macro that creates a wrapping function given a string
01:24grantmthe reason i (thought i) had to use eval was because if you pass in a symbol to my create-wrapper macro, it makes a <symbol> wrapper instead of a <(eval symbol> wrapper
01:25grantmbut that's separate from the weird thing i put on gist
01:25amalloygrantm: so this is because macros are explicitly about *generating code*, not about "doing things" at runtime
01:26grantmokay
01:26amalloyif you had a macro like (wrap-with-whatever [tagname body]), say
01:26amalloyyou couldn't call it like (let [tagname "test"] (wrap-with-whatever tagname "the-body"))
01:27amalloybecause no macro can go from the symbol "tagname" to "test" - at *compile time*. the value "test" only exists at runtime
01:27grantmaaah. interesting.
01:27amalloyfortunately, your task is easy to do with functions
01:29scottjgrantm: certainly not humourous
01:29scottjsorry, my copy paste is broken
01:29grantmhaha
01:30scottj(defmacro html [body] `(hiccup/html [:html (into [] '~body)]))
01:30grantmso to summarize, if i find myself trying to turn symbols into values in a macro, that's a bad sign?
01:30scottj(html (body "yay")) => what you had
01:30amalloygrantm: yeah. one sec while i gist something up
01:31grantmcool, thanks
01:31amalloyhttps://gist.github.com/1091384
01:34grantmnice, ok, let me get my head around this :P
01:34amalloyyeah, (fn [x] (fn [y] ...))) can be unsettling
01:36amalloygrantm: updated the gist with a different way of writing it, if that's clearer
01:39grantmok yup it makes sense
01:39grantmthe second one
01:39grantm;)
01:40grantmoh, the first one is almost the second one
01:40amalloygrantm: it is the second one
01:40amalloythey're the same, except the second one uses global defs instead of local bindings
01:40grantmokay, i see
01:42amalloythen if you want to, you can paper this over with a layer of macros, that does the repetitive work of creating the dozens of (foo-wrapper) functions for you using the html-wrapper function
01:42grantmthe (def x (html-wrapper "x"))?
01:43amalloyright
01:44amalloy(defmacro def-wrappers [& tags] (cons `do (for [tag tags] `(def ~tag (html-wrapper ~tag))))), (def-wrappers html body table ...)
01:45amalloyexcept i guess it needs to be (html-wrapper '~tag) or (html-wrapper ~(str tag))
01:45grantmbut wait, when you do `(def ~tag (html-wrapper ~tag)), one has to be a string and one a symbol right?
01:46amalloygrantm: meh. the symbol will get converted to a string by the (str) call in html-wrapper
01:46grantmokay interesting
01:46grantmi think i have a better conceptual framework for macros
01:46amalloy&(str "<" 'test ">")
01:46lazybot⇒ "<test>"
01:47grantmhaha, cool.
01:49amalloyso macros are great, but they're kinda for three purposes: (1) convenience wrappers over functions, (2) introducing new syntactic constructs, such as (when-let), (3) when functions simply won't do
01:49amalloy(3) and (2) are pretty closely related; it's amazing how many things you can do with functions
01:49grantmclarification on 3? :)
01:50amalloy3 is mostly a restatement of 2: most things that can't be done by functions are new constructs
01:51amalloybut one example is when someone else has written a macro, and you want to layer some more stuff over that
01:51amalloymacros don't compose very well, so you usually have to wrap their macro with one of your own that does the substitutions you want
01:53grantminteresting.. alright
05:06bsteuberso what was the new thing Rich's been talking about?
05:10raekI think the talk is 6:45 PM on wednesday, New York time
05:44bsteuberoh ^^
05:44bsteuberbeing able to read really is an advantage these days
05:51bsteuberis there a way for resetting swank to the initial state without restart?
05:51bsteuberfor example, to clean polluted multimethods
05:51bsteubercalling (remove-ns ..) by hand and recompiling all seems a bit painful
06:58dbushenkohi all!
07:13bsteuberis there a version of some returning the element, not the predicate applied to the element?
08:23solussdis there a media playback framework for clojure, ala FMJ or JMF?
08:23bendlasyou can just use one of them
08:23fliebelsolussd: Well, you can use those Java things... or try JNA + VLC :)
08:24bendlasalso, i've made good experiences with gstreamer-java
08:24solussdthanks!
08:24fliebelbendlas: Can gstreamer play ALAC? That's why I used VLC
08:26bendlasTBH, i don't even know ALAC
08:27fliebelbendlas: Apple Lossless Audio Codec
08:28bendlasit probably does, after installing gstreamer-bad and gstreamer-ugly
08:29bendlas=-0987654321`+
08:29bendlaswhoops, wiped my KB, sry ^^
08:33fliebelbendlas: http://imgur.com//gallery/i7zEm
08:35bendlaslol
08:59ogonzalezbsteuber: you can use (comp first filter)
09:19bsteuberogonzalez: oh yeah, more elegent than (some #(when (pred %) %) coll)
09:26dbushenkobsteuber: yesterday you've advised me to make a jar for Clojure-WebApp -- it is done now, just have a look
09:58bsteuberdbushenko: looks good
09:59bsteuberhow do you want users to talk to the db?
10:00bsteuberclojureql? or some custom active-record clone you're going to write?
10:02dbushenkofor now it is contrib-sql (or something like that which is a standard for clojure). I'm not going to rewrite that layer. Also, the user is free to use any libraries here, e.g. clojureQL
10:03dbushenkowhat really will be usefull -- is detailed documentation with lots of examples
10:03dbushenkothere are lots great of libraries for clojure which are not so popular -- just because nobody knows how to use them
10:05bsteuberindeed
10:05dbushenkofor instance, if you look at my code, you'll see tons of comments
10:05dbushenkoI made this because I want make it easier for the other users to evolve the framework
10:06dbushenkoI need help in developing the Clojure-WebApp so I try to make my source friendly to newcomers
10:07bsteuberif you're quite new to clojure, doing a big project like this might be quite hard, I suppose
10:07bsteuberwell maybe it's not that big with all the existing stuff ^^
10:07dbushenkothis is the reason :-D
10:08dbushenkoalso what I've learned from it is that Clojure is very-very expressive
10:08dbushenkoMy framework is very small but it does many interesting things:
10:08bsteuberindeed
10:08dbushenkorouting, templating and so on
10:09bsteuberif you know what you want, just a bunch of small namespaces will make it most of the time
10:09dbushenkothat's why I'm not afraid of what I'm doing. I need not so much code to make good things
10:11dbushenkowell, I know what I want in the nearest future. I exepriment with what I have and evolve it. If at some time my design will cause problems -- then I will change it as I've already done two times starting from ClojureBlog
10:12bsteuberideally, your stuff is split into so many functions that even "big refactorings" don't involve that many changes
10:12dbushenkoprobably -- yes..
10:13dbushenkobsteuber, OK, I have to get back to home. See you!
10:54timvisherhey all
10:57timvisherif you were of the mind to serve up a static file via an http
10:57timvisher*** server for functional testing, but didn't want to have to remember
10:57timvisher to start that server before each test, how would you go about
10:57timvisher starting up a server before the relevant tests each time they're run?
10:57timvishersorry for the filling!
10:58kumarshantanutimvisher: start up the daemon via system init script?
10:59timvisheris that a clojure specific thing or do you mean starting the server as soon as my system starts as a whole?
10:59kumarshantanuthe latter
11:00timvisherah
11:00kumarshantanuor do your tests have different places to serve static files from?
11:00timvisherwell, I'd prefer not to have the server running all the time as it's only used for my testing
11:01kumarshantanuthen script your tests in a way that it starts up the daemon before the tests are run, and closes it afterwards
11:01timvisheri'm wondering if there's a simple wrapper I could use from ring to start up a little instance of jetty or something
11:01kumarshantanulein-daemon plugin?
11:01timvisherI can imagine how to do that, is there anything pre-written?
11:01timvisherah
11:01timvisherI'll check that out
11:01kumarshantanulein-daemon can start and stop things
11:02kumarshantanuand if you use lein 1.6.1, you get a key called :extra-classpath-dirs that won't be included in the JAR or WAR
11:02kumarshantanuyou can use that to place your daemon startup/shutdown code
11:03timvisherthat looks promissing
11:04timvisherok
11:04timvisherwell thanks for the idea
11:04kumarshantanu\m/
11:04jcromartiefor some reason I can't use the metadata key :type
11:04jcromartie(in a defn)
11:06jcromartie(defn ^{:type :foo} f [x] x)
11:06jcromartiethat fails
11:07jcromartieerrp
11:07jcromartiesorry (defn ^{:type :foo} f [x] x)
11:07jcromartieerr... yeah
11:07kumarshantanujcromartie: it is working for me
11:08jcromartiethat fails with java.lang.ClassCastException: clojure.lang.Var cannot be cast to clojure.lang.IObj
11:08kumarshantanu,(defn ^{:type String} foo [] "foo")
11:08clojurebotDENIED
11:08jcromartieif I change :type to :types it works
11:08kumarshantanuaccess it thus -- (meta #'foo)
11:10kumarshantanujcromartie: and thus -- (type #'foo)
11:11Hodappwow... pretty much every single web-service technology I've dealt with has been fugly, and in the case of Java it's completely riddled with made-up terms that are then used very loosely
11:12HodappI greatly look forwardd to being able to mess with Clojure when I get home...
11:12jcromartiekumarshantanu: is that what (type var) does
11:12jcromartieah I see
11:12kumarshantanujcromartie: the :type key should be associated with a class, not a keyword
11:12jcromartieyeah
11:12jweissdoing my first multithreaded program in clojure - not quite sure which tools to use. i have a single tree (zipper) data structure, and i want all children of a node to be processed by multiple threads (which will update that node). agents/atoms/refs?
11:13kumarshantanujcromartie: this should work -- (defn ^{:type clojue.lang.Keyword} foo [] "foo")
11:14jcromartieit doesn't, because I believe :type is reserved
11:14kumarshantanujcromartie: #'foo is same as (var foo)
11:14jcromartieyes I know
11:14kumarshantanutypo above, i meant this -- (defn ^{:type clojure.lang.Keyword} foo [] "foo")
11:15jcromartieyeah
11:15jcromartiewell that's reserved by Clojure for that purpose
11:15jcromartieI think
11:15kumarshantanuyes, it is used for type hints i guess
11:20jcromartieso speaking of type hints
11:21kumarshantanugot to head home...
11:21jcromartieI figure it would be possible to add (optional) static type checking to clojure using metadata
11:22jcromartiethis is a totally crude draft v0.0.1alpha https://gist.github.com/f2e6713ba14261115dde
11:22kumarshantanujcromartie: i thought pre/post conditions are better suited at that
11:22jcromartiethey can't be applied statically
11:22jcromartielike, what if you wanted static checking?
11:22jcromartieto say (typecheck some-code ...)
11:23jcromartiejust as an analysis
11:23kumarshantanunot sure if that's possible in Clojure without changing the language
11:23jcromartieyou don't think?
11:23jcromartiewe'll see
11:23jcromartieit would be entirely imposed by the programmer
11:24kumarshantanufor standalone analysis, with metadata....perhaps it's possible as long as you have a metadata repo
11:25kumarshantanuleaving for home...
12:33lnostdal-laptophm, so what's the difference between send and send-off? .. in the docs i see, briefly, that send-off is for potentially blocking calls; does it perhaps use a different thread pool than send?
12:34TeXnomancylnostdal-laptop: correct
12:34lnostdal-laptopthanks, TeXnomancy
12:34lnostdal-laptopi just found this too: http://stackoverflow.com/questions/1646351/what-is-the-difference-between-clojures-send-and-send-off-functions-with-res
13:08lnostdal-laptopi seem to do something like this a lot: (assoc m :something (conj (:something m) more-stuff)) ;; perhaps there's an already existing shortcut in the clojure api? .. my mind is on a sugar low at the moment, browsing .....
13:08raeklnostdal-laptop: update-in
13:08lnostdal-laptopraek, thanks!
13:08raek(update-in m [:something] conj more-stuff)
13:09lnostdal-laptop..very nice..
13:09lnostdal-laptop:)
13:09dnolenlnostdal-laptop: assoc-in, get-in also useful.
13:09lnostdal-laptopyeah
13:11dnolen,(assoc-in {} [:foo :bar] 1)
13:11clojurebot{:foo {:bar 1}}
13:19amalloylnostdal-laptop: you can also combine update-in with assoc to perform multiple insertions at the same level: ##(update-in nil [:a] assoc :b 1 :c 2)
13:19amalloy,(update-in nil [:a] assoc :b 1 :c 2)
13:19clojurebot{:a {:c 2, :b 1}}
13:19dnolenand for ultimate power you have zippers.
13:20amalloyman, i just got an email about an eclipse bug i filed a year ago. "Fixed in CVS head". people still use cvs?
13:21ieureamalloy, Humans are disgusting.
13:21ieureMasochists.
13:21ieureCVS is the CBT of SCM.
13:22ieureThat’s goin’ on Twitter.
13:22amalloyyou have something against cognitive behavioral theory?
13:23Scriptoramalloy: cock and ball torture, clearly
13:25stuartsierrawow, wrong time to walk into the room.
14:20redline6561What's the difference between lein swank and lein repl?
14:21redline6561(Sorry if I missed an earlier obvious resource...)
14:21dnolenredline6561: lein repl is a standalone repl, lein swank is generally for connecting to from Emacs
14:21redline6561dnolen: Aha. That makes a lot of sense. Thanks.
14:21dnolenclojurebot: ~max
14:22clojurebotmaxine is http://research.sun.com/projects/maxine/
14:22dnolenclojurebot: max people
14:22clojurebotmax people is 317
14:52mattmitchellhow do i create a Character?
14:53kumarshantanu\s is a Character
14:53kumarshantanu(seq "hello") ;; will produce a sequence of Character objects
14:53kumarshantanumattmitchell: similarly, \space is also a Character
14:54kumarshantanumattmitchell: and this - http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/char
14:58lnostdal-laptophmmm, clojure is kinda like common lisp; most things fit together quite nicely .. each thing is quite trivial in isolation, but it is composed nicely; that's the key i guess
15:06Cozeyi cannot lein deps 1.3.0-master-SNAPSHOT - what am i missing?
15:06Cozeydo i need to add some repository?
15:06Cozeysorry - full name is : org.clojure:clojure:jar:1.3.0-master-SNAPSHOT
15:08mattmitchellkumarshantanu: thanks!
15:08technomancyCozey: you need to add the clojure snapshots repo
15:08technomancyit's listed on confluence
15:09Cozeybut i wasn't doing it on my old setup - and it worked. or i have forgottne. and now on new setup i need to do it ?
15:09technomancyCozey: IIRC clojure/core deprecated the old snapshots server and the new ones are available elsewhere
15:10Cozeyahh. because i have them in local maven repo perhaps
15:10Cozeyso what should be used now?
15:10Cozey-alpha?
15:10technomancyalphas and snapshots are both available, it depends on what you want.
15:10dnolenlnostdal-laptop: not so surprising since rhickey is a big CL fan, rhickey circa 2000 on comp.lang.lisp http://groups.google.com/group/comp.lang.lisp/msg/fb3e3efa3b0f1f12
15:11dnolen^ the birth of Clojure?
15:11Cozeytechnomancy: i want 1.3 - and as developed as possible, but also bugfree as possible, so i guess alpha4 would be smart
15:11technomancyyou probably want beta1 then
15:12Cozeyand what repo is that ?
15:13Cozeyhttp://build.clojure.org/releases/org/clojure/contrib/fcase/
15:13Cozeyhere is don't see betas
15:13Cozeyahh ok
15:13Cozeycontrib doesnt have it
15:13Cozeytechnomancy: thanks! it clears things
15:16hugodanother use for elisp injection - rename your slime buffers after your projects, so you keep separate slime repl histories for each project
15:18lnostdal-laptopdnolen, yeah, i know his background .. i used several of his CL<-->Java libraries back in, hm, 2005-6 or so :)
15:19dnolenlnostdal-laptop: heh, cool.
15:36bpri'm having a hard time getting tests to report useful failure information with the latest clojure-mode and slime available in marmalade. Is this a known bug?
15:37gtrakdoes clojure-mode autocomplete java?
15:38lnostdal-laptopnope, gtrak .. (at least not here)
15:38lnostdal-laptop..it'd be great though
15:38vijaykirangtrak: I didn't see the java autocompletion - only works on the words in the file I think
15:38gtrakah, sad
15:39amalloygtrak: it couldn't really work very well without static type information
15:39amalloywhere do you look to find a completion for (.setMe<tab>?
15:40vijaykirangtrak: may be jdee can help - I didn't use it though
15:40gtrakhmm, it seems the slime repl can do it though
15:40lnostdal-laptopoh, indeed it can
15:40gtrakthough badly
15:40clojurebotIt's greek to me.
15:40lnostdal-laptop..i guess static methods?
15:41amalloy*shrug* it's just guessing based on god knows what
15:41gtrakthe classpath that lein set up for it?
15:44gtrakamalloy, well, you could do imports easily enough
15:45amalloygtrak: how would that be useful? i import java.sql.ResultSet, then i do (.getD<tab> -- how does it know to look at the java.sql.Date class?
15:45amalloyit can't know that i was planning to get a date field out of a ResultSet when i haven't even mentioned ResultSet yet
15:48gtrakof course it wouldn't be as useful as the full parse tree reading your mind, but say you're declaring imports, you could go import Dat<tab> and get a list of java.util.Date, etc..
15:51buddywilliamsWhat is the different between sharp-quote and using a fn symbol? Ex. (map #'+ '(1 2 3) '(10 100 1000)) and (map + '(1 2 3) '(10 100 1000))
15:51gtrakthe .getD would be broken, but (. Classname (.getD<tab> could work
15:51buddywilliams,#'+
15:51clojurebot#'clojure.core/+
15:51buddywilliams,+
15:51clojurebot#<core$_PLUS_ clojure.core$_PLUS_@8fb65>
15:52amalloy,@#'+
15:52clojurebot#<core$_PLUS_ clojure.core$_PLUS_@8fb65>
15:52buddywilliamsSo they return different values
15:52frou100Is anyone familiar with the unix tool netcat? I'm trying to use it to send text to lein's socket repl and am having a problem.
15:52gtrakfrou100, I used it once and it's pretty self-explanatory
15:52amalloy,(var +)
15:52clojurebot#'clojure.core/+
15:53amalloy,'#'+
15:53clojurebot(var +)
15:53buddywilliamsgtrak were you talk to me previously?
15:53gtrakbuddywilliams, no
15:53buddywilliamsokay, thanks
15:53amalloybuddywilliams: anyway, those are the interesting examples. #'foo is a var, in fact is shorthand for (var foo); if that doesn't answer your question, probably time to get more familiar with what a var is
15:54buddywilliamssounds like a plan
15:54buddywilliamsI am just diving in here so I am sure there is much to get familiar with
15:54raekif you do (.<tab> it will list all methods it knows of
15:54buddywilliamsbut if var is simply a normal variable then that doesn't seem to difficult
15:55amalloybuddywilliams: clojure doesn't have variables
15:55amalloyit has locals, vars, and refs
15:55frou100gtrak: I give netcat a file on its stdin to send to the repl. I'd expect netcat to close and exit once it has sent the data but it just sits indefinitely.
15:55amalloys/refs/reference types
15:55lazybot<amalloy> it has locals, vars, and reference types
15:55buddywilliamssounds like I need to do some reading
15:55buddywilliamsthe clojure site doesn't seem to explain exactly what things are
15:55buddywilliamsjust how to call them
15:56buddywilliamsI'll poke around some more
15:56gtrakfrou100, there's some option for that
15:57buddywilliamshttp://clojure.org/vars
15:57buddywilliamsthat's was easy :_
15:57buddywilliams:)*
15:58gtrakfrou100, http://linux.die.net/man/1/nc "After the file has been transferred, the connection will close automatically."
15:58raekwell, you could argue that Clojure has variables in the mathematical sense
15:59gtrakfrou100, maybe you're using a version from 1997
16:00frou100gtrak: that is exactly the behaviour I want. Just checking, homebrew on OSX installed gnu netcat 0.7.1
16:01gtrakmaybe try < instead of |
16:02frou100I do: netcat localhost 5659 <$REPL_INPUT >$REPL_OUTPUT 2>&1
16:05sritchieif I'm defining a macro, is there some way to get the namespace in which the macro's being used?
16:06sritchieif I wanted to prefix some.namespace to something, for example, when (mydefn cake ...) was called inside of some.namespace
16:06sritchieahead-of-time syntax quoting, I guess that'd be?
16:13jcromartiesritchie: what's the actual purpose?
16:14sritchieso, hadoop requires AOT compilation on classes, so I can invoke jobs with "hadoor jar path some.namespace.ClassName ..."
16:14arjanyone know what Riches talk tomorrow is going to be about? :)
16:14sritchiehttps://gist.github.com/1093590
16:15sritchiejcromartie: I wanted a macro that would write out the gen-class, set main to true, assign the proper prefix, etc, and wanted it to set the :name value to be some.namespace.SuppliedName
16:15sritchieso, (defjob SuppliedName [x] ...) etc would create some.namespace.SuppliedName
16:17arjhas anyone tried running clojure on java7 yet?
16:19frou100oh well, gtrak, I don't think this is possible. my dubious plan b is to start netcat in the background, record its pid, then kill it after a second
16:20gtrakfrou100, yea, I don't know, seems like it should work
16:24jonabbeyi've run clojure on java 7, no issues in basic interaction with the repl and leiningen
16:25arjjonabbey: cool thx
16:25sritchiejcromartie: looks like that gist gets the job done
16:25paohi all, would it be possible to define a "lazy" _or_ implementation in clojure? are macros needed?
16:26pao> (+ 1 1)
16:26hsbot No instance for (GHC.Show.Show (a0 -> a0)) arising from a use of `M8168114599624083945.show_M8168114599624083945' Possible fix: add an instance declaration for (GHC.Show.Show (a0 -> a0))No instance for (GHC.Num.Num (a1 -...
16:27pao> let myor x y = x || y in myor True undefined
16:27hsbot True
16:28pao> let myor x y = x || y in myor True (error "foo")
16:28hsbot True
16:28paothat's lazy
16:28jcromartieor is short-circuited
16:28jcromartieit's a macro
16:28paojcromartie, so with a macro I could implement a lazy myor, right?
16:29RaynesKind of.
16:29paojcromartie, what do you mean with "short-circuited"?
16:29paoRaynes, could you elaborate? :-)
16:29jcromartie,(or true (println "hi"))
16:29clojurebottrue
16:29gtrakhow would you guys go about doing a 'find-callers' in clojure-mode?
16:29jcromartie,(or nil (println "hi"))
16:29clojurebothi
16:30pao,(+ 1 1)
16:30clojurebot2
16:30RaynesAll the 'or' macro does is prevent latter arguments from being evaluated until when/if they need to be. I'm not sure it can be called laziness, but it acheives the same effect. I have trouble calling it 'laziness' because of what macros can do.
16:31paojcromartie, I know that or implementation is "lazy", the question is: do I have a chance to implement function that are lazy in the evaluation of their parameters as or is?
16:31RaynesOr, better yet, how macros work, I suppose.
16:31gtrakRaynes, in other languages, this short-circuited behavior is called laziness too
16:32Scriptoror basically rewrites itself into an if expression, which I guess you could call lazy
16:32paoRaynes, thanks ... I guess that macros are the tool for "lazyness"... I'll pospone my understanding till macro chapter :-)
16:32Scriptorin that the else part of an if expression isn't necessarily evaluated
16:35pao> let myor x y = x || y in myor False (error "foo")
16:35hsbot *Exception: foo
16:38paothanks everyone
16:38paogood night!
16:39technomancygtrak: slime gives you completion on class names and static methods. instance methods are impossible to complete without type hints, and type hints are rare enough that nobody's bothered to hook them up to completion.
16:52pmbauerHas anyone run into issues with "lein swank" after upgrading to lein 1.6.1?
16:52jonabbeywhat kind of issues?
16:52technomancypmbauer: agent/future issues are solved by swank 1.3.2
16:52pmbauerI'm getting a rather opaque stack trace whenever I add incanter as a dependency
16:53pmbauerlein repl, test etc work fine
16:53pmbauerI tried swank 1.3.2 as well as swank-1.4.0-SNAPSHOT
16:53technomancypmbauer: incanter bundles an obsolete swank snapshot
16:53pmbauerah
16:54technomancyneed to file a bug report for incanter and use an exclusion for now
16:54pmbauerI was beginning to suspect it was incanter's fault ... I'll clone incanter's repo and see about fixing that dependency
16:55pmbauerThe stack trace was particularly unhelpful (IllegalArgEx with no source file)
16:55pmbauerThanks
16:55technomancyno problem
16:59pmbauerSuccess. Thanks again, Phil!
17:01mjg123I've vector, contains room-reservations like {:start ... :end ... :name ...}
17:01mjg123- when I want to add a new reservation I need to make sure it doesn't clash with one, then add it
17:01mjg123can I do this check-then-add with (atom []) ?
17:02amalloysure
17:02mjg123"do this" == avoid the race-condition of someone adding another reservation between my check & my add?
17:03amalloythere are certainly ways you can do it with (atom []), and ways you could misuse an atom so as to not achieve your goal
17:03mjg123:)
17:03mjg123I'm just trying to get the hang of the difference between atom & ref
17:04mjg123so I could do (swap! reservations (my-function-which-does-check-and-insert-if-possible)) ?
17:04amalloyindeed
17:05mjg123cool
17:05mjg123then how do I know if my insert was successful or not?
17:05mjg123fail => swap! returns nil ?
17:06technomancymjg123: if it fails it'll be retried
17:06mjg123OK
17:06mjg123but if it fails that is a permanent case - it will never succeed
17:06technomancyI mean if there's a concurrency conflict
17:07mjg123oh, I see :)
17:07frou100you mean the difference between failing to do an atomic swap, and failing by the definition of your app logic?
17:07technomancyif you're checking for validity in your function then it's up to you
17:07mjg123yes, what frou100 said
17:09mjg123Maybe I wasn't clear...
17:10mjg123I've an atom, and I want to swap! in a new value, but only if the current value is in a suitable state
17:10mjg123obvs I can't check-current-state then swap!
17:11mjg123because of the race condition
17:11technomancyif you need to signal a failure without changing the value of the atom, then an exception is probably your best bet.
17:11mjg123ah - OK
17:11amalloyblurgh
17:12amalloytechnomancy: that makes me sick as a solution, if i've understood his problem
17:13technomancyhow else would you return more than one value from your swapping function?
17:13amalloymjg123: do you need to *know* that the swap decided not to add anything, or are you content to just have it return either the previous value or a new one?
17:14amalloytechnomancy: you can either do like (atom [reservations succeeded-flag]), and update both
17:14mjg123I need to know if the attempt to add was unsuccessful, yes
17:14stuartsierraYou need a ref. Then you can return whatever you need from the transaction.
17:15mjg123if it was a sql-type database, I'd need a transaction.
17:15mjg123so I wonder if I need a re
17:15mjg123f
17:15stuartsierraE.g., (dosync (if … (do (alter my-ref …) :success) :fail)
17:15amalloya ref is the easiest solution, for sure
17:15mjg123Well I'll do that then :)
17:15stuartsierraAtoms are just degenerate Refs.
17:15amalloyi take a perverse joy in trying to do everything with atoms
17:16technomancya ref is better if you don't consider reserving over an already-reserved slot an exceptional case.
17:17bprquick question: if i have something like (definline get-sessions [] @*sessions*) where *sessions* is private in the namespace, can other namespaces use get-sessions to see the current value of the *sessions* reference?
17:17mjg123thanks guys :)
17:17fliebeli take a perverse joy in trying to do everything with pure functions ;)
17:18amalloyfliebel: that's a socially-approved joy
17:18amalloyyou don't get to eat lunch with the cool kids if that's your perverse joy
17:18Raynesfliebel: I once wrote a webserver using nothing but pure functions.
17:18RaynesI guess that was Chuck Norris. Or Jon Skeet.
17:19Hodapppsssh. I didn't eat lunch with the cool kids - I ate lunch with the weird group who included the neice of the dean of the school.
17:19bpri'm wondering if the definline will be smart enough to fully qualify the *sessions* name in the other namespace? If it does, will the :private-ness of the name cause issues at that point?
17:19Hodappwhich meant I'd never get in trouble for anything.
17:19amalloybpr: it probably will work fine. but...definline? really? what for?
17:20bprnah, i'm actually using defn, but i was curious about that case
17:20tbatchelli_hey, here is a poll to see what people think Rich Hickey will announce tomorrow. Please cast your vote :) -- http://svy.mk/pptW0I
17:20bprthe reason i'm not exporting the name directly, is because i'm not sure how i'm going to implement it
17:20fliebeltbatchelli_: I dodn;t even knwo he was announcing something. I'm not a good fanboy.
17:21tbatchelli_also, don't cast your vote if you *know* what he'll talk about ;)
17:21tbatchelli_fliebel, he is, supposedly, tomorrow in NYC
17:21tbatchelli_(it's all for fun, by the way)
17:21RaynesMan, a poll? Really?
17:22RaynesI'm almost hoping he announces something entirely uninteresting just so I get the (perverse) joy of seeing everyone's jaw hit the floor.
17:22technomancyfliebel: five demerits!
17:22technomancyRaynes: iTeXL
17:22fliebeltechnomancy: five what?
17:22technomancyerr--iTeX?
17:23fliebelI'm with Raynes on this, though I do hope CinC will be around soon.
17:23technomancyclojurebot: google define:demerits
17:23clojurebotFirst, out of 181000 results is:
17:23clojurebotdemerits - definition of demerits by the Free Online Dictionary ...
17:23clojurebothttp://www.thefreedictionary.com/demerits
17:24technomancyhmm... that didn't come out quite right
17:24technomancy~dict demerits
17:24clojurebotHuh?
17:24technomancylazybot: dict demerits
17:24lazybottechnomancy: noun: Plural form of demerit
17:24technomancylazybot: botsnack!
17:24technomancylazybot: dict demerit
17:24lazybottechnomancy: noun: A quality or characteristic deserving of blame or censure; a fault.
17:24technomancyno, the other definition.
17:24technomancydang it
17:25fliebelhttp://www.urbandictionary.com/define.php?term=demerits
17:26technomancyfliebel: it's like when Snape is all "Five points from Gryffondor!" because they did something they weren't supposed to or whatever.
17:27fliebeltechnomancy: All because I didn't know about the ANN? :( I don;t want to know what happens when I do mutable state in a macro... or whatever.
17:27technomancyclojurebot: demerits is <reply>Ten points from Griffindor! http://29.media.tumblr.com/tumblr_kuqfz5zPOD1qz4eedo1_500.jpg
17:27clojurebotc'est bon!
17:28technomancyfliebel: just messing with you
17:28pjstadigget back to work technomancy!
17:28Raynesfliebel: He's foreign. Doesn't understand humor.
17:28RaynesIt's sad, really.
17:29fliebeltechnomancy: Where are you from? Raynes: I'm Dutch, so at least I understand Python.
17:29Raynes;)
17:29Chousukemutable state in a macro. hrrr
17:29Chousukeeven better, global mutable state
17:30technomancyfliebel: man I don't even know. I grew up in Indonesia but I'm from the US.
17:30technomancyso I know a few words of Dutch.
17:30ChousukeI only know what clojurebot knows
17:31technomancylike stroopwafel
17:31Scriptorfliebel: Netherlands Duth or Vlaams?
17:31Chousukeof dutch, that is
17:31fliebelScriptor: Duth ;)
17:31Scriptorgah
17:32fliebelChousuke: Clojurebot speak dutch?
17:32amalloyclojurebot: vvadlqw?
17:32clojurebotNo entiendo
17:33amalloyfliebel: he might have a dutch reply in there somewhere
17:33Chousukeyeah
17:33Scriptorargh, why couldn't making a simple http server in java be as simple as with python
17:33fliebelScriptor: Are you playing with NIO?
17:34Scriptorfliebel: nope, I'm thinking of using enlive to make a highly basic slide maker that can run in its own server
17:34Scriptorbut first, how to server
17:35fliebelScriptor: Jetty is easy. NIO is not...
17:36Scriptorooh jetty, forgot about that
17:38brehautScriptor: its a one liner with the ring adapter
18:04lnostdal-laptophm, so ... is Netty the thing Java/JVM/Clojure peeps go for when AJAX/Comet/WebSockets/ReverseHTTP is an important thing?
18:07wilfredhquick question about tracebacks
18:07dnolenlnostdal-laptop: Netty seems popular, Aleph is the Clojure library furthest along trying to build an idiomatic layer over it.
18:07wilfredhif I have an exception raised in foo/a.clj how do I distinguish it from an exception in bar/a.clj? It makes finding the offending code tricky
18:08amalloywilfredh: the name of the class throwing the exception will have either foo or bar in it
18:09lnostdal-laptopdnolen, yeah, i saw aleph .. i couldn't get it to work with 1.3 though
18:09wilfredhI can't see where: "Exception in thread "main" java.lang.Exception: No such namespace: ring (comments.clj:14)" (I have two files called comments.clj)
18:10amalloywilfredh: well, that's a compiler exception, raised while parsing the file, not raised from within the file
18:10lnostdal-laptop..i might check it out closer later; i did patch it here, banging my head against it for a while .. but gave up eventually :)
18:10wilfredhamalloy: ah, my mistake. So there's no way of finding which file had the compile exception?
18:11amalloyi don't think so. the compiler isn't very loud about that sort of thing
18:11amalloybut seriously, debugging *part* of a stacktrace is not very productive. if you want definitive answers, gist the whole thing up and link to it
18:12technomancywilfredh: I found that to be a huge annoyance until I switched to clj-stacktrace
18:12technomancyit's nicer in every way
18:12technomancyespecially the aligned frames
18:12wilfredhamalloy: I'm happy fixing it, it's just slowing me down
18:13wilfredhtechnomancy: thanks, I'll check it out
18:14technomancywilfredh: this hasn't made it into a release yet, but you may find it useful: https://github.com/mmcgrana/clj-stacktrace/blob/lein-hook/src/leiningen/hooks/clj_stacktrace_test.clj
19:05rbuchmannso, I figured out that (-> {blah} (assoc :a 1) (apply dissoc [:b :c])) doesn't do what I thought it would :)
19:06rbuchmannIs there an elegant way to use apply with threading?
19:09amalloymeh
19:09amalloyyou can write that as (-> (blah) (assoc :a 1) ((partial apply dissoc) [:b :c]))
19:10rbuchmannhm, okay... better then (dissoc (assoc ...)), especially in longer chains
19:10amalloybut that's hardly elegant. i don't find i often need to do this, which is probably a common feeling; that's probably why no solution has ever become popular
19:11rbuchmannthe result is pretty funny though, because of the way maps work as functions :)
19:12rbuchmann&(-> {} (assoc :a 1) (apply dissoc [:b :c]))
19:12lazybotjava.lang.IllegalArgumentException: Wrong number of args (3) passed to: PersistentArrayMap
19:12amalloy&(-> {} (assoc :a 1) (apply dissoc [:b]))
19:12lazybot⇒ :b
19:12amalloymore amusing imo
19:12rbuchmannexactly :)
19:13rbuchmannthat was what I was trying to get
19:13rbuchmannand what happened in my code
19:13rbuchmann...
19:16rbuchmannMaybe you can help me with something else... On my laptop, the following happens:
19:16rbuchmann(def t (agent 0))
19:16rbuchmann(send t inc)
19:16rbuchmann@t => 0
19:16rbuchmannno matter what I do
19:16rbuchmannsend-off doesn't work either
19:17rbuchmannin a swank-clojure repl from emacs
19:17rbuchmannany idea?
19:24rbuchmannthe "same" swank from exactly the same leiningen project does this correctly on any other platform I've tried it on
19:24rbuchmannI am a little out of ideas
19:26technomancyrbuchmann: you need swank 1.3.2
19:26technomancylein 1.6 includes a workaround for a clojure thread pool flaw that breaks old versions of swank
19:26rbuchmannso its a swank bug?
19:26rbuchmannah, I see
19:27rbuchmannthank you
19:27technomancynp
19:27technomancyneed to put that in the swank readme or something
19:27rbuchmannyeah, that would definitely help ^^
19:29rbuchmannare there instances where (apply f [...]) doesn't work when f is defined as (def f g), where g is a variadic function?
19:30rbuchmannI'm getting weird (wrong number of arguments supplied [0]) exceptions when using clj-processing (which does that for example for fill, background, etc
19:30rbuchmann)
19:32rbuchmannusing it as a (very cool, thanks for that technomancy) checkout dependency, if that helps or is in any way related
19:33technomancyI don't think you can get those kind of issues just by doing (def f g)
19:33technomancyif (apply g [...]) works, applying f will work too
19:33rbuchmannthats what i'd expect
19:33rbuchmannhmm
20:05lnostdal-laptopslime or swank-clojure or whatever is pretty stupid; maps pointing to each other leads to infinite loops
20:06lnostdal-laptop..dynamic var with cycle detector is needed i guess
20:07lnostdal-laptop..i recall already seen structures being replaced by #1 in a CL context .. then the previously mentioned structure got a #1 prefix so one could see
20:08technomancysounds great, want to implement it?
20:08lnostdal-laptopnot really
20:08lnostdal-laptop:)
20:08technomancythat makes two of us
20:10lnostdal-laptop..i'm just wrapping stuff in a thingy which returns nil for now; when exploring things in the repl
20:10RaynesI wrap all my stuff in thingies.
20:10lnostdal-laptopyeah, lisp makes that easy
20:27amalloylnostdal-laptop: printing #1# is probably not that hard, but printing it readably sounds harder. i think CL lets you type in self-referential objects that way
20:27lnostdal-laptopyup, amalloy .. not something i've used a lot
20:28lnostdal-laptopyeah, #1# .. not just #1
20:28lnostdal-laptop..as i said above
20:28amalloywell, some of both
20:28amalloy#1=(a . #1#)
20:29amalloyactually i guess printing is harder than reading
20:29amalloyi dunno. everything is hard
20:30brehautlets go shopping?
20:31amalloybrehaut: i was actually in the middle of reading about the history of that phrase
20:31brehautits an accident right?
20:31amalloywhat is?
20:32brehautthat phrase/
20:33amalloywell. apparently there was a talking barbie doll whose phrases included "Math class is tough!" and "Want to go shopping?"
20:35brehautso separate phrases rather than one?
20:35brehautand they ran together quickly by accident?
20:36amalloybrehaut: http://itre.cis.upenn.edu/~myl/languagelog/archives/002892.html is my source
20:36brehautcheers
20:36amalloyout of 270ish phrases, each doll got loaded with four of them
21:08ibdknoxwhat's the replacement for clojure.contrib.duck-streams?
21:08pickles1clojure.contrib.duck-ponds?
21:08clojurebotclojure bot is not immune to ,(iterate inc 0)
21:23amalloyibdknox: clojure.java.io, mostly
22:07dnolen_so Oracle is implementing it's own JavaScript.
22:09Hodappdnolen_: bah?
22:09dnolen_announced at JVM lang summit, http://www.wiki.jvmlangsummit.com/images/c/ce/Nashorn.pdf
22:11dnolen_interesting Jigsaw+Clojure presentation there
22:16cemerickdnolen: do you see materials for that anywhere, or are you just referring the talk being being on the schedule?
22:16cemericker, dnolen_ ^^
22:16dnolen_cemerick: I did not see any materials.
22:16dnolen_and JetBrains announces it's own statically-typed lang for the JVM Kotlin
22:16cemerickMan, bummed I wasn't there for the Gosu talk.
22:18methodsgosu talk ?
22:18cemerickyeah, http://www.wiki.jvmlangsummit.com/Main_Page
22:18dnolen_Comparing Kotlin & Scala http://confluence.jetbrains.net/display/Kotlin/Comparison+to+Scala
22:18cemerickDamn, no one fell for the trolling. ;-)
22:19dnolen_cemerick: heh, I almost said something but I've taken a vow to not to respond to anything w/ the words Gosu.
22:19cemerickdnolen_: Wise man.
22:20cemerickKotlin looks pretty sane.
22:21dnolen_cemerick: it does, first class delegation is pretty cool.
22:24methodswhat in the world is kotlin
22:25dnolen_methods: a new programming language being created by JetBrains
22:28cemerickI wonder if they'll eat their hat and build proper tool support beyond IntelliJ
22:29justinkois the convention to put function arguments on a new line?
22:29methodsjust another java look alike ?
22:30justinkoseems random for what people do
22:31brehautjustinko: it makes sense when you have docstrings and multiple aritys
22:31cemerickso, challenger to Scala, challenger to Groovy (Gosu), where's the challenger to Clojure?
22:33justinkowhat do you guys think about Noir?
22:38technomancygosu is one of those boring-on-purpose languages, right?
22:38technomancylike fantom?
22:48iceycemerick: I can't think of anything from the "Functional lisp on the JVM" angle, but from the "functional lisp" angle I guess there's Qi/Shen
23:03DeusExPikachuanyone go through the logic-starter tutorial?
23:04dnolen_DeusExPikachu: I think a couple people have, are you running into trouble w/ it?
23:05DeusExPikachuno, was just curious, I'm just trying to walk through typedo atm, I think I understand geto now
23:06DeusExPikachuhonestly I got lost with the tutorials walkthrough, i'm just trying to decipher it myself
23:06dnolen_DeusExPikachu: well let me know if you have questions, I helped write the type inferencer in that tutorial.
23:41technomancyDeusExPikachu: yeah, I didn't find it very illuminating either
23:42technomancylots of text and samples without explaining much of what was actually happening.
23:47DeusExPikachuI found the stuff before the walkthrough helpful
23:48dnolen_technomancy: I'm interested in making this simpler, what do you mean by "what was actually happening"?
23:48DeusExPikachubut with all the context going through the failures first made me confused
23:48DeusExPikachuI think I got it now though, I think to present the material probably explaining the successful base cases first would be a better approach
23:49DeusExPikachualso is there a design decision to switch the order of args for geto vs typedo?
23:49dnolen_DeusExPikachu: by walk through do you mean the very end of the tutorial?
23:49DeusExPikachuyeah, the code walkthrough
23:49DeusExPikachubefore that is fine imo
23:50technomancydnolen_: "s# represents a successful goal" <= what's s#? a symbol? why's it gen-symmed? I don't see goals being defined until I've already asked myself "wait, what's a goal again" several times.
23:51technomancywhy are we calling run*? shouldn't run expand into a macro that calls run* for us?
23:51dnolen_DeusExPikachu: I think the order for geto is natural for what it does, I think typedo is natural for what it does as well. But I think that's a minor point.
23:52technomancy"The run returns () because typedo returns a failed goal." wait, we just said above that u# represents failed goals.
23:52DeusExPikachudnolen_, I was thinking probably geto on its own, the arg order makes sense, but for the purposes of the tutorial, unless I'm familiar with geto before hand, I think renaming geto and changing the order would make it easier to digest
23:52dnolen_technomancy: x# is a valid symbol outside of macro.
23:52technomancyit's just skipping around without explaining how each steps relates to the last
23:53dnolen_technomancy: it can certainly be improved, feedback like this is great.
23:53technomancydnolen_: it's technically legal, but unidiomatic.
23:54technomancyI suspect that it's breaking a lot of the rules of clojure style because it's a very literal port, but it would help a lot to state that at the top.
23:55dnolen_technomancy: sure, but miniKanren programs in general can't be read as Clojure anyhow.
23:55amalloytechnomancy: perhaps more importantly it means you can't write a macro that expands into a use of s# or u#
23:55amalloywell. you could. ~'u#, but blech
23:56dnolen_amalloy: valid point, but u# and s# are there purely for pedagogical reasons, not tools that you actually use.
23:56amalloyzoiks. then it seems crazy to pick a pedagogical point that "sounds" like something else (gensyms)
23:57amalloyor...no, you're saying that s# and u# are real things, but are implementation details you wouldn't actually use?
23:57DeusExPikachuits namespaced though, I don't see the problem of the notation
23:58DeusExPikachuthe special semantics of symbol# only apply in a `()
23:58dnolen_amalloy: #s isn't valid in Clojure it's valid in Scheme. I could use s or u, but again, to me it's pointless bikeshedding. It's there until the point that people are familiar enough with core.logic that I can remove them or put them in beginners name space.
23:58amalloyDeusExPikachu: yes, we've been over that. it's still confusing
23:59amalloydnolen_: ah. so this is a...remnant from its scheme roots, where you would write #s and #u?
23:59dnolen_amalloy: I have to balance beween people who approach core.logic via The Reasoned Schemer and those people who don't.