#clojure logs

2011-04-07

00:22HavvyGiven the following as the classpath:
00:23Havvy(#<URL file:/C:/clojure/lein/havvy-irc/src/> #<URL file:/C:/clojure/lein/havvy-irc/test/> #<URL file:/C:/clojure/lein/havvy-irc/classes/> #<URL file:/C:/clojure/lein/havvy-irc/lib/clojure-1.2.1.jar> #<URL file:/C:/clojure/lein/havvy-irc/lib/clojure-contrib-1.2.0.jar> #<URL file:/C:/clojure/lein/havvy-irc/lib/irclj-0.4.1-20110104.084027-1.jar> #<URL file:/C:/clojure/lein/havvy-irc/lib/dev/swank-clojure-1.2.1.jar> #<URL
00:23Havvyfile:/C:/clojure/lein/plugins/swank-clojure-1.3.0.jar>)
00:23HavvyI can't get (use 'irclj) to work.
00:24tomojI would hope irclj isn't a sing-
00:24tomoj..single-segment namespace
00:24DeranderI have some java object. I'm not really sure what class it is. Is there a way to find out easily?
00:25tomojit appears it's irclj.core
00:25tomojwhich, again, interestingly, appears nowhere in the readme
00:26Havvytomoj: Ah, thanks. That got me out of quite a jam.
00:26tomojDerander: surely you know about ##(class "foo") ?
00:26sexpbot⟹ java.lang.String
00:26Derandertomoj: surely I don't :-(
00:26tomojalso interesting are ancestors and supers
00:27tomojthough I can never remember the difference
00:27Deranderbeats me
00:28tomojclojure.contrib.repl-utils/show can alse be very helpful
00:29Derandertomoj: I will look it up.
00:29Derander.. after I figure out how to dump the html content of this dom element :-(
00:30tomojrepl-utils/show may be very helpful in doing just that
00:30tomojit will list all the instance methods with return and parameter types
00:30tomojif javadocs are handy, of course they will be more enlightening
00:36flea__,(doc var)
00:36clojurebotIt's greek to me.
00:36flea__,(doc defvar)
00:36clojurebotHuh?
00:44ataggart,(doc def)
00:44clojurebotDENIED
00:45ataggart$(doc var)
00:54HavvyPerchance, is there a function that tells you all possible values you can insert into (use) [and maybe variants]?
01:06tomoj(doc +)
01:06clojurebot"([] [x] [x y] [x y & more]); Returns the sum of nums. (+) returns 0."
01:06tomojheh
01:06carllercheI'm trying to grasp macros, but I'm having a hard time getting this to work: https://gist.github.com/cf3f20d4524d78d79311 (setting a variable in the macro to use in the sexp passed in. Is this possible?
01:07tomojcarllerche: do you have a really good reason to do that? :/
01:07brehautHavvy: http://clojure.org/libs (doc require) (doc use) (doc ns)
01:07Deranderfuck I hate html parsing in java
01:07Deranderfucking trivial in ruby
01:07tomojistr recommending enlive
01:07tomojbut you already had some sort of DOM thingy
01:07brehauti second tomoj's suggestion
01:08DeranderI'm trying to run html through htmlcleaner and then do a rudimentary readability algorithm on it
01:08Derandernot sure if enlive is suitable for that
01:08Derander(honestly not familiar with enlive.)
01:08carllerchetomoj: dunno, learn macros?
01:09brehautDerander: enlive is a layer ontop of tag soup; you can use it for generating and scraping
01:09tomojcarllerche: macros like that are called "unhygienic"
01:09brehautDerander: have you seen https://github.com/swannodette/enlive-tutorial ?
01:09tomojin general one should prefer hygiene
01:09Deranderbrehaut: yeah.
01:09tomojbut perhaps learning to be unhygienic is instructive
01:10Deranderbrehaut: I have not put the mental effort in to learn it
01:10tomojcarllerche: the dirty trick is to replace x with ~'x
01:11carllerchetomoj: ah... so, clojure's macros are hygenic?
01:11tomoj&`x
01:11sexpbot⟹ clojure.core/x
01:11tomoj&`~'x
01:11sexpbot⟹ x
01:11carllerchei googled the hygenic bit but haven't found a clear answer... thanks for the tips, i'll play around in the repl more
01:11tomojclojure's macro stuff encourages hygiene more than some other lisps
01:11Deranderbrehaut: do you know off the top of your head if there is an easy way to dump the content -- including html tags -- of a certain node?
01:13tomojwait, what? clojure.core/x?
01:14tomoj&`frobniz
01:14sexpbot⟹ clojure.core/frobniz
01:14brehautDerander: you'd use html/select (where html is enlives html lib) to select a node, and then i forget how to get the nodes to text but its easy
01:14Deranderbrehaut: experimenting
01:14tomojI think you'd just emit it?
01:15brehauttomoj: i think so?
01:15brehauttomoj: emit is private i think
01:15brehautemit* is perhaps the one to use
01:16tomojodd
01:16brehautthats what template uses
01:16brehauttomoj: agreed
01:20brehautDerander: you might want to esperiment with sniptest if you are mucking about in the repl btw
01:20tomojI noticed today another oddness, that despite enlive's working in general perfectly well with non-namespaced xml, deftemplate and friends hardcode html-resource, and the list of self-closing-tags is html specific
01:20Deranderbrehaut: googlign
01:20brehautDerander: https://github.com/cgrand/enlive/blob/master/src/net/cgrand/enlive_html.clj
01:20brehautright at the bottom
01:22Derandermakes sense
02:17symuynHello, I just have a quick question: what's the best way to get [0 1 2 3 4 5 6 7 8 9 10 11 12 13] -> ((0 3 9 12) (1 4 7 10 13) (2 5 8 11))?
02:20raek,(apply map list (partition 3 (range 14))) ; one way to do it
02:20clojurebot((0 3 6 9) (1 4 7 10) (2 5 8 11))
02:21symuynThanks!
02:22raekhrm, the 12 and 13 is lost, though
02:22raek,(partition 3 (range 14))
02:22clojurebot((0 1 2) (3 4 5) (6 7 8) (9 10 11))
02:22raek,(partition-all 3 (range 14))
02:22clojurebot((0 1 2) (3 4 5) (6 7 8) (9 10 11) (12 13))
02:23raekmap stops when one of the seqs are out of elements
02:24raek,(let [coll (range 14)] (for [i (range 3)] (drop i (take-nth 3 coll))))
02:24clojurebot((0 3 6 9 12) (3 6 9 12) (6 9 12))
02:25raek,(let [coll (range 14)] (for [i (range 3)] (take-nth 3 (drop i coll)))) ; ahem...
02:25clojurebot((0 3 6 9 12) (1 4 7 10 13) (2 5 8 11))
03:40TobiasRaedermorning
03:40ejacksonmorning
03:52symuynraek: Hey, I had to disconnect suddenly. I see the problem too; is there a way to prevent 12 and 13 from being lost by map?
03:52symuynLike, is there a function f like map: (f list [1 2 3] [1 2 3] [1 2]) -> ((1 1 1) (2 2 2) (3 3))?
03:53symuynOr to repeat the general question, what's the best way to get [0 1 2 3 4 5 6 7 8 9 10 11 12 13] -> ((0 3 9 12) (1 4 7 10 13) (2 5 8 11))? (->> % (partition 3) (apply map list)) omits the last element.
04:01__name__symuyn: https://gist.github.com/806541
04:03Derandersymuyn: (let [coll (range 14)] (for [i (range 3)] (take-nth 3 (drop i coll)))) is what he came up with
04:03Deranderbut that is ((0 3 6 9 12) (1 4 7 10 13) (2 5 8 11))
04:03__name__symuyn: what i posted is the map function you wanted.
04:03Deranderif the initial 6 matters to you
04:04symuynWonderful, thank you.
04:04__name__symuyn: if you use concat as the fun and nil as the placeholder, it will do what you stated above.
04:09__name__Ehm, not concat.
04:09__name__(fn [x] (filter #(not (nil? %)) x))
04:09symuynlist?
04:09symuynAh
04:09symuynAnyways, I have to go; thanks again
04:10__name__did it work?
05:11thorwilso i have (for [k (keys mymap)] k), but how do i include a [v (vals mymap)] in there?
05:19thorwilnm, (for [k (keys mymap) v (vals mymap)] [k v])
06:15clgvhow about (seq mymap) ?
06:15clgvthorwil: you already get key value pairs when you try to use a map as seq, e.g. with map
06:17clgvthorwil: I dont know if you have the assertion that the first key in keys belongs to the first val in vals - you dont have that problem if simply use the map as seq
06:18thorwilclgv: actually i'm trying to build a let-map, binding all values in a map to the names of their keys
06:18thorwilbut now i gotta run, bbl
06:19clgvthats already integrated with let and destructuring
06:20clgvthorwil: see http://clojure.org/special_forms#Special%20Forms--%28let%20[bindings*%20]%20exprs*%29
06:21clgvyou want either the :keys form or the :strs form
07:04thorwilclgv: i looked at that very page before and still don't understand how i would do it without ever listing any key
07:05clgvthorwil: can you limit yourself to either use strings, keywords or symbols as keys? then I could give you an example
07:06thorwilclgv: keywords
07:07clgvor wait, I explain: if you use that destructuring the values in the vector are the names of the symbols you can use within the let and they will be converted to the keywords so that the values can be bound to the symbols
07:08clgv&(let [mymap {:a 1 :b 2 :c 3 :d 4}] (let [{:keys [a b c d]} mymap] [a b c d]))
07:08sexpbot⟹ [1 2 3 4]
07:09clgvyou know the key you want to use in advance?
07:09clgvyou probably have to if you want to write code that makes sense within the let
07:11thorwili quickly arrived at (let [{:keys [a b c d]} mymap] [a b c d]), but i would like to get rid of the explicit [a b c d]
07:12clgvwhy?
07:12clojurebotwhy not?
07:12clgvstupid clojurebot!
07:13thorwilas i will use all the keys. even if it should not be a good idea, it will grow my understanding of this destructuring busines ;)
07:15clgvbut you need to know the name of a local to use it
07:17thorwilyes. i know the keys, anyway. of course implicit binding would make the code harder to read
07:18thorwilclgv: thanks for your input
07:18thorwiltime to power off and hit the road, summer is upon us! :D
07:20clgvthorwil: you could write the macro as follows
07:20clgv(defmacro let-map [m & body] `(let [{:keys ~(vec (map #(symbol (name %)) (keys m)))} ~m] (do ~@body) ) )
07:21clgvbut it will only work if the map is accessible at macro expansion time
07:22clgvyou can call it like: (let-map {:a 1 :b 2 :c 3} [a b c])
08:04naeuSomeone just sent me some compiled classes that I'd like to be able to call from Clojure
08:04naeuIs it enough to just place them on the classpath?
08:05naeuThey don't appear to be explicitly namespaced, so I don't know how to actually access them
08:16clgvIt is enough to have them in the classpath. but for usage of use or refer they need a namespace
08:17clgvon a lower level you can also use "load" to load the files via their names
08:17clgvs/names/paths/
08:17sexpbot<clgv> on a lower level you can also use "load" to load the files via their paths
08:25fmwdoes anyone have experience sending cookies with the Apache HttpComponents client? I wrote some code that is supposed to include cookies (http://paste.pocoo.org/show/367163/), but it doesn't arrive at the server.
08:26fmwthe HttpClient seems like the typical over engineered Java bloat to me. I've been smashing my head against the wall on this for a while now.
08:30naeuclgv: thanks - I needed to 'import' them
08:30naeuthat's the step I was missing
08:30naeu:-)
08:31clgvnaeu: you mean "load"?
08:31naeuclgv: I used (import 'MyClass)
08:32clgvnaeu: ah java classes^^ I thought of compiled clojure first ;)
08:32naeuclgv: oh, sorry for being ambiguous
08:51clgv$source partial
08:51sexpbotpartial is http://is.gd/zZxzDD
08:56clgv$findfn {:a 1 :b 2 :c 6 :d 7} {:a :b} {:a 1 :b 2}
08:56sexpbot[]
08:56clgv:(
08:57mec$findfn {:a 1 :b 2 :c 6 :d 7} [:a :b] {:a 1 :b 2}
08:57sexpbot[clojure.core/select-keys]
08:58clgvargs. thanks mec
08:59clgv$findfn {:a 1 :b 2 :c 6 :d 7} #{:a :b} {:a 1 :b 2}
08:59sexpbot[clojure.core/select-keys]
08:59clgvah well, I see the error ;)
09:00clgv&(select-keys {:a 1 :b 2 :c 6 :d 7} [:d :c])
09:00sexpbot⟹ {:c 6, :d 7}
09:01clgvhm damn. I need them sorted like in the list
09:02mec?
09:03clgvI want to have [7 6] as output when given {:a 1 :b 2 :c 6 :d 7} and [:d :c]
09:03mecok let me see
09:04clgv$findfn {:a 1 :b 2 :c 6 :d 7} [:d :c] [7 6]
09:04sexpbot[clojure.core/map clojure.core/replace clojure.core/keep]
09:04mecya map would work
09:04clgvlol yeah. strangely obvious...
09:05mecindeed, i was about to try reducing into an array-map
09:07clgvhmm replace seems to be most fitting with respect to semantic
09:09mecim partial to keep
09:11clgvI can tell you what the whole thing does
09:11clgv(let [param-values (replace param-map param-keyword-list)] (if (empty? param-values) func (apply partial func param-values) ) )
09:12clgvI have a parameter map that contains keywords and values and a specification that knows the order of the parameters in the function signature of "func"
09:13clgvand I want to create a partial from that. so replace makes pretty much sense ;)
09:29mecyou could do (if-let [param-values (seq (replace param-map param-keyword-list))] (apply partial func param-values) func) since apply calls seq on it anyway
09:44avysk$findfn [:a :b :c :d] [1 3] [:b :d]
09:44sexpbot[clojure.core/map clojure.core/replace clojure.core/keep]
12:02amalloyavysk: that one always makes me squint. seems like magic
12:04amalloycarllerche: i have a blog post about intentional bad macro hygiene if you're interested: hubpages.com/hub/Unhygenic-anaphoric-Clojure-macros-for-fun-and-profit
12:04carllercheamalloy: I'll look over it, thanks
12:31SaturnationCould someone help me understand the structure of the function defined at the end of page 85 in "Joy of Clojure"?
12:33dnolenSaturnation: what are you confused by exactly?
12:36SaturnationWell, what the params to the function?
12:37SaturnationI read the first 4 chapters yesterday and they are only starting to gel today...
12:38Saturnationah, think it just made sense
12:38SaturnationI takes three parameters?
12:38Saturnations/I/It
12:38sexpbot<Saturnation> It takes three parameters?
12:40amalloySaturnation: i think my version of JoC isn't up to date. what function are you talking about?
12:41dnolenSaturnation: functions support multiple arities in Clojure.
12:42dnolenSaturnation: that function can take 2 *or* 3 arguments.
12:43devnSo I need to sort a map, but not by alphabetical order -- i want to define the ordering of fields so I can do something like (sort-with-keys {:my 1 :out 8 :of 3 :order 88 :map 0} [:of :order :out :my :map])
12:44devnwhich returns {:of 3 :order 88 :out 8 :my 1 :map 0}
12:45dnolenjoin /racket
12:45dnolenoops
12:45devn:)
12:47amalloydevn: clgv was just doing this a while ago in here
12:47fliebeldnolen: Logos ruined my Clojure writing. I keep using ==. By the way, how is disequality going?
12:47RaynesThere is nothing worse in the universe than having to write a technical book in Libre/OpenOffice.
12:47RaynesThere can't be. There just can't.
12:48fliebelRaynes: Then why attempt it?
12:48Raynesfliebel: Because my publisher makes me.
12:49amalloybut you really want a *map* as the output? in that case i'd start with writing a comparator-from-seq-of-literals function
12:49fliebelRaynes: Isn't there a Textile/LaTeX/Markdown to ODT converter somewhere?
12:49Raynesfliebel: Not one that will adhere to their overly complex stylesheet.
12:49amalloythen use (sorted-map-by (comparator-from-seq-of-literals [:order :of :what :i :want]) {actual map})
12:49RaynesI could roll my own, but I'm probably better off just doing it this way.
12:51amalloy(defn comparator-from [literals] (fn [a b] (- (.indexOf literals a) (.indexOf literals b)))), maybe
12:51dnolenfliebel: heh, disequality is done. Though after some thought I don't really think it helps much with Sudoku. That really needs a constraint solver.
12:52dnolenfliebel: so new plan is to do a serious clean up what I have, and then tackle the pile of papers I have on implementing efficient constraint solvers.
12:52fliebeldnolen: Okay. What about a sieve of erastmus? :D
12:52dnolenfliebel: haven't looked at.
12:54fliebeldnolen: It'll be wonderful, doing some recursion up to n, negating all multiples of n. Did I say multiplication? Shit… Well, projection maybe. Is there a way to do (cond-e (range))?
12:55dnolenfliebel: I've been brainstorming things like (cond-e (range ...)).
12:56tomoj&(->> ["foo" 1 "bar" 2] (map #(if %1 (keyword %2) %2) (cycle [true false])) (apply hash-map))
12:56sexpbot⟹ {:foo 1, :bar 2}
12:56tomojprettier way?
12:57dnolenfliebel: would be useful to use Logos easily again collections in general. Lots of thinking to do there tho.
12:58fliebeldnolen: Yea, that'd be great for using it with real data.
12:59dnolenfliebel: I don't have much of a problem with projection personally. Any useful Prolog program uses it to get anything done w/ numbers. Prolog programs that involve arithmetic generally can't run backwards.
12:59amalloytomoj: are you trying to generate a sorted map with that?
12:59amalloyor something else
13:00tomoja hash map
13:00fliebelI see...
13:01amalloyoh i see. you're asking for a prettier way, not proposing a prettier solution to someone else's question
13:01tomojah, right, sorry
13:02amalloy&(into {} (for [[k v] (partition 2 ["foo" 1 "bar" 2])] [(keyword k) v]))?
13:02sexpbot⟹ {:foo 1, :bar 2}
13:02tomojmuch easier to understand
13:03dnolenfliebel: nqueens in Logos is pretty darn short, https://github.com/swannodette/bratko-logos/blob/master/src/bratko_logos/nqueens.clj. It's only twice as slow as most of the solutions I've seen in idiomatic Clojure written with list comprehensions.
13:03tomojI feel like there should be a pointfree way to say "apply f to the first element of the seq, leave it unchanged otherwise" and similar
13:03fliebeldnolen: neat!
13:03tomoj..without zippers
13:04tomojI guess zippers are exactly the machinery you would end up having to build if you tried, anyway
13:06Saturnationamalloy, neighbors function on page 85, Listing 5.1
13:07amalloySaturnation: wow, things got moved a lot since i last updated
13:08Saturnationdnolen, I don't see the arity there and I don't see the three parameters now either :)
13:08amalloyit's on page 123 of my book :P
13:08amalloySaturnation: (defn neighbors ([param1 param2] (definition with 2 params)) ([param1 param2 param3] (definition with 3 params)))
13:08amalloyyeah, i have that at home, but you caught me at work :P
13:09Saturnationah, OK, now I see it (hope it sticks)
13:09Saturnationah, so the version with two parameters calls the version with three parameters with basic deltas, yes?
13:09dnolenSaturnation: yes.
13:10Saturnationliteral deltas, perhaps is a better term
13:10Saturnationthanks, got it! :)
13:10amalloySaturnation: that's a very common pattern. define the two-arg version of your function to add one param and then call the three-arg version
13:10SaturnationI can't see that looking at the API for defn
13:10Saturnationmakes sense
13:10amalloy&(doc defn)
13:10sexpbot⟹ "Macro ([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata"
13:11Saturnationwhere in that definition is arities?
13:11amalloy[params*] body is one version. ([params*] body)+ is what you want
13:11amalloy+ being the repetition operator
13:12Saturnationthanks
13:12Saturnationme fooled by the fact there was a space between the closing paren and the +
13:13amalloySaturnation: yes, i noticed that in the docstring too. i don't think it's intentional
13:13SaturnationDon't know what I assumed it was, but not that
13:13amalloyif you read the "same as" section you see basically the same thing but without a space
13:13SaturnationI see it in the same as, but I didn't look closely at that
13:13Saturnation:)
13:13amalloyand who could blame you
13:13amalloy&(doc fn)
13:13sexpbot⟹ "Special Form: Please see http://clojure.org/special_forms#fn&quot;
13:14Saturnationthanks for the help
13:20scottjhttp://jaderholm.com/paste/kup.html (clojure slice) http://coffeekup.org/ (coffeescript)
13:20mecclojure needs better special form doc support at the repl
13:21cemerickThe repl is such a sad spot to read docs in general.
13:22cemerickIt's sort of sad how little documentation has progressed over the decades.
13:23cemerickStill just lists of functions / namespaces / packages / whatever
13:24technomancyns-level docstrings are a step in the right direction
13:24technomancyit's a shame clj-130 makes them less practical
13:25cemerickhuh, I'd never noticed that, actually
13:25cemerickns and function metadata is a good dataset, but the REPL is a bad UI for it
13:26Saturnationfilter works the opposite of what I expected
13:26cemerickSaturnation: see remove
13:26fliebelSaturnation: Then use remove
13:26hiredmancemerick: in what way?
13:27Saturnationjust threw me a curve, happy to use it :)
13:27cemerickhiredman: in any of a 100 ways. Far easier to just produce a solution than describe it.
13:27hiredmanthe ability to read and lookup docs and write little snippets code in the same place is great
13:27hiredmancemerick: I doubt it
13:28cemerickhiredman: we'll see :-)
13:29hiredmancemerick: given that we generally seem to be at odds on this kind of thing, I feel confident prejudging
13:29scottjmec: maybe you can elaborate what you mean
13:30cemerickhiredman: as long as I can be confident of your disapproval of a concept, then I feel good about it's broader acceptance
13:30mecWell rather than just saying "go to this website" it could give a short description and usage too
13:30cemerick:-D ;-)
13:31fliebelI agree with mec, sometimes I don't even have internet.
13:31hiredmanit just seems like the repl is great, what should be done is make it better, not do other things that won't be half as good unless they include a repl
13:31cemerickI mostly agree.
13:32cemerickThere are things that pure text interactions don't allow for though.
13:32hiredmanrepl's don't have to be pure text
13:32cemerickTrue, true.
13:32hiredmanlook at factors
13:32cemerickYeah, I'm working on corollary functionality for ccw, actually.
13:32mecor mathematicas
13:32cemerickBut that's orthogonal to my documentation-related stuff.
13:33cemerickat least at the start, anyway
13:33hiredmanhttp://www.thelastcitadel.com/images/Screenshot-Repl.png
13:34technomancyhiredman: proportional width? really?
13:34technomancyಠ_ಠ
13:34cemerickhiredman: that REPL is your own creation, I assume?
13:35hiredmantechnomancy: *shurg* the swing default I expect
13:35cemerickThat was back in my jedit days. ~2002, maybe
13:35mec,(let [do 5] (do (println do) (+ do do)))
13:35clojurebot5
13:35clojurebot10
13:35hiredmancemerick: given the wild code and lack of tests I think that is a safe assumption
13:36meci knew it, special forms are magic
13:36cemerickhiredman: just checking :-)
13:36amalloy&(let [if 10 do 20] (if do (do if)))
13:36sexpbot⟹ 10
13:36cemerickSo yeah, images and such in a REPL will work. Maybe HTML+js+css in an embedded webkit container too, but that could get really unwieldy.
13:36amalloymec: that one always looks funnier to me
13:37hiredmancemerick: but it would open the door to maginalia in the repl
13:37mecamalloy: nice one
13:37cemerickhiredman: true; for my part, I've never quite grokked the utility of such presentations though.
13:38hiredmanbut failing that, possibly marginalia could generate a documentation datastructure that could be used for other presentation mediums
13:39hiredmansince it does work like extracting comments (not just docstrings)
13:39scottjI have this function http://jaderholm.com/paste/show-help.html that I like for displaying docs, you just C-c C-h anywhere in the form and it tooltips the doc for the function like http://jaderholm.com/tmp/show-help.png
14:21amalloyscottj: C-c C-d C-d already does something pretty similar to that
14:22technomancyscottj: you think that could go into durendal?
14:38carllercheif using emacs & swank, is it possible to jump to where the symbol currently under the cursor is defined? M-. doesn't seem to work (neither does slime-edit-definition)
14:38jfieldsisn't there a built in fn to swap keys and vals in a map?
14:38technomancycarllerche: M-. should work as long as the file is compiled already
14:39carllerchetechnomancy: i just compiled the file (C-c C-k) then try it and get (definition not found)... but emacs is highlighting the definition right above it.
14:41technomancyman... I was a lot bigger fan of multimethods when they let you change the dispatch function =(
14:42technomancycarllerche: do clojure.core fns work?
14:42amalloytechnomancy: seriously, the defonce behavior there doesn't make me happy
14:44amalloy(defmacro defmulti-for-realz [name & args] `(do (ns-unmap *ns* '~name) (defmulti ~name ~@args))) maybe?
14:44technomancy(def name nil) is actually enough
14:45technomancybut srsly
14:45scottjtechnomancy: sure
14:45carllerchetechnomancy: clojure.core functions? like (and ...) ? they work in the open repl i have
14:46scottjamalloy: yes C-c C-d C-d has a few weaknesses you're probably aware of though, including that it's not a tooltip it opens a new window, and that it can't be run from anywhere in the form
14:53technomancycarllerche: yeah, you should be able to M-. on for in your clojure-mode buffer too
14:55carllerchetechnomancy: ah... i can M-. to a clojure.core function
14:55carllerchejust not to one in my current buffer (even though I thought I compiled it, i can try again)
14:56technomancyit isn't available in the current namespace. could be it hasn't been compiled, or it could be slime is confused about which is the current namespace.
14:56carllercheis there a way to tell (right now i'm trying to navigate around aleph)
14:56scottjcarllerche: windows? you've run C-c C-k on current namespace?
14:57carllerchescottj: i have (and it did the fortifying message)
14:57carllerchetechnomancy: it looks like it is confused about the current namespace
14:58carllerchethis is the file that I am in: https://github.com/ztellman/aleph/blob/master/src/aleph/netty.clj
14:58tomojyou may need the one-character tweak for new style ns metadata
14:59scottjprobably that skip-wiki that's confusing it
14:59technomancycarllerche: yup, ^{:skip-wiki true} is throwing off slime's namespace detection heuristic
14:59carllerchetomoj: I'm just learning clojure :P not sure what the new style ns is
14:59tomojin clojure-mode.el, in clojure-find-package, there should be a question mark after the #
15:00technomancytomoj: nice.
15:00tomojif that's missing, you add it, then C-M-x, maybe it will work
15:01technomancytomoj: actually still no dice; only fixes it if the name is on the same line
15:01technomancythat regex is terrifying
15:02technomancyside note, that's the first useful non-docstring namespace-level metadata I've even seen
15:02carllercheshould I just try to pull clojure-mode off of a git repo instead of elpa?
15:02scottjyeah makes me want to learn emacslisp package rx
15:02technomancycarllerche: no, I don't have a fix for it yet; sorry
15:02technomancyugly workaround is to just delete the :skip-wiki true bit for now
15:02tomojhuh.. I haven't run into the problem since I added that question mark. guess I just got lucky
15:02carllercheyeah... that's fine, i'll just browse aleph anymore :P
15:03tomojcarllerche: btw, in the issues for ztellman/potemkin on github you will find a patch that makes M-. skip the import-fns
15:03tomojalways bugged me
15:03scottjcarllerche: easiest would just be use imenu
15:04carllercheimenu? for what? (not super familiar w/ emacs yet either)
15:04tomojtechnomancy: huh, seems to work for me
15:04scottjcarllerche: for M-. in current buffer
15:05tomojexcept when point is on the line with the name
15:05scottjcarllerche: M-x imenu RET when on the function name ou want to go to
15:05tomojor right after the metadata
15:33redingercarllerche: You hopping aboard the Clojure bandwagon finally? :)
15:34carllerchei'm dabbling :P
15:34redingerYou looking at it for SproutCore? I briefly played with that for fun
15:35carllerchebuilding some server components on top of netty
15:47devn<-not a huge fan of sproutcore
16:06wireshi, i want to install a plugin in leiningen which is on a sonatype repository; lein plugin install doesn't seem to search this repository. I specified the repository in project.clj:
16:06wires :repositories {"sonatype" "http://oss.sonatype.org/content/repositories/releases&quot;}
16:06wiresyet running lein plugin install org.cloudhoist/pallet-lein "0.4.1" failes because leinigen cannot find some dependency...
16:07wiresany thoughts..?
16:07amalloywires: i wouldn't expect lein plugin to look inside any project's clj
16:08dnolendeftype/record/protocols kinda remind me of SML modules a bit.
16:08wiresamalloy: so I'm not too suprised either, but how can I specify some other repositories to search besides the standard four
16:09wires(clojure
16:09wires clojure (http://build.clojure.org/releases),
16:09wires clojars (http://clojars.org/repo/),
16:09wires clojure-snapshots (http://build.clojure.org/snapshots),
16:09wires central (http://repo1.maven.org/maven2)
16:09dnolenhttp://en.wikipedia.org/wiki/Standard_ML#Module_system
16:09amalloyeh. i use cake, which has a global project.clj as well as per-project ones
16:09amalloyi'm sure lein has a way to do it
16:15wiresamalloy: couldn't find anything on the google regarding that (add repository)
16:17wiresbut thanks :)
16:45thorwilwhy o why do i get a status 200, despite using ring's redirect
16:46brehautthorwil: paste up you handler somewhere?
16:47thorwilbrehaut: currently the handler's only content is (rsp/redirect "/admin")
16:48brehautthorwil: are you running an internal jetty?
16:48thorwilwith [ring.util.response :as rsp]
16:49thorwilbrehaut: i guess, using appengine-magic
16:49brehautim not familiar with the specifics of appengine-magic, but how are you specifying the handler to it?
16:51thorwilbrehaut: routing via moustache, i just confirmed that the handler is definitively triggered
16:53brehautthorwil: can you paste this all somewhere? id rather not keep making wild stabs in the dark
16:55thorwilof course, was just working on that
16:55thorwilhttp://paste.pocoo.org/show/367472/
16:57brehautthorwil: quick question: does the problem exists across restarts of your whole server?
16:57thorwilbrehaut: yes
16:57brehaut(i dont know how the AEM stuff works but with the basic jetty adapter you can just keep reloading in the repl)
16:58brehautthorwil: is this your first moustache app?
16:58thorwilthe paste i actually wanted to make, with the ns: http://paste.pocoo.org/show/367476/
16:58thorwilbrehaut: my first clojure app, even
16:59brehautthorwil: ok sure. try changing delete-queue-article to (defn d-q-a [req slug] (rsp/redirect "/admin")) and the RHS of your inner app to (delegate d-q-a slug)
17:01thorwilunfortunately, that will have to wait for tomorrow :/
17:01thorwilbrehaut: thank you!
17:01brehautthorwil: no problem
17:25devnredinger: you around?
17:36maaclIf I define metadata for a field in a record like this: (defrecord Thing [#^{:foo "bar"} name]) how do I then read the metadata?
17:39amalloymaacl: i doubt it's possible
17:39maaclamalloy: ok, odd that it is possible to define it then
17:39amalloymaacl: it only seems that way
17:40amalloyyou're just putting metadata on the symbol "name", which defrecord probably doesn't do anything with; it just compiles into a basic java class with a field called "name"
17:40maaclamalloy: ok
17:40amalloydefn does you the favor of pulling metadata from the symbol and attaching it to the var
17:40maaclamalloy: shouldn't it be possible?
17:41amalloyeverything "should" be possible
17:41amalloybut the point of defrecord is to have basic, performant, host-level classes. how would that benefit from meta?
17:43choffsteinhey all, quick question: can i define a function within a function that uses the values I have defined in the let statement above?
17:43amalloyyes
17:43choffsteinI could just define an anonymous function, I suppose -- but I mean using the defn special form
17:43scottjwhat ns changing/creating form uses keywords for the name of the namespace? like (ns :foo)
17:44amalloychoffstein: you *can* do that, but having a function that contains "defn" at all is usually wrong
17:44maaclamalloy: well, my idea was to attach validator functions and "type" information so I could derive html fields (textbox, text etc) directly from the record class
17:44choffsteinamalloy: okay. is it better to just do it a named anonymous function in my let statement?
17:45amalloymaacl: so don't use records. just use a plain old hashmap
17:45maaclamalloy: metadata look like an elegant approach to this
17:45amalloychoffstein: starting to get too vague/abstract. coedz plz
17:45choffsteinamalloy: okay. i'll write up a quick gist
17:46maaclamalloy: sure, but then you loose the benefits you just outlined
17:47choffsteinamalloy: https://gist.github.com/908804
17:47choffsteinbut f would do more complex stuff...
17:47amalloymaacl: if you're doing any inspection on the fields, you were never getting those benefits anyway. you only get them if you know the fields at compile time
17:48amalloychoffstein: that is a zillion times better than using a defn
17:48choffsteinbut basically relies on the two values in the let above which are big pieces of data. I know since it is immutable, it could just be pass by value -- but it feels weird since the function is only used inside the outer function.
17:48choffsteinamalloy: okay
17:48amalloyand a very common/powerful pattern
17:49amalloyLet Over Lambda is a whole book about the exciting things you can do with this ability: you have a let sitting "over" a lambda (or clojure's equivalent, fn)
17:49choffsteinHmmm, I might have to pick that up
17:50maaclamalloy: What would be the diffference btw asking for a field and it's associated metadata?
17:50amalloychoffstein: you could even return a reference to f, letting other people take advantage of the a and b after they've gone out of scope
17:50choffsteinamalloy: oh, that is very cool.
17:51amalloyor if complex-method-n really take no args, you could compute them at the top-most scope
17:51amalloy(let [a (complex-whatever)] (defn process [x] (use x and a)))
17:53amalloy&(let [make-adder (fn [a] (fn [x] (+ a x))), adder-5 (make-adder 5)] (adder-5 10))
17:53sexpbot⟹ 15
17:53amalloyis kinda the classic example of this sort of thing
17:53amalloychoffstein: ^
17:54choffsteinoh, very cool
17:54choffsteinohhh, yeah, i've seen that before
17:54choffsteinwhen I took my class on functional programming 4 years ago in college :D
17:56tomojlucky they had one
17:57amalloychoffstein: in one of the early chapters LoL points out that you can easily build OO sorts of "objects" by stacking up with lambda::let::lamda
17:58choffsteinsounds like this is a book i'm gonna have to pick up
17:58amalloyif you do, send me a copy
17:58amalloyi only read the free chapters
17:58choffsteintomoj: Yeah -- it was in SML/NJ. Definitely hard to wrap my mind around at first.
17:58choffsteinamalloy: haha, well, you probably deserve it for how much you help me :D
17:59amalloyhttp://letoverlambda.com/
17:59tomojis that the one that's like "lisp is the best language ever and this is the best book ever?"
17:59tomojayup
17:59amalloytomoj: are there lisp books that aren't like that?
17:59RaynesMine!
18:00RaynesOh, you mean Common Lisp, don't you?
18:00amalloyi guess On Lisp doesn't claim to be the best book ever. it does definitely claim lisp is the best language
18:00amalloyin fact i don't, mr whiny-pants
18:00amalloyOn Lisp has several chapters where he delves into scheme instead because common lisp would make the concepts ugly
18:01tomojamalloy: sure, but..
18:02tomojI remember laughing almost hysterically after reading that intro
18:02companion_cubethe first paragraph on the site is amazing
18:02companion_cubei like that this book title says "LOL" in whole letters
18:03tomojperhaps just because of the "your humble author," at the bottom
18:04tomojwhich I hope was a joke
18:11BorkdudeI am trying out some compojure and want to send a hebrew unicode character to the client
18:11Borkdudebut it gets displayed as a question mark. does anyone know where things could go wrong?
18:11amalloyBorkdude: character encoding
18:13Borkdudefor example, I have this:
18:14Borkdude(defroutes handler (GET "/" [] "\u05D2"))
18:14RaynesI managed to screw try-clojure.org up in the most hilarious of ways -- it now links to a Ruby on Rails getting started page.
18:14Borkdudeamalloy: do you know if there is something which fixes this problem?
18:15BorkdudeI can display the letter just fine with my GWT-application
18:15Borkdudebut that is probably because it is all client side
18:15amalloyBorkdude: i don't do much web programming. i'd say make sure you set your character encoding to match whatever java is sending
18:15tomojis there a header for that or just the meta tag?
18:16amalloytomoj: header
18:16tomojoh, in the content-type header
18:16tomoj?
18:16amalloyi think so
18:16scottjtechnomancy: what do you think? https://github.com/scottjad/clojure-mode/commit/ab9e3f175024a5d5f355c9a2359b2bcbb989964f
18:17brehauttomoj: the meta tag is the http-equiv for the header of same
18:17amalloytomoj: <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
18:17amalloyis just a workaround for setting the header called Content-Type when you don't have access to modify the actual server
18:17technomancyscottj: nom!
18:17technomancyscottj: looks great; thanks
18:17technomancymaybe put the test in a separate file?
18:17technomancydo you have commit on my repo?
18:17brehautthe metatag has a sideeffect of causing processing of the whole html doc to restart to reinterpret with the new content type so make sure its as early as possible
18:18scottjtechnomancy: maybe just on swank-clojure
18:18technomancyscottj: you do now; feel free to give it a push
18:18scottjtechnomancy: I think someone wouldn't see the tests if it were elsewhere
18:19scottjtechnomancy: btw in case you didn't notice this fixes the dude earlier's problem
18:19scottjbut also supports 1.3 style ^:foo and stacking those
18:19technomancyscottj: yeah... don't worry about the tests then
18:19technomancywoot
18:19technomancyclojure-mode-test.el would just get confused with clojure-test-mode.el
18:20scottjthere are a couple cases of metadata that don't work, they're the ones with :fail in the tests
18:20scottjI remember hearing regexes can't ensure matching parens, that's why I didn't look into those failing cases
18:20scottjI don't know if that's true
18:21tomojI wonder if that's specific to regex or all regular languages
18:22technomancyIIRC it's that regexes can't be used for handling general nesting of arbitrary depth
18:22Borkdudeamalloy: like this? https://gist.github.com/908901
18:23tomojguess it's not just regexes http://en.wikipedia.org/wiki/Pumping_lemma_for_regular_languages
18:23Borkdudeamalloy: I just edited an example program from here http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html
18:24Borkdudeamalloy: but I want to do some hebrew stuff with it
18:26amalloyBorkdude: augh. you're writing a webserver. don't put http-equiv in your document when you have the option of passing an *actual* http header
18:27amalloyBorkdude: also, find out what character encoding java is actually sending. it might be utf-8, but i don't know
18:28amalloyBorkdude: does compojure really want the doctype inside of the html tag?
18:30Borkdudeamalloy: view source, then I see this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt; <html ...
18:30Borkdudeamalloy: so that looks correct I guess
18:32tomojthe "html" there is just the hiccup macro
18:33tomojthat it looks like it's supposed to be the html tag is misleading
18:39amalloyfun
18:52_ViHow to force Leiningen to offline mode (like "mvn -o")?
18:53_Vi"lein deps -o" fails (behaves just like "lein deps")
18:55technomancy_Vi: in general it shouldn't be necessary. what's the problem you're trying to solve?
18:57_Vitechnomancy, Try "lein uberjar" on project created by "lein new" without downloading megabytes of jars first (I prefer to build clojure of the required version from source and then install it by 'mvp install-file' or whatever)
18:57_Vis/mvp/mvn/
18:57sexpbot<_Vi> technomancy, Try "lein uberjar" on project created by "lein new" without downloading megabytes of jars first (I prefer to build clojure of the required version from source and then install it by 'mvn install-file' or whatever)
19:00_ViAnd I want Leiningen/maven to try-and-fail downloading that file and output "Try downloading the file manually from the project website. Then, install it using the command" message with correct command.
19:02technomancythere's not really any way Leiningen could support doing that well
19:02_Vitechnomancy, Is Leiningen based on Maven?
19:03technomancyunless maybe you put your own marker in the version string when you do mvn install so it doesn't try to use any of the official Clojure builds maybe
19:03pdkif lein can't find it in its repositories then it doesn't know it exists
19:03technomancyit is
19:03pdkso it can't make assumptions about where it is and how it's installed :p
19:03technomancywhat I'm saying is the equivalent of "mvn -o" wouldn't really solve the problem you're describing
19:04_Vi(applied workaround by temporary "iptables -I OUTPUT -m state --state NEW -j REJECT")
19:04technomancyyou could also use :omit-default-repositories true in project.clj
19:05miltondsilvaHi, I think I saw some clojure benchmarks on a azul machine, but now I can't find them, does some one have a link or were I just dreaming?
19:05amalloy_Vi: that sounds as sophisticated as ripping the ethernet cable out of your machine. why not just do that?
19:05_Vitechnomancy, Workaround succeed. The result is "mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure -Dversion=1.2.1 -Dpackaging=jar -Dfile=/path/to/file". How do to is properly?
19:06_Viamalloy, Don't want to lose connections/SSH session/this chat.
19:06tomojwhy would you rather it error out so you can go compile from source instead of just downloading it?
19:07amalloyso you don't want an offline version of leiningen at all. you want it to print out "here's the command to install a jar"?
19:07Borkdudeamalloy: I now have this :headers {"Content-Type" "text/html" "charset" "utf-8"}
19:07amalloycharset is not a header; it is a part of the content-type header
19:07Borkdudeamalloy: but in chrome I see these headers: Content-Type:text/html; charset=iso-8859-1 Date:Thu, 07 Apr 2011 23:01:52 GMT Server:Jetty(6.1.14) charset:utf-8
19:08Borkdudeamalloy: ah that explains it
19:08tomojit already does print out "here's the command to install a jar", doesn't it?
19:08amalloy{"Content-Type" "text/html;charset=utf-8"} or something
19:08_Vitomoj, Yes, because of my internet connection is rarely cheap and stable.
19:09Borkdudeamalloy: it works! tnx
19:09_ViQuestion 2: Why leiningen just copies libraries from $HOME/.m2 to libs/ when it can sym/hardlink them? Unnecessary duplication.
19:09amalloy_Vi: echo echo "mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure -Dversion=1.2.1 -Dpackaging=jar -Dfile=/path/to/file" > ~/how-to-install-a-jar.sh
19:10amalloy./how-to-install-a-jar.sh
19:10amalloynow, you never need lein in offline mode again
19:10_ViWhat if I don't exactly know the groudId, artifactId and don't remember is it "mvn install-file" or "mvp install:file"? Why Maven itself has "-o" option then?
19:11amalloy_Vi: that's why i just told you to write it to a file
19:11amalloythen you won't forget
19:12_Viamalloy, For example, can I ask Leiningen to output equivalent "mvn" command? (so that I can modify it and execute)
19:13scottjtechnomancy: _Vi no, lein doesn't use the mvn command
19:14amalloythe things that you want are fundamentally weird and undesirable. it's hard to make recommendations for "how to use lein without using lein"
19:14scottj_Vi: symlink issue has been discussed on mailing list
19:14amalloyif your connection is slow, then fetching the source will be no faster than fetching a jar. both will be cached in ~/.m2
19:14amalloyso the difference is, if you fetch source you have to compile
19:15_Viscottj, And what the conclusion is? (and what about hardlinks?)
19:15_Viamalloy, If I have clojure's Git repository I can build any version.
19:16scottj_Vi: I don't remember, you can check the archive
19:23technomancy_Vi: you can have jars symlinked into lib/; future versions will construct the classpath straight out of ~/.m2
19:24technomancythey are copied for historical reasons, because the calculating the classpath needed to be as simple as possible
19:24_Vitechnomancy, (after reading maillist) May be it should be the option? E.g. by default it will construct the classpath, but run "lein lib" and it build "lib" directory.
19:25technomancy_Vi: yes, that will probably happen in 2.0
19:25hiredmanclojurebot: scopes?
19:25clojurebotHuh?
19:25hiredmanclojurebot: scope?
19:25clojurebotscope is at http://paste.lisp.org/display/73838
19:26_Vitechnomancy, OK. /* may be add maven's options like -o, -fn, -D, -s as well? */
19:28technomancy-D is handled in Leiningen by making tasks functions that take arguments instead of needing fancy syntax for arguments. I don't know what -fn or -s are
19:29_Vi-fn is "fail never" mode. Like "make -B -i". Like "build as much of the project as you can, ignoring errors".
19:29_Vi-s is to specify other Maven settings file.
19:30technomancyyou can specify an alternate settings file by setting the LEIN_HOME environment variable
19:31technomancyI can't think of a justifiable use case for fail-never
19:31_ViIn general, should Maven and Leiningen command-line interface be somewhat compatible?
19:32technomancy(not that there isn't a use case; I would just need to be presented with one before considering it)
19:32technomancy_Vi: not at all.
19:33technomancythe only overlap between the two is the mechanism by which they fetch and cache dependencies internally
19:33technomancyand I guess deploying to remote repos now
19:33_Vitechnomancy, Large project that fails to build (and builds very long time when succeeds). You start "mvn -fn", it builds most of the project, you go for a walk. When you return, it finished the build, you restart without "-fn", fix error, "mvn" again, fix error etc. Don't need to wait loads and loads of time between fixing errors.
19:34_Vitechnomancy, OK, I thought Leiningen just prepares things to run Maven.
19:34technomancyleiningen builds typically don't have multiple compilation phases
19:35technomancyit should already DTRT if deps fail. I guess if AOT fails maybe it would be nice to be able to fall back to stale class files? I'm not sure. but it would be very different from the way maven does it.
19:35technomancymost "builds" don't even involve AOT compilation
19:51amalloytechnomancy: Make include make -i, which i found useful for similar reasons: "if a command fails, give up on its dependent subtree, but keep doing as much useful work as you can"
19:52amalloyi haven't found any reason to want it in clojure yet
19:53_ViQuestion 3 (not about lein): Writing Swing application. I want program to exit when the window is closed, but not when I running it from REPL. What is the best practice for this?
19:54_ViIs there something like (when (not *running-from-repl*) (System/exit 0))?
19:55technomancy,(bound? #'*1) ; might be one way to check if you're repling it up
19:55clojurebotfalse
19:55amalloyhaha ewwww
19:56amalloy_Vi: see also ##(doc when-not)
19:56sexpbot⟹ "Macro ([test & body]); Evaluates test. If logical false, evaluates body in an implicit do."
20:13TimMc_Vi: DISPOSE_ON_CLOSE
20:13TimMcamalloy, technomancy: You people are disgusting. :-P
20:14amalloywut?
20:14amalloyTimMc: that doesn't solve his problem at all
20:15amalloyiirc, java doesn't stop the process just because there are no non-disposed windows
20:15TimMc_Vi: Does your main thread exit after launching your swing app?
20:16_ViTimMc, Yes, it just uses SwingUtils/invokeLater.
20:17TimMc_Vi: https://github.com/timmc/CS4300-HW3/blob/master/src/timmcHW3/gui.clj#L194
20:18TimMcAs long as you don't have any other threads, Swing will exit the JVM when all windows have been closed and disposed of.
20:19amalloyTimMc: ah, i guess that changed in 1.4, apparently
20:19TimMcah
20:19_ViAlso: I start 1. "lein repl", 2. "(-main)", 3. Window shows, 4. I close the window, 5. I change the source file, 6. "(-main)" again, 7. The same (non-reloaded) window appears. How to make it like with :reload-all?
20:20TimMcamalloy: I went from developing AWT in 1.2 to not using Swing (until recently) in 1.6.
20:20livingstonis there a good example of calling some clojure code from java anywhere? (there seems to be some competing options on the web) I have a library I would like to expose to some java programmers.
20:20TimMc_Vi: (use 'foo.core :reload-all) as step 5.5 doesn't work?
20:23_ViTimMc, OK, considering it as simple enough because of namespace name is already here (before "=>") thing.
20:24_Vis/\) thing/ thing)/
20:24sexpbot<_Vi> TimMc, OK, considering it as simple enough because of namespace name is already here (before "=>" thing).
20:25amalloylivingston: don't call clojure code from java. instead, use clojure to gen-class a real java class
20:25hiredmanamalloy: stop that
20:25amalloyi mean, it's *possible* to call clojure from java, but it's a lot more painful
20:25hiredmanyou can call clojure from java just fine
20:25TimMcTerminology difference?
20:25amalloyor do what hiredman says. whatever
20:26hiredman((IFn)RT.var("clojure.core", "println").deref()).invoke("Hello World");
20:26livingstonamalloy: I've seen that option, but if I don't have an actual class I want to expose, just some functions, it seems a bit heavy handed...
20:26hiredmancasting could be off, not sure
20:26hiredman^-
20:27amalloyhiredman: casting looks right to me
20:27TimMclivingston: gen-class should be fine
20:27livingstonhiredman: that was the kind of example I was looking for, I saw something like that, but wasn't sure it was still preferred.
20:27hiredmanit is
20:27livingstonthat seems a little messy to get a java coder to want to do though
20:28hiredmanit is clojure transliterated into java (except clojure does some caching around var derefing)
20:28TimMchiredman: That's really preferred over a gen-class? Ew.
20:28amalloylivingston: with genclass you can get something more like: new ClojurePrintlnWorker().print("Hello World")
20:29hiredmanlivingston: you can also use definterface + defrecord (or deftype)
20:29TimMcThrow a factory in there somewhere, it's not idiomatic enough yet.
20:29hiredmangen-class is digusting
20:29amalloy*murders TimMc*
20:29livingstonTimMc: lol
20:29hiredmanit has no useful place except interacting with java code you have no control over
20:29_Vi(when-not (bound? #'*1) (System/exit 0)) fails. It exits even if I run from "lein repl".
20:29amalloyhiredman: that sounds exactly like his situation
20:30TimMchiredman: Which is what libraries do all the time.
20:30livingstonI actually do have defrecords that will be returned
20:30hiredmanamalloy: it doesn't at all
20:30amalloy"there are some java programmers who i wish would use my clojure code but they don't know/like clojure"
20:30hiredmanif he wants to call java from clojure obviously he has control over the java
20:30amalloyhiredman: "I have a library I would like to expose to some java programmers."
20:31hiredmanso you can use definterface to generate and interface, deftype or defrecord to implement it, and the java programmer will just new up your type and call your methods and it will all work
20:31hiredmanno gen-class
20:31livingstonI have a lab full of java coders (and a lot of existing java code) that will benefit from some of my stuff - I'm just trying to get it to them as conveniently as possible.
20:32amalloylivingston: definterface/defrecord does sound like a good approach
20:32amalloyonce you get past the dogmatic shouting about gen-class
20:32livingstonhiredman: I have protocols too, so that should get me the interfaces right..
20:33hiredmanlivingston: for java interop definterface is nicer
20:33hiredmanlets you specify types etc so you can avoid casting
20:33hiredmanhttps://gist.github.com/909068
20:33hiredmanis what it kind of ends up looking like
20:33livingstonI just also had some helper functions that instanciated one of the records and was hoping to expose that too, in addition to the objects.
20:33livingstonoh cool
20:34hiredmandefinterface has some quirks
20:34hiredmantype hinting seems to be sort of broken, unless you do the string thing like I did there
20:34hiredman(on 1.3 alpha something or other)
20:35hiredmanI would recommend defrecord unless you know that you need deftype
20:35livingstonoh that's weird, I'm still on 1.2 (this is all still there too? or I need to upgrade?)
20:36hiredman,definterface
20:36clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/definterface
20:36livingstonI have been using protocols and defrecord so far, it works good in the clojure world, but to go to the java world you're suggesting definterface
20:36hiredman,*clojure-version*
20:36clojurebot{:major 1, :minor 2, :incremental 0, :qualifier ""}
20:36hiredmanyes
20:36hiredmanbecause if you use definterface at the java boundry you don't need to do all this casting
20:39_ViHow to check if we are running from "lein repl" if "(bound? #'*1)" fails?
20:40livingstonhow does definterface compete/compliment protocols? I just switch over entirely or use them both
20:41livingstonprotocols say "defprotocol will automatically generate a corresponding interface, with the same name as the protocol, i.e. given a protocol my.ns/Protocol, an interface my.ns.Protocol. The interface will have methods corresponding to the protocol functions, and the protocol will automatically work with instances of the interface."
20:41livingstonoooh right but the type hints, duh
20:41hiredmanright
20:41hiredmanprotocol interface methods all have Object signatures if I recall
20:42livingstonalthough all clj function effectively do under the hood, this is really only an issue for the return type right? re: calling from java
20:43hiredmandeftype+definterface get you very close to bare vm, minimal reliance on clojure runtime
20:43hiredmanlivingston: depends
20:44hiredmanmy main annoyance is macros that get expanded out of the code still end up having their vars referenced in the class file
20:44hiredman(with deftype+definterface)
20:45livingstonI can't find the documentation on definterface
20:46hiredman,(doc definterface)
20:46clojurebot"([name & sigs]); "
20:46hiredmanheh
20:46hiredmanlike defprotocol, but with type hints
20:46livingstonit's remarkably absent on the web too
20:46livingstonok
20:46hiredmanright, not an often used feature
20:47hiredmanI fear most people do horrible things like use gen-class or worse
20:47technomancyhiredman: how's that compiler patch coming? =)
20:49hiredmantechnomancy: I have it patched on a local branch, but the compiler is significantly altered there so I can just take it from there
20:49hiredmanand I wasn't sure that I actually got the go ahead
20:50livingstonso I use the interface just like the protocol it seems and I still get to avoid dispatch etc. that's good. I can use it with defrecord just like I am right? (if I just change my defprotocols to definterface and add type hints I'm 90% there right?)
20:50hiredmanyes
20:50livingstonhiredman: cool - thanks.
20:51hiredmanactually, it maybe better to switch to deftype in some places, I kind of recall defrecord's being a drag to create in java, but deftypes get a no-arg constructor
20:51hiredmanI don't entirely recall though
20:51hiredmanmay be
20:54hiredmantechnomancy: I've have to remember how to find clojure's jira too
20:54livingstonoh huh. ok. I went with records because I was using some extra map fields too
20:55technomancyhiredman: yeah... good luck with that. =)
20:57jweiss_does it make much difference in performance ( or size of compiled classes, etc) to have code produced by a macro, versus factoring that code out into its own function and having the macro call it?
20:58jweiss_seems kinda wasteful to have my macro that's called so many times, expand into a fair bit of code when i could just put it in a function... but then all the callers would have to know about that function as well, which is why i haven't done it.
20:58tomojcall it once? no. otherwise? seems impossible to answer in general
20:58jweiss_tomoj: let's say it's called in thousands of other places
20:58tomojbah
20:59jweiss_let me be more specific, does the size of the generated classes shrink if i factor it into its own fn?
20:59livingstonjweiss_: if you are using macros to optimize compiled code size, you might be doing it wrong...
20:59tomojI think any optimization advice from me will be premature
20:59jweiss_livingston: my purpose isn't to optimize, i'm just wondering if the way i did it was inefficient in some way.
20:59hiredmanjweiss_: macros do make the generated byte code larger
20:59tomojdoes the size of generated classes matter for some other reason besides disk space?
20:59tomojload time or something?
21:00jweiss_compile time does matter a bit
21:00hiredmantomoj: they have to exist in ram
21:00jweiss_and ram too
21:00tomojah
21:01livingstonin general for clean maintainable code you want functions, when you need to add to the language, require that something be called before or after a block etc. use a macro then
21:02jweiss_livingston: these macros are just sugar mostly, to allow my callers to write more succinctly
21:02livingstonmacros are powerful tools, but often over used
21:02jweiss_there's no doubt i need a macro (unless i want my callers writing repetitive stuff)
21:03livingstondepending on what it is, they were going to write it anyway, it just gets compiled away (lots of the core "functions" are actually macros) there's no harm in them
21:03tomojI feel like I don't really understand well the problem of visibility there
21:04jweiss_tomoj, if my macro is the only thing 'used' from the namespace, and it calls another fn in its namespace, my callers need to 'use' it too.
21:04tomojthe functions need to be public, at least, but the callers will never need to require or use some namespace to use a macro, right?
21:04tomoj(..besides the one the macro is defined in)
21:04tomojah
21:04jweiss_hm, i thougt they did
21:04tomojI was actually asking
21:05tomojit would surprise me if they did, though
21:05tomojunless the macro is written badly
21:05jweiss_hm, well that may be the case :)
21:05tomojsyntax quoting's full qualification seems like it would get rid of that problem
21:05jweiss_i tried once to factor out the lengthy code into a fn, and that's the problem i hit
21:05jweiss_i think i'll give it another go, seems worth it from the responses i've gotten here.
21:06jweiss_tomoj: yeah, i thought it would have worked but it didn't. i didn't investigate fully, so i'll do that now :)
21:09tomojhuh
21:09tomojthat you can defmacro something that syntax-quotes a symbol that doesn't resolve is interesting
21:10tomojin that case the macro-definer may clearly rely on callers to at least require the namespace
21:10tomojwait.. that can't be right. I'm confused and giving up now.
21:12hiredmanthe symbols will be fully qualified, so they will resolve correctly as long as the namespace with the var they point to has been loaded
21:12hiredmanbut there is nothing to guarantee that
21:12livingstontomoj: you can quote anything your want in a macro - all macros are are ways of manipulating the s-expressions (or whatever clj calls lists etc.) that are the sequences of symbols etc that are then handed off to the compiler -- it's then the compilers job to sort out what's there or not
21:12hiredmanpresumably the namespace you got the macro from makes sure supporting code is loaded
21:12tomojmy confusion is that the process of fully qualifying a symbol is namespace-dependent
21:13tomoj..right?
21:13hiredmanat compile time
21:13tomojso how come there's no error at compile time?
21:13hiredmanbut load + runtime can take place on a different jvm
21:13hiredmanwithout the needed namespaces loaded
21:13tomojoh, I think I see
21:14tomojyeah, (defmacro foo [] `baz) in user complains about user/baz when you try to use it in some other namespace
21:18livingstonon java interop: so I can easily pass a clojure map/hash back to java caller of my function, but now they are going to have casting nightmares working with it aren't they?
21:21tomojwhat are they dreaming of casting to?
21:21ataggartlivingston: only if they work with it as something other than a java.util.Map.
21:21livingstonI more meant the values in it
21:22ataggart,(.get {1 2} 1)
21:22clojurebot2
21:23livingstonI just mean that on the java end the type signature is going to be Object on the keys/vals etc. and they'll have to know to cast accordingly
21:26ataggarthow are you getting the map from clojure?
21:26ataggartinto javaland
21:27hiredmanhow do you tag files in jira?
21:28livingstonoh good point - with a call off an interface - I could probably put a type signature on the interface...
21:28tomoja definterface interface?
21:28livingston... except the values in the hash could be a couple of different things so, yeah, they'll just have to deal with it I guess.
21:28livingstontomoj: yes
21:28tomojyou can't fill in generic types there, can you?
21:28tomoj(or whatever they say in javaland)
21:29livingstonyeah I could.
21:30tomojoh? what's the syntax?
21:31livingstonthe key is symbols, the value unfortunately will be symbols, strings, or numbers ... so there's no avoiding that for them they'll just have to get it out into an Object variable and deal from there
21:31livingstonhiredman: what do you mean tag? point to one somewhere else? or upload one? (that's under the "more actions" menu at least on our install)
21:33hiredmanlivingston: dunno, http://clojure.org/patches says 'tag'
21:33hiredmanI kind of recall figuring out how to do that in assembla
21:36livingstonhiredman: oh. there are labels for issues (that I think work like "tags"), maybe after you upload the file you can put labels/tags on it too?
22:08trptcolinis it accurate to say that if there are multiple protocol implementations for a given record/type, the impl in the last ns to be loaded in that process/classloader wins? regardless of the current ns's ns dependencies?
22:09trptcolinthat's what i'm observing, but i'd thought the faux-monkey-patching capabilities were supposed to be namespace-limited, so i think i'm misunderstanding one end or the other
22:12Havvy"lib names inside prefix lists must not contain periods" when I put "[:use '[irclj.core]]" in an (ns). If I do (use 'irclj.core) it works. What am I doing wrong?
22:12pdkthe ' shouldn't be needed in the (ns) case
22:13pdkit's all being quoted in there already
22:13HavvyOh. :/
22:24trptcolin:) of course the answer is in Joy of Clojure
22:26HavvyAll I've got right now is Stuart Holloway's book. ;)
22:26trptcolinHavvy: sorry, i meant the answer to my question
22:26RaynesHavvy: Check out sexpbot and his irc.clj for an more decent example of Ircljiness.
22:26Raynes$whatis sexpbot
22:26sexpbotsexpbot is not clojurebot
22:27tomojHavvy: also, vectors there are odd
22:27kephale00$whatis clojurebot
22:27sexpbotclojurebot does not exist in my database.
22:27Raynes$whatis source
22:27sexpbotsource is http://github.com/cognitivedissonance/sexpbot
22:27tomojfor some values of "wrong" that is wrong
22:27RaynesHavvy: Furthermore, if you have any problems or queries, #sexpbot would is our little channel.
22:27tomojit'll work, but it's nonstandard
22:27HavvyI don't see a case where vectors would not work there.
22:28RaynesMinus the 'would'. Long day. <3
22:28tomojspecifically for (:use ...) vs [:use ...], vectors deeper inside are common
22:28tomojbut vectors right there... I think this is the first time I've ever seen them
22:29HavvyI've seen code that has vectors for all of them not written by me.
22:30brehautHavvy: vectors are weird there because in a list, the first term has 'precedence' (inaccurate term) over the rest of the list, while ina vector all terms are equal
22:30trptcolinHavvy: sure, that may be, but it's fairly rare in clojure code
22:30HavvyRaynes: With irclj, whenever I start it, I get a NullPointerException, but it continues running.
22:30tomojwell, if it works and you like it, go ahead :)
22:30brehautHavvy: in other words, the meaning of a list is denoted by the first thing (eg :use) but a vector isnt
22:31tomojwe'd be worse off if everyone always agreed
22:31tomojbut do expect funny looks
22:31RaynesHavvy: That's odd. Did you try running the example bot? Chances are, it's your code causing the NPE.
22:32TimMcI get vectors and lists mixed up in the require, use, and import forms all the time.
22:32TimMcUsually it doesn't make a difference.
22:32RaynesSurprisingly, I don't.
22:32livingstonI don't like how sometimes it's vectors in code and sometimes lists - it makes certain types of macros etc. on code a pain because you can't just cons stuff up you have to get the right containers back in there
22:34brehautlivingston: know your standard lib ##((juxt identity vec) (cons 1 [2 3]))
22:34sexpbot⟹ [(1 2 3) [1 2 3]]
22:34meccons always adds to left and makes a seq, conj is the one that changes
22:34brehautforms generally use vectors to denote special evaluation semantics
22:36HavvyMy code changes so far include adding a personal namespace, changing the server/channels it connects too, and adding another form to the :on-message handler...
22:36devn,(conj '(1 2) 3)
22:36clojurebot(3 1 2)
22:36livingstonbrehaut: somethings work, say if you're just adding (cons, etc.) but if you have to muck it up more or rebuild the whole thing because say you've replaced something deep in the sexp then your traversal algorithms need to know more.
22:36devn,(cons 3 '(1 2))
22:36clojurebot(3 1 2)
22:36devn,(conj [1 2] 3)
22:36clojurebot[1 2 3]
22:36devn,(cons 3 [1 2])
22:36clojurebot(3 1 2)
22:36brehautlivingston: then use the appropriate traversal functions; the standard lib is full of tools for processing all of its built in structures
22:37brehautlivingston: [colloquial saying about hammers here]
22:37devn,(doc juxt)
22:37clojurebot"([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"
22:37livingstondon't mind me I'm a grouchy lisp hacker - and "get off my lawn"
22:43brehautclojure seems to reside in an uncanny value for people from more traditional lisps
22:43brehauts/value/valley/
22:43sexpbot<brehaut> clojure seems to reside in an uncanny valley for people from more traditional lisps
22:44livingstonbrehaut: yes. there are things like the transactional memory that make it very attractive though, but others that are annoying (still way better than java though)
22:45tomojwonder what the once crusty CL'ers who stick with clojure for, say, two years, think
22:45tomojif there are any?
22:45tomojgotta be at least a few
22:46pdki havent really seen any posts from people making a serious cl -> clojure transition
22:46pdkbut sure as hell plenty from cl guys dissing it from a distance
22:46tomojheh
22:46livingstontomoj: I've been here almost 1 year, give or take. (I'm in a place that does mostly Java though, so if it's clj or java, ... if it's CL or clojure, I don't know yet, jury is still way out on that one)
22:46tomojI can equally only diss CL from a distance
22:47tomojbut it's hard for me to imagine the jury not returning immediately
22:47pdkthere's certainly a few snap judgments immortalized in blog posts out there
22:47tomojbut of course I focus more on the stuff I like about clojure and don't know what I'm missing in CL
22:48tomojfrom this point of view it seems like, how can you live without a built-in set of persistent data structures?
22:48livingstonCL has it's problems, but look at how long it's survived and the functionality it had way before anyone else - all the other stupid crippled object models etc. that came after CLOS etc.
22:48TimMcpdk: The phrase "immortalized in blog posts" struck my funny bone for some reason.
22:48pdktwo things i tend to miss from cl
22:48pdkcl's handling of exceptions
22:49pdkand multiple-value-call
22:49pdkit's really useful to know when nil is being returned as a sentinel value vs when it's the actual return value of a data structure lookup
22:49tomojboth correspond to weaknesses clojure inherits from the jvm, yeah?
22:49livingstonmultiple-value-bind is huge - I miss that so much
22:49devnanyone know of any existing clojure parsers out in the wild?
22:49tomoj(where "inherit from the jvm" means "rich thinks it's too ugly to hack this into the jvm")
22:50livingstonpdk: yeah, clj for traversing lists etc. seems ever so slightly less elegant than CL, but there's some nice things too like the sequence abstraction over maps etc. that you just don't have in CL
22:52livingstonjava question: can names have hyphens in them? i.e., if I'm calling definterface I better make my names look right if the java people want to call them
22:53brehautlivingston: they cant but i believe (test this!) that clojure in 1.2.1+ does the right thing to munge it to javaable
22:54livingstonbrehaut: yuch, I don't want it to look funny, rather they just match ugh
22:54brehautlivingston: well it is a type, so java convention is UpperCamelCase
22:54brehautand thats entirely appropriate for clj too
22:55brehaut(i believe the munging is that hyphens become underscores)
22:55livingstonthat's what happens with ns names
22:55tomojas a lisp1 I think camelcase should be viewed as useful, not ugly
22:56tomojs/as a/as clojure is a/
22:56livingstoncamel case is another thing that rubs my lisp side funny
22:56tomojwell, you had a lisp2, probably? not that that totally explains your rubbiness
22:57pdknot seein the connection here :p
22:57pdki've never seen hyphens in java symbol names
22:58brehautpdk that would be a direct result of the java lexer thinking - is an operator right?
22:58pdkthis is kinda why letting people write x-y; and x - y; is bs :p
22:59pdkor worse yet
22:59livingstonpdk: CL convention is count-pattern (and what I'm inclined to put in my definterface as names, but Java convention is countPattern
22:59pdk*x/*y;
22:59pdkgood ol C
22:59pdkclojure code ive seen always used cl convention
23:00livingstonright, but when I want them to talk to each other using defprotocol / definterface I have to be more cognizant of the border
23:01livingstonprogramming in prefix notation has totally ruined me for infix. I screw that up all the time "x minus y" ok write that first, now "times z" wait why is this so negative... 5 minutes later, oh
23:04tomojI've still yet to learn calc
23:05tomojwhich is, what, postfix by default? I feel like I really like RPN and that it is unexcelled but have barely used it\
23:13technomancychouser: have you documented anywhere your specific reservations about the error-kit implementation?
23:25livingstondo function names from definterface need to be called like java functions with the (.fn args) dot notation? instead of like plain clj functions that you get with defprotocol
23:26dnolenlivingston: yes, definterface is for declaring Java interfaces.
23:27livingstondnolen: thanks. and arghh that's a lot more code that needs updating now, just to see if this is going to work
23:28dnolenlivingston: did it seem to you that definterface and defprotocol were similar?
23:29livingstonactually there seems to be no docs on definterface, and I had a lot of defprotocol code that runs well on the clj side but I want to make that available to java people as a library
23:30livingstonhiredman suggested that the change was a good way to go as I could put type signatures on my functions then to help the java people
23:30dnolenlivingston: defprotocol creates Java interface from what I understand.
23:30livingstonyes
23:31livingstonand I understand that I can use either protocols or interfaces for the "interfaces" of defrecord and deftype
23:33livingstonI guess there's no reason I couldn't implement a protocol and an interface, but that seems redundant and like I should only need one.
23:33dnolenlivingston: definterface to me stinks, it's only about perf and interop.
23:33dnolenlivingston: I mean rather, definterface is great for those two scenarios. Yucky otherwise.
23:34livingstonwell if I'm giving a library to some java hackers... interop is kinda called for. although that's not the only thing this library will be used for, and it will be used extensively by clojure code too
23:35dnolenlivingston: writing a macro to declare both the protocol and the interface for interop seems like the way to go to me at least.
23:36livingstondefprotocol gives you an interface, but I think everything's type signature is just Object everywhere
23:55livingstonif I have a compiled java .class file is there any magic I can use to see what's in it?