#clojure logs

2011-08-05

00:01scottjflazz: I don't know, (= (Foo. 1) (Foo. 1)) works
00:02amalloyflazz: = works. but as always, reconsider whether you need records or a plain hashmap would do
00:02technomancyamalloy: I bet there's a better name for haskell's juxt if you use latex
00:04amalloyeverything looks better with some latex
00:49Generic_Dumbassi followed the steps on this page and got "1.2.0 MASTER SNAPSHOT" on my Ubuntu rather than 1.2.1, bummer http://riddell.us/ClojureOnUbuntu.html
00:54amalloyclojurebot: blog posts?
00:54clojurebotmake a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive
00:54amalloyhiredman: dang it, teach this bot about blog posts
00:55amalloyGeneric_Dumbass: blog posts get out of date quickly. once you have clojure installed, please do not write a popular blog post about how you made it work
00:55amalloyclojurebot: lein?
00:55clojurebotlein is http://github.com/technomancy/leiningen
00:55amalloygo there instead
00:55Generic_DumbassLol, ok, I won't
00:56Generic_DumbassThanks
01:11kephaleis there a way to have arrays of hash-maps? i need indexed access of an array of maps
01:16kephaleoh object-array… derr
01:19amalloykephale: vectors have fast indexed access too
01:19amalloyarrays are mutable and thus a tremendous pain
01:37tomojlobotomy: if you make any progress on that puzzle problem I'd love to hear about it :)
01:38tomojsome math problems cause me to stay up all night scribbling, this is one. but don't have any more time to think about it now
01:42amalloytomoj: what problem is that?
01:43tomojrepresentation of happy cube shapes for a solver
01:43tomojhttp://happysolver.sourceforge.net/
01:43tomojI was just thinking about shapes in a 3d grid, though, ignoring the representation of the ragged edges
01:44CodeWarin hour 1 of clojure ... dumb question ... can I receive an arbitrary String Buffer containing Clojure code and execute it?
01:45tomoj..receive from where?
01:45CodeWartomoj, ideally off a socket
01:45tomoj:(
01:45CodeWar*from
01:45tomojwho's on the other end?
01:46CodeWarI d like to pass code as data .. sender queues code moves on ... receiver(s) load balance receive code execute
01:47CodeWarright now receivers have certain Java objects setup and we use JMS messages to ivnoke them .. I m wondering
01:47CodeWarif with clojure we dont need to setup these Java objects as receivers instead ship the code directly
01:47tomojit's possible
01:47CodeWarYES!!
01:47CodeWarand I don;'t have to ship .CLASS files right?
01:47tomojuh
01:48tomojif you need any AOT features you have to compile it
01:48CodeWarwell ok receiver can be expected to have some libraries
01:48CodeWarwhats AOT?
01:48tomojlike gen-class, which generates java classes
01:48tomojif you eval it at runtime it won't do anything
01:49tomojyou have to compile it Ahead Of Time
01:49CodeWarfair enough so you ll receive text .. compile generate class and execute it... fine!!
01:49tomojeval is the key, by the way, but I'm almost reluctant to tell you
01:49CodeWarWe can setup a code cache to avoid regenerations
01:49tomojit seems unlikely that that is a reasonable thing to do
01:49CodeWarok whats the catch
01:50tomojbut what you are talking about sounds more complicated than I feel qualified to advise about
01:50CodeWarour stuff is needlessly complicated.... yes
01:51CodeWarbut my take home is that I can ship code as data have the receiver compile and run .. sure it can throw exceptions if it doesnt like xyz
01:51tomojhmm
01:51tomojI guess, just really try to think of a way to do something without eval before using eval
01:51tomojin general
01:51CodeWarwhy so
01:51tomojif you're writing a repl you don't have to think about it
01:52tomojeval can just be used to do terrible nasty things I guess
01:52tomojbut if your thing is not terrible and nasty..
01:52CodeWartomoj, I m in hour 1 of clojure .. quickly whats eval and REPL
01:52tomojread-eval-print-loop
01:52CodeWarmeaning what exactly
01:52tomoj&(class '(+ 1 2))
01:52lazybot⇒ clojure.lang.PersistentList
01:52tomoj&(eval '(+ 1 2))
01:52lazybotjava.lang.SecurityException: You tripped the alarm! eval is bad!
01:52tomojoh, duh
01:52CodeWarah ok .. interpreter right?
01:52tomojit returns 3
01:52CodeWarinterpret and run
01:53tomojdo you have a repl running?
01:53CodeWarno I dont .. just found out what it is
01:53CodeWaryou were tellign me about eval .. and why its bad ... please continue
01:53tomojso just reading about clojure so far?
01:53CodeWaryes
01:53CodeWarread the code-as-data part and my lights went on
01:54CodeWarwe re evaluating writing a query language but if clojure works in sending code as data and it runs on top of JVM and has these libraries heck why not
01:57CodeWarok googlling it seems its not eval but (eval (read-string ...)) that I want
01:57tomojare you generating this code on the fly?
01:58tomojor do programmers write it ahead of time?
01:59CodeWarprogrammers pul it out of their ass and submit .. server/receiver doesn't know how he gets it
01:59CodeWarmy goal is to let client.submit(code-as-string) do a basic syntactic check and pass the string over to server
01:59tomojah
02:00tomojsounds like hell
02:00tomojfor the programmer I mean
02:00CodeWarwell these are SQL programmers used to queries ..
02:00tomojnow they're getting clojure exceptions back
02:00tomojguarantee they're not going to be happy about them :)
02:00CodeWarwe re threatening to give them another query language .. instead clojure looks much more complete
02:01CodeWarwhat exceptions?
02:01tomojif they make any mistakes, attempting to eval the code will cause an exception to be thrown
02:01CodeWartell me this .. can I take an arbitrary string and do basic syntactic test on it without executing it?
02:01tomojyes
02:01tomojbut that doesn't guarantee that the code will run without throwing an exception
02:01CodeWarperfect.. I d like clients to do this before submitting ...
02:01CodeWaryes yes understood
02:01tomoj..or successfully compute the intended result
02:02CodeWarsyntax check means they dont submit Harry Porter
02:02tomojI never want to have to debug clojure I can only run by submitting to some external clojure
02:02tomojer, external server
02:02tomojwell..
02:02tomojno
02:02tomoj&(read-string "Harry Porter")
02:02lazybot⇒ Harry
02:02CodeWarYou let me worry about that .. what we have in place is worse than that so :-)
02:02tomoj"Harry Porter" is valid lisp code
02:03CodeWar&(read-string "(Harry Porter)")
02:03lazybot⇒ (Harry Porter)
02:03CodeWarsh*t
02:03tomojthat's going to try to call a function called Harry and throw an exception
02:06amalloyCodeWar: tomoj is trying to tell you not to use eval, but he's also trying to be polite. if you like, i can tell you that using eval for this is nutso crazy
02:07CodeWaramalloy, thanks I need brutal answers .. it will save me hours/days later
02:07CodeWaramalloy, are you opposed to the idea or the idea of using clojure for it
02:07tomojyeah, I think it's crazy, but I only think that because I've heard so many people say eval is evil
02:07tomojI never bothered to think about why really
02:07amalloy"code is data" in lisps generally refers to the ability, through macros, to construct code out of data *at compile time*
02:07amalloy(if you prefer, "manipulate code like data"
02:08MasseRamalloy: That's actually quite difficult to grok :D
02:08amalloyyou absolutely can use eval for this, and it would be far from the worst use of eval i've ever heard of, but it would be a lot more work than "we'll just send code over the wire and all our dreams will come true". another approach will be easier
02:09CodeWaramalloy, how about a simple examlpe to illustrate the do-es and don'ts of taking code-as-data principle
02:09CodeWaramalloy, there is not another approach.. currently Java and C programmers use builder pattern to prepare a command buffer which is shipped and executed on the server
02:09amalloysounds great
02:10CodeWaryes it givse them a DSL but limited in ability ... in reading clojure it appears if the promise of code-as-data is true
02:10CodeWarthen I can give them a DSL with conditionals / loops / macros / expansions
02:11zvrbaunfortunately, "code is data" does not enable self-modifying code :(
02:11tomojmaybe they can just submit jars, like hadoop?
02:11tomojthen they can run and test the clojure code on their machine
02:11CodeWaris that what hadoop does ... submit entire jars? ;-) well yes that is a possiblity
02:11zvrbabtw, is clojure an interpreter or compiler?
02:11amalloyzvrba: clojure is none of those things
02:11amalloyit is a language
02:11tomojdon't necessarily have to have all the code needed at runtime in the jars they submit either
02:11zvrbaamalloy: but its implementation?
02:12CodeWarwell its a bit more complex than that but I can explain how the server side works if folks are interested..
02:12zvrbaamalloy: does it interpret S-exprs directly or does it compile them to some bytecode?
02:12amalloyit is compiled, at the moment, but so what? you could write an interpreter
02:12zvrbai could, but it's not feasible.
02:12hiredmancompiler, which in some limited cases for interactive use it interprets
02:13hiredmanhttps://github.com/hiredman/Arkham
02:15CodeWarhiredman, not sure if this is relevant for me but *eval is evil* aside I m trying to understand the feasibility and then try to appreciate the real life problems of ..
02:15CodeWar<a> compiling arbitrary user passed in string <b> shipping the compiled form of <a> <c> executing <b>
02:16zvrbaCodeWar: the problem is that the user can pass a string that will format your hard drive.
02:17zvrbaCodeWar: for example.
02:17amalloyCodeWar: one example of how this can go wrong, presuming you're smart enough not to expose this api to the public and create "clojure injection vulnerabilities"
02:17CodeWarsecurity is a nightmare ... point noted and respected .. enxt
02:17CodeWar*next
02:17zvrbaCodeWar: or copy all your private files to some server.
02:17amalloyeven your best-trusted engineers will make mistakes and, for example, bring the server to its knees by accidentally sending it a fork bomb or a memory leak or...
02:17CodeWarzvrba, or empty my ex gfs bank account .. understood
02:18zvrbaCodeWar: or download CP.
02:18amalloyCP?
02:18amalloyoh
02:18zvrbachild porn
02:18CodeWarzvrba, these are all virtualization problems not language problems .. any language can and crap things .. next problem please
02:18zvrbaCodeWar: well, yes, with a proper sandbox you can limit what resources are available.
02:19amalloyCodeWar: the point is that these are neither language problems nor virtualization problems. they're problems you introduce by your "algorithm", which is "let other people supply the algorithm"
02:19CodeWarwhat he can or cannot do is meant to be checked by OS / virtualiation layer and other sandboxing layers not give the programmign language a tough time
02:19CodeWaramalloy, point noted ...
02:20zvrbaCodeWar: but how do you prevent the user-supplied code from modifying the rest of your program's logic?
02:21CodeWarzvrba, you submit a stringbuffer which *is* your program ... if it doesnt throw exceptions generate runtime errors it may succeed
02:21hiredmanif the clojure compiler had more hooks to guide compilation it would be easier to sandbox clojure code
02:21CodeWarsucceed here means side effects of program on server data are globally visible
02:21zvrbaCodeWar: but that code executes in some larger context? how do you prevent it from modifying it?
02:22CodeWarhang on let me write some pseudo code .. the bulk of logic is not in clojure its in primitives
02:22hiredman*shrug* there are things you can do
02:22ataggarthas anyone here successfully done anything in the repljs? I get errors for every little thing.
02:23hiredmanI may even start allowing defs in clojurebot, given that it runs sandbox code in a seperate clojure runtime now
02:24hiredmanso sandboxed code would have to try pretty hard to alter the clojure runtime that is actually executing clojurebot
02:24hiredman,*clojure-version*
02:24clojurebot{:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"}
02:24CodeWarhttp://pastebin.com/0AP6UJF7
02:24hiredman(clojurebot is running under 1.2)
02:25CodeWarI only need clojure as a glorified DSL ... with loops conditionals and variables .. no real code or function calls will happen there
02:25CodeWarwe expose atoms and tiles for real code and its memory and until (transact ...) succeeds side effects are not globally visible
02:26CodeWarbut what I m taking away from here is .. its probably better to execute clojure on the client have it spit out the command buffer then ship commandbuffer .. only problem is now I ll need to write my own command buffer interpreter on the server
02:27zvrbai guess it would be possible to write a macro that parses a DSL
02:27zvrbaor returns an empty list on error
02:27CodeWarand generates the command buffer... soudns pretty good
02:27CodeWarperhaps I could do that in LISP ... I dont really need JVM here
02:28CodeWarwell I have truly 4 functions .. serial concurrent wait stream .. I d like to use the language to actually invoke these cals on the server
02:29CodeWarelse I ll have to write my own command buffer interpreter
02:30CodeWarguess while explaining the problem I answered my own queries ... 4 commands write your own interpreter .. let cleints use Java/C builder pattern to generate cmd buffer
02:30amalloyCodeWar: writing a DSL intepreter is just Not Hard
02:30CodeWaryes
02:31CodeWarI ll start with a switch statement and see where I go from there thanks everybody
03:03lobotomytomoj, i have already solved the happy cube probem ;)
03:03lobotomybut that was in java... the clojure version will look rather different, for obvious reasons
03:03lobotomy(haven't had time to proceed with that yet)
03:05tomojoh, right, you already figured out the part I'm stuck on
03:06tomojhow do you represent a target shape?
03:06lobotomyat which level?
03:07tomojhmm.. so you're filling in faces of the shape, you need to know which faces in the shape are open, and for a given face, which other faces you need to check for edge compatibility
03:07tomojat that level I guess
03:09tomojor do you cut the problem differently
03:09lobotomythe user at first gives a bunch of 3-d coordinates that define where the shape extends to
03:09lobotomye.g. [0,0,0], [0,0,1], [0,1,0] is an L kind of shape
03:10lobotomythen i loop through those, constructing a basic cube at each point, and merging it with the existing structure, linking the edges together and eliminating redundant edges
03:10lobotomyalso i keep track of holes, eliminating redundant ones; a Hole is basically a collection of 4 MutableEdges
03:12tomojso the only shapes are multiple cubes stuck together?
03:12lobotomyhmm... there's not really a shape; there's just a "graph" of sorts consisting of MutableEdge objects
03:12tomojright, I mean..
03:12lobotomyanyway, every possible shape for the arbitrary case is basically "cubes melded together"
03:13tomojthe only structures you ask the thing to solve for are multiple cubes
03:13tomojno faces can be missing or something
03:13lobotomyhm, you mean you want to also solve for e.g. a "double decker" structure, but with the top piece missing?
03:14tomojI don't, but I was thinking of the problem that way
03:14tomojrepresenting arbitrary collections of faces in a grid really
03:15lobotomyyeah, some other kind of representation might be better for this, i haven't really explored it that much
03:15clojurebotamac: So it's a seq of connections? And what do you do with them? I understand what disjoined sets look like, but the representation and iteration is where I run into trouble.
03:15tomojhow about a 2x2 cube with nothing inside?
03:15tomojoh
03:15tomojthat's just 8 cubes and you remove the guts?
03:15lobotomyyeah
03:16tomojoh, hmm
03:16lobotomyconsider the double decker; it's just two cubes, with the two holes in the middle removed, redundant edges removed, the appropriate edges linked together
03:16tomojI didn't think well about it :)
03:16tomojI thought you could have two cubes stuck together with the inside face included
03:17tomojlooking at the pieces it is obvious that isn't possible
03:17lobotomybuilding the arbitrary structures was by far the hardest part of this. took me months to get it correct (well, i wasn't working on it full time, but still). debugging was quite hilarius ;)
03:17tomojwait.. could it be??
03:17lobotomyhey, you could have the piece in the middle be halfway inside one cube and halfway inside the other ;)
03:18amalloyclojurebot: wow, well done on the contribution so on-topic i thought it might be someone else saying it
03:18clojurebotI'll be in the brig with a bottle
03:19tomojbasically can you build two cubes with one missing face which fit together?
03:19tomojer, no
03:19lobotomyyou could, but isn't that more demanding?
03:19lobotomyfor each five-piece cube with one missing face: find all other five-piece cubes with missing faces that happen to fit it
03:20lobotomyinstead of just a simple dfs on the whole thing
03:21lobotomywell, if you want the dfs to find every solution, then that'll take the same amount of time as the previous idea, but... ;)
03:21tomojI mean can you build a six-piece cube where one face has spots left open
03:21tomojby using pieces that don't really fit together
03:22tomojI am going to have to buy some of those..
03:24lobotomyhahah, this indeed demands that you have a set of the physical cubes, otherwise it's so much less fun ;)
03:37MasseRDamn, I still haven't grokked the (ns syntax :/. I get 'Don't know how to create ISeq from clojure.lang.Keyword' when trying to (ns foo.bar.baz :use ['foo.hello])
03:38amalloytwo mistakes there, i'm afraid
03:38amalloyMasseR: why don't you pick an open-source project (doesn't matter which) and compare their ns forms to yours?
03:39Generic_DumbassSo (rem 1 4) is 1, and (/ 1 4) is 1/4. What operator gives 1 / 4 = 0, equivalent to what Python outputs?
03:39MasseRamalloy: Even that would be overkill. I have somewhere in my harddrive examples, loads of them. Rather I'm trying to learn by making mistakes :)
03:39amalloyGeneric_Dumbass: i think that's the "use shitty math" flag
03:39lobotomy,(int (/ 1 4))
03:39clojurebot0
03:40amalloy&(quot 1 4)
03:40lazybot⇒ 0
03:40Generic_Dumbassfacepalm. thanks
03:40tomojMasseR: (doc ns)
03:40amalloytomoj: man, the ns docs suck
03:40tomojthe example there corrects your first mistake
03:40amalloy~ns form
03:40clojurebotDon't bash in place
03:41amalloy...
03:41tomojalso, you don't quote things inside ns like you do when calling use/require/etc directly
03:42MasseRtomoj: The problem was/is that I don't really know what I'm doing (yet). Meaning that I can't see the difference between a function that takes keywords and arguments, compared to function that takes evaluated arguments
03:42tomojns is a macro
03:43tomojit gets to decide what to evaluate and what not to
03:43tomojit doesn't evaluate anything though
03:43MasseRWhich doesn't make it easier to reason :D
03:43tomojat least, I don't think it does..
03:44tomojsure, but at least (doc ns) doesn't contain any '
03:44leonid,(doc ns)
03:44clojurebot"([name docstring? attr-map? references*]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class .....
03:44MasseR"except the arguments are unevaluated and need not be quoted"
03:45MasseRSomehow it seems now plain as day, compared to last week when I checked from clojure api docs o.O
03:45tomojthe use/require docs are hard to understand at first
03:45tomojbut as it says each arg is either a lib name or prefix list or flag
03:45raekclojurebot: ns form |is| http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns
03:45clojurebotRoger.
03:45tomojhuh
03:46tomoj(use [foo]) actually works though
03:46tomojer, (use '[foo]) :)
03:46raekyeah, zero options
03:46raek(use '(foo)) is different
03:47raekzero namespaces starting with the prefix "foo"
03:47tomojoh, right
03:47tomojs/lib name/libspec/
03:53amalloyraek: the thing is, i know technomancy taught him about the ns form already. but i can't ever say the right words to get clojurebot to say what he's learned
05:40wjlroeI'm trying to set SSL options to be used by Leiningen (for deploying artifacts and downloading dependencies), and this hook in init.clj isn't working: https://gist.github.com/1127209 Anyone know why I get that error?
06:15ejacksonI think I have found a bug in clojure.test where the report multimethod is not declared dynamic, and hence libaries such as clojure.test.junit, which rebind it, don't work. Anybody have time to give it a quick glance ?
06:35jsankeyejackson: see http://groups.google.com/group/clojure-dev/browse_thread/thread/232e2a080a932520/b29528df06b580f7
06:36ejacksonjsankey: cool, thanks.
07:01ordnungswidrighi
07:01duke39'ello
07:02ordnungswidrigI'm looking for a simple RPC lib in clojure.
07:32jonasenI'm struggling with macros in clojurescript. Where should I put my macros so that they are available to my cljs scripts? I'm compiling my project with 'cljsc src/ > app.js'?
07:32chouserjonasen: you need to use :require-macros in your .cljs file's (ns ...)
07:33jonasenchouser: I have that. but I keep getting FileNotFoundExceptions. It's a classpath issue I think
07:34chouserah, sure.
07:35jonasenchouser: also, I think the docs are wrong as they say :refer-macros instead of :require-macros
07:36chouserI put my foo.clj in the same dir as my foo.cljs
07:39jonasenchouser: That don't seem to work for me.
07:57chousermy foo/bar.cljs has (:require-macros [foo.bar :as fb])
07:57chouserthen I use macros from foo/bar.clj like: (fb/mymacro ...)
07:58chouserI don't think I'm doing anything else worth noting.
07:59jonasenand you can compile it with cljsc?
08:21JochenRquestion: is there a way to catch multiple exceptions in one clause like in new java 7
08:23JochenRlike (try ... (catch [ExA ExB] e (dosomething e)))
08:24Vinzentbtw, what do you think about binding *error-handler* and "pushing" it to stack instead of try\catching? is there any libs using this approach?
08:25VinzentJochenR, not with standard try\catch, i think
08:25jonasenchouser: Here is a gist of the problem https://gist.github.com/1127420
08:26JochenRhmm, is it possible to expand a macro to multiple forms
08:28Vinzentno, you should wrap the outer form in your macro
08:28JochenR(would allow a kind of catch* macro to generate multiple catch clauses))
08:28raekJochenR: let it expand to a do form
08:28raek(catch ...) is not macroexpanded
08:28JochenRraek: I believe catch-es will only work on top level below try
08:29VinzentJochenR, you need try* as well
08:29JochenRVincent: looks like you are right :-(
08:29raekwhat Vinzent said. :) try is a special form and defines the meaning of catch, which does not exist on its own
08:29raek,catch
08:29clojurebotraek: Titim gan éirí ort.
08:29Vinzent(but I believe it's already done, try googling for try+ (can't remember the name of that lib...))
08:30JochenRI tried to google, but try and catch are not very unique terms :-)
08:31raekI made a lib that has a try+ form, but I dunno if that's the one you are thinking of
08:31JochenRah try+, found it. Thanks Vinzent!
08:31JochenRraek: is this yours at github/scgilardi?
08:32raekno, I'm "raek" at github too
08:33JochenRthanks a lot, will check it out!
08:35Vinzentraek, so, when you was writing that lib, you thinking about bindable hanlder instead of usual try\catch?
08:35MasseR\o/ My programming clojure book came in today
08:36Vinzentit looks more functional and allows to pass context easily
08:39raekVinzent: no, I just wanted a way to define new "exceptions types" in Clojure
08:39raeka condition system like error-kit would be more nice
08:40kephaleamalloy: long delayed reply W.R.T. array v vector, is there a better way to set the value at an index in a vector than the concat based techniques? i'm porting an experiment that is mostly "random-access" R/Ws to a 40,000 element collection. it is the kind of thing that would normally make me consider wrapping some java code. i've had some issues in the past with using vectors in such situations
08:40VinzentMasseR, congrats! :) is it halloway's book or the new one? (they have very similar names, always mixing them up)
08:41Vinzentraek, ah, ok
08:41MasseRVinzent: Sorry, I'm horrible with peoples names :D
08:41MasseRI doubt I've even read who wrote it
08:41raekkephale: assoc
08:42raekvectors are built to support random access updates
08:42raek,(assoc (vec (range 10)) 5 100)
08:42clojurebot[0 1 2 3 4 ...]
08:43raek,(assoc (vec (range 10)) 4 100)
08:43clojurebot[0 1 2 3 100 ...]
08:43kephaleraek: oh…. i should have known that… thanks!
08:44raekconcat does not work on a data structure directly, but on a sequential view ("sequence") of the data structure (which you can accuire by calling seq or rseq on it)
08:44Vinzentbtw, why assoc works on vectors, but dissoc doesn;t work?
08:44raekVinzent: vectors don't allow "holes" in the index range
08:44raekbut you can dissoc the last element, I think
08:45raek,(dissoc [0 1 2] 2)
08:45clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.IPersistentMap>
08:45Vinzentno, I mean this behaviour: (dissoc [1 2 3] 0) => [2 3]. it may be implemented with subvec
08:45kephalehrm… although not now, i do need dissoc in a similar situation
08:45kephalenow that Vinzent brought it up, that was the situation where concat was a huge slowdown
08:45raekVinzent: that operation is not possible to do efficiently on a vector the way they are structured
08:46raekyou need to rebuild the internal tree for all the elements after the one you want to remove
08:46Vinzentraek, but subvec calls is O(1)
08:47raekI was thinking of the general case of removing one element in the middle
08:47raekbut I'm not totally sure how subvec is implemented
08:48kephalei've had an issue with a 10,000 element collection that needs 1,000 elements removed
08:48raekkephale: so why do you need to remove them by index?
08:48kephalein code that is agent based, so the removing process turns out to be really expensive since the elements to be removed aren't contiguous
08:49raekkephale: would (vec (filter predicate the-vector)) work?
08:50kephaleraek: not really, the process goes like: grab 7 random indices, compare the values of a key, remove element with the minimum
08:50raekhrm
08:50raeka set is better if you easilly want to remove an element
08:51raekbu then you need to be able to pick some random elements
08:52kephaleraek: good point about sets, i'm going to have to check to see if that would work
08:53raekif you somehow can get 7 random elements from a set, I don't think you need vectors and indices at all
08:54kephalei am thinking a clever predicate for select might work for getting hte random elements
08:54kephalethe*
08:57depyGuys.. I heard that in lisp (clojure) you shape the language so that it solves the problem better not like in OO where you shape the problem so you can solve it with OO
08:58depybut, haven't seen any good sample/program that would show this style.. any suggestions where to look?
08:59ordnungswidrigdepy: practical common lisp has a section about this where the author is "deriving" a unit test library.
08:59ordnungswidrigdepy: it's not clojure but easily translatable
09:00ordnungswidrigdepy: http://amzn.to/qI3oQk
09:01depywhich chapter? :)
09:03HodappOO is like violence. If it doesn't work, you just need more of it.
09:04ordnungswidrigHodapp: *g+
09:04Hodappbah?
09:04depyI mostly agree with you. but it's the most popular so it's gonna stick with us for a while ...
09:04ordnungswidrigdepy: chapter 9, page 103++
09:05depythank you!
09:05ordnungswidrigHodapp: I mean't "*g*"
09:06Vinzentdepy, you can take a look at compojure syntax, or cgrand's moustache (and enlive), or clojureql, also try googling "clojure binary files parsing" (or something similar) - there is small example of building sort of DSL on top of the java api
09:07depyWill do that...
09:08depyHavent really found time to learn clojure properly.. Gotta do the diploma first :/
09:09wjlroeThis is crazy - every time I try to compile something on Linux that uses a Java library, `lein compile` just hangs doing nothing
09:11Hodappdepy: It is interesting to see, though, how OO has varied so much from its original instantiation by Alan Kay.
09:12depyDon't know much about that I must say.. ^^
09:12HodappLook it up sometime. He wrote extensively on it.
09:13depyWill do
09:14jcromartiedepy: another good book is SICP
09:14jcromartiehttp://mitpress.mit.edu/sicp/
09:14HodappI need to read SICP
09:14jcromartiedepy: it gets into the kind of composition and abstraction that really works well in Lisp
09:15jcromartieand concepts like closure (not anonymous functions) of a set of functions over their inputs
09:15jcromartiecombine that with macros that fit your problem, and you get pretty close to a "sweet spot" as you can get in any language
09:15HodappI was going to use the 1986 videos with Sussman and perhaps lead a group through SICP with me
09:15Hodappbut that's a big time investment
09:15jcromartieyea
09:15depyBut it's surprising how many people still write procedural code. I'm Java programmer and I have 4 coworkers that use php. And most of the code they wrote is still more like procedural than OO.
09:16jcromartiedepy: I think it's the default for people to think in steps
09:16depyI agree
09:16jcromartieand I make full use of let bindings to do the step-by-step sort of stuff where it is simple
09:16depyHodapp I'm waiting for Clojure SICP to be finished.. :P (bad excuse actually)
09:17Hodappdepy: psh :P
09:17jcromartiedepy: yes, bad excuse... Racket is nice!
09:17HodappI wonder how well SICP could be adapted to Clojure
09:17jcromartieHodapp: it would be pretty simple
09:17edwdepy: I would guess that an inexperienced procedural programmer might make less of a mess than an OO one. Playing with a knife vs a shotgun...
09:17dnolenI think that SICP in Clojure wouldn't be very useful IHMO
09:17Hodappdnolen: Why's that?
09:18dnolenSICP is not that functional, you'll be fighting an uphill battle once you get the parts that involve state.
09:18depyThere's SICP book for clojure in progress I think
09:18MasseRThe link was in here yesterday
09:18depyhttp://sicpinclojure.com/ <-
09:18jcromartieSICP doesn't introduce assignment for a while, and when it does I think atoms would be fine
09:18dnolenScheme and Clojure are different enough that it will be very frustrating
09:19ambrosebsdnolen: that was my first reaction
09:19Hodapphmmm
09:19ambrosebsscheme is so simple
09:19edwMost people's minds get blown way before the non-functional parts of SICP. And Clojure isn't some Haskell-like state-hater of a language.
09:19jcromartieand once they get to assignment, they go on to streams and it's back to functional style
09:20jcromartiesection 3.3 introduces modeling with mutable data. 3.4 addresses concurrency, and 3.5 introduces infinite lazy sequences of inputs that map to outputs as a better way to manage state
09:20jcromartiethe rest can all be done with atoms for local state just fine
09:20dnolenthis SICP in other languages in just baffling to me. You have an amazing easy to install Scheme - Racket, why add complexity to an already tough book.
09:20jcromartieyeah I'll say it again: Racket is *nice*
09:21edwjcromartie: Yes, SICP realizes that assignment is a Pandora's Box and reflects an intelligent, not Clojure-incompatible way of thinking about.
09:23Hodappif you're going through SICP, is Racket a good Scheme implementation to use?
09:23edwI see Clojure as a godsend. I am a Schemer at heart trying to get stuff done in the Real World.
09:24edwHodapp: Ugh, no. Try Scheme48.
09:24ambrosebsedw: ah, so these people do exist :)
09:24edwambrosebs: My web framework in Scheme: https://github.com/edw/magic
09:25depyhow hard is to go from clojure to for example lisp, scheme, ... ?
09:25depyor is it better to learn lisp/scheme first then go clojure?
09:25edwHodapp: Scheme48 has a module for SICP-compatibility, I believe. As does MIT Scheme.
09:26edwdepy: I'm sorry, I missed the beginning of your conversation; what are you expeirenced with right now, language-wise?
09:26depyjava :) and I know just a little of clojure
09:27depyAnd I'm not very interested in scala :P
09:27dnolendepy: if you want to learn Clojure learn Clojure. Scheme is very much a different language.
09:27dnolenpersonally I'm not much of a fan of standard Scheme outside of papers. Racket is more my speed.
09:28edwI think Scheme might be a nice "now for something completely different" way of getting completely away from Java Land and learning some concepts that will come in very handy for you as you program in Clojure, JavaScript, and many other languages. But I think the best way to learn Clojure...is to learn Clojure.
09:28Vinzentdepy, I think it's better to learn java (if not already), then go to clojure :)
09:28depyI know java.. :)
09:28depySo Clojure then... :)
09:30edwdnolen: I think the Racket people are fundamentally unhinged. The whole point of Scheme (and Lisp) is to keep the syntax insanity at bay, yet they've undertaken a profound pollution of Racket with a million little distinct domain-specific languages. It's insanity and a repudiation of what's appealing about Scheme and other Lisps.
09:31ambrosebsedw: re: web framework, I must confess I've never seen a real scheme project in the wild
09:31ambrosebsfacinating :)
09:32dnolenedw: not surprising they are language researchers. But there's a core set of functionality that is quite useable.
09:33edwdnolen: I hear you, but I'm reminded of a comment from the art director of Wired magazine, to the effect that you can't make progress if you don't make mistakes. My question to the art director, and to those guys down in Texas, is whether it's vitally important to publish your mistakes.
09:34dnolenedw: and then you have the opposite, standard Scheme which is so anemic every Scheme implementation feels compelled to reinvent data structures, concurrency constructs, all with different apis. Yuck.
09:36edwdnolen: I and much of the Scheme community don't disagree about the folly of a minimal, crystalline, "perfect" Scheme.
09:38dnolenedw: I'm sure, but the community is fractured along those lines.
09:38edwdnolen: With Racket, there's so much kruft that it's hard to find the useful stuff. For example, they have a datalog implementation in there, but it's extreemely difficult to figure out how to use it from Scheme because there's so much information about their pointless from-the-ground-up DSL.
09:39dnolenedw: I'm not in disagreement about that.
09:40edwdnolen: True. And that's why I've written several orders of magnitude more lines of Clojure than Scheme in the last six months. Again, I'm a Schemer trying to get by in the Real World, and I love Clojure as Clojure.
09:40kjeldahlOn data read with table.read, I can scale a column with data$Col=data$Col/data$Col[1] (scale to 1 based on first value). On a table read with read.zoo this fails miserably, setting all rows to a constant 1. I've tried going back and forth between data.frames and zoo objects, but that fails in other ways (for me). Any easy ways of doing such operations directly on the zoo column?
09:41kjeldahlOops, wrong channel, sorry.
09:49edwdepy: BTW, if you're interested in learning Scheme at some point, you should check out Geiser, a very appealing alternative to SLIME that works with Racket and Guile. It works inside Emacs which given your background may not be something that you're already familiar with. http://www.nongnu.org/geiser/
09:51dnolenGeiser is awesome
09:57edwdnolen: Yeah, it's what led me to give Racket another try.
09:58depywhat's Geiser?
09:58edwCheck out the link I posted above.
10:00depyI prefer vim :D
10:00depyBut could not get clojure plugin runnign in vim :/
10:02edwWhen Michael Schumacher asked me if I wanted to drive his car for a few hot laps, I asked if it used Bosch sparkplugs, he said no, so I declined and instead drove an '84 Taurus that did.
10:04depyNo funny... :)
10:04depynot*
10:04edwSometimes tools choose you...
10:05edwEven outside Soviet Russia.
10:07cemerickIn a world where certifiable geniuses prefer notepad, tool preference is purely cultural.
10:08edwOut of curiousity, who's the Notepad-using genius?
10:09kephalecemerick: perhaps a slightly hyperbolic statement
10:09edwOf course.
10:09edwWe are friends here. We understand.
10:10cemerickpart making a point, part being a PITA ;-)
10:10kephalemmm, but when it comes down to the vim v. emacs argument, you're right on
10:11cemerickedw: It was someone working on/at a particle accelerator — I think the one on Long Island.
10:11edwcemerick: My attitude is if a tool does something you need, suck it up and learn it. I have yet to see anything for vi that rivals SLIME, which I consider a disgusting kludge that happens to work,
10:11cemerickBrookdale something. Anyway.
10:12cemerickIt's the "need" part that gets tricky.
10:12edwcemerick: A close collaborator of mine used Notepad for HTML extensively back in '99. She was one of the brightest people I've ever worked with.
10:14edwcemerick: All I *need* that only Emacs provides is Paredit and good indenting in general. Is there anything else with a Clojure mode anywhere as nice as clojure-mode + paredit?
10:14cemerick=> (= (* 2 *anecdote*) *data)
10:14cemericktrue
10:14cemericknice! :-D
10:14cemerickAs long as the proportion of our time that we spend typing code into the computer is low (and hopefully declining!), editor selection is a non-issue in the large.
10:14jcromartieedw: as far as I know, Emacs+paredit is unmatched by any other editor
10:15cemerickccw's paredit impl is surely more basic, but perfectly reasonable IMO.
10:15edwcemerick: CCW?
10:15chousercemerick: keep saying that. I want it to be true.
10:15jcromartiewhat is ccw?
10:15kephalecounterclockwise
10:15cemerickccw?
10:15jcromartiewhen people watch me code with Paredit, they are always amazed, because there's really nothing like that for editing the structure of other panguages
10:15clojurebotccw is http://github.com/laurentpetit/ccw
10:16chouserre: typing (key bindings) being low priority
10:16pyreditor wars are so 1990's
10:16cemerickthat's totally not the right link
10:16cemerickhttp://code.google.com/p/counterclockwise/
10:16cemerickclojurebot: ccw is http://code.google.com/p/counterclockwise/
10:16clojurebotYou don't have to tell me twice.
10:16cemerick'course, the github one will linger
10:16edwjcromartie: Yes, there's no reason there should be a similar thing for C-like langs. Splicing, barfing, slurping. I sometimes use Paredit keys while editing JS.
10:17edwAnd then I cry a little.
10:17edwWhen it doesn't work.
10:17jcromartiehah
10:17ejacksoni violated my 'never upgrade anything - it'll just break' rule today to move up to 1.3. Ensued an upgrade of the entire toolchain. The swank etc went really nicely. Insist on getting CDT working now.
10:17jcromartiewell Paredit has its issues with Clojure... {} doesn't work right
10:17cemerickI've long used the "expand selection" shortcut in eclipse/netbeans for non-lisps.
10:17timvisherhey all
10:17ejacksonjcromartie: there are ways around that
10:18edwOh gawd, Eclipse!
10:18jcromartieejackson: I guess I could bind { to input {}
10:18cemerickedw: surely a sign of the coming apocalypse ;-)
10:18timvisheri've discovered a bug in my web app where I kick off two requests and basically end up with a bug in my implementation of shared state where I get duplicate entries that I don't want
10:18edwcemerick: LOL.
10:18timvisheri'm trying to figure out how to write a test that exposes that bug so that I can fix it and be defended from it in the future
10:19ejacksonjcromartie: i nicked this snippet off somebody: https://gist.github.com/1127627
10:19edwjcromartie: { inserts a balanced pair for me. It doesn't work for you?
10:19jcromartieooh nice ejackson
10:19timvisherdo i need to get into the Executors framework or something like that or is there a simpler way to get that going?
10:19jcromartieedw: nope
10:19edwIn Emacs?
10:19edw?!
10:20edwjcromartie: Seriously, { doesn't work for you in Emacs+clojure-mode+paredit?
10:20jcromartienope
10:21timvisherjcromartie: what's your mode line read like?
10:21edwHow old is your Paredit? It works fine for me.
10:21timvishermine (Clojure Hi Paredit hs mate o^o ws Fill)
10:21edwGet thee to Riastradh's ftp server!
10:21jcromartie[(Clojure Slime Paredit AC)]
10:22timvisherhmm
10:22timvisheryou appear to be in a recursive edit
10:22timvisherdoes typing C-M-c remove those brackets?
10:22edwjcromartie: I have version 22 of Paredit. What's yours?
10:22jcromartieno, it raises the Debugger
10:23timvisherah, perhaps C-]
10:23jcromartie20
10:23timvisherhmm
10:23timvishertry M-x abort-recursive-edit
10:24timvisheri don't know why it would, but i'm wondering if recursive editing messes with your bindings
10:24jcromartieI'm restarting Emacs :P
10:24timvisherhas this worked for you in the past?
10:24jcromartiebecause I've got some mess going on with my clojur emode hooks
10:24jcromartiedunno
10:25timvisherhow did you install everything?
10:25timvisherdid you use elpa?
10:25edwtimvisher: OMG, do you really want to hear the answer to that? :)
10:25jcromartietimvisher: yes
10:25timvisherok
10:26timvisheredw: to what, my original question when i got here, or to what i just asked jcromartie? :)
10:26jcromartieafter a clean restart, with mode of (Clojure Paredit AC), { just inserts {
10:26timvishercause i really want to know the answer to that. :)
10:26timvisherwhat does C-h k { return for you?
10:27timvisherfor me it's bound to paredit-open-curly
10:27jcromartieself-insert-command
10:27jcromartieI think I need to update paredit
10:27timvisherwell that's your problem
10:27timvisherC-h v paredit-mode-map
10:27liquidproofhey guys, what's the difference between a future and an agent
10:29jcromartieElpa paredit is only v 20
10:29timvisherhave you udpated elpa to technomancy's version?
10:29jolyliquidproof: an agent has a message queue and processes messages sent to it. A future runs a single computation. I believe their threads are pulled from the same thread pool
10:29timvisherare you on 23 still?
10:30jcromartiehm, yeah probable
10:30timvisherM-x version
10:30jcromartieEmacs 23.3.1
10:30jcromartiepackage-el-version is 0.9
10:30liquidproofjoly: I see, thanks
10:31timvisherjcromartie: i'd work through this post: http://technomancy.us/144
10:31timvisherthat should get you going with the elpa that everyone's actually using and updating
10:32timvishermine's 1.0
10:32timvisheri'm still on 23 as well
10:32timvisheri have paredit version 22 installed
10:33jcromartiehm
10:33timvishervery strange though that the paredit.el file that is linked to in the documentation for the paredit-open-curly function doesn't actually appear to define that function, nor is it defined in paredits mode map
10:33jcromartiemaybe time to nuke my elpa then
10:33timvisheri have no idea how it's working
10:33timvisherit's possible
10:33timvisheri believe that's what i ended up doing when i did the manual package.el upgrade outlined in that post
10:34jcromartie*le sigh*
10:34jcromartiepackage.el depends on tabulated-list
10:34jcromartieWTF i sthat
10:35timvisher ah, it looks like those might be generated at runtime, that makes sense
10:35timvisherlol, that's interesting
10:36jcromartieI'm using this
10:36jcromartiehttp://emacsformacosx.com/
10:36jcromartieit looks like it doesn't have tabulated-list-mode
10:37timvisherwell, i'm out of 'expertise' at this point, but gl. https://gist.github.com/1127670 is the exact copy of package el that i'm using
10:37jcromartiethat's different from the one in technomancy's post
10:37timvisheri don't have tabulated-list-mode installed either
10:38ejacksonjcromartie: yeah, my setup is identical
10:38timvisheri did download it awhile ago so it's probably different considering that technomancy linked to head
10:38timvisherHEAD*
10:38ejacksonand rebuilding everything today there was no mention of tabulated-list-mode
10:39timvisherjcromartie: is your .emacs heavily customized?
10:39timvisheri installed the version of emacs i'm running using brew, also
10:39timvisherdon't know what the differences are there
10:39timvisheroh well, gotta get back to work
10:39jcromartietimvisher: yes
10:40ejacksonjcromartie: I pulled paredit out of elpa/marmalade
10:43jcromartiewhat's your .emacs look like, with regards to package.el?
10:43jcromartiebecause now I've got more issues
10:44ejacksonnothing fancy: https://gist.github.com/1127677
10:46jcromartiealright I think I've got it
10:46jcromartieclojure mode, paredit, etc. all back in action
10:46jcromartieslime
10:46jcromartieyay
10:46jcromartieOK thanks guys
10:46jcromartieand { works :P
10:46jcromartieall to save me a }
10:47ejacksonthat's how it goes
11:26dnolenpattern matching is going to take a lot of pain out of macro writing.
11:26paul__hello peoples!
11:27PPPaulhello peoples
11:27jweissis there a way to prevent the repl from deref'ing a promise object just by trying to print out an object containing one? eg, at the repl put {:hi (promise)} - i'd like it to print something like {:hi <promise$objectblahblah>}
11:28PPPauli'm using lein, and i have a dir struct like: src -> transaction_migration -> import_inv
11:29raekjweiss: I think you can redefine the print multimethod implementation for promises or something
11:29PPPauli want my ns name to be small, am i allowed to name it just import_inv, or do i have to name it transaction-migration.import-inv?
11:29raekI know people have done this for refs
11:29raekjweiss: another solution is to set *print-level*
11:29jweissraek: ok, that is what i thought, any idea what it should do to get the <> string like when it's a java object?
11:30jweissi suppose i could just print "<promise>"
11:30raekI think it does something like (format "#<%s %s>" (class x) (str x))
11:31stuartsierra1.3 betas print "Pending" things as <TypeOfThing :pending>
11:31jweiss(str (promise)) blocks too :)
11:31jweissoh fun and i can't even C-c C-c out of it in slime either
11:32raekyeah, the .toString implementation of promises calls str on its content I think
11:33jweissoh wait nvm "clojure.core$promise$reify__5542@3fa768de"
11:36raekjweiss: (System/identityHashCode x) should yield the number after the @, I think
11:36jweissraek: how does print-method match a promise object?
11:37jweissnot even sure where to look in the source
11:38raekjweiss: this seems to be the implementation: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_print.clj#L90
11:41raek(defmethod print-method Object [o, ^Writer w] (.write w "#<") (.write w (.getSimpleName (class o))) (.write w ">"))
11:41raekjweiss: ^ this could be a workaround.
11:41jweissraek: isn't the IDeref one at the bottom the 1.3 impl?
11:41jweissi think i'll just use that
11:42jweissah hm, no clojure.lang.IPending
11:42jweissoh well
11:43jweissi can mess with it
12:14TallAdamgeneral question: I don't come from a functional background, more OO, so I keep wanting to use protocols and records to do type dispatches going back to my encapsulation/polymorphic tendencies. Am I mixing metaphors?
12:15technomancyTallAdam: polymorphism via protocols is not the only way to do encapsulation in clojure
12:15stuartsierraProtocols/records are good for polymorphism. Clojure discourages encapsulation in the data-hiding sense.
12:15TallAdamtechnomancy: go on...
12:15mdrogalisstuartsierra: I noticed that. Why is that?
12:15technomancyTallAdam: I find that there are very few things that really need polymorphism in Clojure. I'd say I've needed it maybe five times in two years personally.
12:16TallAdamtechnomancy: I know, me too, but given the tool, I am settling back into old grooves
12:16technomancytry using private defns and namespaces for encapsulation instead of thinking about encapsulation from the data perspective.
12:16stuartsierramdrogalis: When data is hidden inside objects, you are essentially defining a new API for dealing with that particular type of data. Clojure prefers all data to be accessible through the same API.
12:17technomancyencapsulation should be about making it clear what parts of your API you intend to keep stable vs what's an implementation detail
12:17technomancyit has nothing to do with coupling data to behaviour
12:17TallAdamtechnomancy: is it more performant to call the protocol multi method on a record and have it dispatch according to type, than to interrogate it and dispatch accordingly?
12:17technomancyor it shouldn't anyway
12:17mdrogalisstuartsierra: That's a very interesting philosophy.
12:18technomancyTallAdam: 95% sure you shouldn't think about performance at that level at all right now
12:18mdrogalisHahah
12:18technomancyrule 2 of optimization (for experts only): don't do it. (yet.)
12:19technomancy(rule 1 is simply don't do it.)
12:21timvisheranyone have a recommendation for easily creating a test that involves concurrent access to a function that changes state?
12:21TallAdamAnother general question to the world at large: in my Aquamacs, the parenthesis gets bold font, when the cursor is over it to show the matching parenthesis (also bold), because of the size of the bold font, my whole screen moves down a pixel to accommodate. Has anyone else had this problem? its driving me nuts!
12:23timvisherTallAdam: M-x describe-face RET show-paren-match
12:24timvisherin reference to my concurrent test, do i need utilize something like the Executors framework for that?
12:24timvisherTallAdam: you can customize that face and it should get rid of your problem
12:25timvisheror you could just use the starter kit
12:25TallAdamtimvisher: but it is useful - are all bold faces 1 pixel bigger? I like the bold, just not the moving
12:25TallAdamtimvisher: is there a starter kit for aquamacs?
12:26timvisherah, i was assuming that your face specified a different height
12:26timvisherit doesn't?
12:26TallAdamno - just weighrt
12:26TallAdamweight
12:26timvisheri'm just assuming that technomancy's starter kit works on AquaMacs. I may be making an ass of my self. :)
12:26TallAdam Height: unspecified
12:26TallAdam Weight: bold
12:26timvisherthat's interesting
12:26TallAdam Slant: unspecified
12:26TallAdam Foreground: #7cb8bb
12:27timvisheri don't believe bold faces take up more height than non in vanilla emacs, but i don't know if font-handling is different in AquaMacs
12:28technomancyaquamacs is general is not well-supported
12:28technomancythe most obvious reason being that it's not portable
12:29TallAdamok - thanks for the help guys
12:30timvishersorry for being misleading! :)
12:31timvisherso no one's written a test for a concurrency bug lately?
12:31ejacksonhave mercy - swank.cdt is unbelievable.
12:34dnolenok cl-format is awesome
12:34dnolen(println (pp/cl-format false "~{~{~:[.~;~:*~a~]~^|~}~^\n~}" [[1 nil 4] [3 4 5] [5 6 7]]))
12:34dnolen,(println (pp/cl-format false "~{~{~:[.~;~:*~a~]~^|~}~^\n~}" [[1 nil 4] [3 4 5] [5 6 7]]))
12:34clojurebot1|.|4
12:34clojurebot3|4|5
12:34clojurebot5|6|7
12:35opqdonutindeed
12:36cemerickwrite-once
12:37ejacksontechnomancy: you could go frenchie and utter a "Formidable" :)
12:37dnolenstill better than writing pointless code for printing tables, which I want it for.
12:47edwDon't want to sound like a caveman, but building a OS X Emacs from source fetched from the git repo.
12:48edwErr, it's easy to do so. That's what I meant.
12:52edwDoes CDT require 1.3?
12:53ejacksondoubt it, but i'm using it there
12:54edwThanks. Reading the docs, which dwell on 1.3, though there is a mention of the 1.2 sources in the example package docs.
12:57Scriptureis there a version of the filter function that takes the index as an argument as well as the element?
13:14pyrhi
13:14pyris there a way to determine a function's arity(ies)
13:14pyrin clojure
13:16Bronsapyr: (:arglist (meta #'function))
13:33pyrBronsa: thanks!
13:33mdrogalis,(meta [])
13:33clojurebotnil
13:36timvisheranyone know what the simplest way to spin up 2 threads and execute a single function is in clojure?
13:36timvishertrying to write a test to expose a concurrency bug
13:36raekExecutorService.invokeAll maybe
13:37raekor (doseq [f fs] (future-call f))
13:38timvisherfuture-call looks interesting
13:38raekor see one of the last example here http://blog.raek.se/2011/01/24/executors-in-clojure/
13:38timvisheri was hoping to avoid learning the Executor framework
13:39timvishernice blog post, though
13:39timvisheri'll definitely put that on my reading list
13:39timvisheri'll give future-call a spin and see if that will suffice
14:08ibdknoxwhat would one have to do to add something to the classpath at runtime?
14:10ataggart,(doc add-classpath)
14:10clojurebot"([url]); DEPRECATED Adds the url (String or URL object) to the classpath per URLClassLoader.addURL"
14:12ibdknoxhah, that's what I get for assuming it would be complicated
14:12ibdknoxthanks ataggart
14:13ataggartnp, though bear in mind it's deprecated for a reason.
14:13ibdknoxand that reason is?
14:13ibdknoxI'm trying to rig something up to leiningen for ClojureScript
14:14ibdknoxso while in general I would say using something like this would be a terrible idea, I think this might be the best solution in this case :(
14:15technomancyIIUC it's deprecated because you aren't always using the classloader that clojure thinks you are (if you're in an IDE or tomcat or whatever)
14:16technomancyI don't know of anything that would cause it to break from leiningen or a bare repl
14:16ibdknoxmkay
14:16ibdknoxtechnomancy: thanks
14:17ataggarthas anyone tried using the cljs repl? I was getting errors for every little thing.
14:17ibdknoxif you use brepl, I made it *much* more resilient
14:18ataggartI just found it odd that (doc foo) would error out on something like "user.doc is not defined"
14:18ataggartand is followed up by a stacktrace
14:18ibdknoxbasically any exception in the included repl kills it
14:19ataggartare clojure.core names no included by default? stepping through the Quick Star, it bombed on trying to require since "user.require is not defined"
14:20ibdknoxrequire doesn't exist in CLJS
14:20amalloyataggart: require is only supported in the ns form, as i understand it
14:21ibdknoxhttps://github.com/ibdknox/brepl
14:21ataggartah, so cljsc/build is meant to be required and called from the clojure repl, not the cljs repl?
14:21ibdknoxhas require
14:21ibdknoxataggart: yes
14:21ataggartit's little things that that that need to be made clear in the docs
14:21ataggartthx
14:23ataggartalong with mentioning that seeing a bunch of warnings from gclosure about using "this" when running the cljsc is to be expected (assuming it *is*)
14:25ibdknoxataggart: hmm I suspect "this" isn't doing what you think it is
14:27ataggartI'm not the one using it. I was just compiling the little hello.cljs in the quick start
14:29ibdknoxweird, I don't get any warnings
14:29ibdknoxand that sample doesn't use "this"
14:31ataggartyes, I assumed it was in the js emitted by cljsc
14:31ataggartare you using the latest from github?
14:34ibdknoxataggart: I am
14:42ataggartodd. I'll look into it when I get back home.
14:45ibdknoxstuartsierra: any thoughts on potentially getting :use in ClojureScript?
14:46stuartsierraWhy me? :)
14:46ibdknoxhaha
14:46technomancyto put :use in clojurescript you'd either need to give it the bad behaviour of bare-use-by-default or make it incompatible with clojure
14:46ibdknoxrumor has it you mentioned something about doing require as a function
14:46stuartsierraClojureScript is, in part, an experiment to see what we can do without.
14:46ibdknoxtechnomancy: how so?
14:47ibdknoxstuartsierra: I can say that I miss it, greatly.
14:47stuartsierra`require` as a unction would useful for the REPL, but it can only work in the REPL.
14:47technomancyibdknox: in retrospect it was a mistake to make (:use foo.bar) refer all vars in bar by default.
14:47mattmitchellwhat's the right way to sort a hash-map by value... where the value is an integer and the highest should be first?
14:48mattmitchelli'm using sort-by... but it comes out backwards
14:48tomojthere isn't any
14:48tomojoh
14:48ibdknoxstuartsierra: I assume because of how goog.require works?
14:48stuartsierrayes
14:48amalloymattmitchell: don't sort by value?
14:48amalloyor, don't use a hashmap?
14:48ataggartmattmitchell: sort by values of sort by keys?
14:48amalloy$google clojure priority queue
14:48tomojmattmitchell: it takes an extra param, comp
14:48lazybot[Big Dingus » Blog Archive » Finding primes with Erlang and Clojure] http://bigdingus.com/2008/07/01/finding-primes-with-erlang-and-clojure/
14:48tomojmattmitchell: pass >
14:48ataggarts/of/or
14:48lazybot<ataggart> mattmitchell: sort by values or sort by keys?
14:49mattmitchellwell, what i want is a list of keys, but sorted by their values
14:49ibdknoxstuartsierra: even in the REPL I had to change how require writes out script tags for brepl
14:49mattmitchelli wouldn't use a hash for this normally, but that's what i'm getting from an outside "api" service
14:50stuartsierramattmitchell: (sort-by the-map (keys the-map))
14:50ibdknoxtechnomancy: I don't doubt it, but could you explain the thinking behind that?
14:50mattmitchellso... {:a 10 :b 2 :z 1000} => [:z :a :b]
14:50mattmitchellok i'll try that...
14:50amalloystuartsierra: oh, that's much nicer than what i was thinking
14:50tomojyou still need the >
14:51stuartsierra(sort-by (comp - the-map) (keys the-map)) to reverse the order.
14:51tomoj:)
14:52mattmitchellstuartsierra: very nice :)
14:52stuartsierrathx
14:52tufflaxor just (keys (sort-by val > the-map))
14:52technomancyibdknox: why it's a bad idea in clojure or why it's not in cljs?
14:52mattmitchellthanks everybody! you're all too clever :)
14:53ibdknoxtechnomancy: the former
14:53tomojintuitively that seems like it would be slower than (map key (sort-by val > coll))
14:53tomojis it?
14:53mattmitchelltufflax: what is the > doing?
14:53technomancyibdknox: it's easier to refactor if the dependencies between namespaces are explicit
14:53tomojtufflax: whoa
14:53amalloytomoj: you think (map key x) is faster than (keys x)? that seem unlikely
14:53mattmitchelltufflax: works perfectly... just curious
14:53tomojamalloy: no, all the value lookups
14:53tufflaxmattmitchell it's the comparator
14:54technomancythere are exceptions (useing clojure.test in a test or using the implementation from the test namespace) but it's a bad deafult
14:54mattmitchellahh ok
14:54mattmitchellnice
14:54tomojamalloy: instead of just getting paired kvs directly from the map
14:55tomojtufflax: I never knew keys called seq on its arg
14:55tufflaxi didn't either until a few moments ago
14:56ibdknoxtechnomancy: are you opposed to having :use with bare-by-default in cljs?
14:57redline6561Hey. Just saw the discussion of Ring 1.0. I'm curious, did anything ever come of the async work? I know there had been some cross-pollination with aleph...
14:58technomancyibdknox: I don't care either way for cljs, but it seems like cljs may be a good place to experiment with a use replacement that could then be ported to clojure
14:58stuartsierrayes
14:58technomancyit's easier to experiment with things like that in cljs since there isn't such an expectation of stability there
15:00ibdknoxfair enough
15:00tomojis there some reasonably sane way to implement partition with reduce
15:00amalloytomoj: not lazily, of course
15:01tomojI can see the basic idea but feel like I want deques
15:01opqdonutno, not really
15:01tomojoh, no need for laziness
15:01tomoj..and I only need step=1
15:03technomancyI'd be happy if :require supported a :refer [x y z] that worked exactly like :use's :only. then :use could be deprecated and nothing would break.
15:03ibdknoxtechnomancy: that'd work for me too
15:03technomancybut this whole issue is subject to staggering amounts of bikeshedding
15:03technomancyeveryone wants to get their say in
15:03ibdknoxhaha
15:04ibdknoxI just want something that works
15:04ibdknoxhaving to alias *everything* is beyond annoying
15:04technomancytheoretically with slamhound you don't even have to write :use/:require/:import anyway, they can just be infered
15:04technomancyit's not quite practical yet to the point where you can use it for everything
15:05ibdknoxinteresting
15:06ibdknoxhow does it decide when there's a name collision?
15:06technomancycurrently it picks the shorter one unless it had a match for that in the ns form already
15:07ibdknoxmm
15:08stuartsierraLooking up names is the the one place where I wish for an IDE sometimes.
15:08technomancyhave you tried slamhound?
15:08stuartsierranot yet
15:09ibdknoxwe just need to come up with a way to put slamhound into our editors :D
15:09ibdknoxproblem solved ;)
15:09arohnerman, is it just me, or does google not know how to search github?
15:09stuartsierraarohner: It's not just you.
15:09technomancyibdknox: I have elisp for it, but it currently doesn't wrap at 80 columns, so I don't use it.
15:09ibdknoxtechnomancy: I'm one of the crazy vim users
15:09stuartsierraSomebody just needs to hurry up and rewrite Emacs in Clojure. ;)
15:09ibdknoxhaha
15:10ibdknoxthat would be fun
15:10technomancystuartsierra: elisp as a compilation target.
15:10technomancyone of these days
15:10ibdknoxlol
15:10stuartsierratechnomancy: that's an interesting idea, shouldn't even be that hard
15:10stuartsierraEspecially once Elisp gets lexical scope.
15:11technomancyjust need to find a willing volunteer
15:11ibdknoxnot it.
15:11stuartsierranoses
15:11redline6561noes!
15:11technomancyibdknox: too busy with your clojure->vimscript compiler? that's understandable.
15:11stuartsierraarohner: it's in the next Emacs release
15:11technomancyarohner: it's got lexical scope already
15:11redline6561But, of course, Elisp *has* lexical scope. Just not in a debian package yet. ;)
15:11technomancythreading is implemented in a branch
15:11ibdknoxhaha client-side cljs framework first ;)
15:12ibdknoxI already have hiccup over DOM objects
15:12ibdknoxnow I just have to the rest of everything goog.* does ;)
15:12ibdknox+ do
15:13arohnerwhy didn't CL ever get around to making an elisp backend?
15:13arohnerseems like they had motive and opportunity.
15:14stuartsierraarohner: They tried writing an editor in CL and failed.
15:14ibdknoxeditors are very difficult to write
15:14zvrbaso lisp is good enough for AI, but not for an editor? ;)
15:14ibdknoxbefore I took over C# and VB, I was on the VS editor team
15:15arohneribdknox: what editor do you use for clojure?
15:15ibdknoxarohner: VIM :)
15:15arohneribdknox: any emacs users in the VS editor team?
15:15arohnerI feel like all modern IDEs have failed to learn from emacs
15:16ibdknoxmost people used VIM if not VS itself
15:16ibdknoxI don't think we had any emacs folks there
15:17ibdknoxlike me, they hated pressing the ctrl key all the time ;)
15:18arohneribdknox: sure, but that's not the appeal of emacs
15:18arohner1) never needing to take your hands off the keyboard. 2) the entire thing is built on an extensible programming language
15:19technomancyarohner: ignoring 2) is a failing of all modern software apart from mozilla, to b efair.
15:19amalloyarohner: in fairness, i think that's the goal of vim too. emacs users just don't feel they succeeded
15:19technomancyit's not just an IDE problem
15:19tufflaxhahaha amalloy i never thought of that, brilliant
15:19amalloybut vim does a damn sight better than a lot of things
15:20arohnertechnomancy: sure, but it's quite obvious how valuable it is in your editor. Other modern software doesn't have an easy example to steal from
15:20redline6561technomancy +1
15:20amalloytufflax: i'm hardly the first to think of it. there's even a song from ages-ago about needing footpedals to use (some other editor) properly
15:20tufflaxhehe
15:21redline6561Did you buy them or make them amalloy?
15:21amalloyredline6561: http://www.kinesis-ergo.com/
15:21redline6561Nice. Thanks/
15:21tomojarohner: frustrating how little people appreciate what 1) means
15:21gtrakI'm having a hard time getting the lein checkouts functionality to work with slime/swank, anyone have a better guide than what's on the lein faq? getting a noClassDefFoundError on a class that I'm hacking on in a dependency project, though I'm compiling it through slime
15:21tufflaxI find the thought of someone using pedals so funny
15:23gtrakemacs-drumset-mode
15:24tomojamalloy: you convinced me. found anything better than http://www.fentek-ind.com/FootPedal.htm#afp3usb ?
15:25amalloytomoj: i've only had my set since wednesday
15:25tomojs/better/significantly cheaper/
15:25amalloyhah. no
15:26amalloythe kinesis ones are charging for the brand, i'm sure
15:26amalloyi think i'd have gotten the ones you just linked to, if i'd found them
15:26tomojhmm
15:26tomojkinesis ones seem the same price
15:26amalloyso far i've found that three pedals are too confusing, and only really use two
15:27tomojexactly
15:27tomojfor two individual pedals
15:27amalloytomoj: the kinesis ones are like $15 more from their website; if you order from amazon instead it's about the same
15:27amalloy(ie, about $15 cheaper)
15:27tomojcool, thanks
15:28tomojthe multipedal units make no sense - where's the snare?
15:28amalloytomoj: c'mon, optional input jack for one more device! you could hook up a snare
15:29tomojbut it won't fit between my legs
15:30stuartsierraAnybody tried using a pedal for SHIFT?
15:31ibdknoxthe cruise control for awesome: a pedal for capslock ;)
15:32amalloystuartsierra: shift is the third pedal i can never remember to use. but once or twice it's been handy when i sit down to write some lengthy plain-text
15:32amalloyeg, a docstring
15:34winkit's hard to resist a "driving stick shift" pun now
15:35arohnerhrm. If I got used to pedals, taking my laptop out would become difficult...
15:36arohnerand listening to music while typing would either become difficult, or make me type in the rhythm of the song
15:38Generic_Dumbasstry-clojure.org results: Clojure> (defn squar­e [x] (* x x))
15:38Generic_Dumbass#'sandbox158157/square
15:38Generic_DumbassClojure> (square 4)
15:39Generic_DumbassUnable to resolve symbol: square in this context
15:39Generic_Dumbassheh
15:40amalloywhat, uh...what are you getting at?
15:41mefestoGeneric_Dumbass: just tried it myself and it worked... typo?
15:41Generic_Dumbass*slinks away guiltily*
15:41amalloyGeneric_Dumbass: when you're done playing with try-clojure, perhaps try out 4clojure.com?
15:42Generic_Dumbassindeed
15:45gtrakis it possible to hack on a class on a dependency project and compile it in slime/swank? I get Unknown location:
15:45gtrak error: java.lang.NoClassDefFoundError: Could not initialize class ...__init even after I've C-c C-k'd the ns
15:45tomojany other exceptions?
15:46arohnergtrak: yes, I do it every day
15:46gtrakno
15:47arohnergtrak: it's probably a typo, where you have a foo.bar that doesn't exactly match the name of a class or ns
15:47gtrakI must be missing something simple... I've added a symlink to the project under checkouts
15:47tomoj"Could not locate" is different from "Could not initialize", isn't it?
15:47tomojthat looks like what I get when something goes wrong during class initialization. when that happens I get the real exception once, and thereafter only an unhelpful exception until I restart the jvm
15:48gtrakhmm...., well let me retry it, just for kicks, arohner do you happen to have a jar of the dependency in the lib directory?
15:48tomojyou need to have the dep in your dependencies even if it's a checkout dep
15:48gtrakI deleted mine, it didn't seem to sync when I made a change, tomoj, I have it listen in lein yes
15:49arohnergtrak: yes. I typically have the jar in lib/, and a copy of the source in another dir. Then I open the source file and C-c C-k it
15:49amalloy(inc arohner)
15:49lazybot⟹ 1
15:49gtrakarohner, are you using the checkouts feature?
15:50arohnergtrak: no
15:50tomojgtrak: and the version for the dep in your project.clj matches the version in its project.clj?
15:50amalloygtrak: i do the same thing, and i don't use checkouts
15:50gtrakha, weird
15:50gtrakthen I'll stop trying to use checkouts
15:50tomojamalloy: do you use M-.?
15:50amalloyjust edit the source file wherever you happen to have it on disk - C-c C-k doesn't care what file you're telling it to load
15:51jweissis there a way to get a thread dump in emacs when you've run M-x lein-swank
15:51amalloytomoj: yes?
15:51tomojbetter not just edit it _wherever_ you happen to have it on disk
15:51tomoje.g. in the jar in lib
15:51tomojwhere M-. takes you
15:51amalloywherever you happen to have [the source file] on disk
15:51amalloyyes, using M-. to take you to an edit location is not usually right
15:52amalloy(though not uniformly wrong, either)
15:52tomojwith checkouts deps and the project itself it works out
15:52arohnerjweiss: you can get stack traces in emacs w/ swank. Is that what you mean?
15:52amalloytomoj: meh. i have the source files open anyway in another buffer
15:52tomojyeah, me too
15:53jweissarohner: no, i'm doing stuff with concurrency, and one thread seems to be holding up the repl, want to know what is happening
15:53amalloycheckout deps are adding a level of complexity for no particular reason
15:53tomojthen when I use M-. I have two copies open
15:53tomojthen I switch to checkouts
15:53amalloytomoj: i believe that's only true if you haven't done C-c C-k on the source version yet
15:53amalloyafter that, i think emacs knows to go to the "right" place when you M-. it
15:54arohneramalloy: yes, because the metadata on where the code came from has changed
15:54arohnerwhen you first load it, the var says "I came from foo.jar"
15:54arohnerafter a compile, it says "I came from foo.clj"
15:54tomojamalloy: you're right
15:55amalloythere are plenty of reasons for me to want to use lein instead of cake, but checkout deps ain't one of them
15:55tomojoh
15:56tomojthought we were talking lein-without-checkouts vs lein-with-checkouts
15:56tomojif you happen to need to add a new file, you need a checkout dep or to go hack on the project itself, right? quite rare, though
15:56amalloydoesn't really matter? i wouldn't use checkouts if i were using lein either
15:58tomoj"using M-. to take you to an edit location is not usually right" -- it strikes me that this is peculiar given M-.'s name
15:58amalloyheh
15:59amalloycan't argue there
15:59gtraklein needs to become the new eclipse to fix that
16:03gtrakI work on a 160 project eclipse workspace in java, and it 'just works' mostly, but that's because eclipse has full control of everything
16:03kephalei
16:04cemerickwhew, 160!
16:04gtrakvery modular :-)
16:05cemerick"only" 58 here
16:05cemerickand that includes a pile of open source stuff :-P
16:05amalloyman, i never had more than like twenty
16:09sritchiehey all, one quick question -- I'm writing a macro that needs to take in a java classname, but it seems that defmacro interprets all inputs as symbols
16:09sritchie for example, (defn printer [x] (.getName x)) returns java.lang.String for (printer String), while subbing defmacro for defn returns String.
16:10sritchieso, the question is, is there a better way to do this than (defmacro printer [x] (.getName (eval x)))
16:10amalloysritchie: well, all inputs *are* symbols
16:10amalloyyou acan use resolve instead of eval, but i'm pretty sure there's something still better
16:11cemerickhard to beat resolve there
16:11amalloyeg, (defmacro printer [x] `(.getName ~x)) unless there's some reason you want the macro to expand to a string?
16:13sritchiehere's the function I'd been writing
16:13sritchiehttps://gist.github.com/1128401
16:13sritchieI tacking resolve onto the parameter inside that anonymous function does the job
16:16gtrakanother question, it seems lein test (namespace) runs differently from clojure-test-mode on a buffer... any way to reconcile that?
16:17gtrakI have a bunch of tests that fail from emacs that work from lein
16:17seancorfielddefine "fail"
16:17seancorfieldclasspath issues?
16:21gtrakno idea, extremely hard to parse the output
16:23gtrakthrows an exception of some sort
16:24gtrakthe test file starts up a jetty with a text fixture and does some requests on it
16:24gtrakso I'm getting back html stacktraces
16:24gtrakworks fine with lein test
16:25kjeldahl_Anybody know how to exit "repl" mode inside "lein interactive"? If I press ctrl-D it exits all the way out of interactive mode..
16:27gtrakseancorfield, "Caused by: java.util.concurrent.RejectedExecutionException" some kind of threadpool not being initialized
16:27gtrakwhere should I look
16:29PPPaulcan someone help me out with my macro?
16:29PPPaul(defmacro def-csv-importer [table-name & fields]
16:29PPPaul `(let [name# ~table-name
16:29PPPaul struct-name# (str name# "-fields")]
16:29PPPaul (defstruct struct-name# ~@fields)))
16:29PPPauli'm looking at tutorials and they aren't helping too much
16:30PPPauli want my macro to write out a defstruct
16:31gtrakdoes it have to be a macro?
16:32PPPaulwell, i want it to do more than just that
16:32PPPaulbut this is the start
16:33PPPauli want it writing out variables and functions as well
16:33clojurebotfunctions are maps
16:35technomancygtrak: you need to upgrade swank to 1.3.2 or higher
16:35PPPaulcurrently my macro isn't doing what i want with regards to making a string out of the 'table-name'
16:35technomancyclojurebot: RejectedExecutionException in swank |means| you need to upgrade swank to 1.3.2 or higher.
16:35clojurebotc'est bon!
16:36gtrakdamn!
16:38gtrakis it possible to override the swank globally and ignore what's in the project.clj? I have buddies that use old lein that don't have this problem, I think it's a problem with 1.6 only, right?
16:38technomancygtrak: yeah, use lein plugin install swank-clojure 1.3.2
16:39technomancyit *should* take precedence over project.clj, but I'm a bit fuzzy on the details
16:39technomancybest to remove it from project.clj if you can, unless you want to have it in production
16:39gtrakmaybe I can persuade them
16:40technomancytell em technomancy sent you =)
16:40technomancymy advice is to only include in :dev-dependencies things that are required for tests and builds to occur. if you have plugins for your own convenience like swank or clj-stacktrace, those are the responsibility of the user since tastes vary
16:42gtrakthat makes sense
16:47gtrakhmm, seems to work now
17:05PPPauli have 2 macros, i would like them to produce the same result.
17:05PPPaul(defmacro tester [table-name & fields]
17:05PPPaul `(defstruct ~table-name ~@fields))
17:05PPPaul(defmacro tester1 [table-name & fields]
17:05PPPaul `(let [struct-name# ~table-name]
17:05PPPaul (defstruct struct-name# ~@fields)))
17:05PPPaulwhat would i change in the second one to do this (while keeping the let statement)
17:06amalloynot possible
17:06PPPauloh
17:06hiredmanPPPaul: I suggest you write out the expansion of your macro and try to run it
17:07amalloydefstruct (and every def) needs a literal symbol as its first arg. you can't (let) a name in the expansion scope and then use that, because it doesn't know about let
17:07hiredmanonce you write the code your macro generates outside of the defmacro, it should be obvious why it doesn't work
17:07PPPauli want my macro to produce a def, function, and struct based on a name
17:07amalloygood advice
17:07amalloyPPPaul: try what hiredman suggests. write out the actual code you want to produce, and see how you can get there
17:08PPPauli have the code, i am trying to figure out how to get there... this is my first time writing macros
17:08PPPauli'm reading tutorials and stuff
17:08amalloyPPPaul: so gist the goal code or something
17:09PPPaulok, give me a sec
17:13PPPaulhttps://gist.github.com/1128542
17:13PPPaulhope that you guys can help me understand macros :D
17:19PPPauli think what i want is very simple... i'm not sure what i'm doing wrong
17:20zippy314Why does tunning clojure tests from lein test, but the trying to do the same test from emacs-swank-clojure test mode, fails with a ClassNotFoundException?
17:23zippy314(s/tunning/running/) correction: Why does running clojure tests from lein test, but the trying to do the same test from emacs-swank-clojure test mode, fails with a ClassNotFoundException?
17:26amalloyzippy314: fwiw, you can just write s/tunning/running and lazybot will repeat your (fixed) message for you
17:26PPPaulwhy doesn't this macro work? (defmacro tester2 [table-name & fields]
17:26PPPaul `(def (symbol (str \* ~table-name \*))))
17:27amalloyPPPaul: observe that in your gist, there is no let
17:27zippy314amalloy: I did! But I think that my client intercepts it first...
17:27amalloyhaha
17:27Raynesfoo bar bat
17:27Rayness/bat/baz/
17:27lazybot<Raynes> foo bar baz
17:27PPPauli know there is no let... but i was told to use let with autogens to avoid redundant evaluations
17:28Rayneszippy314: What client is that? o.o
17:28zippy314Raynes: colloquy
17:28amalloyPPPaul: but you don't want to evaluate anything!
17:28RaynesYeah, I can't tolerate colloquy.
17:28PPPauli guess i'm really confused
17:29amalloyspoiler: (defmacro whatever [name] `(do (defstruct ~(symbol (str name "-fields")) ...) (def ...)))
17:29PPPaul:D
17:29PPPauli need the do?
17:30RaynesA macro only expands to a single form. Therefore, if you need it to expand to multiple forms, you wrap it in a 'do', which makes it all one big form.
17:30amalloyjust like any other function, a macro can only return a single form
17:30PPPauli tried the ~(symbol...) but i get an error
17:31PPPaulthanks for the info
17:31RaynesIt's a bouncy house of fun, really.
17:33PPPaulthanks... i was putting the '~' in the wrong place
17:50CozeyGood evening. Why can't i create deftype feld with a hyphen?
17:51hiredmanCozey: what version of clojure?
17:51Cozey1.3
17:51amalloyCozey: that was a bug in some version that's been fixed
17:51Cozeyoh
17:51amalloycemerick probably knows the ticket number, even
17:51Cozey1.3.0-beta1 i'm using
17:51Cozeywhat should i use then?
17:51hiredmandeftype fields are java fields and java field names cannot contain '-'
17:51amalloyhttp://dev.clojure.org/jira/browse/CLJ-819
17:52amalloyi guess i was wrong about it having been fixed
17:52amalloyit works in 1.2.1 - time to downgrade? :)
17:58Cozey:-)
17:58Cozeynah, i'll drop the hyphen and go for good ol' camel case haha
18:06Cozeyhas anyone stumbled upon an issue when lein swank uses stale class files in target/ directory instead of modified sources?
18:06Cozeyeven when restarted?
18:08technomancythat's clojure, not leiningen
18:24momoxis it possible to rewrite this snippet using map? http://pastebin.com/2js7MFSv
18:25ibdknox(map sleep-print (range 10))
18:25hiredmanof course
18:25hiredmanibdknox: incorrect
18:25ibdknoxah
18:25momoxit should return a sequence of function calls
18:26momoxnot the value of the calling the function
18:27amalloycertainly you *can* write it with map
18:27amalloyi think the for is probably clearer
18:27ibdknox(map (fn [i] #(sleep-print i)) (range 10))
18:27ibdknoxwould work I think
18:36momoxibdknox: yes, it works...thank you for your help
18:37ibdknoxmomox: I agree with amalloy though, that should probably stay as a for
18:37ibdknoxit's more obvious what it's doing there
18:38amalloy(map #(...)) is something i only use in a ->> pipeline
18:38momoxyes...i agree too, but I was just curious on how to a express that using a map
18:39momoxamalloy: example, please?
18:39amalloy(for [x xs] anything) => (map (fn [x] anything) xs)
18:39amalloywill work every time
18:39amalloy&(->> (range) (filter even?) (map #(* 2 %)) (take 4))
18:39lazybot⇒ (0 4 8 12)
18:49momoxamalloy: thank you for your explanation
19:06seancorfieldJava interop Q... I have a Java object with public fields and no setters... what's the right / recommended syntax for setting those fields? I'm drawing a blank :(
19:07amalloyset!
19:08seancorfieldah, that's why i was drawing a blank... thank you!
19:09seancorfieldjust found it halfway down the java interop page http://clojure.org/java_interop - man, that's ugly
19:09amalloyugly how?
19:10seancorfieldthe example shows (set! (. instance member) expr) but i assume (set! (.member instance) expr) also works?
19:10amalloyshould, yeah
19:10seancorfieldthanx
19:14triyo.quit
19:14triyooops
19:15seancorfieldit would be cleaner to have a map from clojure-y name/value to member access on MongoOptions but i know i can't just do (defn opt [o m v] (set! (. o m) v))
19:16seancorfielddo i have to define a macro for that or can i do it in a function with some magic combination of ~ ` etc?
19:17hiredmanit's called reflection
19:17hiredmanit's how you do that kind of thing
19:17seancorfieldi went with a macro (defmacro opt! [o m v] `(set! (. ~o ~m) ~v))
19:19hiredmanhttps://github.com/hiredman/ring-jetty--adapter/blob/master/src/ring/adapter/jetty+.clj
19:21seancorfieldmeh, the macro doesn't really do what i want either... and that code listing is not helpful as a whole without a bit more commentary on which part, specifically, addresses my question
19:22seancorfieldafter all, i'm not trying to call methods here, i'm trying to set fields
19:22hiredmansure, you can set fields with reflection as well
19:23hiredmanthe listing takes a map of options and turns it into calls to setters for those options, but it could set ields too
19:23hiredmanfields
19:25hiredmanit's actually even easier if you use clojure.lang.Reflector instead of java's reflection apis directly
19:45nishanthas anyone used clj-ssh for scp'ing ?
20:00seancorfieldhiredman: any reason you used split / mapcat in that field name conversion rather than clojure.string/replace with #"-." ?
20:00seancorfieldor #"-[a-z]" i guess
20:01hiredmanlazy I guess
20:01hiredman~hiredman
20:01clojurebothiredman <3 XeLaTeX
20:01hiredman~hiredman
20:01clojurebothiredman is slightly retarded
20:01hiredmanhmmm
20:01hiredman~hiredman
20:01clojurebothiredman is lazy
20:01hiredmanthats the one
20:02hiredmanoh, well, actually for camel casing
20:02hiredmanit uppercases the words at the edges
20:03seancorfieldah, so it also uppercases the first letter... gotcha
20:09cemerickamalloy: I have it fixed locally, will be adding a patch to the ticket shortly.
20:32jcromartieclojure-jack-in just sits there...
20:32jcromartieStarting swank server...
20:32jcromartieoh
20:32jcromartiebecause /bin/bash: lein: command not found
20:36hiredmanright, you need lein on your path
20:37jcromartieand not just on my path
20:37jcromartieI use lein from bash
20:37jcromartiein ~/bin/lein
20:38jcromartieok now *swank* is filling with lisp code
20:38jcromartieis it loading slime?
20:38hiredmanyes
20:38jcromartiebecause I already have slime
20:38jcromartiethat will cause problems, won't it
20:39technomancywell, the whole point of jack-in is you don't have to already have slime installed
20:39technomancyor maybe half the point
20:39technomancyif you want to get technical
20:39jcromartie:P
20:39jcromartieman, this morning I had it all set up, and I went down this road because { wasn't working correctly in paredit
20:40hiredmanuh, that is just clojure-mode
20:40technomancyprobably from paredit 20 instead of 22 actually
20:40jcromartieyup
20:41jcromartiethere we go
20:48hiredmantechnomancy: 22 doesn't seem to do curly braces for me
20:48hiredmanand curly praces aren't in the place where it looks like brackets are listed
20:48hiredmanbraces
20:51amalloyhiredman: paredit defines curly-brace functions but doesn't bind them to anything. clojure-mode sets the bindings
20:51amalloyprovided you have paredit 21+
20:52hiredmanmy elpa-to-submit has paredit 22
20:54amalloywell, if you haven't updated clojure-mode since...2008, it looks like...it might not have that code :P
20:54hiredmanI work with phil, of course I have an updated clojure-mode
20:54amalloyyeah, not a serious suggestion
20:56technomancyI've noticed the curly braces don't work with paredit in slime-repl, but I've never noticed them not work in clo-mo
20:56technomancyman it is so obvious that today's dinosaur comic was written by a programmer: http://www.qwantz.com/index.php?comic=2015
20:58hiredmanugh, so describe-key { even says it is bound to open-curly
20:58hiredmaner
20:58hiredmanparedit-open-curly
21:10jcromartieheh :) I'm not the only one huh
21:14amalloytechnomancy: it's not hard to configure them to work in the repl too
21:14amalloyoh. no, that's just dumb
21:15amalloyi have them configured to work better than default syntax-table wise, but i don't turn on paredit in my repl
21:31dnolenhttps://gist.github.com/1128891
21:31dnolen:D :D :D :D
21:34chousernice
21:36dnolengod bless maranget
21:38hiredmanit has the inverse key/value thing just like map destructuring? (makes sense just hadn't thought about it)
21:38dnolenhiredman: yes, I want pattern matching to follow destructuring as closely as possible.
21:39hiredmannice
21:41dnoleni don't think people will generally do this, but this is fun, https://gist.github.com/1128901
21:42dnolenoops just cleaned that up
21:43hiredmanmmmm
21:44dnolenhiredman: ?
21:46hiredmanmatching matching is a wonderful thing
21:48jcromartiemaybe off topic, but why is Clojure a single .jar, and Scala is not?
21:48jcromartieor, *how* is Clojure a single .jar while Scala is not
21:48jcromartieit seems like quite a feat
21:58dnolenit never ceases to amaze what 600 lines of Clojure can do ...
22:24amalloyjcromartie: you can jar up your whole hard drive, and then it's one jar. i'm not sure how that's a meaningful measurement of anything
22:28jcromartiewhat's the "clean" way to restart clojure-jack-in
22:31jcromartieafter slime-disconnect or slime-quit-lisp, running clojure-jack-in yields: "error in process filter: Symbol's value as variable is void: Process [2 times]"
22:31amalloyreinstall your operating system
22:32amalloy(disclaimer: the internet is a bad place for blindly following advice. don't actually do that)
22:32jcromartieright
23:00drewrjcromartie: hit , in your repl
23:01drewrat least that's how I do it; not sure what it eventually calls
23:06fmware there problems with doseq in clojurescript? I'm suppose I'm just using it incorrectly: https://gist.github.com/1128963 ? I'm getting notified that something in core.js is undefined (see the provided paste)
23:27fmwhmm, I've applied the doseq-related fix at http://dev.clojure.org/jira/browse/CLJS-39 but that doesn't fix my problem
23:54technomancyjcromartie: kill *swank* and re-run M-x clojure-jack-in