#clojure logs

2010-10-04

02:03LauJensenMorning all
02:04amalloymorning LauJensen
03:00amalloya style question: if i'm using (defrecord) to define a class that i expect to use only from within clojure, should i name it like java (MyClass), clojure (my-class), or some mix (My-Class)?
03:03carkhi do it java like (pascal case)
03:25jlaskowskiHi
03:25jlaskowskihow to inspect a function?
03:25jlaskowskito see its args
03:25jlaskowskiinput params
03:26carkh,(doc partition)
03:26clojurebot"([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."
03:26carkhthat's what you mean ?
03:26jlaskowskicarkh: not necessarily
03:26jlaskowskiI've defined one in a script
03:27jlaskowskiand pass it to some other functions
03:27jlaskowskiI'd like to know if the one I defined somewhere
03:28carkhi'm not sure i understand your question
03:30carkhyou want to know if the function you'll be using has been defined, this function being passed as a parameter ?
03:43jlaskowskiI'm back, sorry - had a offline conversation with a co-worker
03:43jlaskowskicarkh: I'm learning monads
03:43jlaskowskiusing c.c.monads
03:43jlaskowskiand would like to know what functions I work with
03:43jlaskowskiand would like to trace their innerworkings
03:44carkhah sorry i know very little about monads, can't help you there
03:44LauJensenIs there some restriction on contrib.shell/sh so that it cannot work with sudo ?
03:44jlaskowskiforget about monads
03:44jlaskowskiit's simply an example
03:44jlaskowski(and I knew you'd step back when heard about them :))
03:44carkh=)
03:44jlaskowskiI defined a function
03:45jlaskowskiin a script
03:45jlaskowskiand in another function uses the former
03:45jlaskowskis/uses/use
03:46jlaskowskihow to print out the pass-in function details from within the latter?
03:46LauJensen(defn myfn "this fn takes an int and a double" [i d] (+ i d)), (doc myfn) ==> "[i d] this function takes an int and a double"
03:46jlaskowskisay, I have (fn [x] x)
03:46raek_there's not much details stored about functions in the function itself
03:46raek_most is stored in the var's metadata
03:46jlaskowskican I query for its input params?
03:47carkhyep you would need to pass the var instead
03:47raek_in 1.2 functions can have metadata too
03:47carkhoh didn't know that
03:47jlaskowskithat's the idea
03:47raek_,(meta #'conj)
03:47clojurebot{:ns #<Namespace clojure.core>, :name conj, :file "clojure/core.clj", :line 71, :arglists ([coll x] [coll x & xs]), :doc "conj[oin]. Returns a new collection with the xs\n 'added'. (conj nil item) returns (item). The 'addition' may\n happen at different 'places' depending on the concrete type.", :added "1.0"}
03:47raek_,(meta conj)
03:47clojurebot{:line 77}
03:47jlaskowskiuse meta
03:47jlaskowskior doc
03:47jlaskowskithanks
03:48raek_(the first one checks the metadata on the var, the second on the function)
03:48raek_vars can be used as functions (they call the function that they contain)
03:49raek_so as carkh said, you could require the caller to pass the var instead
03:49raek_or write a macro that adds the var-quote arount the argument
03:49raek_I think that is how 'doc' does it
03:50raek_(doc ^{:doc "Test"} (fn [x] (* x x)))
03:50clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
03:51raek_mm, yes... that call turns into something like (doc* (var ^{:doc "Test"} (fn [x] (* x x)))
03:51raek_where doc* is the underlying function doing the actual stuff
03:54raek,(let [x conj] (doc x))
03:54clojurebotTitim gan éirí ort.
03:54raek,(+ 1 29
03:54clojurebotEOF while reading
03:54raek,(+ 1 2)
03:54clojurebot3
03:55carkhdoc really wants a var
03:55carkhpicky doc !
03:59raekessentially, it calls (println (:doc (meta v)))
03:59raekhttp://github.com/clojure/clojure/blob/b578c69d7480f621841ebcafdfa98e33fcb765f6/src/clj/clojure/core.clj#L3880
04:03esjmorning all
04:30konrAny idea why this code prints nothing on Emacs/swank but does print on a terminal with `lein repl`? (dotimes [i 10] (.start (Thread. (fn [] (println i)))))
04:30LauJensenkonr: In Emacs, look in the buffer *inferior-lisp*
04:44esjkonr: its just shy.
04:45konr:)
05:01LauJensenkonr: Did you look?
06:36rrc7czhow can you apply a seq of arguments to a Java method? Something like (apply (.foo bar) [1 2 3]) when what I want is (.foo bar 1 2 3)?
06:40cemerickapply doesn't know anything about interop forms (like ctors and methods)
06:40cemerickThe best you could do is (apply #(.foo bar % %2 %3) [1 2 3])
06:41cemerickI seem to remember a more elegant solution, if one was willing to swallow reflection.
06:41cemericks/solution/solution floating around some while back
06:42rrc7czcemerick: reflection for this case would be fine. I'll take a look. I'm using something like your first suggestion right now, but it doesn't handle variable arity
06:42LauJensen(defmacro japply [obj f args] `(. ~obj ~f ~@args)) ?
06:42rrc7czLauJensen: perfect! thanks. The ~@ will splice the seq into form
06:43cemerickA macro buys you nothing here; why not just do (.foo bar 1 2 3) in that case?
06:43LauJensencemerick: macro buys you arbitrary number of args
06:43rrc7czcemerick: the [1 2 3] was just an example. In reality it's a variable length seq
06:45cemerickrrc7cz: mmm, I should have inferred that. My brain's still not fully online. :-)
06:45raekjapply only works for a litteral collection as 'args', right?
06:46cemerickyup
06:46rrc7czcemerick: :-) at least yours comes online now and then
06:46rrc7czI'll have to play with it so it doesn't require a literal seq
06:46cemerickif it's a runtime reference, you'll just get (. bar foo symbol-of-seq)
06:48cemerickrrc7cz: Risking being dense again....but it seems you're asking for more than can be known at macro-expansion-time.
06:48carkhi think those java functions that take variable number of arguments are using an array as last parameter underneath
06:49rrc7czcemerick: couldn't you first evaluate args before splicing? the literal should eval to itself, while any symbol would eval to the literal
06:49cemerickYeah, I was assuming rrc7cz's method isn't variadic, just that he'd like to spread a seq as args to it.
06:49LauJensencarkh: correct
06:49cemerickrrc7cz: Sure, if you use eval.
06:49LauJenseneval?
06:49clojureboteval is sometimes useful - but only sometimes
06:49cemerickindeed
06:50cemerickreaching for it *usually* means you're not thinking about things right
06:50rrc7czcemerick: so am I thinking about things right? :-D
06:50rrc7czI don't see any other way except to first eval args
06:50rrc7czbefore the splicing is done I mean
06:50cemerickrrc7cz: Not if you're hoping to evaluate runtime values of symbols at in a macro expansion.
06:51carkhrrc7cz : (String/format fmt (to-array args)
06:51raekusing the reflection stuff that a method call is compiled to could be an option
06:51rrc7czwow, so my brain's offline too
06:51cemerickraek: indeed, far preferable IMO
06:51cemerickthat, or a macro that will produce a fn from an object, method name, and argument arity
06:52rrc7czokay, so two options: one is great for literals, and reflection will work fine for non literals where performance doesn't matter
06:52carkhwell you only want to apply if the parameter list is variable in length, so that means the method has variable length arguments, so that means you can use the same pattern as the format function
06:52LauJensenIf its an option you can hardcode japply to a specific method on a specific object, then call it using a function as a driver
06:53rrc7czcarkh: my case is a bit differnt: I have a fn that returns the args to apply to a Java method. It returns a seq, and I'd like to (apply (.method foo) (compute args))
06:54carkhcan't you just (.method foo (first my-seq) (second my-seq))
06:54rrc7czcarkh: so variable arity was one side of it, but I have another case where the arity is static. Right now I just deconstruct the return value into x,y,z and pass those manually, but I was hoping for something less verbose if this comes up a lot
06:54carkhdestructuring my-se beforehand might be usefull
06:54rrc7czcarkh: absolutely, but I was hoping to find another way, especially if I have to be doing this a lot
06:55carkhi see
06:55raekhttp://download.oracle.com/javase/6/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object, java.lang.Object...)
06:56rrc7czcarkh: it's something like.. I know I need apply, but with Java interop. I guess it doesn't exist, but checking out the reflection idea is worthwhile
06:57rrc7czraek: so invoke takes an array, that will work
06:58carkhusing reflection your call will be very slow, which might not be a problem... i guess your function would look like this (japply instance method-name param-seq) and might error at run time
06:58cemerickrrc7cz: I still think this is mostly *yuck*, but: https://gist.github.com/0b4b6b437360b3e2f2e0
06:58raekthe problem might be to get the correct method instance...
06:59raekthis is probably implemented somewhere in clojure.lang
06:59carkhcannot be done at macro-expansion time i think
06:59rrc7czcemerick: that's pretty neat. It's a shame we have to pass the arity
06:59cemerickclojure.lang.Reflector is very handy.
06:59raekas long as the classes has been loaded, I think the refelction alternative should work
07:00cemerickrrc7cz: use Reflector ^^ if you think so :-)
07:00carkhwell then you need to add the call name to your macro call
07:00carkhwhich is again lots of work, while the goal is to make it easier
07:00carkhi mean :
07:00carkhwell then you need to add the *class name to your macro call
07:01carkhthe macro only sees the symbol used as a name for your instance
07:01carkhso japply needs to be a function
07:02LauJensencarkh: or have a function driver
07:02carkhbu why would you need a macro then ?
07:02carkhbut*
07:04LauJensenfor the splicing
07:05carkhhum, the splicing can only occur if the seq is literal
07:05carkh(in a macro)à
07:08LauJensenah right. Then perhaps just calling applyTo from lang.RT might do the trick
07:25carkh(defn japply [instance method-name args] (clojure.lang.Reflector/invokeInstanceMethod instance method-name (to-array args)))
07:25carkh(japply (Integer. 1) "compareTo" [(Integer. 2)])
07:25carkhstill uggly =P
07:26carkhthere you could use a macro so that you can use a symbol instead of the string
07:27cemerickcarkh: um, (str method-name)? :-)
07:27carkhyou'll get errors if the symbol is not declared
07:27cemerickif one can stand the '
07:27carkhright
07:28carkhremember he wants it for convenience
07:28carkhanyways =P
07:28cemerickyeah…the whole objective is off the mark *shrug*
08:40tobiasraederhey :)
08:41tobiasraederis there a way to create an implementation of a java function without retrun value?
08:41tobiasraederfor example if i wanted to impletement void setMyField(String)
08:42chousercemerick: your methodfn is remarkably similar to memfn
08:44chousertobiasraeder: do you mean with 'reify' or something?
08:44tobiasraederusing deftype but i think i just got it to work
08:45tobiasraederbut can't really explain what i did wrong as it seems
08:50chouserI was realizing the other night that clojure's locals are just as much variables as algebraic variables.
08:51chouserthat is they don't vary within the scope of one function or loop (although creating a new local with the same name but a new value looks more like mutation than algebra allows)
08:51chouserjust like algebra variables don't vary within an equation or proof
08:52chouserbut at different times they can have different values, which is why they're used instead of plain constants
08:53chouserso it's perhaps okay to call clojure locals "variables" and just make the point, at the appropriate time, that they're immutable variables.
08:53AWizzArdI just wanted to ask where you see the differences to constants.
08:53chouser(fn [a] ( + 5 a))
08:53chouser5 is a constant. it will always have the value 5.
08:54AWizzArdyes, your previous statement made it clear to me
08:54chousera is an argument variable. each time the function is called, a may have a different value -- in that sense it varies.
08:54chouserah, ok.
08:54AWizzArdone thing that I "often" do is (let [x (foo 1), x (bar x), x (+ 5 x)] ...)
08:55chouseryes
08:55AWizzArdi.e. reducing the complexity for human readers
08:57cemerickchouser: Yup. Though I never think of memfn, given #() *shrug*
08:57chousercemerick: ditto
08:57cemerickActually, can't memfn be deprecated entirely?
08:57chouseryes. I wish it were
08:58chouserit continues to trick people into thinking it provides a different feature-set than #()
08:58AWizzArdhmm
08:58chouserthough someone recently mentioned that it allows one level of nesting with #()
08:58AWizzArd,(doc memfn)
08:58clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn."
08:59cemerickCertainly not a reason to let it live.
08:59cemerickEspecially since damn near no one thinks of it.
09:00AWizzArdBtw, do you know how definlines do work? To me it seems: when their name is used somewhere else than the first position in a list, it expands into a fn. If it is used as first element of a list, then it works like a macro.
09:01chouserAWizzArd: roughly, yes
09:01AWizzArd(definline mydefinline [n] `(+ n 10)) (map mydefinline (range 10)) ... works as if it were a fn. But (+ 3 (mydefinline 20)) can be done without calling mydefinline at runtime.
09:01labatitudeHi, I'm trying to partition a list in a funky way. Here's what I've got: http://gist.github.com/609643 but am wondering if there is a more clojurey way of doing it.
09:01AWizzArdIs it the compiler or reader who is doing this work?
09:02chouserAWizzArd: a definline is expanded into a function definition once, when it is defined. Everywhere that the name is used like a value, that one function is used.
09:02chouserAWizzArd: compiler
09:06chouserlabatitude: (mapcat (fn [[[v] ks]] [v (if (next ks) ks (first ks))]) (partition 2 (partition-by vector? vmix)))
09:06AWizzArdchouser: k
09:07chouserlabatitude: patition-by is an option only because you're promising at least one non-vec after each vec.
09:07labatitudechouser: ok, somehow I missed partition-by.
09:08chouserthere are a lot of functions. It's hard not to miss some.
09:09chouser560 public vars in clojure.core
09:10labatitudechouser: i've been mostly looking at the clojure.org/data_structures and clojure.org/sequences pages
09:10labatitudethey are'nt up to date I guess
09:10chouser978 in the Common Lisp hyperspec list of all symbols
09:11chouserlabatitude: hm, that would probably be my fault. :-/
09:11labatitudeoh dear
09:11chouserindeed. I should update that for 1.2
09:11AWizzArdcemerick: some of those could be hidden you mean? It would be great if core would have a def-, and both def and def- should get the patch of bsteuber that allows to attach doc-strings to def's.
09:12chouserAWizzArd: clojure.core has plenty of hidden vars already
09:12chouser77 private vars
09:12cemerickAWizzArd: No, that's just a very large footprint for a single namespace.
09:12cemerickThe convenience of it is undeniable, but...
09:12cemerickIt definitely impacts discoverability.
09:13chousercemerick: I agree. I noticed when I pulled up the hyperspec the other day and for the first time *ever* thought: well, that's not *that* many functions...
09:13cemerickyeah
09:13AWizzArd(:
09:13cemerickI think it'd make sense to segment core up in a reasonable way, and immigrate vars into core.
09:14cemerickThough various redefinitions may make that painful/impossible.
09:14cemerickMaybe especially given static
09:14labatitudeanyhow, thanks chouser. I'm still trying to grok the destructuring in the anon function, but I will get there :)
09:14chouserlabatitude: yeah, that's dense, as most usful destructuring is.
09:15chouser(second (partition 2 (partition-by vector? vmix))) ;=> ((["b"]) (:b1 "b2" :b3))
09:16chouserso that's what the one argument for one call to the anon fn looks like
09:16labatituderight. I totally see how useful that is. in other languages you spend about 10 lines digging out your arguments.
09:16chouser[[v] ks] so that v = ["b"] and ks = (:b1 ...)
09:17chouserlabatitude: yeah, I don't think it's be any more clear without destructuring
09:18labatitudeso in [[v] ks], the brackets around the v are basically doing (first ...)?
09:18chouserlabatitude: exactly
09:18chouser(fn [x] [(ffirst x) (if (next (second x)) (second x) (first (second x)))])
09:19chouser^^^ not clearer
09:19labatitudeagreed!
09:21labatitudei just need to go play with that at the repl so that it sinks into my brain. destructuring-bind was something I just avoided in Common Lisp.
09:21AWizzArdfogus_: would you sometimes like to destructure from the end?
09:21AWizzArd(let [[* x y z] my-vector] (println "last three elements:" x y z))
09:21fogus_AWizzard: Yes. The need came up for me recently
09:22chouserand just in case destructuring isn't quite powerful enough yet, perhaps we can look forward to http://www.assembla.com/spaces/clojure/tickets/211
09:22fogus_chouser: I can't wait!
09:23AWizzArdyes, that sounds good
09:25chouseroh no. every single link to a function doc on clojure.org is pointing to the old github url, not the new one. :-(
09:28fogus_It would be great if destructuring leveraged unification also. :-)
09:29chouserApparently I need to read a book to understand what unification means.
09:30fogus_That makes two of us. :p
09:30cemerickfogus_: "Why does the destructuring in this snippet of Clojure take 40 minutes to unify on my Core i7?" ;-)
09:31fogus_cemerick: Weren't we all?
09:32cemericksadly, I blew professional time on it. I wish I had served my time in college, as most sane people seem to have.
09:32fogus_The funny thing about Prolog is that the cut operator has a tendancy to *actually* cut you. It's the strangest thing
09:36fogus_cemerick: Sounds like you do too
09:36cemerickIt seems that a plurality of clojure coders have Programming PTSD of some form or another.
09:37chouserthat may be true of professional coders in general.
09:37chouserclojure coders are perhaps more likely to have recognized it as such
09:37cemerickfogus_: I got into rehab very quickly compared to some, thankfully.
09:38chouserhard to see trauma sometimes when you're still in it.
09:39cemerickHrm. Being able to talk about one's tools as if they were significant others is a helluva pathology.
09:39chouserhehe
09:40fogus_BTW, have you gentlemen started/completed your Conj slides?
09:40cemericks/significant others/(war|addiction|etc)
09:40chouserfogus_: neither. :-]
09:40fogus_whew... so it's not just me then
09:40chousermine for strange loop are getting close to done
09:40cemerickfogus_: My talk at Clojure NYC last month was a preview.
09:40chouserfogus_: sounds like your last talk was well-received
09:41cemerickI need to work on my demo flow, but a tweak or two to the slides are all that are required.
09:41fogus_I was freaking out about the CUFP slides and couldn't find the evenrgy...
09:42fogus_chouser: I hope so. I walked to the front of the room all full of confidence, looked in the front row and saw Simon Peyton-Jones staring at me. I don't think I've ever had a confidence crash quite like it
09:42chouserI find my feelings, correct or not, is that StL is enemy territory and I need to "sell" Clojure (which I don't much enjoy). The conj will just be talking to old friends. :-)
09:43chouserfogus_: heh. I can imagine.
09:43cemerickchouser: What, all haskell and F# there?
09:43fogus_chouser: Although it would be worse if Guy Steele were sitting there. :p
09:44cemerickfogus_: very approachable fellow.
09:44chousercemerick: strange loop? I think it's mostly more mainstream than that. Java, C#, maybe ruby.
09:44cemerickOh, I thought you meant St. Louis :-x
09:44chousercemerick: yep, strange loop is in st louis
09:44fogus_cemerick: I have heard that about Steele (and Peyton-Jones also)... the psychosis is purely within me
09:51chouserlabatitude: http://clojure.org/sequences now has all the new 1.2 fns
09:51chousermixed in with the old ones. If you just want a list of the new ones, see http://github.com/clojure/clojure/blob/1.2.x/changes.txt
09:52chousercemerick: I wonder if hard-partitioning of core would be able to make much sense
09:52labatitudechouser: cool! this will actually help a lot.
09:52chouserso many functions fall into more than one "category", or none at all
09:53cemerickchouser: Well those actually are "core". Insofar as fns can be dropped into one of the documentation categories on clojure.org, they're namespaceable.
09:54chousermany fns in the doc categories on clojure.org appear in more than one category
09:54chouserset-validator
09:54chouserderef
10:04jjido,(trampoline (letfn [(continue [n s brk] #(forloop (inc n) s brk)) (forloop [n s break] (if (< n 100) (if (zero? (rem n 4)) (continue n s break) (if (= n 13) #(break (str s n)) (continue n (str s n ", ") break))) #(break s)))] (forloop 1 "" identity)))
10:04clojurebot"1, 2, 3, 5, 6, 7, 9, 10, 11, 13"
10:05chouserwow
10:05jjidoexperimenting with break and continue... this stuff is simple after all :)
10:09chouserit somehow never occured to me to use trampoline to explicitly manipulate returns the was call/cc does.
10:10chouseryou know something is brilliant when, having seen it, it suddenly seems obvious even though you'd never thought of it before.
10:11esjchouser: exactly - I had that flash reading about monads this morning. Ooooh, why did this take me so long to wrap my head around :)
10:11jjidoI will be doing plenty of that. after this all I'll need is syntactic transformation from my pet language to clojure
10:12chouseresj: ah, congrats. I have yet to reach that point with monads.
10:12esjwell, i'm not claiming mastery, merely understanding what the fuss is about.
10:14leafwjjido: this paste of yours ... like a contest of obfuscated code
10:16jjidoleafw: lol. for me it is clear enough because I am used to writing continuation-passing style, which is different from clojure's functional style.
10:22jjidodid you read Philip Wadler paper about monads? Not that I find monads that interesting personally.
10:24tobiasraederis there a way to define a second constructor for deftyped classes? (one that takes 0 arguments preferably)
10:24chousertobiasraeder: no. just create a regular function.
10:25tobiasraeder@chouse it's beeing called by java code which expects a no parameter constructor
10:25esjjjido: no I'm not haskell literate which obviously limits how far I could take that subject. So I worked through Jim Duey and Konrad Hinsen's tutorials.
10:27chousertobiasraeder: ah, for that kind of interop case you may have to use gen-class
10:28tobiasraeder@chouser is gen-class able to have mutable fields, like deftype [^{:volatile-mutable true} myparam] ?
10:28chousertobiasraeder: no, you get a single immutable (final) instance membet, but you can put an atom or ref in there so that it can be mutated.
10:29chousermember
10:29chouserwhich is more likely correct anyway, than a volatile-mutable
10:29jjidoyou will have trouble with mutable defrecord and java interop
10:30tobiasraedertbh it worked pretty nice so far
10:30chousertobiasraeder: what kind of high-performance thing do you have going where you are using :volatile-mutable anyway?
10:30jjidoI think (what does atom translate into?)
10:30tobiasraeder@chouser i just need to implement an interface in clojure (which is generated in clojure aswell) and said implementation needs mutable fields
10:30tobiasraeder@chouser so the volatile-mutable deftype way is completely wrong for that purpose in your eyes?
10:31cemerickFor my money, gen-class'ing a class providing static factory fns returning records is the best path at the moment if one has Java callers.
10:31chousertobiasraeder: if it's not high-performance, don't touch volatile-mutable. Use one of clojure's controlled mutable reference types: atom, ref, agent, var, etc.
10:31chousereven if it is high-performance you should use one of those first
10:32tobiasraederwell i got n numbers of parameters which all need to be mutable and are generated inside a macro
10:32chousertobiasraeder: not a problem. put them all in a vector or map and store then in a ref
10:33chouseror possibly a vector or map of refs, depending on your exact situation.
10:33tobiasraeder@chouser alright, guess ill try that out later today. ill look into gen-class then i guess
10:41chousertobiasraeder: yeah, I think that's the only way to get a no-arg constructor, which is unfortunate because gen-class is rather hairy to use
10:42tobiasraeder@chouser well im using gen-interface alright, i guess its pretty much "the same"?
10:43chouserwell, that does mean you're doing AOT already, which is at least half the battle
10:45tobiasraederyeah
10:45tobiasraederits kinda scary interop really lol
10:45tobiasraederthe javaside is alot of reflection driven analysis of the supplied class/interface
10:48LauJensentobiasraeder: When you get tired of Java you should try doing some Clojure :)
10:50tobiasraeder@LauJensen lol i am tired but need to finish that interop stuff first i guess :/
11:04chouserreplaca_: will there be an api page for clojure.string?
11:05astoddardI have started working with defrecord. It appears the generated constructor uses strictly positional arguments; this is for efficiency?
11:06astoddardI have seen others write "factory" functions for constructing records with named parameters. Is this recommended?
11:06chouserastoddard: sure, for any kind of customized construction
11:07chousernamed parameters, defaults for unset fields, pre-computed fields, etc.
11:07chouseralso helps ease use in other namespaces.
11:08astoddardThank you, makes sense. I'll have to think a bit to grok that last one.
11:09astoddardAll those functions will ultimately call the positional constructor to actually get a record?
11:09chouseryep
11:11astoddardGot it. One last question. Positional only because it goes as close as possible to the bare JVM and the JVM only does positional arguments?
11:12konrIs there a better way to do this? http://4f6e998fe0ca9c6f.paste.se/ Basically I'm logging function call results and running before-running and after-running functions
11:13jjidoastodard: it is short too. I don't like it when there are many args though.
11:13chouserastoddard: probably. there's been talk of a named-arg constructor function as well, and I wouldn't be suprised if one shows up eventually. There's been some differences of opinion on specific semantics and naming.
11:15chouserkonr: I don't think you need any of those atoms
11:16astoddardFair enough, thanks. I'm imagine there are some macros out there wrapping fancier constructor semantics around defrecord. Does anyone have a favorite one?
11:16chouserkonr: just initialize your job map with the actual values you need
11:17chouserastoddard: this one has been out there. I haven't found any single macro to be useful in general in my own work yet. http://cemerick.com/2010/08/02/defrecord-slot-defaults/
11:18konrchouser: hmm, inside the Thread object?
11:18astoddardchouser: Thanks.
11:18chouserkonr: ah, I was misreading, sorry.
11:19chouseryou're collecting return values.
11:20chouserkonr: do you actually look at those return values later?
11:20konrchouser: sure! They'll contain web crawling data
11:20drewrhttp://ubuntuone.com/p/IZI/
11:21chouserdrewr: hm. yeah. maybe (conj others me)
11:22fogus_astoddard: I have a modified version of cemerick's defrecord+ that also allows kwargs and invariants (with some extra support needed http://github.com/fogus/trammel/blob/master/src/fogus/me/trammel.clj#L239 )
11:23scottjfogus_: have you tried do get your defrecord+ in c.c?
11:23chouserkonr: hm, ok. will you be looking at intermediate values of a job before it's complete?
11:23jjidoesj: this is how I got the "obfuscated" code: http://gist.github.com/609842
11:23fogus_scottj: no. I'm not sure if its wider appeal
11:23fogus_s/if/of/
11:23sexpbot<fogus_> scottj: no. I'm not sure of its wider appeal
11:24scottjevery time I look in this channel someone is asking about it
11:24scottj(little exaggeration)
11:24chouserjjido: I think using clojure as a target lang for various syntaxy languages has a lot of promise
11:24fogus_scottj: Oh? I think that such a macro, while useful, is controversial.
11:24konrchouser: not at all... it would be nice to have some sort of progress counter, but I'm not worrying about that for a first version
11:26esjjjido: interesting. Although I don't think I busted out the obfuscated code comment :) I'm still at a point that most good code looks obfuscated to me, so I'm a little cautious.
11:26scottjfogus_: apply macro is controversial and in c.c.
11:26chouserkonr: then I'd still recommend building and returning an immutable map, instead of a map full of atoms
11:27chouserkonr: like (assoc {} :time (get-time) :pre (when pre (pre)) ...)
11:27scottjor maybe not, looks deprecated now
11:27cemerickscottj: I wrote defrecord+, and even *I* dislike it. :-P
11:27drewrchouser: that's exactly where pjstadig's and my conversation went
11:28scottjcemerick: why?
11:28freakazoidspeaking of maps full of atoms, how would one do an MVCC database where insertions don't always conflict with other insertions?
11:28chouserdrewr: heh, sorry, what are you referring to?
11:28cemerickscottj: It defines multiple with a single def* form. That's almost always bad IMO.
11:28konrchouser: thanks! btw, nice book you are writing!
11:29chouserkonr: thanks! mostly done now, thank goodness.
11:29freakazoidright now I'm using a vector that I don't delete from
11:29freakazoidfull of refs
11:29drewrchouser: the t-shirt snafu
11:29cemerickscottj: It defines many things with a single def* form.
11:29jjidoesj: no problem. To add to what chouser said, I am happy my code converts so straightforwardly in Clojure
11:29chouserkonr: also, you might look at 'future' instead of start-Thread-fn...
11:29freakazoidand a separate map from key to index in the vector
11:29chouserdrewr: ah
11:30chouserdrewr: probably too late, eh?
11:30cemerickGiven a type Foo, what's the factory fn called? new-Foo? new-foo? make-Foo? Bleh.
11:30freakazoidwhy not Foo?
11:30cemerickFoo is the class itself
11:31scottjcemerick: if there were one defrecord+ in c.c then that would be clearly defined and consistent
11:31freakazoidCouldn't a class implement the IFn interface?
11:31chouserClass is final
11:31freakazoidMaps and vectors do
11:31cemerickfreakazoid: no, Class is final
11:31freakazoidhmm
11:31freakazoidI suppose learning Clojure would be easier for me if I knew Java
11:32chouserfreakazoid: I know Java better now than I ever did before learning Clojure.
11:32cemerickscottj: A just-so standard is stupid and unhelpful to newcomers. Esp. when simpler options are available.
11:32freakazoidI'm learning bits of it in the rpocess.
11:32chouserI still get completely tripped up with Java syntax though
11:33chousercemerick: I'm sure we've been on this merry-go-round before, but how would a 'make' macro (with a better name) sit with you? (make Foo :a 1, :b 2)
11:34chousermacro, though -- requiring a literal class name there.
11:35AWizzArdHow can one do Enums in Clojure? As in: public class Bar { public enum Foos {SMALL, MEDIUM, LARGE} ... }
11:35jjidochouser: I use something like that called new*
11:35chouserAWizzArd: define or use?
11:36jjidowith my own class structure though, I don't have java interop as a goal
11:36AWizzArdchouser: define
11:36cemerickchouser: IIRC, that was fine by me.
11:36AWizzArdUse would probably be something such as Bar$Foos/LARGE
11:36cemerickThere's a lot of intersecting concerns re: the factory fn thing.
11:36freakazoidAWizzArd: the normal lisp thing to do is to use symbols for that
11:36AWizzArdfreakazoid: yes, I know. Keywords even.
11:36freakazoidor keywords, whatever they're called
11:37chousercemerick: because that could of course generate a call to either (-maker-for-Foo :a 1 :b 2) or even just (Foo. 1 2 :default-for-c)
11:37freakazoidthey're atoms in erlang, but clojure uses atom to mean something else
11:37cemerickchouser: That doesn't help apply cases, and doesn't help with require-before-import problem though.
11:37AWizzArdThough the Enums may have hotspot advantages, and they are easier to use from Java.
11:37cemerickchouser: dear lord, the latter please :-|
11:37freakazoidAWizzArd: he said he didn't have interop as a goal ;-)
11:38cemerickchouser: you understand, CLOS poisoned me w.r.t. defining multiple "things" with a single def* form.
11:38freakazoidIn general it's best to only depart from doing things idiomatically if you really need ultimate performance
11:39chouserAWizzArd: that's a good question -- are you sure you need enums and not just keywords
11:39chouserI'm not sure if there's a way to generate enums from clojure short of ASM
11:40jjidoAWizzArd: enums in java use some kind of inheritance maybe you could go back to that
11:40freakazoidAWizzArd: whoops for some reason I got it into my head jjido asked the original question
11:40freakazoidthe java interop thing was a red herring with respect to enums
11:40AWizzArdI can imagine that I would like to offer easy to use classes for a Java API. Those guys are more used to Enums and have (java) language support for those.
11:41chouserAWizzArd: so this is about interop
11:41AWizzArdI would start off writing my code using keywords, if it were I who should use the code. So yes, mostly interop.
11:41AWizzArdThe enums have some advantages, such as compile time checking, easy use from Java, etc.
11:42AWizzArd(defenum MyEnum [X Y Z]) ... MyEnum/Y don't know if such a thing would be possible, and get the same advantages.
11:42jjidoand integer values?
11:42AWizzArdMy example from above used an inner Enum as I see it.
11:43freakazoidAWizzArd: did you look at http://markmail.org/message/zatkdrrunyp4mhpv already?
11:43freakazoidgoogle has lots of hits for "java enum clojure"
11:44chouserah, when genclass was new
11:44chousermight be able to use deftype now?
11:45AWizzArdhmm
11:45freakazoidanyone using clojure on .net on azure yet?
11:47freakazoidHmm, for all I know the JVM works on azure
11:47freakazoidoh look at that
11:47freakazoidgoogle says yes
11:47cemerickfreakazoid: it apparently does -- I was being pitched on running tomcat-hosted apps in azure by a MS rep a few months ago
11:48freakazoidI need to get Membase onto Azure.
11:48freakazoidAnd looks like making it dependent on the JVM for running server-side user code would not be an impediment to that
11:51arohnerwhat affects when tab completion works in slime?
11:52arohnerit works 100% of the time for me in repl mode, but seems to work 50% of the time in clojure source files
11:52defnarohner: among other things I believe you need to have TAB bound to some swank command
11:52defnbut that should be done for you?
11:53arohnerdefn: interestingly, it's not, in my clojure file. But I'm certain it has worked before in clojure files...
11:53defnarohner: just for kicks try to do Shift + TAB
11:53defnand let me know if that fixes it...
11:53arohnerdefn: shift + tab is bound to yank for me
11:54arohnershould it be slime-indent-and-complete-symbol?
11:54defnarohner: yeah that sounds familiar
11:54defnarohner: also try meta-tab
11:55arohnerdefn: that's what my repl TAB is bound to
11:55arohnermeta-tab is alt-tab, that OSX eats
11:55defnnot for me?
11:55defnmaybe you're thinking of Cmd + TAB
11:56arohnerdefn: I have meta and option switched
11:56defnsorry im not of much help here, i just seem to remember in SLIME TAB has always worked
11:56defnbut in clojure-mode, in the file itself
11:56defni needed to use some modification of that
11:56arohnerdefn: just getting me to check what tab was bound to helped a lot. I'm surprised though that it's transient
11:57defn*nod* -- weird behavior
11:57defnlatest version of clojure-mode?
11:57arohnerdefn: my clojure file is not bound to slime-indent, but I'm 100% sure it's worked recently
11:58chouserAWizzArd: java.util.Calendar seems to use static fields instead of enums
12:00rplevyis there any way to control or configure memoization in newer versions of Clojure? For example, if it is using too much memory.
12:02arohnerrplevy: not in the built in memoize
12:02arohnerrplevy: http://kotka.de/blog/2010/03/memoize_done_right.html
12:04defnarohner: technomancy might be a good guy to ask
12:04defnhe's intimately familiar with all of those details
12:04defnme...not so much
12:04defnmy setup works, beyond that I'm sort of a clueless :\
12:05rplevyarohner: thanks, this looks useful
12:06chouserAWizzArd: looks like we used to have clojure.contrib.enum for this, but not anymore?
12:15AWizzArdchouser: I did not even know about contribs enums :)
12:55cemerickchouser: why the dashes in your colored repl?
12:57chousercemerick: I really wanted the prompt to be in a different color, to make it stand out
12:58chouserbut that messes with rlwrap's concept of horizontal cursor position.
12:58chouserso the dashes are just to help the prompt stand out from the rest of the output
12:58cemerickah
12:58cemerickI don't think I'll include those :-)
12:58cemerickThough I never see red, only green and blue.
12:59cemerickI wonder if I'm just terminally hopeless with the console, etc.
13:01chouserexceptions aren't red?
13:02freakazoidterminally hopeless… I like that
13:02freakazoid(with the console)
13:02chouserheh
13:02cemerickfreakazoid: I was wondering if anyone would catch that.
13:02chouserI completely missed it
13:02freakazoidbash has a way to use escape characters in the prompt without screwing up position
13:03freakazoid\[\e]2;\h:\W\a\]\!,$? \u@\h:\w$
13:03chouseryeah, but this isn't bash
13:03freakazoidJust hack it to do something analogous
13:03chousermaybe rlwrap has some options -- I didn't look into it too deeply
13:05freakazoidor just add a separate option to explicitly specify a character position
13:05freakazoidbash just doesn't count characters between \[ and \]
13:06cemerickchouser: bleh, I was printing exceptions in nrepl to *out* :-P
13:06chouserah. I'm not actually sure if *err* is correct
13:06chouserI think I was just mimicking the built-in repl
13:07chousers/correct/best/
13:07cemerickno, I mean nREPL was printing exceptions to *out*, server side, so that content wasn't coming over in messages with an :err slot, etc.
13:07cemericknm, it was my bad :-)
13:09chouseroh, I see. ok
13:09cemerickchouser: you said that colored output was usually optional...is there a standard option enabling it?
13:10cemerick20s of googling turned up nothing obvious.
13:10chouser--color on the command line is probably most common, is that what you're asking?
13:11cemerickyup, that'll work
13:29cemerickchouser: FWIW: http://github.com/cemerick/nREPL/blob/master/src/main/clojure/cemerick/nrepl/cmdline.clj
13:29cemerickI poked around at trying to get :err println boldly, but had no luck
13:31abedrafogus_: How did your talk go on Saturday?
13:33fogus_abedra: Better than I expected. It was fun.
13:34fogus_abedra: And your tutorial?
13:35abedra fogus_ went well. Glad yours did too. Really enjoyed the audience
13:35abedrafogus_: I'll catch you finally in raleigh in a few weeks!
13:37fogus_abedra: People seemed genuinely interested in Clojure, and had very insightful questions. I guess that's to be expected given the auidence mix
13:42lazy1cemerick: (println "\033[31mfoo\033[m") printed in red for me
13:42lazy1cemerick: Ubuntu via rlwrap
13:44cemericklazy1: Yeah, the problem was unrelated to what was being printed :-)
13:45cemerick(see prior commit)
13:57chousercemerick: ah, cool.
14:18defnIf you don't have this: You want it.
14:18defnhttp://sr3d.github.com/GithubFinder/
14:20cemerickdefn: damn
14:20mrBlissdefn: it doesn't have syntax highlighting for clojure though ;-)
14:48aavif i have a protocol - what is the portable way to find the name of java interface behind it?
14:49aavis this a good option: (.getName (:on-interface protocol))
14:50chouserportable?
14:51Dawgmatixhow do i specify clojure contrib 1.3 alpha as a dependency in leiningen ?
14:52aavchouser: means it will not be affected, in case some internals of protocol implementation will change
14:52chouseraav: I don't think :on or :on-interface is documented or guaranteed to not change)
14:53chouserbut it looks like as good an option as any right now. :-)
14:53aavchouser: than you. that was my question. :)
14:53kotarakDawgmatix: [org.clojure "1.3.0-alpha1"] should come close
14:54Dawgmatixthanks
14:54kotarak[org.clojure/clojure ...] that is
15:02AWizzArd~seen rhickey
15:02clojurebotrhickey was last seen quiting IRC, 5293 minutes ago
15:02AWizzArdRich is having vacation :-)
15:02LauJensenAWizzArd: He's in Denmark
15:02AWizzArdLauJensen: oho?!
15:02jfkwTrying to get started with swing windows. Platform is Gentoo Linux ~amd64, sun-jdk-1.6.0.21, window manager: awesome (tiling, it might be pertinent). First question: (. javax.swing.JOptionPane (showMessageDialog nil "Hello World")) works, but when the window is closed, lein repl doesn't return to prompt until new input processed. Is this normal, and is the swing window loop still running awaiting some terminate method?
15:03AWizzArdvery nice, touring through Europe
15:03LauJensenAWizzArd: JAOO
15:15hugodLauJensen: you solve your tomcat woes?
15:15carkhjfkw: i had the same problem in emacs/windows it soemhow disapeared
15:16LauJensenhugod: The Tomcat is now purring like a kitten, yea everything is great
15:17carkhjfkw: i think it's a matter of using swing as it should be, and call swing methods with invokeLater
15:17carkhjfkw: as swank is in its own thread
15:31jfkwcarkh: #awesome is pointing me to sun-jdk-1.6 problems with non-reparenting window managers. I'm trying their workarounds.
15:32jfkwcarkh: Workaround using utility wmname, trick jdk into thinking I'm using LG3D, fixes it completely.
15:33chouserjfkw: link? I bet I've seen problems from a similar cause.
15:35carkhahwell i guess my problem was a different one
15:36LauJensenjfkw: I had the same, and yes LG3D and restarting the JVM solves it
15:40jfkwchouser: See http://awesome.naquadah.org/wiki/Problems_with_Java#Impersonate_Another_Window_Manager , Arch's bug would seem to be a good start to port the fix to other distros: https://bugs.archlinux.org/task/15674 My own Gentoo doesn't have a sun-jdk-1.6 fix yet.
15:55AWizzArdkotarak: grats to VimClojure 2.2.0!
15:56chouserjfkw: thanks
16:04freakazoidAnyone have a suggestion for an embeddable lisp interpreter for a C++ program? There are so many to choose from.
16:05freakazoidEase of embedding and apache2 compatible license are what i'm looking for
16:05freakazoiddoesn't have to be common lisp or any standard
16:05chouserumm... maybe clojure?
16:05chouserembedding a jvm can't be *that* hard, right?
16:06freakazoidhaha
16:06freakazoidthis is a pretty small C++ program :)
16:06freakazoidEmbedding a JVM into it would be kind of comical.
16:06freakazoidI just don't want to implement a confguration & command language.
16:07technomancyguile is designed for that kind of thing
16:07chouserI've had fair success using C and C++ libs from clojure, but haven't tried the other way 'round.
16:09freakazoidguile was one of the many I was looking at.
16:10freakazoidSomehow guile's installation manages to be larger than spidermonkey's
16:10freakazoidprobably because of all the examples
16:10freakazoidwhereas spidermonkey is *just* the header files and library. Ah.
16:11turbofailtinyscheme maybe
16:12freakazoidAnything not in homebrew makes me suspicious ;-)
16:13freakazoidunless it has a native package
16:16turbofailtinyscheme is small enough that you can audit the source yourself if you're suspicious
16:17freakazoidI'll check it out
16:17s450r1how about gambit, chicken, or bigloo then? They are supposedly pretty easy to embed, since they all can compile scheme to C.
16:17freakazoidthe current binary for this program is 1.2 megs, guile is 1.7 megs, lua is 328k, but I'd like to avoid lua
16:17turbofailthough ironically one thing it was infamous for was that a malware developer mentioned that he used it in his work
16:18freakazoidthis is for runtime config
16:18freakazoidtinyscheme?
16:18turbofailyeah
16:18freakazoidwell, that is a testament to its ease of embeddability
16:18s450r1turbofail: I remember reading that interview too :-)
16:19carkhah funny guile allows linking without infecting with the gpl
16:20freakazoidoh, I forgot to mention crossplatform… this thing will build and run on windows, but doesn't use autoconf so will need some work
16:20turbofaili've built tinyscheme using mingw
16:20turbofailit required very few tweaks
16:20freakazoidbuilding it on OS X is proving to be a bit of a challenge.
16:21turbofaileh... can't help you there, that's one platform i've had zero time on
16:22freakazoidusing the linux section is helping
16:23freakazoidhmm, it has a call to something called "ccommand" which I can't find any information on
16:24turbofailodd... my copy of the makefile doesn't have anything like that
16:24freakazoidOh, it thinks I'm on apple and not osx
16:25freakazoidwoo! it built!
16:27turbofailcool
16:29fhdHi. I'm using the Clojure Maven plugin and I have to manually load my .clj files when calling mvn clojure:repl. Any hints what I can do about that?
16:30kumarshantanufhd: what is "manually load"?
16:30fhd(load "foo/bar")
16:32fhdSteps to reproduce: 1. Create a file "bar.clj" in a directory "foo" with the following contents: (ns bla) (defn main [] (println "Hello, World!"))
16:32fhd2. Invoke mvn clojure:repl and try to execute "(foo.bar/main)" <-- doesn't work.
16:33chouserfhd: I think you need your .clj files in a different directory tree.
16:33fhd3. Invoke mvn clojure:repl and execute '(load "foo/bar") (foo.bar/main)' <-- works
16:33fhdchouser: which one?
16:33kumarshantanuis foo/bar in classpath?
16:34chouserfhd: I haven't used maven much. just a sec...
16:34fhdkumarshantanu: I think clojure:repl adds it. It does at least compile it.
16:35fhdI'm not exactly sure if clojure:repl is supposed to load my .clj files, I'm just expecting that.
16:35abrenkfhd: your .clj files are supposed to be in src/main/clojure
16:35cemerickfhd: it doesn't -- you have to use/require them per usual
16:35fhdabrenk: They are. If they weren't they wouldn't be compiled.
16:35cemerickand what abrenk said
16:36kumarshantanufhd: hmm, repl doesn't load files by default
16:36fhdcemerick: I'm new to clojure, is use/require an alterantive to load?
16:36cemerickfhd: load is essentially never used in app-level clojure code
16:37cemericksee use and require, as well as their associated forms in ns
16:37AWizzArdcemerick: I am using load at a few places
16:37hiredmanwe use load for somethings too
16:37technomancy"use" is old-school; I'm porting my code over to "uses"
16:37cemerickAWizzArd: Indeed. See "essentially" :-)
16:37AWizzArdIt allows me to move some code parts into different files, and they share the NS.
16:37technomancy(not really)
16:37abrenkfhd: you could specify replScript in the configuration and require your namespaces there
16:37AWizzArdcemerick: yes okay, not typical, I agree
16:37chouserlein source code trees aren't laid out the same as maven source code trees?
16:38cemericknope
16:38abrenkchouser: not by default
16:38AWizzArdI use it very rarely, and 98% goes into require
16:38AWizzArdlike technomancy said
16:38AWizzArdtechnomancy: one could use with a :only specifier
16:38technomancyAWizzArd: actually I was joking; "uses" hasn't been implemented yet
16:38AWizzArd...use 'use' with...
16:38freakazoidtinyscheme looks like exactly what we need. Thanks, turbofail!
16:38technomancyit's a mythical replacement to unify use/require/refer
16:39AWizzArdah, I only got that first part, before the semicolon
16:39kumarshantanufhd: just curious - are you trying to do interactive development using the REPL?
16:39fhdI see, it works with both require and use. Does that mean I have to require all the namespaces I want to use? Is there a combination of require/use and ns so I can switch namespace directly?
16:39hiredmanI was looking at some example code for a database project some guy just posted to the mailing list, and he seems to think use is uses
16:39fhdkumarshantanu: I'm actually just trying to do some random experiments with Clojure
16:39clojurebotclojure bot is not immune to ,(iterate inc 0)
16:39AWizzArdstrange that I didn't see the other part.. it is like the situation when a lisp newbie tells me that there are too many parens. Only when I get this explicit remark I even notice them.
16:39hiredmanthe code does (:use some.name.space :as space :only ())
16:40cemerickfhd: not in a bare repl -- require + in-ns is typical
16:40cemerickGood tools will provide you with a load-and-switch-ns command, tied to the current buffer, etc.
16:40fhdcemerick: :( Pretty ugly with long package names
16:40hiredmanyou can provide short cuts in a user.clj
16:40cemerickfhd: almost no one uses bare repls for development AFAIK
16:41cemerickexcept for chouser ;-)
16:41abrenkfhd: add <configuration><replScript>src/main/scripts/repl.clj</replScript></configuration> to the plugin and use "require" and "in-ns" in that file.
16:41chouserit builds character
16:41cemerickand RSI, I presume
16:41kumarshantanufhd: it seems you can specify an initialization script for clojure:repl in pom.xml -- http://github.com/talios/clojure-maven-plugin
16:41chousernope, vi-bindings destroy RSI
16:42fhdabrenk, kumarshantanu: Thanks, looks useful.
16:42kumarshantanufhd: search for "clojure:repl" on the page
16:42fhdI could also define my own require-and-ns in that file :)
16:42hiredman*ahem*
16:42hiredmanuser.clj
16:42hiredmanno xml required
16:43abrenkhiredman: but then user.clj is packaged into the jar...
16:43hiredmandepends on what your classpath is vs. what you are packaging
16:43kotarakIn (let [x (int 1234)] (< x 4321))... Do I have to hint 4321 with (int)?
16:44chouserkotarak: which version of Clojure?
16:44kotarak1.2 for now, but later on 1.3 of course.
16:45chouserwell, you never have to hint. but for unboxed math in 1.2, yes you need (int 4321)
16:45abrenkhiredman: the script config could get some sensible defaults... perhaps I'll put together a patch for that.
16:45kotarakchouser: yeah. unboxed was the question.
16:45LauJensenhugod: bestinclass.dk is now Tomcat driven
16:45kotarakchouser: should I also go with long instead of int?
16:45kotarakchouser: for future proofness
16:46chouserhm.
16:46chouser(clojure.contrib.repl-utils/expression-info '(let [x (int 1234)] (< x 4321)))
16:46alexykninjudd: is there a way to blink closing/open parens as rlwrap does? I really miss that in cake
16:46chouserthat should tell you the truth -- but I'm getting :primitive? true on 1.2, which surprises me.
16:46ninjuddalexyk: i wasn't aware rlwrap did that
16:47alexykninjudd: beautifully
16:47kotarakAh. Expression-info....
16:47chouseroh, nm
16:47fhdIs there a way to require multiple namespaces with a wildcard? e.g. (require foo.*)?
16:47chouserboolean primitive. duh.
16:47kumarshantanufhd: no wildcards available
16:47kotarakhahaha :) Yeah. expected from <.
16:47ninjuddalexyk: sounds like a great first cake contribution for you ;-)
16:48alexykninjudd: I need to write up my PhD first, by then will run on assembly if need be :)
16:48alexykbut I'll investigate how rlwrap does the blinkin'
16:48chouserkotarak: hang on -- testing 1.3.x
16:49fhdcemerick: What are the tools you mentioned other Clojure devs use?
16:49chousercemerick: If I'm a maven-clojure user and want to just start up a quick repl in some specific version of clojure, what would be my best route?
16:49hugodLauJensen: :) if you let me know the issues you had, I can embed the solutions in the #pallet tomcat crate
16:50chousertechnomancy: If I'm a lein user and want to just start up a quick repl in some specific version of clojure, what would be my best route?
16:50cemerickchouser: assuming you're on the command line: set your clojure dependency version, `mvn clojure:repl`
16:50chouserninjudd: If I'm a cake user and want to just start up a quick repl in some specific version of clojure, what would be my best route?
16:50chousercemerick: how do I set my clojure dependency version?
16:50chouserdo I have a project dir sitting around just for such occasions?
16:51technomancychouser: lein new scratch-project; edit project.clj, then lein repl should do it
16:51KirinDaveSo guys.
16:51technomancylein repl got a significant fix in 1.4.0-snapshot
16:51KirinDaveI gots more advice to consider.
16:51cemerickfhd: you sound like a lisp user; I'd point you in that direction if that's the case. Otherwise, counterclockwise for eclipse, enclojure for netbeans.
16:51technomancychouser: actually if you don't have a project, cljr might be better
16:51KirinDaveAnyone want to let me sound off them?
16:51fhdcemerick: Ah, I thought you meant commandline alternatives to REPL.
16:52chousertechnomancy: ok, scratch project
16:52kotarakchouser: you didn't ask for gradle, but I have to market things. Apply the clojure plugin in build.gradle, add clojure dependency of choice, start your favorite editor backend via a custom task. The last step is kind of not implemented right now, but eg. a VimClojure task will be there in the future.
16:52cemerickchouser: yeah, that's assuming you've got a pom.
16:52ninjuddchouser: if you want to do it without creating a project, just run 'cake' from your home directory. then you can edit the global project (~/.cake/project.clj) to specify the version of clojure you want
16:52KirinDaveAs Webmachine moves down the state graph
16:53ninjuddthe default is 1.2.0
16:53KirinDaveIn the erlang impl it sets up temporary variables
16:53chouserkotarak: sorry, no offense intended!
16:53KirinDaveI'm wondering how I should mirror that.
16:53ninjuddchouser: to start a repl after changing your clojure version, just do 'cake repl'
16:53KirinDaveWith bindings?
16:53kotarakchouser: non taken. Just to keep it on the radar. ;) (shameless promotion)
16:54fhdcemerick: Still, how does Counterclockwise prevent me from having to require/ns?
16:54KirinDavehttps://gist.github.com/e1b9d6920877fa5ed3bc
16:54fhdcemerick: I've tried it and it seems to bascially run a REPL inside Eclipse.
16:54KirinDaveThe erlang code puts the chosen response handler in a temp variable.
16:54lancepantzchouser: in short, just 'cake repl' will give you a repl with 1.2
16:54cemerickfhd: There's a load-and-switch-ns command that loads the current file and switches you to the corresponding ns.
16:54KirinDaveShould I do that?
16:54KirinDaveWith like, um, bindings?
16:54chouserhm, so the basic pattern is: scratch project, set dependency version. Do any of these work with a custom clojure.jar?
16:54fhdcemerick: Oh, I see.
16:55lancepantzchouser: if you want a different version, you can edit ~/.cake/project.clj to change the global project
16:55cemerickchouser: that you built locally?
16:55kotarakfhd: VimClojure provides an option to start a repl with the initial namespace set to the one of the current file. Maybe ccw provides something similar.
16:55kumarshantanufhd: in Eclipse/CCW, you just right-click a .clj file and say "Run in REPL"
16:55kotarakchouser: yep.
16:55chousercemerick: right. I just changed Compiler.java, ran ant, I want to try it out.
16:56chouserKirinDave: almost certainly not bindings
16:56kumarshantanufhd: CCW loads the namespace automatically and switches ns for you
16:56KirinDavechouser: Why?
16:56hugodKirinDave: I just moved pallet from bindings to passing an explicit map argument, and I haven't regretted it - haven't looked at your use case though...
16:56jjidoDave: bindings is for vars that you want to attach to a specific thread isn't it
16:56cemerickchouser: if you run ant using the target that is used in hudson (ci-build?) that will install a clojure.jar snapshot locally, which should get picked up immediately by your next mvn invocation (assuming your dep is set for the corresponding snapshot version).
16:57KirinDavejjido: Bindings are for dynamic scope. It can be used for thread bindings.
16:57fhdHm, I see, it works. Problem is that I'd prefer working on the commandline with mvn clojure:repl. I think I'll just live with the duplication for now...
16:57KirinDavehugod: It just.. gets kinda tedious to move all that around.
16:57chousercemerick: interesting.
16:57cemerickchouser: it's exactly the same process that build.clojure.org uses, which I have to presume will work in a single-user setting.
16:58kotarakfhd: maybe you can start up the backend via maven and tell ccw to connect to it?
16:58cemerickWhich is why I've never quite understood you and Rich having such trouble with the workflow.
16:58hugodKirinDave: I use a single map argument - which can then be used to pass different keys as required - tedious to set up, maybe
16:58fhdkotarak: wouldn't that still require Eclipse?
16:58KirinDaveI just need to keep in mind scala compatibility in the future.
16:58KirinDaveMaps of maps of maps will make them angry.
16:59chouserKirinDave: if you use bindings you have basically zero options when it comes to delays, closures, multiple threads, saving state machine state anywhere, etc.
16:59kotarakfhd: Oh sorry. I though you were using eclipse.
16:59fhdkotarak: I do, sometimes, but I'd rather not for clojure :)
16:59kumarshantanukotarak: the unified REPL-over-network interface is in works I guess (for CCW, in this case)
16:59fhdOkay I think I've got it. What I want is to create a number of examples and execute them explicitly.
17:00fhdSo I think I'll just create a Java main class that accepts a sample as an argument.
17:00fhdI think that's how clojure.main works, isn't it?
17:00kotarakkumarshantanu: I know. Working in VimClojure
17:07AWizzArdHey aav, und ihr anderen deutschsprachigen, es gibt auch einen deutschen Clojure-Kanal. Einfach mal ein .de anhängen und joinen :-)
17:13chousercemerick: looks like I want my own thing (target?) to launch a customized repl
17:13chouserI guess I should look at creating my own maven plugin?
17:20cemerickchouser: you mean for your highlighting, etc?
17:20chouseryeah, but more importantly rlwrap
17:21chouserhm, maybe that's backwards.
17:21abrenkwhy's there no "ant repl" target?
17:25LauJensentomoj: I almost... cant...hold my breath... any longer...
17:36AWizzArdAnyone here who knows the gzipIOstreams "well"?
17:37AWizzArdTheir constructor offers a size argument, for a buffer. Does this mean that a BufferedIOStream is not required, as the gzipstream implicitly creates one?
17:47cemerickchouser: I don't use rlwrap myself, but I have to assume it'd be rlwrap mvn ...
17:49jjidois there a "letrecord" like there is a "letfn"?
17:50jjidoI want to change the way it implements a protocol without adding a new type at the top level
17:50raekjjido: no, but you might be intetested in reify
17:51jjidoraek: yesI think so
17:52chousercemerick: yeah, had just realized that
17:52chousercemerick: how do you quit out of said repl? EOF such as ^D doesn't seem to work.
17:52chouserreally, I'm just whining. why doesn't ^D work. :-)
17:53KirinDaveIs there a version of if-let that allows for more bindings?
17:54chousernot standard, that I know of.
17:55KirinDavechouser: https://gist.github.com/4a808194d428697eeb9f makes me feel dirty.
17:59chouserthat's not really too bad. could use a second if-let inside
18:00chouserbetter than http://gist.github.com/560765 for example
18:00jjidoraek: if I want to add fields to my reify'ed record, can I merge it with an existing record?
18:01chouserjjido: yep, but that won't bring in any implemented methods
18:01chouserok, gotta run. ciao all
18:01jjidochouser: that's fine thanks
18:01raek,(merge (reify) {:a 1, :b 2})
18:02clojurebotjava.lang.ClassCastException: sandbox$eval8647$reify__8648 cannot be cast to clojure.lang.IPersistentCollection
18:02raekhrm, right.
18:03raekreify is more like an anonymnous deftype rather than a defrecord
18:03MunksgaardHi. I'm really lost here, how do i use the clojure-contrib functions? I'm on a completely fresh install, i've downloaded leiningen created a new project and downloaded the deps, but when i start a repl i cant use the contrib libs... Isnt it (:require clojure.contrib.math) ?
18:04raekthat makes sure that it is loaded, but yoy can't use the vars in that namespace without qualifying the symbol
18:04raek(clojure.contrib.math/some-math-fn 1 2 3)
18:04AWizzArdMunksgaard: do you have this (:require ...) inside a (ns ...) declaration?
18:04AWizzArdOr do you try this in the repl?
18:05raekthe corresponding function is used like this: (require 'clojure.contrib.math) ;notice the quote
18:05MunksgaardAWizzArd, i'm trying it in a repl, and i get classnotfoundexecption)
18:06Munksgaardraek, (clojure.contrib.math/expt 2 4) gives me a classnotfoundexception
18:06raekMunksgaard: the :require variant is for inside ns only
18:06AWizzArdtry it without the :
18:06Munksgaardraek, if i do (ns munksgaard (:require clojure.contrib.math)) i get nil and it just hangs
18:06raekhangs?
18:06Munksgaardi dont get a new promt (=>)
18:06raekthere was a bug that made the output no flush sometimes
18:06AWizzArdin emacs?
18:06cemerickchouser: ^C ?
18:07raektry evaling 1 or something
18:07Munksgaardno, im in the terminal now, with lein repl
18:07Munksgaard1 evals to 1 fine
18:07raekafter the ns thingy too?
18:07AWizzArdMunksgaard: and what does happen when you say (require 'clojure.contrib.math)
18:07Munksgaardraek, oh, when it hangs? no
18:07AWizzArdi.e. not :require
18:08Munksgaardhmm
18:08Munksgaardsec
18:08raekit shouldn't hang.
18:08AWizzArdand it should probably reply with nil
18:08apgwozso, i'm trying to compile a simple clojure file using ant and failing miserably. i'd use leiningen and not have any problem, except i'm trying to integrate this with a bigger ant build...
18:08Munksgaardraek, hmm, it doesnt give me a new prompt, but when i typed in 1 it returned to functioning normally
18:08AWizzArdapgwoz: you already have a target for compilation?
18:08clojurebotcompilation is see compile
18:08apgwozi've gotten my build file down to the bare minimum, but it still fails. anyone able to take a look if i paste the error, and source?
18:08Munksgaardso i get a new prompt after evaling 1
18:08raekMunksgaard: then it was the output flush bug...
18:09raekit has been fixed, but maybe not in the most recent jar
18:09apgwozAWizzArd: yeah, i've created a second build file to figure out the problem
18:09Munksgaardraek, okay. So every time i want to use, say expt, i need to do (clojure.contrib.math/expt base expt)?
18:09raekMunksgaard: use ns declaration in source file, and the underlying functions at the repl
18:09lazy1Can we have http://richhickey.github.com/clojure* redirect to http://clojure.github.com/clojure* ?
18:10raekMunksgaard: replace require with use, and you don't have to do that
18:10raekor do a (require '[clojure.contrib.math :as m])
18:10AWizzArdapgwoz: inside your target you should have something like <java classname="clojure.lang.Compile" fork="true"><sysproperty key="clojure.compile.path" value="${build.dir}"/><classpath refid="classpath"/><arg value="your.namespace"/></java>
18:10raekthen you can use m/expt
18:11apgwozAWizzArd: yup, I know
18:11Munksgaardraek, okay, cool. Thanks a lot both of you, i'll try to play around with it
18:11AWizzArdapgwoz: so, then it should work :)
18:11apgwozhttps://gist.github.com/06cc3d292d10047ed5ee
18:11apgwozit doesn't. i get this error
18:11jjidowow if what I just wrote works, I deserve an award
18:13freakazoidI've found that generally with clojure actually, jjido… I write something and it just works
18:13freakazoidand I'm surprised.
18:13freakazoidSLIME helps a lot with that
18:13jjidofreakazoid: don't you get scared?
18:13AWizzArdapgwoz: on a first glimpse it does indeed look correctish
18:13freakazoida little
18:13freakazoidbut clojure's like my 27th programming language
18:14apgwozAWizzArd: that's why I'm asking... :)
18:14apgwozthanks for looking
18:14freakazoidthough it's my first jvm language
18:14lazy1freakazoid: What was #1?
18:14freakazoidBASIC on an IBM PC in 1982
18:14jjidofreakazoid: really? would you mind having a look at http://dodo.sourceforge.net and criticise?
18:15lazy1I guess everybody started with basic then (I d●●●●●●●●●●●●●●●●●●●●●●●)id
18:15lazy1Ooops
18:15AWizzArdapgwoz: one thing that I would try is <arg value="com.thingy.feed-queue.core" /> (the underscore replaced by a minus)
18:16apgwozAH! i bet that's it
18:16apgwozAWizzArd: indeed. that did it
18:16apgwozthanks for catching that!
18:16AWizzArdgreat
18:16AWizzArdyes yes, this underscore-minus-thingy can be a tricky beast
18:17freakazoidjjido: I have not seen the terms "prototype" and "class" used together in that way before.
18:18jjidofreakazoid: the class is quite standard though
18:18jjidofreakazoid: only it is implemented using prototypes
18:19AWizzArdapgwoz: it seems you are doing Python. Do you use (or did you try) Jython?
18:19apgwozAWizzArd: we're using it at work for some things, so yes
18:19freakazoidjjido: it looks like you have both
18:19jjidofreakazoid: yep
18:21anonymouse89anyone have a problem with lein where "lein uberjar" hangs on "Copying .. files to .."?
18:21jjidofreakazoid: the whole thing (save for parallelism) is constructed on top of prototypes and continuations
18:24freakazoidjjido: does dodo have call/cc?
18:24jjidofreakazoid: nope I am against it
18:25freakazoiddoes it have TCO?
18:26freakazoidjjido: In general I am not a fan of the need to thread callbacks/continuations through the code; I'd much rather have some kind of lightweight thread, coroutine, or even generator that can just block, yield, etc.
18:28freakazoidthough your syntax for it isn't bad
18:29freakazoidhaskell's do syntax is a little cleaner.
18:32freakazoidhaving states built directly into the syntax reminds me of LSL
18:32freakazoidthough in LSL they're script states
18:32jjidofreakazoid: what is LSL?
18:33freakazoidjjido: that's Second Life's scripting language
18:33freakazoidjjido: an object can have an arbitrary number of scripts that each execute concurrently and independently. The scripts have multiple states and each state has a set of event handlers defined
18:34freakazoidthe set of events is fixed and there are (very) primitive messaging facilities.
18:34jjidofreakazoid: that resembles the scheme I defined for services
18:38freakazoidjjido: What I'd really like to see for dodo is an expansion of the top section where you talk about your design goals, particularly how each of your design choices drives you toward that goal
18:39jjidogood idea freakazoid
18:40freakazoidI'm quite interested in finding out what new and rare ideas you're interested in
18:40jjidoI have blog posts but they are in French
18:40jjidofreakazoid: I follow ltu for fresh ideas ;)
18:41freakazoidMe too, though I can't understand half the papers on there
18:41freakazoidMy understanding of type theory is still limited
18:41freakazoidI can derive it from first principles, but the language around it confuses me
18:42freakazoidhmm, that's true of a lot of math, cs, and physics papers, actually. I can understand the concepts involved, just not the language
18:42jjidosame for me
18:43freakazoidI need to actually sit down and learn Haskell. I feel like it would be a big mind-expander
18:43freakazoidI only vaguely know OCaml or Haskell at this point
18:43freakazoidso all my languages are either old, crappy type systems like pascal or c++ or dynamically typed
18:44turbofailformal math notation vs. Haskell: http://www-formal.stanford.edu/jmc/puzzles/node3.html vs. http://okmij.org/ftp/Haskell/Mr-S-P.lhs
18:45jjidoOCaml is not old? ;0
18:46freakazoidIts type system is pretty much Standard ML's
18:46freakazoidYes, it's old
18:46freakazoidSorry, I misread.
18:47freakazoidI don't know what you call Pascal and C++'s type systems
18:47freakazoidin a way they're weak, though most people consider them strongly typed
18:52amalloyfreakazoid: i've heard C++ described as weak, static typing
18:52freakazoidthen what's C?
18:52freakazoidC is weaker than C++
18:52freakazoidand than Pascal
18:52freakazoidPascal and C++ seem about the same in terms of their strongness
18:52amalloyso? it's weak too, and also static
18:52amalloyyou don't need another word for every slight difference
18:52freakazoidI suppose that's true.
18:52amalloyC++ lets you cast anything to anything
18:53amalloythat is pretty weak
18:53freakazoidit makes you jump through more hoops to do it though :)
18:53freakazoidand provides nice features like dynamic_cast
18:53amalloyyep. and that's what makes it static, mainly: the hoops
18:54freakazoidof course, you don't have to jump through any hoops to segfault though
18:54amalloyclojure is an interesting example of strong, dynamic typing: you don't need to know what type things are, but if you treat them as something else, the program fails
18:54freakazoidsince there's no bounds checking and nothing at all to help you write safe multithreaded code
18:54freakazoidseems like most dynamically typed languages are strongly typed
18:54amalloyphp
18:55amalloymaybe python too, but i don't do any python so i may be misunderstanding
18:55freakazoidwell, that's not true; automatic type coercion can lead to pretty hilarious errors.
18:55amalloyanyway i find it helpful to think of two axes: strong/weak, and dynamic/static
18:55freakazoid(that most of them are strongly typed)
18:55freakazoidthat makes sense
18:55freakazoidI'd been thinking along those lines as well
18:55freakazoidpython won't let you add an int to a string like perl and tcl will
18:56freakazoidso python's a bit stronger
18:56freakazoidI'm not a fan of any sort of operator overloading, myself
18:56freakazoid+ should always mean "add"
18:58technomancywell you can add to a set.
18:58technomancyin English
18:59freakazoidyou really only run into trouble when operator overloading is combined with automatic coercion, I guess.
18:59jjidofreakazoid: then I sinned ;) Dodo lets you redefine the operators, provided your type has the appropriate qualifier (+ is special, on its own in the Augmentable qualifier)
18:59freakazoidjjido: the real question is "what mistakes are programmers likely to make?"
19:00jjidofreakazoid: use the wrong interface for their type?
19:00freakazoidand "how does your language help programmers avoid mistakes without using the expedient of making them repeat themselves?"
19:01jjidoAlso, too much state is not good.
19:01freakazoidyeah, the way Rust handles state seems pretty cool
19:01freakazoidand clojure
19:01jjidoThere are some parts that make the programmers repeat themselves
19:02jjidolike, if you want private members then you need to define a public interface separately
19:03jjidoFor a library you also need to specify what to export
19:05jjidofreakazoid: in my opinion Clojure is a bit inconvenient when you want state
19:05jjidobut I don't know it that well yet
19:05defnfreakazoid: i disagree -- i think it makes state easier to manage
19:06defnwhen you're working on a clojure app -- you can point to specific functions and say: "look, this has state."
19:06defnit just feels like you have more command over it
19:07freakazoiddefn: I think you meant to respond to jjido. I agree with you :)
19:07defnoh sorry -- yeah
19:07freakazoidmost languages don't really think at all about state
19:07freakazoidit's pretty much up to the programmer to either touch something or not touch it
19:08freakazoidand it's very syntactically convenient to mutate arbitrary data
19:08freakazoidthe most convenient way should be the way least likely to have bugs.
19:09defnit felt weird at first, but i feel like it's "sloppy" to handle state in other ways now
19:10abrenkchouser: you're interested in how to easily build clojure-contrib with a customized clojure jar, right? what do you think about http://github.com/abrenk/clojure-contrib/commit/21a8ba7a3bed01008388f842c47054539f83e76a ?
19:11jjidofreakazoid: my approach is: local mutations only in functions, do-whatever-you-want in constructors (which cannot be called from functions)
19:12abrenkchouser: I think I got rid of the hoops especially rhickey was complaining about
19:15abrenkcemerick: perhaps you could also take a quick look at my latest change proposal to the clojure-contrib build (see url above)
19:16cemerickabrenk: Seems fine to me.
19:17cemerickthough, as I was saying to chouser earlier, using the ci-oriented build target implemented in clojure's build.xml should make building contrib against the last-built snapshot easy and automatic.
19:18abrenkcemerick: yeah, but only if you set maven to offline - otherwise it might overwrite your local snapshot with a more recent one from the snapshot repo
19:19cemerickabrenk: very true -- but that's very unlikely within the course of a 24-hour period.
19:19defncemerick: re:githubfinder -- thanks for the credit on twitter :)
19:19defnmy coworker showed me that today and i freaked
19:20cemerickabrenk: I've been trying to get him and Rich away from a simple `ant; mvn` process for a bit :-/
19:20defnbest way to view a github project without pulling source
19:20cemerickdefn: credit?
19:20cemerickOh, right, I heard about it from you :-)
19:20cemerick(too many handles in my life)
19:20defnyeah i was just saying thanks cause i saw it go across twitter but you gave me credit :)
19:20cemerickof course
19:21defni forget about twitter
19:21cemerickYes, it's a little absurd that every directory descent requires a full refresh.
19:21defnyeah, it's painfully hard to navigate a source tree
19:23abrenkcemerick: I'm just trying to soften the hard edges in the maven build so that the "talent" can focus on their areas of expertise
19:23cemerickabrenk: definitely appreciated :-)
19:23cemerickdo you have a CA in?
19:24abrenkit's on its way
19:24cemerickexcellent
19:24cemerickI wonder just how much time I'm going to end up talking about maven/build stuff at the conj...
19:27abrenkdo you plan to record the talks? would be a nice addition to the blip.tv channel!
19:29KirinDaveOh man, I love clojure.
19:29KirinDaveAll my lisp instincts are coming back.
19:30jjido_,(cons 2 9)
19:30clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
19:31KirinDavejjido_: Does that surprise you? :)
19:31KirinDaveIt'd work in common lisp tho.
19:31jjido_KirinDave: exactly
19:31KirinDaveThere isn't much of a reason do have cons be a generic data structure in clojure.
19:32KirinDaveThe #1 reason was structure sharing (do you see my pun! this is a visual pun!) and the #2 reason was to make micro hashtables
20:12gstampQuestion... if I (read) at the REPL I can read in an expression no problem however if I try (def my-val (read)) at the REPL I get a ClassCastException. Why the difference?
20:16troussangstam: it works for me on 1.2
20:16gstamphrrm. ok. i am still on the 1.2 beta. I'll upgrade and try again
20:17KirinDavegstamp: Let me guess
20:17KirinDaveyou're trying to do something like (def my-val (read))
20:17KirinDaveAnd then type in an fn expression?
20:19gstampLooks like it's working now. Sorry for the noise.
20:30ataggartis anyone here working on the master branch out of git?
20:47rickmodedoes defrecord support a docstring?
20:50dnolenataggart: do you just mean using it?
20:51ataggartdnolen: yes. I submitted a patch that makes some changes to the way methods/contructors are resolved, and was hoping someone using 1.3. could try it out
20:51ataggartrickmode: I don't think so
20:52dnolenataggart: I can't test it out at the moment, but if you send me a link to the ticket/patch I can try it out later.
20:52rickmodeataggart: thanks. I don't see it in the docs, source or examples either. Odd inconsistency. oh well.
20:53ataggartdnolen: that'd be great. https://www.assembla.com/spaces/clojure/tickets/445
20:55jjido_does reify create a type, not a record?
20:55ataggartit creates a new anonymous clas that implements the interfaces/protocols
20:55ataggartand then returns an instance of that class
20:57ataggartso in that regard it's more like type than the mapiness of record.
20:57jjidoataggart: and if I want it to implement clojure.lang.IPersistentCollection?
20:59ataggartjjido: then you'd need to implement the methods. The particular approach depends a lot on what you're trying to accomplish.
21:00jjidoWhat I am trying to do is to take a record implementing a protocol, and override one of the methods without creating a new top-level type.
21:02jjidoI tried: (merge (reify myprotocol (mymethod [self] ...)) self)
21:09jjidosuggestions?
21:11ataggartthis is just a one-off instance?
21:11ataggartTrying to understand the restrictions
21:13jjidoataggart: yes, just a one-off instance
21:15jjidocreated depending on arguments
21:15ataggartk lemme past something into gist
21:17ataggartmaybe like this: http://gist.github.com/610783
21:18ataggartbasically composition instead of extension
21:26ataggartwhoops, updated to include the missing protocol definition
21:27jjidoataggart: that is equivalent to my solution isn't it? What if you want to access a field of r2?
21:29ataggartdepends on who's doing the accessing
21:29ataggartif it's the reified instance, then you can reach the field
21:29ataggartbut not externally
21:29ataggartsince that field isn't part of the protocol
21:29jjido(defrecord R [gah] ...) ... (:gah r2)
21:29ataggartso, I infer the use of the refiied instance is not limited to the protocol definition
21:30jjidommh no it is not. I could add an accessor but it would not be part of this protocol.
21:31jjidoI will just do a new protocol for the accessor and be done with it :)
21:40jjidoataggart: eh, maybe the error I got was because of trying (merge) on a (reify). I need that to work (the record I use is not known in advance)...
21:41jjidoI will have another look at (extend)
22:14jjidoI give up... Looks like that is not possible in Clojure
22:17Nate75Sanderswho's up for a drunken Visual Basic sprint?
22:17Nate75Sanderssorry wrong window
22:18lancepantzhah
22:27amalloy1Nate75Sanders: does that mean we're not invited?
22:29ataggartjjido: if you just need to have the lookup behavior, then implement clojure.lang.ILookup
22:29ataggarte.g., clojure.lang.ILookup (valAt [_ key] (get r key))(valAt [_ key nf] (get r key nf))
22:30ataggartit's ugly, but it's possible
22:30jjidoataggart: ok... I need to check if that works for me.
22:32ataggarthmm, didn't realize until just now that records can't be used as fns like maps can
22:32hsuhleiningen question: suppose i want to use ring, don't know the last version, how would you do it ? clojars displays more than one match for ring
22:35ataggartiirc maven supports wildcarded versions
22:35ataggartthus lein should
22:37Nate75Sandersamalloy1: no mouse allowed -- this is an all-keyboard drunken VB sprint
22:37ataggartluddites ;)
22:38Nate75SandersI remember in my day we didn't have wildcards and we liked it
22:38amalloy1Nate75Sanders: it's cool, i use emacs on the terminal. i'll just have to learn vb :P
22:40Nate75SandersThere should be more "Rosetta Stones" in tech. Cookbooks are certainly a step in the right direction but Rosetta Stones would be good, too. I've tried to pick up emacs several times and it just didn't take. Maybe a rosetta stone isn't the right thing for this particular situation as vim and emacs are so different.
22:40Nate75SandersRosetta stones seem right for languages, though.
22:42Nate75SandersI'm drunk and off-topic, though, so kick me out of the channel if need be.
22:46amalloy1haha. well, i'm only ignoring you cause you're not giving me name highlights, Nate75Sanders :P
22:47Nate75Sandersamalloy1: sorry man
22:48amalloy1i think emacs took for me (like three months ago) mainly because vi never took. so i'm not really the best source
22:48ataggarthttp://rosettacode.org/
22:50Nate75Sandersataggart: thanks -- not bad
23:15ldhanson2I have a set which i'm trying to add into a sorted set. like (sorted-set-by comparator other-set). that gives a set with one element (the other set). what i want is each element of other-set to be added to the created set. i could do that with apply: (apply sorted-set other-set), but i can't pass the comparator in using apply. any thoughts?
23:31amalloy,(let [myset (sorted-set-by <)] (into myset #{4 7 1 6}))
23:31clojurebot#{1 4 6 7}
23:31amalloyldhanson2: ^^
23:33amalloyof course, this still works if myset already has elements
23:33ossareh'lo. Anyone run any jython stuff from their clj?