#clojure logs

2011-08-06

00:02jcromartietechnomancy: thanks!
00:03technomancynext version you'll be able to just to M-x clojure-jack-in, but there's a bug right now that means sometimes it'll mess up if you don't kill *swank* first
00:42fmwI guess this wasn't a good time to ask a question
00:42fmwI'll try again later :)
00:45jcromartiefmw: sup?
00:47fmwjcromartie: "<fmw> are there problems with doseq in clojurescript? I'm suppose I'm just
00:47fmw using it incorrectly: https://gist.github.com/1128963 ? I'm getting
00:47fmw notified that something in core.js is undefined (see the provided paste)"
00:48fmwI tried applying the patch in CLJS-39 that fixes an issue with doseq scoping, but no luck
00:49jcromartiesorry :( no idea... kind of strange that it says "<big long string of code> is undefined"
00:50fmwjcromartie: yes, basically it is doing (function() [...]).call()
00:50jcromartiebut the compiler must be doing something strange to yield that undefined message
00:50fmwbut it says the thing its doing .call on is undefined
00:52fmwhttps://gist.github.com/1129025 there is the javascript function that is undefined (starting at line 11)
00:53fmwaccording to firebug that whole function is undefined
00:53jcromartieah
00:54jcromartiebasically: (function () {})().call(null,o);
00:56fmwjcromartie: indeed
00:56fmwI'm going to try and find the relevant cljs code now
00:57fmwand see if I can do (let-fn [fn [...]] (my-fn o)) or something to that extend
00:57fmwso it gets compiled differently
01:01amalloyfmw: letfn isn't implemented yet
01:01amalloy(or ever? i think it will be eventually but i don't know)
01:04fmwamalloy: ah, thanks
01:05fmwamalloy: anyway, I will just (let [my-fn (fn [] ...)] ...) in that case
01:06fmwI can't really find where to do that for cljs.core, though (see https://gist.github.com/1129025 for the function I'm trying to let-fn on line 11)
01:09fmwhttps://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L126 seems to be how that JavaScript output I pasted is generated, but I can't figure out where to change it
01:09fmwthe implementation, that is, to work around the undefined bug
01:12amalloyfmw: the line you linked to doesn't even have any code. it's just a protocol definition
01:12amalloythe generated code was from the (or) macro
01:13amalloy&(macroexpand '(or x y))
01:15fmwamalloy: I wonder where that is called, though.
01:15fmwamalloy: it seems to figure out the type of protocol and call the seq implementantation for it
01:17fmwamalloy: so maybe I'm looking in the wrong file and I should check where defprotocol is implemented, to find that (or) macro
01:18fmwamalloy: ah, https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/core.clj#L113 I think that the or macro is there
01:22fmwyes, its that method I linked that produces the function that is undefined according to both chrome and firefox (https://gist.github.com/1129025)
01:23fmws/method/defprotocol implementation
01:23lazybot<fmw> yes, its that defprotocol implementation I linked that produces the function that is undefined according to both chrome and firefox (https://gist.github.com/1129025)
02:27jcromartieis there a good way to do something with a timeout?
02:27jcromartielike, don't let a function run more than some amount of time?
02:28tomojyou don't happen to need async i/o or event driven stuff, do you? :)
02:28tomojlamina has very cool timeouts but wouldn't be worth including just for that
02:33jcromartieno
02:34jcromartiealthough what would be even better would be a time-bound lazy sequnce
05:34zoldarhello, I'm trying to use ztellman's gloss library for serializing/deserializing data. My attempt mostly follows the basic header usage example given on the wiki page but encoding attempt fails: http://paste.lisp.org/display/123831 . What am I missing?
05:44fantazohi, how do you actually import in clojure all classes of a package? like in java java.awt.*?
05:47zoldarfantazo, afaik there's no way to do this
05:47fantazook, thank you
06:19fantazohmm. in scheme you normally do the simple counter example with (define (make-counter) (let ((x 0)) (lambda () (set! x (+ x 1)) x))) as clojure works with non-mutable structures in default, how do you something trivial like that? I know, this is actually not functional style.
06:25zoldarfantazo: (let [entity-counter (atom 0)] (defn gen-entity-id [] (swap! entity-counter inc))
06:29fantazois ok, but doesn't yet do what the scheme version does.
06:33fantazobut this version does what I want: (defn make-counter [] (let [x (atom 0)] (fn [] (swap! x inc))))
06:36zoldarfantazo, yup, sorry, mindless copy-paste from my old code
06:37fantazoclojure is interesting, it helps to get over the non-functional coding habits.
06:37fantazoor atleast seeing them as that.
06:37zoldaradded benefit: clojure version of that counter if thread-safe
06:41fantazowith clojure java is finally useable.
09:29pyrwhen i define symbols in macros
09:29pyrwith the symbol# idiom
09:29pyrthey only live within the context of the expanded code, i can do no manipulation on them, right ?
09:31pyrfor instance if one of these holds a vector, I can't do (fn argvector# ~@body)
09:35raekpyr: a macro is basically function that returns code in the form of clojure data structures
09:35raeka symbol is just a variable name
09:35clojurebotc'est bon!
09:36raekwhen the returned code is compiled, there might be a variable with that name, and only when that code is actually executed it hols a value
09:36thorwilpyr: in other words, you can do "manipulations" on them
09:40Vinzentbut (fn argvector# ~@body) won't work anyway
09:43pyrVinzent: yep
09:43pyrgot it
09:43thorwilVinzent: because of the @, or is there an additional problem?
09:43pyrthorwil: because (fn somevec (do-something)) doesn't work
09:44pyrthorwil: and because there's no way to replace argvector# with it's value
09:44Vinzentyep
09:44pyralright then, no worries
09:45malkomalkois there a more idiomatic way to add up the values in deeply nested maps then reduce combined with assoc/merge?
09:45raekpyr: yes, it doesn't have a value at that point. but your macro can emit code that does the operation on the value
09:45paul__hey
09:47paul__(clojure.contrib.str-utils/re-split #"\s+" "sdf sdf sdf")
09:47paul__i get an error with the above code :(
09:48paul__my swank auto completion can't find contrib.str-utils
09:48raekpaul__: first, there is clojure.string since clojure 1.2
09:48Vinzentand re-split is in core
09:48raekpaul__: have you required the namespace?
09:48raekit isn't loaded until you have require'd or use'd it
09:48paul__i thought that i didn't need to do that when i write out the whole path
09:50dnolenpaul__: the library needs to be loaded first, it's not loaded by default, and that won't automatically load it.
09:50dnolen,(require '[clojure.string :as string])
09:50clojurebotnil
09:50dnolen,(string/split "sdf sdf sdf" #"\s+")
09:50clojurebot["sdf" "sdf" "sdf"]
09:52paul__thanks
09:52paul__i wanted re-split because it has reverse args
09:55dnolen,(let [flip (fn [f] (fn [& args] (apply f (reverse args))))] ((flip string/split) #"\s+" "sdf sdf sdf"))
09:55clojurebot["sdf" "sdf" "sdf"]
09:56raekskynda
09:57raekeh, wrong channel
09:57paul__cool
10:36ejacksonhmm... Google Closure doesn't seem to have a datagrid widget.
10:37ejacksonan emoji picker, yes.... datagrid, sorry.
10:49abedratechnomancy, does @hiredman's RT.load fix solve your issues?
10:49abedraI am reviewing the patch right now
10:50abedraI'm trying to collect patches and get them checked in so we can cut a beta2 soon
10:51abedraeverything looks reasonable in the patch, but I just wanted to make sure it resolves the issue you were having
11:14triyoIs there a filter-like function that can actually return two sequences, the difference based on predicate?
11:18thorwiltriyo: you mean one list with matches and one with non-matches?
11:18triyooops, I mean a vector with two elements. [pass-pred-test-seq, fail-pred-test-seq]
11:19triyothorwil: I see there is something simple in clojure.contrib called seperate
11:20triyosource -> [ (filter f s), (filter (complement f) s) ]
11:23thorwilsure, though the whole filtering work is done twice
11:23triyoHmm, thats quadratic time right?
11:23triyohehe
11:23triyo;)
11:23triyon^3
11:23triyooops
11:23triyoI mean n^2
11:24triyoO(n^2)
11:24thorwilif you can make sense of (source filter), you could do a trivial modification to get your result, i guess
11:25triyoyup, I'll come back to efficiency question after I finish the implementation.
11:25triyothat seems the most logical to me.
11:26triyoQuestion is also what size of seq I'll be dealing with
11:26thorwilyes, premature optimization and all that ...
11:31abedratriyo, remember that contrib is deprecated
11:32abedraand won't be supported on 1.3
11:32abedrathis isn't a big deal in your case since the function you are working on is pretty simple.
11:32abedrabut it is worth remembering
11:33triyoabedra: yup, I know, thanks for the reminder. I did a search on clojuredocs.org and came across the implementation. I just wanted to look at the source.
11:33abedratriyo, ok good deal
11:33triyo"he function you are working on is pretty simple." -> exctlly
11:44malkomalkomaybe I'm missing something, what's the best way to test if something is a number?
11:45Vinzent,number?
11:45clojurebot#<core$number_QMARK_ clojure.core$number_QMARK_@70cf21>
11:45Vinzent,(number? 5)
11:45clojurebottrue
11:47malkomalkoahh, that's not on the api cheatsheet
11:50Vinzenthm, indeed (and here http://clojuredocs.org/quickref/clojure%20core too)
11:56abedramalkomalko, The best way to learn is to crack open core.clj
11:56abedraput a marker in the code and take a look at one or two functions a day and try them out
11:57malkomalkomakes sense
11:57abedrapretty soon you will have a great understanding of the language
11:57malkomalkothe most difficult part of clojure is realizing how much is already there for you
11:57abedra it
11:57abedrayes
11:57malkomalkoand trying to re-implement things that already exist
11:57abedrayes
11:57abedrathat is why I encourage people to look inside
11:57abedrathe language is evolving
11:57abedracheat sheets really won't cut it
11:58malkomalkotake for example http://clojure.github.com/clojure-contrib/map-utils-api.html deep-merge-with
11:58abedrathe source is really easy to examine
11:58malkomalkolove that function, just found it, exactly what I needed
11:58abedramalkomalko, but that is clojure-contrib
11:58abedranot clojure
11:58malkomalkoI know
11:58abedraand contrib is being deprecated
11:58malkomalkoin 1.3?
11:58clojurebotI don't understand.
11:58abedrayes
11:59abedrain 1.3
11:59malkomalkowhat are they planning to do with those libraries? require things in as needed instead of having a clojure.contrib?
12:00abedragithub.com/clojure
12:00abedralibraries from inside of contrib have been pulled in as their own projects
12:00chouserand/or will be
12:00chouser<-- culprit
12:01malkomalkois the plan to have all ported over? or are some going to not make the cut?
12:01abedramalkomalko, a lot of libraries went unmaintained
12:01abedrano some will not make it
12:01malkomalkothat's understandable
12:01abedrathose that have gone stale
12:01abedramalkomalko, here's the current plan http://dev.clojure.org/display/design/Contrib+Library+Names
12:01malkomalkowell chouser wrote map-utils so I hope deep-merge-with makes it in :)
12:02abedramalkomalko, that's up to @chouser :)
12:02malkomalkothat's very helpful
12:02chouserI wrote map utils?
12:02malkomalkowell, either your name is on it
12:03abedramalkomalko, the idea is that any library from contrib can get it's own project as long as there is a maintainer
12:03abedrait does not have to be the original author
12:03abedrait does, however, fall under the same CA policies as Clojure
12:03malkomalkoalright
12:03malkomalkois there a good post detailing the gameplan for 1.2 -> 1.3?
12:03abedrathe link i just posted
12:03abedrait gives the current strategy
12:03chousermalkomalko: quite possible I did and have forgotten. :-P
12:04abedrafor contrib
12:04malkomalkonot for contrib libs
12:04malkomalkofor core
12:04abedrathere has been lots of mailing list posts
12:04malkomalkoyah yah, no worries :P
12:04malkomalkook, I'll check the google group
12:04abedraquite a bit has changed
12:04abedraand there's a beta1 that you can grab
12:04abedraor if you want to just run off of master
12:05abedrahttp://dev.clojure.org/display/doc/Maven+Settings+and+Repositories
12:05abedraif you add the sonatype repository to your project.clj file or pom.xml you can pull in 1.3.0-master-SNAPSHOT
12:05abedrawhich should become beta2 soon
12:06abedrajust a few more patches to get in
12:06malkomalkovery helpful.. I'll go look around to figure out the bigger changes
12:06abedracool
12:07abedranumerics, defrecord, :dynamic, bindings, all kinds of things have been modified
12:07malkomalkoand very good idea to just read core.clj
12:08abedrayes
12:08abedrachouser, I just put up a patch to make BigInt math much faster for long sized values inside of BigInts
12:08chousercool
12:10malkomalkoalso, the joy of clojure rocks
12:10malkomalkoso, thanks for that :)
12:11abedrayes, that book is awesome
12:13malkomalkoreading the tests seem very handy too, no brainer way to pick things up
12:14chouserah, sure! glad you like it.
12:15abedrachouser, I hope you guys get the Jolt!
12:17ejacksondoes anybody know how to determine which events a Closure Library widget supports ?
12:21chouserhuh, Jolt? Hm.
12:21jsoftw.
12:22lucianejackson: don't the closure docs say such things
12:22lucian?
12:22ejacksonlucian: to which docs do you refer ?
12:23lucianejackson: it has no docs
12:23lucian?
12:23lucianbah
12:23ejacksonit does
12:23ejacksonfor instance: http://closure-library.googlecode.com/svn/docs/class_goog_ui_BidiInput.html
12:23ejacksonthought you might have others
12:24ejacksonbut these don't give me the events it can produce
12:24lucianhmm
12:25luciani don't know of a way to introspect event listeners in js
12:25lucianuh, rather which events one can listen to
12:38momoxhow do i read (filter (fn [x] (every? #(% x) filters)) coll) ? I am particularly confused on the #(% x) portion...
12:42ejacksonit depends on what filters contains
12:43momoxejackson: it contains a sequence of functions
12:43momox filters [#(> % 1) #(< % 5)]]
12:43ejacksonok
12:44ejacksonin that case it filters coll, returning a seq for which applying every predicate in filters to the elements is true
12:45ejacksonthe (every? ...) bit runs each function in filters against x, and return true if each function application returns true
12:45ejacksonthe outer filter will return only those x
12:46ejacksonin coll for which that inner operation is true
12:47momoxbut i don't know what #(% x) expands into...i know x will be the element in coll but what is %?
12:48ejacksonoh, % will be each function in filters in turn
12:48ejacksonyou see, x gets bound to an element of coll
12:48ejacksonthen every? runs the #(% x) function for each element of filters, and in each case % is bound to one of those functions
12:49ejacksonthe problem you might have is that you've got % meaning two things, apparently :)
12:50ejacksonas far as every? is concerned its a function, but that function is itself written in terms of #(> % 1), so in the inner case the % will be bound to the argument THAT function was passed, being x.
12:50ejacksonfoncusing indeed
12:52ejacksongotta hop, cheers all.
13:33pyris there a way to update a var
13:33pyras in, change it's meta data for instance
13:34Vinzentalter-var-root to update value, and something similar for meta :)
13:35pyralter-var-root!
13:35pyrthanks
13:50arohnerpyr: there's also vary-meta for metadata specifically
14:00pyrok, alter-meta! was the one i was looking for
14:00pyrultimately
14:09crazyFoxHi. Ive got a question about (lazy) seqs. Anybody there to answerß
14:14VinzentcrazyFox, don't ask to ask, just ask :)
14:14crazyFoxalright. coming up...
14:17crazyFoxim trying to do (take 10 (cons 2 primes)) in the repl. wheres primes is an infinite lazy seq. The thing is: the expression doesnt evaluate. No result shows up. No new prompt shows up. What am i doing wrongß
14:19Vinzent,(take 10 (cons 2 (range)))
14:19clojurebot(2 0 1 2 3 ...)
14:19VinzentcrazyFox, probably the problem is in definition of primes
14:20crazyFoxits the one from clojure.contrib.lazy-seqs. actually i just tried again. it worked...
14:21crazyFoxomg. it was a paren mistake. bugged me yesterday already. i just realize now. ok all is fine. dont be bothered.
14:24VinzentcrazyFox, :) you should consider using paredit
14:25crazyFoxi know. still have to set up emacs or some other decent editor with built-in repl.
14:32zvrbaVinzent: i looked at paredit and it introduced a bunch of hard to remember keyboard shortcuts :(
14:35Vinzentzvrba, I use only 5: C-M-i,k for killing sexps, C-M-j,l for navigating and C-M-u for going up level
14:36Vinzent(M-j,l,i,k for moving cursor)
14:36Vinzentvery handy
14:50leedaIs this the best way to write this: (last (take-while #(>= x %) cutoffs)) ? (cutoffs is a vector of integers in strictly increasing order)
14:54leedaactually what I want is: (- (count (take-while #(>= 15 %) cutoffs)) 1)
14:54leeda(the index in the vector)
15:04crazyFoxleeda: so, u want the index of the largest number <= 15 in a vector with strictly increasing order, is that rightß
15:05leedacrazyFox: yeah. (15 actually would be any integer)
15:09crazyFoxleeda: i would do (dec (take-while #(>= limit %) yourvec)). im not too firm with the clojure libraries though. still a newcomer... :)
15:09crazyFoxleeda: i forgot the count...
15:10leedacrazyFox: oh yeah ok. so same thing but just use dec instead of #(- % 1), good idea
15:10MasseRDidn't read the entire conversation, but I just learned about 'indexed' which might be of use
15:10crazyFoxleeda: yes
15:11MasseRhttp://clojuredocs.org/clojure_contrib/clojure.contrib.seq/indexed
15:11MasseR(indexed "foo") would return [1 \f 2 \o 3 \o]
15:11leedahm i think that would just make it more complicted
15:18jsnikerisIs it idiomatic clojure to throw exceptions?
15:18thorwilleeda: just for fun: (reduce #(if (>= 20 %2) (inc %1) %1) 0 [1 5 9 12 15 20 34])
15:19leedathorwil: nice
15:20jsnikerisFor example, I have a function that attempts to save a blog entry. If a similar entry already exists, I don't want to overwrite it, and I want to communicate to the caller why the entry wasn't saved. Would this be the right place to throw an exception?
15:21VinzentMasseR, vtw, there is map-indexed and keep-indexed in core
15:21Vinzent*btw
15:22Vinzentjsnikeris, I think if you don't have to ineroperate, you should prefer more flexible exception system over plain java exceptions
15:22jsnikerisVinzent: What would you suggest?
15:23zvrbajsnikeris: why not return an error code?
15:23crazyFoxleeda: there is faster solutions though, but much harder to write
15:24leedacrazyFox: yeah i'm sure.
15:25Vinzentjsnikeris, I can't remember the name... try to search scigiraldi try+ on github. also, raek have written such lib. There is error-kit in the 1.2 contrib.
15:29jsnikerisVinzent: looks like there is clojure.contrib.condition by Stephen C. Gilardi
15:30Vinzentjsnikeris, yeah, and also c.c.condition. (first two libs was for 1.3)
15:33crazyFoxis clojuredocs.org linked from clojure.org? i didnt know about it up to now. its neat! better than the doc on github
15:44mjg123If I have a list of functions (f1 f2 f3... ) and a list of values (v1 v2 v3...) what's a good way to create a list like ((f1 v1) (f2 v2) (f3 v3) ... ) ?
15:45mjg123as in, to apply each function to its corresponding value?
15:45crazyFoxdid anybody try jswat-4.5 with clojure-1.2.1? Does it work?
15:48MasseRmjg123: Maybe (map #(%1 %2) funs vals)
15:48MasseRor (map apply ..
15:50MasseR(Both are untested)
15:52mjg123MasseR, the first does me fine, thanks!
15:53thorwil,(reduce #(if (integer? %2) [(conj (first %1) %2) (second %1)] [(first %1) (conj (second %1) %2)]) [[] []] [1 "a" 2 "b" 3 4])
15:53clojurebot[[1 2 3 4] ["a" "b"]]
15:53thorwiltoo bad triyo isn't around anymore ^^
15:58thorwil,(partition 2 (interleave ["a" "b"] [1 2]))
15:58clojurebot(("a" 1) ("b" 2))
15:58thorwil^ mjg123
16:03crazyFox,(map #(%1 %2) '(+ - * /) (range 1 5))
16:03clojurebot(nil nil nil nil)
16:03crazyFoxwhy does it not give results i expect?
16:04Vinzent,(map #(%1 %2) [+ - * /] (range 1 5))
16:04clojurebot(1 -2 3 1/4)
16:04crazyFoxso whats wrong with the quoted list?
16:04Vinzent,(#('+ %) 1)
16:04clojurebotnil
16:05Vinzent,('+ {'+ :ok})
16:05crazyFoxok. makes sense. ty
16:05clojurebot:ok
16:06VinzentcrazyFox, so symbols acts like keywords when treated like a functions
16:06pdk(key map) is a common idiom for value lookup in maps
16:07pdkit's not a matter of the symbol being in function position, it's that it's quoted and the second argument is a map
16:07crazyFoxyeah. knew that. its cool
16:09lucian,(take 10 (iterate + 1))
16:09clojurebot(1 1 1 1 1 ...)
16:10crazyFox,(take 10 (iterate inc 1))
16:10clojurebot(1 2 3 4 5 ...)
16:11Vinzentpdk, but it's quoted = it's a symbol in that case :)
16:11crazyFox,(+ 1)
16:11clojurebot1
16:11pdkexactly
16:11lobotomyit would be kind of cool if (=) worked
16:12crazyFox,(take 10 (iterate #(+ 1 %) 1))
16:12clojurebot(1 2 3 4 5 ...)
16:12Vinzentalso, only keywords and symbols work that way?
16:12luciancrazyFox: hmm
16:13Vinzentlobotomy, hm, should it return nil or true?
16:14lobotomydunno :)
16:19crazyFoxmy Firefox just crashed. Its also a crazy fox... :)
16:51lucashansenhello world
16:55lucashansenI am just starting with Clojure. What is the best way to use it with vim?
16:56crazyFoxdid u have a look at http://dev.clojure.org/display/doc/Getting+Started+with+Vim already?
16:57markskil1ecklucashansen: :! emacs
16:58markskil1eck;D
16:58lucashansenI'd seen that plugin but I wasn't sure if it was the complete experience. Whenever I look up lisp on vim, people tell me to use emacs ha ha
16:59markskil1eckI love Vim, so I do. But it felt as though I was fighting Vim to get some Lisp support, so I gave up. Emacs offered a better immediate experience.
16:59markskil1eckSlimv was... alright.
17:23crazyFoxdid anybody try clooj? (https://github.com/arthuredelstein/clooj) Is it worthwhile?
17:25micryptcrazyFox: Some screenshots would've been nice.
17:27crazyFoxtry this http://dev.clojure.org/display/doc/getting+started+with+Clooj
17:31wastrelclooj fancy
17:39crazyFoxso u tried it?
17:47jsnikerisHow do I access a class created with :gen-class? For example, I want to check if this class is being thrown: http://tinyurl.com/3bvsd3s. So I have (require '[clojure.contrib.condition :as cond]) and I want to write something like: (is (thrown? cond/Condition (fn-where-it-might-be-thrown)))
17:48jsnikerisDo I always have to write out the whole ns: clojure.contrib.condition.Condition
17:55amalloyjsnikeris: you can't require/as the class, because it's a class, not a function. but you can import it, just like any other class
17:58jsnikerisamalloy: ahh, import. I knew I was missing something. Thanks
17:59zoldarwhen using leinigen, can I point to a certain git repository as a dependency ?
18:00arohnerzoldar: kind of. read the 'checkouts' section of the lein faq
18:01jsnikerisamalloy: so I added, (:import [clojure.contrib.condition.Condition]) to my ns declaration. I expected to be able to reference a bare Condition in my code, but I'm getting an Unable to resolve classname: Condition exception. Am I missing something?
18:01amalloyjsnikeris: you probably don't want the []s
18:02zoldararohner, thanks, this will do
18:03jsnikerisamalloy: that did it. Thanks
19:29zmarilWhat's the function that lets me iterate over two lists at the same time element by element? Not for, but something that iterates index by index
19:29crazyFoxinterleave ?
19:30zmarilNot interleave. Can you use map on two collections at once?
19:30crazyFox,(interleave [:a :b :c] [1 2 3])
19:30clojurebot(:a 1 :b 2 :c ...)
19:31crazyFoxyes, if the supplied function can deal with two args
19:31zmarilNice! Thanks
19:31crazyFox,(map str "abc" "123")
19:31clojurebot("a1" "b2" "c3")
19:32amalloymap
19:41PupenoApparently I became the clojars most valuable programmer: https://www.masterbranch.com/developer-achievements?uid=1566 lolo
19:47amalloyman, the recent attempts to make "social" programmer profiles that just scrape their data from github are pretty unimpressive
20:14pschorfI've defined a macro which is a wrapper around defrecord, but records defined using it cannot be imported to another ns
20:14pschorfhas anyone else seen this behavior?
20:19amalloypschorf: then your macro is broken
20:24zoldar(apply hash-map (reduce concat (SomeRecord. a b c))) -> is there some more succint way of converting record to pure map?
20:27amalloyzoldar: if you want to do that, why are you using records at all?
20:27amalloy(that said, (into {} (SomeRecord. a b c)) is nicer)
20:28zoldaramalloy, I'm using gloss library for data serialization and at the same time I do some java interop - gloss works with maps but doesn't play nicely with records
20:29veeredSorry for the noob question, but I can't seem to get the REPL to work on osx. It runs and evals ok, but I can't use the arrow keys. They come up as "^[[C" etc.
20:29zoldaralways forget about "into" ..
20:29pschorfamalloy, it turns out it was due to a - in the lib name...for the import, i had to replace it with a _
20:30pschorfveered, you need to use JLine or something similar
20:31MicahElliottveered: I just installed leiningen: https://github.com/technomancy/leiningen
20:31MicahElliottand it nicely gives history editing, via realine AFAICT.
20:32MicahElliottSo I'm even doing vi-mode editing in repl. Very nice.
20:33MicahElliottWhich gets to my question...
20:33MicahElliottIt's pretty annoying to kill repl with ctrl-c.
20:33MicahElliottI found this old thread: https://groups.google.com/d/topic/clojure/MuT4kwBFYRg/discussion
20:33MicahElliottBut it's not addressed. Anyone know how to enable ^C without killing repl?
20:37amalloyveered: or rlwrap: http://stackoverflow.com/questions/5639502/one-repl-to-bind-them-all
20:37veeredMicahElliott: Thanks that did the trick. I can now work on finishing my first Clojure tutorial!
20:43MicahElliottamalloy: rlwrap is awesome! thx
20:55amalloyMicahElliott: you don't say what you mean by "enabling C-c", but if you mean interrupting a single command while leaving the repl running, that's not possible in general. java doesn't have a portable way to handle signals like SIGINT
20:57MicahElliottamalloy: Yes, that's exactly what I mean. Bummer.
21:56jimblomois there a way to define a global variable in lein? eg dev-mode/debug?
22:06Nanarpussis anybody using clojurescript?
22:10jimblomoa bit
22:12NanarpussI'm having a hell of a time getting my timer callbacks to work. I'd like to have one timer update the counter on 6 divs
22:13jimblomoyou're using goog.Time/callOnce?
22:13jimblomoTimer
22:13Nanarpussno (. timer (start))
22:15Nanarpussit only updates the last div
22:21jimblomoso are you setting up a event listener?
22:21Nanarpussyeah, hold on I might have something
23:21jweissi'm having trouble using proxy to subclass a java class - getting 'no matching ctor found'. there are several ctors of the same arity so i assume i need a type hint. but that doesn't seem to help: http://paste.lisp.org/display/123845#1
23:22jweisstried adding ^ThreadFactory before the (reify ...) - no help
23:27amalloy$google javadoc threadpoolexecutor
23:27lazybot[ThreadPoolExecutor (Java 2 Platform SE 5.0)] http://download.oracle.com/javase/1,5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html
23:29amalloyjweiss: what version of clojure? could be int/long confusion maybe?
23:29jweissamalloy: 1.2
23:29jweisswhat i am not clear on with type hints - do you need just enough hints to narrow the choices down to 1?
23:30jweissor do you need to hint everything? or something in between?
23:30jweisshinting the ThreadFactory in 6th position should narrow it to 1
23:31ataggartjweiss: it's all or nothing to resolve reflection
23:31jweissataggart: so i have to hint all the arguments?
23:31ataggartthere are improvements pending for Reflector, but they've been pushed back another release
23:31ataggartyarp
23:31jweissah, that would explain it, thanks
23:32ataggartnot needing that is one of the many fixes I made for Reflector
23:32ataggartbut it's too big of a change to fit into 1.3.0
23:33ataggartright now I'm trying to figure out why clojurescript is utterly broken
23:33seancorfieldwe're close to the next milestone build i'd hope? (of 1.3.0)
23:34jweissataggart: how do i hint an int or long?
23:34jweiss^int 2 gives me "Metadata can only be applied to IMetas"
23:35ataggartwell, you only need to type hint variables, not literals
23:36bortrebI want to make something that behaves like vectors, but has the additional property of either being "up" or "down". What's the best way or going about this?
23:36ataggartso, it would be mor correct to say, all args need to be known to resolve reflection
23:36ataggarteither by typehinting or literal
23:37jweissataggart: expressions need to be hinted i assume
23:37ataggartif the expression does not have a known type, yes.
23:38jweissataggart: hm, i'm not sure - it's a call to reify.
23:38jweissshould have a known type, the interface i'm reifying :)
23:38ataggartneed more information
23:38ataggartgist it
23:38jweisshttp://paste.lisp.org/display/123845#1
23:39jweissnot sure which i need to hint. tried the ^TimeUnit, ^BlockingQueue, and ^ThreadFactory, no help
23:40amalloyjweiss: reify may actually not have a known type, because you can reify multiple interfaces and the tagging system can only hold one class at a time
23:40jweissamalloy: i see. not sure what's missing then, maybe forgot an import or something - checking
23:41jimblomocan i use clojure forms in my lein defproject? eg. an (if) form?
23:43jweissaha - ataggart amalloy - (int 2) (int 2) (long 0) fixed it
23:43jweissthanks for your help!
23:44jweissgood knowledge about type hinting there, not sure i've ever seen that explicitly stated in the docs
23:44ataggartodd. IIRC the reflector automatically coerces ints to/from longs
23:45amalloyataggart: it's supposed to, but i wouldn't be surprised if there are edge cases
23:45ataggartah wait, no, the reflector is dumb. it can't make widening conversions
23:45ataggartthat was the main driver for my changes
23:45ataggartand 1.2.0 those literals are ints
23:49amalloyreally? it only makes narrowing conversions? i guess that makes a little sense given 1.2's automatic widening of arithmetic
23:50amalloybut widening is the conversion it *should* do, isn't it?
23:50amalloylike, the direction that java goes
23:52ataggartamalloy: the method finding code does not account for widening conversions. The calling of methods in the copmiler *does* though.
23:53amalloyi don't understand the distinction
23:53amalloydoesn't it have to find a method to call it?
23:54ataggartAt compile-time Compiler asks Reflector for a Method object given a collection of args. If an arg is an int, and all the methods take longs, Reflector returns null.
23:54ataggart*if there is more than one method for a given name
23:56ataggartassuming a Method was returned, the Compiler emits bytecode to call it, and that's when it does the long/int autocoerce
23:56ataggartso, in the case of only one named method that takes a long, you could call it with an int and it'd work.
23:56amalloyand if no method is found, then it emits bytecode to do runtime reflection, which does widen? i see
23:56ataggartyarp
23:57ataggartthough that only works for int/long and float/double
23:57ataggartthe other integral types don't get converted
23:57ataggartsadly
23:57amalloyright
23:58ataggartbut again, I fixed all this months ago
23:58ataggartit's sitting in jira
23:58amalloybut short and byte are sorta a joke anyway. who uses them
23:58amalloyshort, anyway
23:58amalloyataggart: yeah, i remember
23:58ataggartpeople who need to work on byte arrays
23:58ataggarthttps://github.com/ataggart/codec/blob/master/src/codec/base64.clj