#clojure logs

2011-09-23

00:00ibdknoxunless they assume that no one will use it for more than a few times
00:00livingstonibdknox: maybe
01:08livingston,(doc partial)
01:08clojurebot"([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & ...]); Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args."
01:40MayDanielkkkqwejl;+
01:40MayDaniellkxd][
01:40MayDaniel +
01:41MayDanielb
01:41MayDanielcb
01:41MayDaniel#
01:41companion_cubeso true
01:41livingstonMayDaniel: your cat may be walking on your keyboard
01:42companion_cubeor maybe it's his domestic cthulhu
01:42livingstoncompanion_cube: lol
03:46patchworkhey all, I have a lein project and I want to load some .clj files that live in a wholly unrelated dir. the classpath seems abstracted away, what is the best way to do this?
03:47patchworkwhen I do (load "/absolute/path/to/file.clj") it fails to find it
03:48amalloyprobably load-file
03:48amalloy&(doc load-file)
03:48lazybot⇒ "([name]); Sequentially read and evaluate the set of forms contained in the file."
03:51patchworkamalloy: that was it!
03:51patchworkthank you
03:51amalloythat said, don't do that :P
03:52patchworkha, I thought someone might say that
03:52patchworkI have the path in a config file
03:53patchworkthere is a real reason, I am building something that supports building other projects. I want the actual project in an autonomous dir from the framework itself
03:53patchworkbut I appreciate the concern : )
03:54patchworkit still may be misguided
04:01khaliG&(prn "test")
04:01lazybot⇒ "test" nil
04:02khaliGnever noticed that it returns a string ..weird
04:05raekkhaliG: the call returns nil
04:05raekbut that might not be what you meant
04:05khaliGraek, oh. i meant the output in the repl
04:06patchworkI took it to mean that it prints out the string with quotes
04:06patchworkyeah
04:06patchworkwhich is weird
04:06khaliGi cant see any reason to use prn then, i'll just use println now
04:07raekthis is the difference between println and prn
04:07raekprn prints clojure data in a form that can be read back by the reader
04:08patchworkraek: ah, that could be useful
04:08raekso in this case it prints a string literal that can be used in clojure code
04:08raek,(pr-str "foo\"bar")
04:08clojurebot"\"foo\\\"bar\""
04:08raek,(prn "foo\"bar")
04:08clojurebot"foo\"bar"
04:09raek(str should almost never be used to stringify clojure data structures)
04:09robermannis read-string's usage related to this topic?
04:10raekyes. read-string is the reverse of pr-str
04:10robermannah ok
04:10khaliGthat's interesting that they're inverses
04:10robermannyesterday I stumbled upon: ,(read-string (str \[ "a,b" \]))
04:10robermann,(read-string (str \[ "a,b" \]))
04:10clojurebot[a b]
04:11raekrobermann: on 4clojure? :)
04:11robermannyes :)
04:11khaliGraek, i dont know enough to disagree but i'm curious why it should never be used to stringify
04:11raekI happened to stumble on that way of solving the problem yesterday too
04:12raeklet's assume you want to turn ["foo bar" "baz"] into a string
04:12raek,(str ["foo bar" "baz"])
04:12clojurebot"[\"foo bar\" \"baz\"]"
04:12khaliGbtw doing silly euler problems is a good way to get practice learning clojure.. i learnt a bit more bout lazy seqs after attempting some problems the last coupla days. the only downside is it wastes too much time on pointless exercises
04:12robermannraek: darren's solution of problem 74
04:13raekok, that didn't really work as I expected it to
04:13raekbut if you want to stringify arbitrary data, it won't work for strings
04:13raeksince they will become something that looks like symbols
04:14raekand lazy-seqs just become this mess:
04:14raek,(str (range 3))
04:14clojurebot"clojure.lang.LazySeq@7480"
04:14raek,(pr-str (range 3))
04:14clojurebot"(0 1 2)"
04:14khaliGraek, interesting.. i haven't run into that problem yet. often use something like (str "boom" foo bar " another string) to concatenate bits together
04:15khaliGmissing " at the end there
04:15raekyes, str works perfectly well to concatenate strings
04:15robermannread-string doc: "Reads one object from the string s"
04:15raekbut not to turn an arbitrary clojure data structure into a string that can later be read
04:16robermannnot a so useful doc :)
04:16khaliGoooh i understand now
04:17raekif you want to serialize data, a string should be wrapped in quotes so that it becomes a literal. str does nothing with the string and is the wrong function to use for clojure data serialization
04:18khaliGraek, sure that makes sense :)
04:18raek,( 123 "123")
04:18clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
04:18raekgah.
04:18raek,(println 123 "123")
04:18clojurebot123 123
04:18raek,(prn 123 "123")
04:18clojurebot123 "123"
04:20robermann,(eval (read-string "(+ 1 1)"))
04:20clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
04:20robermannops
04:22khaliGraek, thanks for explaining
04:23robermannthank you
04:25khaliGi might just start doing 4clojure too since everyone else is :P
04:30amalloy$sed khaliG s/everyone else is :P/it's AWESOME/
04:30lazybot<khaliG> i might just start doing 4clojure too since it's AWESOME
04:30piskettihaha
04:31piskettiI'd say, don't do it because everyone else is doing it. Do it because it's the most fun you'll ever have programming.
04:32khaliGpisketti, true but I do need the practice, half of the time i dont know how to do stuff in the language and i'll be sitting there helplessly
04:34piskettiof course you'll need google
04:34khaliGto look up docs?
04:36piskettiyeah
04:37khaliGclojuredocs is pretty nice i must admit
04:44robermannkhaliG: I'm learning by solving 4clojure problems with 10 lines and comparing them with the 1-line others's solutions :D
04:46amalloyof course you can solve the problems however you want, but i usually like the 10-line solution better
04:47robermannI noted that I'm using too much loop/recur, maybe I'm thinking still in an procedural/object-oriented way
04:48amalloyi learn a lot less writing (comp first reverse) than i do writing (fn my-last [coll] (if-let [xs (next coll)] (recur xs) (first coll)))
04:49robermannI see your point
04:49amalloybut that's because i know most of the builtins pretty well, and enjoy practice with recursive thinking. if you're learning the builtins but are pretty confident about your low-level problem-solving, (comp first reverse) is a "better" solution for you to find
04:50amalloy(and (comp peek vec) is arguably better)
04:51robermannyes, I'm trying to study the API stuff (I was forgetting stuff like interpose, interleave etc!)
04:51amalloyanyway, enjoy 4clojure. i'm going to bed
04:51robermannok :)
04:52robermanngoodnight
04:52robermannhave a recursive dream
06:00pyris it feasible to build a clojurescript app and do without the ugly closure look&feel ?
06:17morphlingpyr: you don't need to use the closure library
06:18pyrok
06:35michaelr525hello
06:35manutterhey
07:03r0manhi, what are people using to replace clojure.contrib.mock in clojure 1.3?
07:05jajuI wish to use "case" on the class of an argument (class x) - what should the test expression look like?
07:05jajuFor example - x is a string - java.lang.String does not match
07:05jajualthough (class "x") - say - prints java.lang.String
07:13raekjaju: the case constants are not evaluated so you end up comparing with symbols instead of classes
07:13raekjaju: you can work around it by having classes instead of symbols in the code: https://gist.github.com/997652
07:15raekjaju: another workaround is to do something like (case (symbol (.getName (class "x"))) java.lang.String "It's a string")
07:17manutter,(apropos "map")
07:17clojurebot(sorted-map ns-unmap zipmap map mapcat ...)
07:18manutterwow, how did I miss that before?
07:19manutterIt's embarrassing how much stuff you can learn from Clojure Intro slides
07:22manutteris # not allowed in Clojure var names? Just saw "#t and #f" as examples of scheme booleans and realized I've never seen # in clj vars
07:22simonjmanutter: it's reserved by the reader IIRC
07:23manutteryeah, sound right now you mention it
07:25manutterwow, did he really present 214 slides at strangeloop? I'm impressed
07:34jajuraek: Thanks, let me try that!
07:37kij,(source pr-on)
07:37clojurebotSource not found
07:38kijis there any tool to "easy" find the source for pr-on, and other java? defined functions ?
07:39pyrkij: your trying to find a source for pron ? on the internet ? surely you should find one :)
07:41kijpyr: lol ;) yea gonna macroexpand it.
07:43pyrkij: otherwise, it's in core.clj
07:44pyr(https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj)
07:44kijyea line 2014, so source is only for public ?
07:44jajuraek: Thanks for the gist snippet. That seems like the better way.
07:47pyrkij: or autodoc doesn't pickup everything
07:48kijuhh http://clojuredocs.org/
08:12michael_campbellMorning all. As a complete #clojure neophyte, would you recommend Programming Clojure or the Joy Of Clojure as a first book? I've got a smattering of dynamic language, FP, and Lisp in my background, but not much. The lispy syntax doesn't bother me. Looking for something that goes over the paradigms and idioms more so than "this is a program" type of instruction.
08:12michael_campbellOr some other book too; those 2 seem to have the buzz is why I mention them.
08:14manutterI had a little trouble following JoC when I first read it, but I was too much of a neophyte back then.
08:14manutterI went back to it after reading Clojure in Action (MEAP) and then JoC was awesome.
08:15michael_campbellAh, thanks; forgotten about the In Action book. Worth it?
08:16manutterI'd say so, I really liked it.
08:17michael_campbellmuch appreciated; I'll check it out.
08:19michael_campbellmeta question (and reply offchannel if appropriate); why do some channels start with ## but most with #?
08:19robermann+1 for Joy Of Clojure
08:20dhm+1 for Joy Of Clojure
08:22opqdonutmichael_campbell: freenode policy
08:22clgv+1 for Joy of Clojure on the condition that it's not ones first clojure/lisp book ;)
08:22opqdonuthttp://freenode.net/policy.shtml#channelnaming
08:22opqdonutmichael_campbell: ^
08:23michael_campbellTHanks.
08:23robermannas a first lisp book I'd advice the SICP
08:23robermannhttp://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html#%_toc_start
08:24michael_campbellrobermann: I've considered that; I have SICP and have made some stabs at it over the last 15 or so years.
08:24michael_campbellAnd Siebel's CL book.
08:24michael_campbellequally stabbed, although in a shorter time period
08:25michael_campbelljust wondered if the syntax differences between clojure and scheme would be another barrier to entry that I'd prefer not be in my way
08:25michael_campbellI guess nothing worth doing is easy though.
08:28ambrosebsI'd say PragPub's clojure book would be more appropriate than SICP
08:28fdaoudambrosebs: second edition on the way, btw
08:29ambrosebs1st ed. is fine too
08:30ambrosebsdon't use SICP to learn clojure, unless you know scheme already
08:30michael_campbellI know enough to recognize it as Scheme, but that's about it.
08:32michael_campbelllooks like pragpub has a beta e-book program like MEAP, too.
08:32michael_campbell(or other way around; didn't mean to imply Manning's came first)
08:33ambrosebsScheme is pretty different to Clojure
08:34fdaoudmichael_campbell: yes, except that pragpub won't let their beta e-books stay unreleased for 3+ years :/
08:34fhdI could need a hand debugging a ClojureScript problem, anyone willing to help?
08:34michael_campbellare any of you guys seeing clojure "in the wild", or are you doing it more for your own projects? If you ARE doing it for more than that, are you getting ok's from companies to do so or is it a more subversive "put it in there, it's just a jar, no one will know" type of thing?
08:34michael_campbellfdaoud: *chuckle* I didn't know Manning had that reputation =)
08:35michael_campbellAnyone got a discount code for PragPub? (Sorry, I'm old, have to ask)
08:35ambrosebsI'm a student, just use it for projects and personal research
08:36joegalloi use it professionally, totally in the open
08:36joegallo(that is, no "it's just a jar" stuff -- which I hope people are usually just joking about)
08:36fhdmichael_campbell: I'm working on a small Clojure+ClojureScript project at work with a colleague. Wouldn't be able to get many more on board for Clojure projects here though.
08:36fdaoudmichael_campbell: I've purchased many Manning MEAPs and it was good, but now I stopped after having 3-4 books that weren't getting finished. The worst are JavaScript Ninja and Spring in Practice: both were started in 2008!
08:36fhdmichael_campbell: Otherwise private stuff.
08:37michael_campbellI have a perverse desire to make a jar of a half dozen classes where every .class file comes from a different source language.
08:37fhdmichael_campbell: My bosses think it's fine if it makes us productive, but I think they are not regarding it as a "serious" language. But they know not to interfere :)
08:38michael_campbellfhd: That's fortunate. My background is financial applications (yeah, I know), so @ work there is nothing even remotely close to "modern", much less cutting edge, so I am doing my "fun" stuff totally off book, by necessity.
08:39fdaoudmichael_campbell: java clojure jruby groovy scala mirah fantom ceylon gosu ...?
08:40michael_campbellfdaoud: At least java clojure jruby and groovy. Probably scala would be next, then perhaps mirah or fantom. That ordering based on my very limited experience with them.
08:42michael_campbellthere's a lot more languages on the JVM than I would have guessed, but of course many are just experiments, half baked and incomplete, etc. I ran across a Modula-2 impl not too long ago. When someone does APL (or J)... that'll be fun.
08:44fdaoudmichael_campbell: I've tried many but always come back to clojure
08:45michael_campbellI guess it'll come with time, but I spent so many years on HP RPN calcs that prefix notation is a real chore for me. Postfix flows from my brain like I was born that way, but prefix... it's a mechanical parsing exercise for me still.
08:47ambrosebsmichael_campbell: I'm still working on postfix :)
08:47michael_campbellIt's all what we're used to I suppose.
08:55fhdmichael_campbell: I used to be in financial services, same problem. Java 6 was pretty much bleeding edge for those guys... Now I'm in logistics, better :)
09:46robermannan off-topic question: anyone using Eclipse's GIT plugin (EGit )? Is it stable?
09:51fdaoud-> is my new best friend
09:51fdaoudthank you JoC for explaining it
09:53clgvwhy does this work? ##('bla 'x)
09:53lazybot⇒ nil
09:53mdeboard`clgv: What do you expect it to do?
09:54mdeboard`clgv: It's just (fn 'bla 'x)
09:54mdeboard`#(fan 'bla 'x)
09:54mdeboard`#(fn 'bla 'x)
09:54mdeboard`isn't it?
09:55mdeboard`##('bla 'x)
09:55lazybot⇒ nil
09:55mdeboard`,('bla 'x)
09:55clojurebotnil
09:55mdeboard`(1 2 )
09:55mdeboard`##(1,2)
09:55lazybotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
09:55mdeboard`##('1 '2)
09:55lazybotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
09:56mdeboard`##('(bla))
09:56lazybotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
09:56mdeboard`Dunno.
09:56clgvno it's a symbol called as function that returns nil
09:56clgv&('bla 'x)
09:56lazybot⇒ nil
09:56clgv&('bla)
09:56lazybotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: Symbol
09:57mdeboard`Yeah didn't know double-hash was the symbol to activate lazybot
09:57mdeboard`soz m8
09:57clgvyeah it's for in-text usage
09:57raekclgv: symbols look them selves up in maps like keywords when then are called as functions
09:57raek,('foo {'foo 1})
09:57clojurebot1
09:58raek,(get {'foo 1} 'foo) ; equivalent to this
09:58clojurebot1
09:58clgvraek: ah ok. I did not know that
09:58clgv(:bla 'x)
09:59clgv&(:bla 'x)
09:59lazybot⇒ nil
09:59clgvmaybe an exception indicating that there is no map involved would be good...
09:59raekyeah, I would prefer that too
10:01michaelr525hey
10:01michaelr525is there video recordings from strangeloop?
10:02manutterI've seen slides but no video so far
10:02manutter(http://goo.gl/MqF9Q)
10:11`fogusClojureScript Atoms now have watchers and validators
10:11manutternice
10:16michaelr525`fogus: it's probably a good thing ;)
10:24lnostdalanyone know how to get enlive to not wrap templates in html+body? .. i currently strip that away using subs, but, yeah
10:26raeklnostdal: maybe 'html-snippet'?
10:28lnostdalraek, thanks .. hm, i guess i can't get deftemplate to use that behind the scenes?
10:28raekI think you can also insert "<bogon>" in the beginning of the text to tell tagsoup to not insert the extra tags in the tree
10:29lnostdalok, well i'm reading from a file our designer has created .. i can't change that file without breaking what he's working on
10:30lnostdalperhaps deftemplate accepts something not a filename though .. i can wrap that up i guess
10:31lnostdalhm, nah, it calls get-resource only AFICT
10:31lnostdal..or it'll actually take an inputstream, yeah
10:33raekI don't know how to do it. tagsoup has options for this, but maybe enlive doesn't expose them...
10:35stuarthallowaygood morning. Anybody want a Clojure 1.3 release?
10:37dakronestuarthalloway: please
10:37stuarthallowayAnybody want to read https://github.com/clojure/clojure/blob/master/changes.txt and let me know if there are any dumb spelling errors?
10:38di-csuehsthe bad part about having the bots is that I can't make smart-ass comments like slurp changes.txt
10:39di-csuehsReading it now
10:42fliebelstuarthalloway: So... "1.3 Disallow recur across try" means that this is no longer allowed, or that this disallowance is removed?
10:42stuarthallowayfliebel: it always was wrong to do it
10:42stuarthallowaynow you get an error at compilation time
10:42fliebelOh, sweet :)
10:43fliebelSomething with dynamic binding, right?
10:43di-csuehsHow nit-picky do you want? Should Operations be captialized in 1.4 Removed Bit Operation[s]
10:44stuarthallowayhrm, seems that capitalization is a bit inconsistent in the sections headings all the way
10:44stuarthallowaylet's ignore that
10:44stuarthallowayor should I say "let's Ignore That"
10:44di-csuehsnp
10:44fliebelI've never been quite able to tell what "2.3 Better Exception Reporting" was all about.
10:44ambrosebsstuarthalloway: section 2.17 "the following code with throw an example"
10:44ambrosebsshould be "exception"
10:45stuarthallowayambrosebs: fixed, thanks
10:45di-csuehsI would consider breaking line 84 to separate lines, allowing easier access to the URL's in the narrow confines of browser's layout.
10:45stuarthallowaywill push in a few minutes when you guys are done
10:45raek"Disallow recur across try" should perhaps be replace with something like "Recur across try is now properly rejected by the compiler" to clarify the intention of the change
10:45stuarthallowaydi-csuehs: agreed, but won't hold release for that
10:46mdeboard`Anyone have a link to dnolen's preso to the NY Clojure group about predicate matching
10:46mdeboard`from august
10:47manutterI can't quite parse 1.2 -- "This allows ... from being in the equality partition" ?
10:47fliebel2.5 clojure.data/diff - huh, where does that live? http://clojure.github.com/clojure/branch-master/clojure.core-api.html
10:47mdeboard`s;predicate matching;predicate dispatch/(match)/g
10:49di-csuehsthere some neat stuff in here
10:49manuttermdeboard: This one? http://vimeo.com/27860102
10:49stuarthallowayI moved recur-across-try into bug fixes, as well as repairing the language. Pushed.
10:51di-csuehsI'm not sure if it is markdown mangling or what is emitting weird glyphs at line 290,291
10:51stuarthallowayproposed revision to 1.2 "This allows ISeq implementers to be in the map or set equality partition."
10:53ambrosebsstuarthalloway: line 416, probably want to delete the period on the end of the line
10:53ambrosebs412
10:54ambrosebsafter http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
11:00stuarthallowayfliebel : I have posted on the dev list requesting a doc update to include data.diff
11:01di-csuehsDone reading. Nothing else jumps out. Looks like some fun stuff.
11:08kzarWhich couchdb library for Clojure should I use?
11:10mdeboard`kzar: Wouldn't any HTTP library work?
11:12kzarmdeboard`: I could use a HTTP library and code my own couchDB layer, I could try out some of the different couchDB libraries too but I'd rather just use whatever's best - if there's a clear winner anyway
11:15`fogusstuarthalloway: The defrecord improvements link should probably just be http://dev.clojure.org/display/design/defrecord+improvements
11:16zerokarmaleftkzar: https://github.com/ashafa/clutch is quite popular
11:21kzarzerokarmaleft: Thanks OK
11:25arohnerstuarthalloway: section 5, "Then, in a separate step, upgrare to Clojure 1.3"
12:04TimMcWhat's wrong with upgraring?
12:09TimMc"Please either indicate ^:dynamic ** or change the name."
12:10TimMcShould that be *fred* instead of **?
12:25tsdhIs there something like CL's atomp function?
12:28bhenrytsdh: what does it do?
12:28tsdhbhenry: Return true for anything that evaluates to itself.
12:30hiredmantsdh: are you sure? what about (atomp 'foo) ?
12:30hiredmansurely (eval 'foo) doesn't eval to foo
12:33tsdhhiredman: Yeah, the definition wasn't that good. :-)
12:33tsdhhiredman: The real def is "Returns true if object is of type atom; otherwise, returns false."
12:33tsdhhiredman: And an atom is anything that is not a cons.
12:34tsdhI'll go with (not (or (number? x) (string? x) (symbol? x) (keyword? x)))
12:34hiredmanclojure doesn't have cons cells, so everything is an atom in that sense, so atomp is useless
12:39manutterit does have atoms, tho ;)
12:46churibtsdh: perhaps you mean not sequable?
12:48tsdhchurib: My intention was to filter out anything that cannot have side-effects when being evaluated.
12:49arohnertsdh: that's not build-in
12:50arohnertsdh: sounds interesting though. Why do you need it?
12:52tsdharohner: I wrote a variant of defmacro that expands into a normal defmacro with the guarantee that all arguments are evaluated once only.
12:53tsdharohner: Now the idea was that one could skip some gensyms for args that cannot have side-effects anyway.
12:53tsdharohner: But that seem to have a benefit, so I'll let it as is.
13:05TimMctsdh: Sounds like you basically just want literals.
13:09tsdhTimMc: Yep
13:13manutterOk, that's a weird lein/swank bug
13:14manutterI could not do clojure-jack-in because I had a ~/.lein/init.clj file that did (println "Loaded init.clj")
13:14manutterSomehow the "Loaded init.clj" line got embedded in the elisp that swank was trying to evaluate, and it was dying with "Symbol's value as a var is void: Loaded"
13:15manutterI changed my init.clj file to print ";;; Loaded init.clj" and now clojure-jack-in works again.
13:15manuttertechnomancy: is that a bug?
13:15jjidoprintln may be a macro?
13:17manutterhmm, don't think so
13:17manutter,(macroexpand '(println "foo"))
13:17clojurebot(println "foo")
13:23technomancymanutter: yeah, I guess it is. jack-in should probably be more specific about what it accepts as elisp. maybe it could search for a pair of markers and eval-region in between them.
13:23technomancycan you open an issue so I don't forget?
13:23technomancyor pull request? =)
13:24manutterok, will do
13:24manutterissue, that is...it'll be a while before my elisp skills are up to a bug-fixing level
13:57dnolen`fogus: I played around w/ it a bit, seems fun.
13:58`fogusQi was [this] close to being my Lisp of choice
13:59gfredericksis there a simple way to take a ring request and forward over HTTP to another server? (does that even make sense?) I was trying to think of a simple way to set up a little proxy server for development that mucks with the headers...
14:00gfredericksthe sticky point seems to be how to get the ring clojure-map back out onto the http wires...
14:02amalloygfredericks: you'd have to issue a new request to the other server on behalf of the client
14:02amalloyto act as a real proxy
14:03gfredericksamalloy: right -- I just don't know if there's code to do that easily given a ring map, or if I'd have to assemple a raw HTTP request myself
14:04gfredericksassemple...I've been noticing a lot of these typos lately. That means I'm old now, right?
14:04manuttergfredericks: have you looked at clj-http?
14:04gfredericksnope!
14:05manutterdakrone is the new maintainer, go to the dakrone one
14:05gfredericksnoted
14:06gfredericksmanutter: thanks
14:07manutteranytime
14:11tcrawleydoes anyone know of a lib that provides simple zip file extraction in clojure?
14:13zerokarmaleftjava.util.zip?
14:13clojurebotamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
14:13TimMcclojurebot: forget that
14:13clojurebotTitim gan éirí ort.
14:13TimMc(Oops, wrong bot...)
14:14tcrawleyzerokarmaleft: I was hoping for something that wraps all the crap there and gives me (unzip my-zip-file output-dir)
14:30khaligi'm looking for a nice way to do the java equivalent of listeners in clojure. was thinking some kind of lightweight messaging system kinda like erlang.
14:45manutterwhen clojure complains that PersistentArrayMap cannot be cast to [B, it's trying to build an array of bytes, yes? or booleans?
14:46symboleIt's trying to pass PersistentArrayMap to byte[], I believe.
14:46TimMcclojurebot, what happened to clojure.contrib?
14:46clojurebotCool story bro.
14:47TimMc(Is there a factoid for http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go ?)
14:47zerokarmaleftkhalig: add-watch isn't sufficient?
14:48manutterAh, there we go -- clj-http wants a string as the body of a post, not the actual map
14:49cemerickmmm, Clojure 1.3.0 has been released
14:49cemerickstuarthalloway: The real question is, why did the promotion of the second release build of that other project succeed? #rhetorical
14:49symbolemanutter: I believe it accepts a string or byte[].
14:50manuttersymbole: makes sense
14:50TimMc,((juxt byte-array boolean-array) [])
14:50clojurebot[#<byte[] [B@1842264> #<boolean[] [Z@1ede158>]
14:50stuarthallowayI would respond but the use of the #rhetorical tag prohibits it ...
14:51TimMcstuarthalloway: Still taking typos?
14:51zerokarmaleftkhalig: wb...is add-watch sufficient?
14:51stuarthallowayTimMc: as patches now :-)
14:51TimMcgrr
14:51TimMcI should sign that stupid form...
14:51manutterTimMc: saw that, tks
14:51`fogusAnyone have a pet example where the use of GClosure's extern facility is needed in ClojureScript?
14:52TimMcstuarthalloway: "now effects" is the only one that makes me rage
14:52stuarthallowayTimMc: impacts?
14:52stuarthallowayaffects?
14:53TimMcaffects
14:53TimMcunless the internet really has finished ruining my sense of spelling
14:53stuarthallowayif that bothers you, what about the horrendous title capitalization
14:53stuarthallowaypatch to fix that also welcome :-
14:54TimMcI'm too used to style guides for that to bother me.
14:54cemerickstuarthalloway: if you know, do share :-)
14:54stuarthallowaycemerick: kidding, I don't know
14:54stuarthallowaybusy working on 1.4 features :-)
14:55stuarthallowaystuartsierra claims to have just posted an explanation to clojure-dev
14:55cemerickI've always been leery of the promotion operation in the nexus plugin; the semantics seem ill-defined.
14:56dnolen`fogus: jQuery?
14:56`fogusRight, but wonder if anyone had a small example.
14:58`fogusCRICKEY! The session timeout on Clojure's Jira is 8 seconds!
14:58dnolen`fogus: ah no, but pretty much anything would do. most common activities are selecting things in the DOM, attaching events, ajax requests.
14:58technomancywhy is "-master" in the version strings for clojure snapshots?
14:59TimMc`fogus: Did someone forget to multiply by 60?
14:59`fogusdnolen: I'll play around. Thanks
15:00`fogusTimMc: It's not really 8, but it feels like it. :-(
15:00stuarthallowaytechnomancy: habit?
15:00TimMcAt least Jira knows how to re-post.
15:00technomancystuarthalloway: ok, fair enough
15:00stuarthallowaytechnomancy: assume it would break things to change it
15:01stuarthallowaytechnomancy: but if there is benefit to it I certainly don't care
15:01technomancyjust an onion then
15:14ibdknox`fogus: if you're just looking for an externs file to play with, there's the d3 externs: https://github.com/shripadk/d3-externs
15:25pauldoois there a technical name for built in functions which aren't special forms?
15:25livingston,(seq? [1 2])
15:25clojurebotfalse
15:25gfredericksso if a take a response from http-clj and return it directly to jetty, everything seems to work like I want it to except images, which get cut off after 3774 bytes.
15:26gfredericks(by "jetty" I mean ring-jetty of course)
15:26symbolepauldoo: Special form doesn't mean "built in". It just means the evaluation rules are different.
15:26pauldoo(ie, things with funciton-like semantics (args evald left to right), but which are provided by the runtime.. Not special in the sense of "if" or "def" which have semantics totally unlike functions)
15:26gfrederickspauldoo: ...functions?
15:27rbransonhow are people doing data persistence with an RDBMS'? are there any patterns? ClojureQL? clj-record seems like more of the same thing I'm trying to get away from :/
15:27pauldoosymbole: yes indeed. special forms are generally built in however, (is that not true)?
15:27gfrederickspauldoo: things that are not functions or special forms are usually macros, which can have arbitrary "semantics"
15:27gfredericksaside from the fact that the first symbol denotes the macro
15:27livingstonI really thought vectors were seq able and responded to seq? clearly not. if want to test for vectors,lists etc. but exclude strings I want what sequential? ?
15:27gfrederickslivingston: yes
15:27pauldoookidoke, so is there a special names for functions provided by the runtime.. ? (with regular function-like semantics)
15:27raekseq? does not mean seqable
15:28ibdknoxlivingston: ,(doc coll?)
15:28gfrederickspauldoo: I guess you're thinking of the functions in the clojure.core namespace particularly then?
15:28gfrederickswhich you could call "core functions" or some such thing
15:28ibdknox&(doc coll?)
15:28lazybot⇒ "([x]); Returns true if x implements IPersistentCollection"
15:28pauldoogfredericks: I'm not thinking of clojure specifically. I've been reading SICP and am now implementing a lisp.. want to make sure I've got my terminology correct.
15:29livingstongfredericks: ibdknox: is coll? better?
15:29gfrederickslivingston: I think they will differ for sets and maps, so it depends what you want
15:29pauldoogfredericks: I think my runtime provides special forms, and built in funcitons.. the rest is all implemented in the guest language (or "standard library")
15:29raekpauldoo: primitive functions, maybe
15:29raekin constrast to compound functions
15:30livingstonI guess I need order in this case so sequential? it is.
15:30ibdknox&(map coll? [ [] '() {} #{}])
15:30lazybot⇒ (true true true true)
15:30ibdknox&(map coll? [ [] '() {} #{} "hey"])
15:30lazybot⇒ (true true true true false)
15:30stuarthalloway,(clojure.data/equality-partition [1 2])
15:30clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.data>
15:30pauldoogfredericks: yep ok- that name would also work. does the distinction have value though..? Is it important to label the difference between a special, primitive, or compound?
15:30pauldoo(I imagine it does)
15:30gfrederickspauldoo: that was raek's comment
15:30stuarthalloway,(use 'clojure.data)
15:30clojurebotnil
15:31gfredericksand I don't know what he meant
15:31ibdknoxlivingston: that's what you wanted right?
15:31stuarthalloway,(equality-partition [1 2])
15:31clojurebot:sequential
15:31stuarthalloway,(equality-partition "foo")
15:31clojurebot:atom
15:31gfredericks,(doc equality-partition)
15:31clojurebot"([x]); Implementation detail. Subject to change."
15:31ibdknox,(doc equality-partition)
15:31clojurebot"([x]); Implementation detail. Subject to change."
15:31pauldoogfredericks, raek: it sounds like I'm on the right track naming these things then. thanks :)
15:31ibdknoxlol
15:31ibdknoxstuarthalloway: awesome docstring :-p
15:32stuarthallowayibdknox: I wrote it myself :-)
15:32gfredericksstuarthalloway: which is subject to change? the implementation, or the docstring?
15:32technomancyis this the first time the term "equality partition" has appeared outside JoC?
15:32stuarthallowaytechnomancy: no idea. the code has been there for a while
15:32livingstonI was unaware of equality partition .. I was about to doc it, but we see.. what's it supposed to do exactly?
15:33technomancylivingston: things from different equality partitions can never be equal
15:33stuarthallowaylivingston: the grouping implied by the baker paper
15:33livingstonoh ok.
15:33ibdknox,(map equality-partition [ [] '() #{} "hey" ])
15:33clojurebot(:sequential :sequential :set :atom)
15:33stuarthallowaybut, more tactically, the grouping used to support data/diff
15:34livingstonI see. thanks.
15:34technomancya lot of people get confused about (= [1 2 3] '(1 2 3)), but since they are in the same partition and contain the same values it evaluates to true
15:34stuarthalloway.(diff {:a 1 :b2} {:b 2 :c 3})
15:34gfredericksI assume :atom is unrelated to clojure.core/atom?
15:34stuarthallowaygfredericks: yes. Atom as in non-collection
15:34stuarthallowayanother possible word is scalar
15:34technomancythere was a CLer in here earlier asking about atomp; if I had known about this function I would have pointed him there
15:34technomancystuarthalloway: good thing it's marked as subject to change =)
15:34gfredericksstuarthalloway: maybe for clarity it should be changed to return :atom-but-not-the-concurrency-primitive-this-just-means-not-a-collection
15:35livingstonI'm now wondering how many places I've erroneously used seq? assuming that'd pick up vectors and lists ...
15:35stuarthallowayI don't think many people use the data API besides me :-)
15:35stuarthallowaybut they should
15:35gfrederickslivingston: seventeen places
15:35ibdknoxlivingston: seq? only tests whether the current thing is a seq
15:36ibdknox,(map seq? [ [] (seq [])])
15:36clojurebot(false false)
15:36ibdknoxhuh
15:36ibdknox,(doc seq?)
15:36clojurebot"([x]); Return true if x implements ISeq"
15:36gfredericksstuarthalloway: after mulling it over I think I prefer 'scalar' to 'atom' maybe
15:36gfredericksat the very least it gets unambiguity bonus points
15:36ibdknox,(map seq? [ [] (seq [1])])
15:36clojurebot(false true)
15:37livingstonfor some reason I was assuming seq? tested for suitability to shove into seq -- obviously it does not.
15:37gfrederickslivingston: such a function could be called seqable?
15:37gfrederickswhich I'm sure exists somewhere
15:37livingston:p
15:38ibdknoxgfredericks: used to be part of contrib
15:38gfredericksyep
15:38cemerickFYI: Now just $300 from reaching the fundraising goal to help send Ambrose to the Conj… http://wp.me/p10OJi-aX
15:38cemerickStill time to slip in there and nab a free signed copy of Clojure Programming ;-)
15:38cemerick(back to your regularly scheduled discussion)
15:39TimMccemerick: awesome
15:39livingstondid seq? used to behave differently (I'm assuming not, but I don't know how I came to misusing it)
15:39ibdknoxlivingston: gfredericks: but really, coll? is probably what you want
15:40pauldoogfredericks, raek: I've realised I named my atoms/scalars as primitives. So I think I'll name primitive procedures "builtins" to avoid the clash..
15:40ibdknoxlivingston: not since I've been using Clojure. That's what it's always done
15:40cemerickTimMc: Yes, it absolutely is. I'm again stunned by the response.
15:41livingstonactually in this particular case I need things where the order of the first two things in specified. in generally though, you are right, 9/10 I want to know "can I map this thing?"
15:42michaelr525i wonder what makes clojure too "heavy" for android? is it the dynamic generation of code that forces the compiler to be included in the app?
15:43ibdknoxlivingston: how about (sequential?)
15:44ibdknox,(doc sequential?)
15:44clojurebot"([coll]); Returns true if coll implements Sequential"
15:44livingstonibdknox: yes sorry I wasn't clear. for my current use that is exactly what I need.
15:44TimMcSomeone should write a blog post called "ISeq, Sequential, seq?, coll? and seqable"
15:44ibdknoxyeah
15:44livingstonha
15:45ibdknoxwe should fix the docstrings for them too
15:45TimMcI don't know enough to do so.
15:45gfredericksTimMc: then everybody would link to it and laugh at clojure for complecting everything
15:45TimMcgood
15:45livingstongfredericks: fine let them
15:45TimMcA little mockery is not a bad thing.
15:45ibdknoxideally that would be a forcing function to improve over the complication
15:46livingstongfredericks: if they want a LCD language use java ;)
15:46ibdknoxlivingston: I dare you to say that on #java ;)
15:46TimMcI'd rather people mocked a little bit than newcomers got confused and ran away.
15:47gfrederickswell I for one think we should hide our flaws under the bed and pretend they're not there.
15:47livingstonTimMc: yes. being explicit about what happens is good.
15:47TimMcgfredericks: :-)
15:48gfredericksnow why does jetty close the connection after exactly 95% of the image has been transferred?
15:48livingstonibdknox: I know plenty of java programmers I joke with about java being the new cobol (sometimes they say it) yes I've programmed both - I prefer cobol - it may be less verbose (error messages are worthless though)
15:48TimMcgfredericks: Solution: Use a smaller image.
15:49gfredericksTimMc: tried that, still 95%
15:49ibdknoxgfredericks: at that point it has enough information to determine what the image is of, and stops on moral grounds
15:49gfrederickshow dare my http server judge me
15:53dnolenchouser: re, CLJS-39. I don't suppose you added have test cases for the :when :while :let syntax.
15:57ballparkWhat is the best way to close down slime-swank?
15:58gfredericksis there an easy way to slurp an input stream into a byte-array rather than a string?
16:00ballpark@rmarianski- Cool. Thanks1
16:00ballpark*Thanks!
16:01rmarianskigfredericks: you can try using make-input-stream from java.io
16:01ballparkIn case anyone wants to make fun of some clojure code: http://codereview.stackexchange.com/questions/4956/a-crude-clojure-progress-reporting-function
16:02gfredericksrmarianski: I have an input stream...
16:02ibdknoxgfredericks: (byte-array (slurp stuff))
16:02gfredericksrmarianski: it'll be fine, I stole and am modifying the code for c.c/slurp
16:02gfredericksibdknox: I'm paranoid about it ever being a string
16:02ibdknoxah
16:02gfredericksgiven that everything's acting goofy at the moment...
16:03dnolenibdknox: pushed a bunch of numeric fixes. should be good to at least write low-level loop/recur math that's competitive with plain JS.
16:03gfredericksbut this slurp-bytes function I'm writing should do the trick
16:03ibdknoxdnolen: I saw that, I'll try it out later. Is that in master?
16:03amalloyyikes. def inside a function is pretty vile, ballpark
16:03dnolenibdknox: yup
16:03ibdknoxdnolen: sweet. I'll let you know.
16:04amalloyballpark: but this function is so huge and doing so many things that i can't really rewrite it for you in a better way
16:04ballparkamalloy: ok
16:04gfredericksamalloy: ooh, that reminds me: if a function needs helper functions, is it more idiomatic to (let [...helpers...] (defn ...)) or (defn _ (let [...helpers...] ...))?
16:05hiredmanletfn!!
16:05gfredericksthe second one seems cleaner to me, but I don't think I see it very often
16:05amalloygfredericks: i favor the former, and anyone who doesn't is a lunatic, but there are lots of people who favor the latter and don't appear to be lunatics
16:05ibdknoxdnolen: I did some more thinking about the arrays vs. seqs performance stuff. I really do think we need something that has near array level performance that can participate in all the seq stuff.
16:05gfrederickshiredman: isn't that just sugar, when the functions are independent?
16:05hiredmanI have half of a patch to λ lift letfns into static methods
16:05gfredericksamalloy: okay, former it is then
16:06amalloygfredericks: i use the latter form when the helper functions can usefully be closures, of course
16:06dnolenibdknox: like I said Pods :)
16:06gfredericksamalloy: of course
16:06hiredmanthe half left is the most difficult part, so unlikely it will see the light of day
16:06ibdknoxdnolen: Is there somewhere I can see that work? I don't think I was around when that was being discussed
16:06gfrederickshiredman: static methods on what class?
16:06dnolenibdknox: https://gist.github.com/306174 pretty dense stuff but you can see the thinking.
16:06hiredmanthe enclosing class
16:07gfrederickshiredman: the function-class?
16:07hiredmanso at the highest level they would end up on the class of the namespace
16:07gfredericksah
16:07hiredmaninside a fn the end up on the class of the fn
16:07hiredmanthey
16:07gfrederickshiredman: does that give a performance advantage?
16:07ibdknoxdnolen: well, for CLJS the impl should be much simpler given we only have one thread.
16:08hiredmangfredericks: actually I haven't checked, but I can't imagine it wouldn't
16:08dnolenibdknox: I've done quite a bit of low level stuff in Clojure proper, so the slightly different style of coding doesn't bother me much, and low-level perf stuff tends to almost always be isolatable.
16:08hiredmanyou avoid object allocation+virtual call
16:08dnolenibdknox: but I agree, moving forward with the Pods idea since we're single threaded seems like a good approach to me.
16:08gfrederickshiredman: and it would still be dynamic?
16:09hiredmandynamic in what sense?
16:09gfrederickshiredman: can be redefined, e.g. at the repl
16:09hiredmanit would be as dynamic as letfns currently are
16:09gfrederickshiredman: oh would the static methods not have canonical names?
16:09hiredmanoh they would, but it doesn't matter
16:09gfrederickse.g. if I do (letfn [(foo ...)] ...) (letfn [(foo ...)] ...), there'd be no naming conflict?
16:10gfredericksI suppose there'd have to not be
16:10hiredmanyeah, the static method name would be something like (gensym 'foo)
16:10gfrederickscan you add static methods to a class after it's been defined?
16:10hiredmanno
16:11gfredericksso what would happen when I letfn at the repl?
16:11gfrederickssince the NS class already exists
16:11gfredericks(does each ns have its own class?? :/)
16:11hiredmanI suggest reading Compiler.java
16:11hiredmanit would speed this discussion up
16:12hiredmanit does, but the repl is a separate code path
16:12gfrederickshiredman: I pride myself in the fact that this is the longest conversation I've had with you before being asked to read a large piece of code :)
16:12gfredericksI must be getting better at something
16:13hiredmanfor most cases (eval 'x) gets turned into (eval '((fn [] x)))
16:13gfredericksfascinating
16:13hiredmanbecause, you know how do you emit bytecode without a method to put it in?
16:14amalloyhiredman: yeah, i was wondering what the wrap-in-a-function was for
16:14gfredericksthat makes sense. I always imagine that the code gets evaled directly instead of compiled, even though another part of my brain knows that's not true
16:15hiredmanwell, actually for simple expressions there is an eval path
16:15hiredmanbut once you have a let or fn or letfn, or loop, etc it has to be compiled
16:15gfrederickshiredman: is that repl-specific?
16:15gfredericks(the eval path)
16:15hiredmanyes
16:17hiredmanyes, and emacs will spend a few minutes reidenting all of it if you are not careful
16:17hiredmanindenting
16:17gfredericksso for once I'm doing the right thing by not using emacs
16:18hiredmannah, you should be using emacs with care
16:18gfredericks:)
16:19semperosI can't access the Google group for some reason, but can I assume 1.3.0 is on its way out now, with the commits on Github from an hour ago?
16:20livingstonsemperos: google has been a little flaky the past 12 hours or so... refresh?
16:20semperoslivingston: got it working, thanks; took a few refreshes
16:23gfredericksfinally I can start using ^dynamic
16:23gfredericksand 12345N
16:25amalloygfredericks: you've finished porting all the libraries you use to 1.3 also?
16:26ibdknoxheh
16:26gfredericksamalloy: nope. But once it's released I wouldn't mind putting the effort in.
16:27amalloysigh. i've made two efforts to get 4clojure using 1.3, and it's just overwhelming
16:27TimMccontrib stuff?
16:27amalloyyes
16:28hiredmanhttps://github.com/hiredman/clojure/blob/what-I-know-about-clojure/src/jvm/clojure/lang/Compiler.java#L6463
16:28TimMcYou saw the 1.3-compat lib, yeah?
16:29amalloyTimMc: i don't think so
16:29TimMchttps://github.com/arohner/clojure-contrib/tree/1.3-compat
16:29amalloybut i'm dubious about its usefulness anyway; we don't use any contrib ourselves, but dependencies do
16:30gfredericksamalloy: eh, maven will fix it. she always does.
16:30ibdknoxamalloy: you should just write everything in house ;)
16:30gfrederickshiredman: is that branch full of little comments like that?
16:31amalloyibdknox: i did that, but everyone said i was hurting the economy by not buying american-made code
16:31ibdknoxdamnit. I knew you had something to do with the recession.
16:32gfrederickshiredman: nevermind, I figured out how to use github myselfs :)
16:32hiredmangfredericks: that is the plan, there are only 3-4 currently
16:32hiredmanI will be taking pull requests (no code, just comments please)
16:32gfrederickshiredman: the point being for it to eventually be merged into the main branch?
16:33hiredmannope
16:33hiredmanjust a reference
16:34gfrederickswell ok
16:35hiredmanClojure/core is kind of strict about licensing and copyright, etc, which I can't fault them for, I just can't be bothered to keep that level of strictness
16:35gfrederickshiredman: oooooh right
16:39gfredericksspeaking of which, having sent in a CA, is there some kind of follow-up I need to do?
16:39gfredericksor do I just start flinging patches?
16:39gfredericksis clojure.org/contributing kept up to date?
16:40hiredmanmore or less, it can take sometime for your name to appear there
16:40gfredericksokay
16:50`fogusUsing an extern file in ClojureScript. https://github.com/clojure/clojurescript/tree/master/samples/hello-js
16:50stuarthallowaygfredericks: just poked redinger, he has your CA in his backpack
16:50stuarthallowaywill be updated shortly
16:50TimMchaha
16:50gfredericksstuarthalloway: thanks!
17:02arohnerthere really needs to be a built in fn for applying maps to fns that take (fn [ & {:keys []])
17:04kharringtonwell, my complaint about that is that i think you should be able to ignore the :keys if you have supplied an :or
17:06arohnerkharrington: sure, but what if I have fn A defined that takes [& {:keys}], and calls fn B that takes [& {:keys}]?
17:10kharringtonaha
17:11devnthe more concise way to say not-nil? when it's used a predicate for a filter... I'm forgetting
17:11devnerr, to avoid defining your own not-nil?
17:11kharrington,(let [f (fn f [& params] (apply hash-map params))] (:b (f :a 3 :b 32)))
17:11clojurebot32
17:11hiredman(comp not nil?)
17:11TimMcdevn: identity
17:11kharringtonarohner: there you go
17:12devn,(filter identity [nil nil nil 1 2 3 nil])
17:12clojurebot(1 2 3)
17:12devnThanks hiredman and TimMc
17:12hiredmanor identity if you don't care about false values
17:12TimMcdevn: Depending on what you think of booleans.
17:12devn*nod* -- identity will work in this case
17:12arohnerkharrington: I know how to do it, I just think it should be built-in
17:12devnthanks
17:12kharringtonah
17:12amalloyTimMc: that's a polarized issue. everyone loves or hates them; nobody is on the fence
17:13TimMcamalloy: An excluded middle, eh?
17:13kharringtonamalloy: har har
17:14TimMcUsing identity as a predicate squicks me out a little. It is yet another idiom that a Clojure (or other logical-booleans language) programmer must learn.
17:21technomancythere's an issue open for making it optional with filter, remove, &c
17:22sritchie(complement nil?) too, right?
17:22sritchieI guess that's the same as (comp not nil?)
17:35TimMctechnomancy: What would that look like?
17:36amalloyTimMc: (filter foo) => (filter identity foo)
17:37amalloywhich i think is pretty common in ruby, for example
17:37TimMc,(filter = [1 2 3] [0 2 4])
17:37clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$filter>
17:38TimMcI guess filter isn't n-ary, so that works.
18:18jliamalloy: hm, what needs to be done to be able to use data.xml with 1.3? can I help with anything?
18:18amalloyjli: i don't know, really; it's mostly chouser's and i'm helping out
18:19amalloyit seems like the builds are failing because the indentation tests don't pass, but when i run them locally they pas
18:27jliamalloy: hum, okay. I'll try looking at it tonight.
18:28amalloyjli: you can also release a copy of data.xml to your own clojars account, and damn the non-passing tests. flatland has that already, in fact
18:28amalloyi thought. maybe not
18:29amalloyhttp://clojars.org/org.clojars.ninjudd/data.xml
18:33bayesiantell me everything about clojure
18:34hiredman~rationale
18:34clojurebotrationale is http://clojure.org/rationale
18:34hiredmango forth and syntax no more
18:48dnolenClojureScripters, anyone got any opinions on inlining truth and remote truth_, https://github.com/clojure/clojurescript/compare/80-inline-truth
18:48dnolenremote -> removing
18:52dnolenibdknox: would also like to hear how perf compares with this patch applied.
18:53ibdknoxdnolen: that seems like it would be a big win, since truth_ is called all over the place, but I'm not so sure the numbers will actually show much of a difference
18:54dnolenibdknox: after the macro ops and this change I see more than a 10X speed up on a simple loop.
18:54dnolenmacro arith ops
18:54ibdknoxdnolen: that's encouraging :D
18:55ibdknoxdnolen: I'll run a few profiles in about 10 minutes and let you know
18:55dnolenibdknox: great thx
19:03ibdknoxdnolen: it's looking good. with the latest master, standard loop-recur is down to 52 (about 2x native) and seqs are less than half what they were yesterday
19:04dnolenibdknox: can you try with the inline truth branch?
19:04ibdknoxdnolen: yep
19:04dnolenthx
19:09ibdknoxdnolen: weird. That's showing better numbers for the seqs (shaved about 100ms) but worse numbers for the loop/recur case
19:10dnolenibdknox: do you have a gist of the code you're testing?
19:11ibdknoxhttps://gist.github.com/1238693
19:12ibdknoxdnolen: hm I switched back to master and am now getting back up to 120ish for loop/recur
19:12ibdknoxdnolen: not sure what the difference could've been
19:13dnolenibdknox: you probably need to wipe out your js, remove out
19:13ibdknoxdnolen: k. Consistently at 50ms for loop/recur
19:13ibdknoxdnolen: on master
19:14dnolenibdknox: k
19:15ibdknoxdnolen: hm. but still getting 110 +- 10 in the inline-truth branch
19:15ibdknoxdnolen: I'll do a couple of real profiles, see if I can track the difference down
19:16dnolenibdknox: that would be helpful
19:16dnolenibdknox: btw, which browser?
19:17ibdknoxdnolen: chrome
19:18dnolenibdknox: hm I see 15ms in Chrome/Safari for loop/recur case
19:19ibdknoxdnolen: interesting. I wonder if I have too much crap open. Let me close everything
19:21ibdknoxdnolen: k, I get that now
19:21dnolencool
19:22dnolenibdknox: so one problem w/ patch is the expression case. it emits something like ((G_XXX = (test)) || (G_XXX != null && G_XXX !== false))?then:else;
19:22dnolenthis will create a lot of global variables
19:23ibdknoxhm
19:23dnolenbut a better way doesn't come to mind beyond creating a function and calling it with the value of (test)
19:23dnolenJS scope rule suck
19:24dnolenCoffeeScript tends find expression like this and lift vars up into the surrounding context outside the expression.
19:24ibdknoxyesh
19:24ibdknoxyeah*
19:25dnolenwould be kinda tricky given the recursive-descent nature of ClojureScript compiler
19:25ibdknoxwrapping it in a function kind of negates the point of the patch
19:25dnolenibdknox: yup
19:25hiredmanis the clojurescript compiler really single pass?
19:25jliwow, what a pain
19:26ibdknoxdnolen: could we create a tmp namespace in the context of the current one?
19:26jlidnolen: so, coffeescript would lift the temp var up just 1 level, but cljs is making it global?
19:27dnolenjli: cljs isn't doing anything, that's just my naive solution doing that
19:27ibdknoxdnolen: the other option is to delete the var after the block
19:27jlidnolen: oh, you're inlining truth, gotcha
19:27dnolenhiredman: looks like it to me, not sure why it would need to be multipass.
19:28hiredmanwell, then you could do things like have the analysis pass notice the need for the vars and set them up for the code gen pass
19:29dnolenhiredman: yeah that's true. though it's current simplicity is a big win too.
19:29hiredmansure
19:30hiredman(dec Compiler.java)
19:30lazybot⟹ -1
19:30ibdknoxdnolen: btw, the speed difference we were seeing was between having debugging enabled or not
19:30ibdknoxdnolen: without debugging, I get 20ish ms consistently
19:31ibdknoxdnolen: so what about a tmp namespace?
19:32jliibdknox: would gc be able to reclaim if you put vars into a tmp namespace?
19:32ibdknoxjli: good point
19:32dnolenibdknox: seems yucky. we really want locals here
19:32ibdknoxdnolen: I agree it's gross
19:33ibdknoxthe only other thing I can think of is to delete the vars after they're out of scope
19:34dnolenk I gotta run, will ruminate some more, open to ideas!
19:35jlihm, is this all because clojure's truth test needs to do multiple tests against the expression, so needs a local var?
19:37ibdknoxjli: it's to handle an expression
19:38ibdknoxjli: whoops, misread. Yes.
19:40ibdknoxanother terrible solution would be to wrap it in another block of some kind
19:40jlihm, why does it need to test against null and false? are those truthy in js?
19:41jliibdknox: don't blocks not help because there's no block scope?
19:42ibdknoxjli: with
19:42jlisorry, I don't understand
19:42amalloyah, with. a js construct that's only useful when it's misused
19:42ibdknoxhaha
19:42brehautamalloy: its not even useful then :P
19:42jlioh, js/with
19:42ibdknoxjli: there are with blocks
19:42ibdknoxyeah
19:43ibdknoxas I said, a terrible solution :-p
19:44ibdknoxjli: the reason it has to check against those two is because those are the only two false values in *clojure*, but there are lots of false values in JS. So you have to explicitly test for one of those two and no others.
19:45amalloyif ((a = myexpr()) === null || a === false)?
19:46jlioh, right. NaN and such.
19:46ibdknoxand 0
19:46ibdknoxlol
19:46brehautand ""
19:46brehautand undefined
19:46brehautbut not new Boolean(false)
19:46ibdknoxamalloy: that doesn't prevent it from leaking
19:46jlioh christ, really? I thought it was better than that. bah.
19:47hiredmancan't you just have if emit the set of var xN = … it needs before emiting the if?
19:48ibdknoxhiredman: I don't follow
19:48hiredmanI guess that would still be global at the top level
19:48ibdknoxyeah
19:49jlithat seems pretty low impact, given how clojure code is typically written
19:49hiredman(if a b c) would emit something like "var x1 = a; if test(a) then b else c;
19:49jliis it a correctness problem? or more of a style problem?
19:50hiredmanhttps://twitter.com/#!/djspiewak/status/117385222491865088 haha
19:51ibdknoxjli: cljs shouldn't be polluting the global namespace
19:52ibdknoxat the very least, we could wrap all the output in a function to prevent it from leaking out of the cljs scope
19:53ibdknoxthat should probably happen anyways
19:53amalloyibdknox: gensym it
19:53brehautdoes cljs use $ vars for generated symbols?
19:54ibdknoxbrehaut: the closure compiler will
19:54ibdknoxamalloy: it already is, I think dnolen's issue is more of a correctness one. The likelihood that these globals would ever cause issue is very low
19:55ibdknoxamalloy: I could imagine a couple instances where their presence is undesirable though. If it's a particularly large value, it would stick around and eat memory
19:55jlihow much of a speedup did inlining truth give?
19:55ibdknoxin the seq-case, as much as 10%
19:56jlihm :/
19:56ibdknoxit's definitely something we want to do
19:56ibdknoxthose functions are used all over the place in tight-loops
19:57jliso, all these function calls are expensive, but the only (obvious) way to not leak memory and trash global is to use function scope
19:58jliwould it be hard to special-case uses that would pollute global, reverting back to a function call?
19:59ibdknoxjli: I don't know how the compiler works well enough to comment on the difficulty of that. I suspect it wouldn't be too bad, since it already has to know scope at some level. The only case where this matters is when you call code directly.
20:00ibdknoxwhich means I'm not sure we actually care that much
20:00jliwhat did your last sentence mean?
20:00jlioh, you mean when you have a top-level expression?
20:00ibdknoxyeah
20:00jliyeah, exactly
20:01ibdknoxso at worst, we're keeping a var around slightly longer than we probably intend
20:01ibdknoxbut it wouldn't leak, which is the important part
20:03jliibdknox: you mean in the non-top-level case?
20:03ibdknoxjli: yep
20:03ibdknoxjli: the only case I'm worried about is (def x ...)
20:03ibdknoxlet's see what that emits
20:04jliactually, doesn't hooking into closure and using goog.provides prevent the global trashing?
20:04jlier, nevermind.
20:05ibdknoxdef seems to be safe
20:05jliI assumed ns did the top-level function thing
20:05ibdknoxit doesn't
20:05ibdknoxbut I think it probably should
20:05jliseems closer to clojure semantics
20:07ibdknoxI think that's probably the best solution
20:08ibdknoxjust wrap ns's in the function call
20:08ibdknoxand leave things as they are
20:11jlidoesn't that still leak memory?
20:12ibdknoxno
20:12ibdknox(function(window) { ... })(window) prevents anything from getting attached to the global js namespace
20:13ibdknoxso those created vars can be gc'd
20:14jlibut wouldn't they be top-level defs inside the object? I guess I don't see how the runtime can know that it's safe to gc
20:15ibdknoxit can mark and sweep them, but if you define something outside of the context of a function, it's equivalent to writing window.myvar
20:16ibdknoxJS can't deterministically remove that var, since it has no idea what may happen with it
20:16ibdknoxby wrapping it in a function, you ensure that only things that you explicitly attach to the window object will ever leave that scope
20:17ibdknoxonce the function is finished running, the gc can check for things that weren't closed over and remove them
20:18amalloyibdknox: except of course js eval has access to named locals
20:19ibdknoxamalloy: hm?
20:19jliif you had (def mything (if hugeobject ...)), a var would be declared at the top-level of your object, right? isn't that just like "mything"? can the GC see that it was only used for defining mything and get rid of it after mything is defined?
20:19amalloy(function() {var y=1; var z=2; return function(name) {return eval(name);};})() // y and z are closed over even though not named
20:19jliclearly I need to review mark and sweep :/
20:21amalloyibdknox: so certainly *some* things can be gc'ed if you do it this way, but not as many as you might like
20:21ibdknoxamalloy: I assume it checks for eval, but maybe not?
20:21ibdknoxamalloy: that's the only case where that's true, right?
20:21amalloyibdknox: i don't know
20:22amalloyprobably not, in retrospect?
20:22ibdknoxtime for some heap snapshots :-p
20:22amalloyibdknox: i just tried (function() {var y=1; var z=2; return function(f, name) {return f(name);};})()
20:23amalloyfigured you could call this with eval, 'z', but it doesn't let you
20:23amalloywhich is a bit weird to me
20:24ibdknoxnever try to apply logic to JS
20:26ibdknoxamalloy: yeah, I can't actually prove that eval captures them
20:28amalloy(function() {var y=1; var z=2; return function(name) {return eval(name);};})()('z') // 2
20:28amalloyis that what you meant?
20:32ibdknoxhrm
20:32ibdknoxI'm not sure how to look into exactly how that works
20:34amalloyibdknox: i'm not sure what you would be looking into. javascript makes locals available to eval, so if there's an eval then (and here i'm guessing) everything is implicitly captured
20:35ibdknoxamalloy: yeah, I guess it's that simple.
20:36ibdknoxin terms of the problem at hand, I think I'm ok with that being the one case these could escape
20:39td123is there a reason why clojure contrib is in the old releases on this page http://www.clojure.org/downloads but isn't listed on the stable release?
20:40hiredmanthere is no single single download for contrib anymore
21:12gary_posterHi. Is there a way to introspect a module in the repl? example use case: I (require 'clojure.math) and want to just remind myself what the function names are in it.
21:13amalloyns-publics is one way
21:13amalloy,(take 3 (keys (ns-publics (the-ns clojure.set))))
21:13clojurebot#<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0)>
21:13amalloy,(require 'clojure.set)
21:14clojurebotnil
21:14amalloy,(take 3 (keys (ns-publics (the-ns clojure.set))))
21:14clojurebot#<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0)>
21:14amalloyhmph
21:15amalloy,(take 3 (keys (ns-publics *ns*)))
21:15clojurebot(sandbox.proxy$java.util.ArrayList$0)
21:15gary_posteramalloy, cool, got it working locally, thanks. I was able to use (ns-publics 'clojure.repl) and it was fine
21:15gary_posterIs (the-ns ...) better?
21:15amalloygood enough, then
21:15amalloyno, i probably just don't remember what args ns-publics takes
21:16amalloy(doc ns-publics)
21:16clojurebot"([ns]); Returns a map of the public intern mappings for the namespace."
21:16jeremyheiler,(take 3 (keys (ns-publics (the-ns 'clojure.set))))
21:16clojurebot(rename-keys union select)
21:16gary_postercool. thanks again amalloy :-)
21:16amalloyhm. i thought the-ns was a macro, but maybe not?
21:16amalloy(doc the-ns)
21:16clojurebot"([x]); If passed a namespace, returns it. Else, when passed a symbol, returns the namespace named by it, throwing an exception if not found."
21:16jeremyheilerI thought so too
21:17jeremyheilerwhat would be a "namespace" here? Given that 'clojure.set is a symobl.
21:18amalloy,*ns*
21:18clojurebot#<Namespace sandbox>
21:18amalloy,(the-ns 'clojure.set)
21:18clojurebot#<Namespace clojure.set>
21:19jeremyheilercool
21:24jli,(the-ns *ns*)
21:24clojurebot#<Namespace sandbox>
21:25amalloy,(apply = (iterate the-ns *ns*))
21:25clojurebotExecution Timed Out
21:25ibdknox,(take 3 (keys (ns-publics 'clojure.set)))
21:25clojurebot(rename-keys union select)
21:26ibdknoxwhy do you need the-ns?
21:29jeremyheileribdknox: Good catch.
21:30td123hiredman: ah ok, thanks
21:32duck1123does anyone happen to know why lein complains that it can't find the ant jar in my dev dependencies when I do lein deps?
21:32duck1123If I do it again, it works
21:38hiredmanduck1123: consider upgrading lein
21:38hiredmanwhat version are you running?
21:39duck11231.6.1
21:39hiredmanfrom a checkout?
21:40duck1123no, it was just the standard lein install
21:40duck1123just installed 1.6.1.1, we'll see
21:42duck1123no, it's still doing it. I think it's related to my patched copy of Midje
22:19simardis there a function that I could use that would print a message to a relevant place when sending a form for evaluation from emacs through slime ?
22:20simarda relevant place could be, a popup message box, or better, an emacs buffer
22:23jlisimard: isn't it already in the minibuffer?
22:25simardactually, nevermind, I was in the *Message* buffer and not in the *slime-events* buffer.. a println works well
22:25simardjli: the minibuffer only displays the end result though
22:25jlioh, you want something you can get at
22:26jliyeah, *slime-events* seems to have everything :)
22:27duck1123doesn't output show up in the slime repl?
22:28jliduck1123: simard is evaling things from a source file
22:29jlithe repl only prints things you eval in the repl
22:29duck1123right, I thought the output would still show up in the repl window
22:29jlinope
22:29duck1123ok
22:30duck1123to be honest, I set everything to log and have my app up in Guake
22:30jliguake? is that like yakuake?
22:30jlisliding terminal thing?
22:30duck1123yep, I like it a little better than yakuake
22:31duck1123F12 is firmly part of my muscle memory
22:31duck1123you can do the same thing with iTerm2
22:49pdk,(* 21 12)
22:49clojurebot252
22:55jeremyheilerIs there a complete markdown parser written in Clojure?
22:56brehautI've been porting some code to 1.3 and new contrib; i can't find a release in maven for the new clojure.algo.monads. Am i blind or is it just not available yet?
22:56jliis there something in core for (comp first (filter <pred> <coll>))?
22:57brehautjeremyheiler: i believe people are use java markdown implementations
22:57amalloyjli: no
22:57amalloycontrib has something like find-first, but (comp first filter) is at least as readable
22:58jeremyheilerbrehaut: I figured as much. Thanks.
22:58amalloyand you can use (some pred coll) if the predicate doesn't "destroy" information
22:58amalloy&(some #{4 5 6} (range))
22:58lazybot⇒ 4
23:03jliwhoo, ((comp first (partial filter #(= (:tag %) :title))) xmljunk)
23:03amalloyjli: #(= (:foo %) bar) always makes me sad
23:03amalloy(comp #{bar} :foo)
23:03jliyeah, was just trying to replace it
23:04jlisweet. point-free!
23:06jlithis is probably excessive
23:07jli((comp first :content first (partial filter (comp #{tag} :tag))) xmljunk)
23:09brehautjli: you might find clojure.contrib.zip-filter.xml (particular xml-> ) and clojure.zip useful
23:11jlibrehaut: thanks. yeah, I figured this has been done dozens of times before
23:12brehautjli: xml-> and xml zippers a really nice little api for consuming xml too
23:13brehautjli: have a look at https://github.com/clojure/data.zip/blob/master/src/test/clojure/clojure/data/zip/xml_test.clj
23:16amalloytechnomancy: the lein README has a "download the script" link, which works but involves a redirect from github.com/.../raw/... to raw.github.com/... - can't you just link to the canonical location?
23:25amalloythere must be something about project.clj, :main, or uberjar that i just don't get. with a project.clj that looks like https://github.com/4clojure/4clojure/blob/develop/project.clj - lein run works perfectly, running my :main class, but lein uberjar && java -jar the-jar.jar gives NoClassDefFoundError: foreclojure/core
23:28jliamalloy: don't you need :gen-class in core.clj's ns?
23:29amalloydo i? if so that makes me sad; can't the jar be hooked up to run clojure.main pointed at my ns?
23:30jliI think early on I associated "core.clj having :gen-class" with "working", and it's stuck :/
23:30amalloyi mean, i rarely try to produce uberjars, because i don't really need to work on machines that don't have lein or cake installed
23:30amalloybut i'm disappointed that i can't produce one without AOT-compiling my whole damn program transitively
23:33jliIf :gen-class is not supplied, when compiled only an
23:33jlinsname__init.class will be generated.
23:33amalloyjli: well, marking main as gen-classed seems to resolve the issue
23:33jliwhoot
23:34jlior maybe :(
23:34sridhas a version of clojure.contrib to fix "IllegalStateException: Can't dynamically bind non-dynamic var: clojure.contrib.pprint/*format-str*" in Clojure 1.3 been released?
23:34amalloysome of both
23:35duck1123just use clojure.pprint
23:35sridhow did /me get in there?
23:36sridapparently it is one of the modules (lamina, aleph, compojure) that I am using which is relying on clojure.contrib.
23:36amalloysrsly. 1.3 is hard
23:36duck1123What I do is I place a global exclusions in my project for org.clojure/contrib and org.clojure/clojure-contrib and then go from there
23:36sridi hope it is not as bad as python3
23:37amalloythat's an interesting approach, duck1123
23:37brehautsrid: it seems unlikely that it will be that bad ;)
23:38duck1123it's a lot better than it used to be
23:38duck1123The number of libraries I had to fix to get working has gone down a lot
23:40brehautit looks like I'm just waiting for algo.monads 0.1.1 to appear in the mavens and necessary-evil should be 1.3 ready
23:42duck1123ok, I know technically you're not supposed to change anything after a release, but I released 0.1.0 of one of my libraries tonight before I realized that 1.3 was out. Since no one but me uses this library that I know of, do you think it's safe to fix it real quick, or should I do it right?
23:42amalloyduck1123: is that an exclusive-or? because i think it's safe to fix it, but you should do it right
23:43duck1123I'm going to fix it, I think. It's been like 4 hours
23:51jliclojure.set/union works on all collections
23:51jlihuh
23:53gfredericksyeah I found that really strange
23:53jli(reduce conj s1 s2), of course.
23:53jlimy ocaml brain reels