#clojure logs

2012-07-31

00:47muhooordnung, eh?
00:51nkkarthikin clojurescript to connect to repl from a page I need to add 'repl/connect' code to the page
00:51nkkarthikbut this I cannot check-in... into production I mean
00:52nkkarthikis there some conventional way that you guys follow?
00:52emezeskenkkarthik: (when config/debug (repl/connect))
00:54nkkarthikemezeske: ah where do I set this?... is config/debug automatically available at compile time?
00:55emezeskenkkarthik: No, I just assumed that your app has some kind of configuration to tell it to e.g. use minified/plaintext assets, verbose logging, etc
00:56nkkarthikemezeske: ok... is there a conventional way to set these properties (or specify a file)... in cljsbuild options or somewhere?
00:57nkkarthikor do your own way
00:58emezeskeI'm not sure if there's much of a standard convention at this point
00:59emezeskeI tend to put my configuration stuff in a crossover .clj file, personally
00:59emezeskeI don't know if that scales well or not, though
01:00nkkarthikemezeske: oh a config.clj file... not config.cljs?... so that this 'connect' code gets compiled out altogether?
01:01emezeskenkkarthik: The crossovers allow you to share .clj code with .cljs; I use that for my config so that both clojure and clojurescript have access to the config variables
01:01emezeskenkkarthik: You could use a macro to compile out that code altogether if you wanted
01:02emezeskenkkarthik: If you are just using cljs, and no clj, then crossovers don't buy you anything
01:03nkkarthikemezeske: yeah I just started out with cljs and going through the quick start... and had this question... I thought maybe we use clojure to compile it to javascript and so we can use a clj file to compile it out
01:03nkkarthikemezeske: the macro idea sounds good too
01:03emezeskenkkarthik: That's definitely an option. If you're just starting out, though, I recommend staying away from advanced features like crossovers until you feel comfortable with the basics
01:03emezeskenkkarthik: They are kind of a hack, and are tricky to get right
01:04nkkarthikemezeske: yeah I will keep out then :)
01:07nkkarthikemezeske: I will stay with the config.cljs file for now then
01:07nkkarthikemezeske: by the way... thank you for the plugin
01:08emezeskenkkarthik: Yeah, I'm glad you've found it useful!
01:30mkcan I change part of a function defined using defn, or must I use a second defn to redefine the function?
01:33mk,(defn f [n] (* 2 n)) (f 2)
01:33clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
01:34mkif I'm on the repl, and there's a thread executing a loop within f, how can I change the 2 to a 3 without interrupting that thread?
01:44emezeskemk: The defn macro takes a list of forms, makes a fn, and then puts it into a Var
01:44emezeskemk: The list of forms is definitely immutable
01:44emezeskemk: And I think the fn is too
01:44emezeskemk: Meaning that if you want to change things, you need to change the "f" Var, which you could do by, as you said, another defn
01:45emezeskemk: If you want to change the "2" by itself, you'd have to do some work up front
01:45mkhow do I go about mutating it?
01:45emezeskeYou could make 2 an atom
01:45emezeske(defonce multiplier (atom 2))
01:45emezeske(defn f [n] (* 2 @multiplier))
01:46emezeskeThen, somewhere else, (swap! multiplier (fn [old] new-value ...))
01:46emezeskeThat would mutate multiplier in a thread-safe manner
01:47mkwhat does defonce do? the doc's "root value" is confusing
01:47emezeskeIt just ensures that if you reload the namespace the atom doesn't get redefined
01:47mkor, what is a "root value"?
01:47emezeskeIt's not strictly necessary, but it can avoid some confusion
01:48emezeskeI probably shouldn't try to explain the root value, etc -- I would probably not get it right
01:48emezeskeYou can read the docs on Vars if you want to understand that
01:48mkoh, I see. Does it redefine if the value has later been removed from the namespace?
01:48emezeskeI'm not sure, I would guess so, though
01:50mkI want to mutate the multiplier while programming via the repl... is atom appropriate for that?
01:53emezeskeYep!
01:53mkthen why don't we use atoms even for definitions?
01:54emezeskeWell, Vars and atoms have different concurrency properties
01:54emezeskeLike when you mutate a Var, it's usually done in a thread-local context
01:54emezeskeVars are not good for sharing state across threads
01:54Raynesemezeske: I think fs's cwd mechanism is a good example of it.
01:54Raynes(of how vars work)
01:55emezeskeRaynes: Yeah, it does, IIRC
01:55emezeskeRaynes: cwd is a dynamic var, right?
01:55RaynesBut I don't know, since I might have force pushed a branch at some point. I damaged the universe like that once, much like Walter's crossing over in Fringe.
01:55emezeskeFringe, that show with Spock?
01:56Raynesemezeske: Haha
01:56RaynesYes.
01:56emezeske:)
01:56Raynesemezeske: But yes, it is a dynamic var. The fun bit is that you can set it with set!.
01:56mkwhat is a dynamic var?
01:56RaynesThe pot of gold at the end of the rainbow.
01:58emezeskemk: It's a Var created like (def ^:dynamic x 5) that can be changed in a thread-local dynamic scope via things like (binding ...)
01:58emezeskemk: But for more detail, the docs are king :)
01:58mkwhen I mutate a var using the repl, and there's a thread busy crunching data, isn't that out of thread-local?
01:59emezeskeYeah, although if you set the root binding (as you mentioned) I do believe it would affect other threads
01:59emezeskeBut really, that is what atoms are for
02:00mkso in cases where we suspect that we might end up modifying code in this way, we should use atoms throughout?
02:01mkthis seems strange
02:02mkif we're both writing the same code, and you do it in one go, while I do it interactively using the repl, my code now has atoms everywhere while yours doesn't...
02:02emezeskeWell, if you reload a namespace with (require ... :reload), all the Vars get changed
02:02emezeskeAnd if you really want to, you can set! a Var
02:03emezeskeI suggest you do some more reading on clojure's concurrency primitives and make an informed decision
02:06mkif you look at the first example, with the multiplier - if I've chosen to use the repl to fine-tune the value of multiplier, I end up making it an atom. But if you know what you want the multiplier to be, you'd just (def multiplier 7.23), without using an atom. This doesn't seem strange?
02:07mkwe end up with the same code, but many of my values are wrapped in atoms. Do I then just remove all of the atom definitions, when I'm done messing via the repl?
02:08emezeskeThis would be a good place to start: http://clojure.org/concurrent_programming
02:09ro_stanyone know of a pubsub impl in cljs that isn't the shoreleave one?
02:09ro_stit's broken and ohpauleez is AWOL :-)
02:10mkemezeske: is there something particular there that I should read?
02:10ro_stalso, does anyone use enfocus? i'm curious as to whether i can use it to focus a textfield
02:11emezeskemk: I would start with reading about Vars and Atoms, to see what the differences/similarities are.
02:12emezeskemk: There's no clear answer about which is "better" -- they are different, and which one you want depends a lot on context
02:21meenalHi, can someone please point me to a good example of slingshot ex-info/ex-data in clojure?
02:21meenalI am trying to use slingshot to avoid writing custom exceptions
02:24emezeskemeenal: I happen to know that https://github.com/cemerick/friend/blob/master/src/cemerick/friend.clj uses throw+ and try+
02:24emezeskemeenal: It's not meant to be an example, but that was the first place I saw slingshot in action
02:26michaelr`Is there a way to destructure in one compojure route definition all of the following: a paramter from params with an aliased name, user-agent header, all headers, all session? Something like this: https://www.refheap.com/paste/3914
02:27meenalthanks emezeske. i will try to read thro' the code
02:34michaelr`ok
02:34michaelr`that's the way you do it: https://www.refheap.com/paste/3915
02:34michaelr`(money for nothing and chicks for free)
02:36muhoothe fun thing about slingshot is it shows the local variables at play when the exception happened
02:38ro_stmichaelr`: i think destructuring is clojure's MVP
02:38ro_stit is insanely useful
02:46y3dido the prismatic guys ever stop by this channel?
02:46ro_styou also want their data store abstractions? :-)
02:47ro_streally enjoyed that guy's talk
02:47emezeskero_st: at clojure/west?
02:48ro_styes, that's the one
02:48ro_sthttp://www.infoq.com/presentations/Why-Prismatic-Goes-Faster-With-Clojure
02:48emezeskero_st: yeah, that was great
02:48emezeskeThose guys are using the #&*? out of clojure
02:49ro_stit rocks. i wish more big guys would talk about how they use it
02:49emezeskeaye
02:49ro_stconvince the fence sitters to take a look
02:49michaelr`ro_st: minimal viable product?
02:49ro_stmost valued pfeature -grin-
02:49emezeske*pheature
02:50michaelr`oh, we add those all the time to our applications ;)
03:12ro_stcontains? checks if a key is in a collection. how do i check for the presence of a value in a collection? in this case, a vector?
03:13DaoWenI think you can use (.indexOf v element)
03:13ro_stwhoa. didn't think i'd have to use java!
03:13DaoWenof you could use (some #{element} vector)
03:13emezeskero_st: Maybe some?
03:14emezeskeHah, DaoWen beat me to it :)
03:15DaoWen:)
03:16djcoinIs there a problem using .indexOf (besides "it's java") ?
03:16ro_stsome does the trick. just found it weird that i'd have to drop to java to find that index. of course, i don't have to, because (some) does the job
03:21DaoWenro_st: if you need to check for the presence of a value in a vector, you might think about switching to a set
03:21DaoWenit depends on what you're doing of course
03:21DaoWenhow big your vector is, how often you need to check, etc
03:22ro_sti could use a set, but in this case i want the order items were added to remain in place
03:22DaoWenone thing I've done in the past is keep a vector AND a set
03:25emezeskero_st: There is a sorted-set if you need it
03:26DaoWenemezeske: I think he's trying to maintain things in the order they were added, which isn't necessarily a sorted order
03:26emezeskeOh, quite right!
03:26ro_styup
03:26emezeskeThere might or might not be some beer in me
03:27ro_stas long as you don't drunk-commit -grin-
03:27emezeskeI have had to revert drunk commits before, I'm sad to admit
03:30ro_stoh dear :-)
03:41muhoowow, nrepl in the hizzy
03:41muhoosuccessfully upgraded to emacs24, latest nrepl.el, and pdo is working
03:46muhoolein2 pdo cljsbuild auto, repl :headless
03:46ro_stsounds awesome
03:46ro_stwhat's pdo? :)
03:46muhooro_st: github.com/raynes/lein-pdo
03:46ro_stok so you have cljsbuild running, and a headless repl, so that you can nrepl in from emacs?
03:46muhooa nifty plugin that lets one lein process handle multiple tasks in parallel. like, a cljsbuild, and a headless repl
03:46muhooya
03:46ro_sti would love to see your emacs and project.clj config for this
03:46ro_stplease :-)
03:46muhooro_st: https://www.refheap.com/paste/3918
03:46ro_stthat looks straightforward
03:46ro_sti guess i'm more curious about nrepl.el and how it works with clojure-mode
03:46muhoothere's no .emacs , i just manually am loading nrepl.el for now, from github.com/kingtim/nrepl.el
03:46ro_sti'm using emacs-live which has swank-clojure and clojure-mode all glommed together
03:46muhooM-x load-file RET /home/clojure/src/nrepl.el/nrepl.el RET
03:47ro_st*reads nrepl.el issues*
03:47muhooeasy enough to just read nrepl.el, it's about 1200 lines
03:48ro_sti'll make time to play with it this afternoon
03:48ro_stit looks great
03:48muhooi find it a lot more approachable than swank, then again, i'm not an old-skool swank user
03:48muhooseems like the keybindings are the same though
03:54ro_stcool
04:12ro_sti guess if i want a vector sorted, i should use sorted-set or sorted-map, and then (vec) afterwards?
04:13ejacksonor just call sort !
04:18amalloyif you want a vector sorted, you probably don't want a vector
04:22ro_stejackson: i don't see the fn you refer to on http://clojuredocs.org/quickref/Clojure%20Core
04:23ro_stamalloy: i actually want a sorted-map, but sorted-map sorts on the key, not on the value, and i need to sort on a field in the map that makes up the values in my map
04:23amalloyro_st: that's a heap
04:23ro_stthis map is an atom, which makes using a sorted-set problematic (ito updating values in this data)
04:26ro_stamalloy: are you referring to heap-sorting?
04:26ejackson,(sort [12 4 8 23 1])
04:26clojurebot(1 4 8 12 23)
04:26amalloyhttp://en.wikipedia.org/wiki/Heap_%28data_structure%29
04:27ejacksonbut amalloy is correct,
04:28ro_stok, this is well out of my comfort zone. i never did compsci :-) can i use a heap/heap sort in cljs?
04:29ro_stin this case, i don't need lazy, as it's to sort a series of models in preparation for displaying a list of html nodes
04:30ro_stso the full collection will be realised. so i'll start with (sort comp coll) for now
04:59ro_stsort fns usually return 1 0 −1 based on whether A is less than, equal to, or greater than B
04:59ro_sti see clojure's sort uses true and false. what do i return for the equality case? i won't have this case now, just curious.
05:14DaoWenro_st: I know tis is a bit late, but you might want to use sort-by rather than sort since it sounds like you're sorting on a specific field in a data structure. that will keep your comp function simpler.
05:15ro_styeah, i found that :-)
05:15ro_stthanks
05:37ro_stsurely there's a better way to print vectors and maps to the js console than cljs.core.ObjMap and cljs.core.PersistentVector trees?
05:38ro_st*reads himera again*
05:48ejacksonro_st: I just log em to the the console
05:49ro_styeah but having to drill down into PersistentVectors is sucky compared to plain js arrays
05:50DaoWenro_st: what do you mean by "drill down?"
05:51ro_sthttp://rationalist.co.za/uploads/Screen%20Shot%202012-07-31%20at%2011.50.38%20AM-rS07Grmbqs.PNG
05:52ro_sti guess i could augment my log fn to dig into these and show the internal items i'm interested in
08:44lotiagreetings all. new projects, relative noob to clojure. nrepl or swank for new projects.
08:44lotiawhats better?
08:44ro_stnrepl is still brand new
08:45ro_stthat said, it's probably better for you to learn that and grow with it than take swank on and switch
08:45lotiai ask because i'm starting a new pallet project using lein2 and want to be able to eval forms from within my files.
08:45ro_sti believe nrepl does that no problem
08:45lotiaso using emacs, i'd need to get the nrepl client
08:46lotiaro_st: thanks. anywhere there's a list of advantages, disadvantages of either? or are the roughly equivalent for most use cases?
08:47ro_stswank is about to be deprecated, once the guys doing nrepl get it to the point they're happy with it
08:47ro_stcoupla weeksish
08:47lotiaro_st: thanks
08:48lotiaanyone using el-get for their emacs here?
08:54ro_sti'm using emacs24 for osx
08:54ro_stcomes with package-install.. i just added the marmalade repo
09:01lotiathanks ro_st
09:04cshelldoes anyone know how to pretty print to a file in clojure?
09:04XPheriorAnyone ever seen the error message "Incorrect table name ''" in Korma?
09:05XPheriorI darn sure specified a name.
09:10gfrederickscshell: at the very least you could (spit "foo.cljj" (with-out-str (pprint data)))
09:10gfredericksand improve from there for any needed perf
09:10gfredericksthere might be a pprint-str also, not sure
09:17cshellgfredericks: cool, i'll give that a shot - thanks!
09:20ro_stXPherior: what does the sql dry-run look like?
09:20XPheriorro_st: I just noticed that my usage of create-db is returning a PersistentArrayMap. That can't be right, heh.
09:21ro_sthaha, um, no, probably not :-)
09:23XPheriorro_st: Have a look. https://gist.github.com/eecf4c8857596c73b72f
09:23XPheriorLine 3 is still returning an array map. Weird.
09:25ro_stXPherior: db contains an execution result, where i think you actually want a defdb definition
09:26XPheriorro_st: I need to create the connection dynamically. I don't know what the DB name is at compile time.
09:27ro_sti get that. i speak under correction, but as far as i know korma uses static defdb definitions.
09:27ro_styou can probably overcome this by doing what defdb does yourself
09:28XPheriorI basically am. Check it out. https://github.com/ibdknox/Korma/blob/master/src/korma/db.clj#L60
09:33ro_stah
09:33ro_stweird
09:35ro_stso, presumably there's something different about the spec there and the one you're providing?
09:40XPheriorLooks like it, yeah.
09:43antoineBhello, how can i construct a list from 2 list?
09:43antoineB(apply list '(1 2 3) '(1 2 3)) => ((1 2 3) 1 2 3) where i expect (1 2 3 1 2 3)
09:44xeqi$findfn [1 2 3] [1 2 3] [1 2 3 1 2 3]
09:44lazybot[clojure.set/union clojure.core/lazy-cat clojure.core/concat clojure.core/into]
09:44xeqiI'd use concat there
09:47antoineBsimply concat, thanks
09:51leafwwhat is the current authoritative repository for clojure monads? Used to be part of clojure-contrib
09:51leafwbut now clojure-contrib is fragmented
09:53xeqi~contrib
09:53clojurebotMonolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
09:54xeqileafw: looks like https://github.com/clojure/algo.monads/
09:55leafwxeqi: thanks. So does that mean that it is included in the main clojure repository?
09:55leafwI see, no
09:55leafwit is in its own
09:56xeqileafw: no, you'll need something like [org.clojure/algo.monads "0.1.0"] as a dependency
09:57leafwthanks
09:57mkhow do I get lein repl started using 1.3?
09:59mkor, does anyone's lein repl start using (clojure-version) 1.3 by default?
10:00xeqimk: make a project using 1.3 and then run `lein repl` in it
10:02mkI was running it in a random dir to get access to a repl. I suppose I can just run clojure instead of lein repl?
10:02mkis there any difference between the two?
10:03ToxicFrogmk: 'lein repl' sets up the CLASSPATH and stuff appropriate to your project, and I think also uses jline automatically
10:04ToxicFrogIf you don't have a project and just want a Clojure repl, 'clojure' (if your distro comes with it) or 'java -cp ...jline.jar:...clojure.jar jline.ConsoleRunner clojure.main' if it doesn't should do the trick.
10:05ToxicFrogOr just 'java -jar /path/to/clojure.jar' if you don't care about readline support.
10:07mkyeah, just clojure seems to work. I was under the impression that lein repl was enhanced in some way, though I'm not sure what way that would be since it's about as bland as it gets
10:11mkis the only difference between bigint and biginteger the hashcode?
10:12leafwhow does one specify a local jar in the project.clj?
10:12leafwas in, where does one put it so that it ends up in the classpath and it is read as a dependency?
10:13ifesdjeenleafw: pretty much the same way as you would do with maven
10:13ifesdjeenleafw: you can add :repositories {"local" ...
10:13leafwifesdjeen: I have no idea how to use maven
10:13ifesdjeenpoint to (.toUri (java.io.File. "maven_repository_path"))
10:13leafwlein is supposed to shelter us all from maven
10:13ifesdjeen:)
10:13ifesdjeenyeah, it certainly does
10:14leafwso the .toUri you add in the project.clj?
10:14ifesdjeenyup
10:14leafwok
10:14leafwthanks
10:14leafwwouldn't need to if org.clojure/algo.monads "0.1.3-SNAPSHOT" existed.
10:14ifesdjeenleafw: hm, people say that you can just say :repositories {"local" "path" }
10:15leafwthe git repos pom.xml says that's the current.
10:15leafwok
10:15ifesdjeenoh my, there's even plugin for that :D
10:15ifesdjeenhttps://github.com/kumarshantanu/lein-localrepo
10:15leafwlein is as complicated as it gets, mostly from lack of documentation.
10:16ifesdjeenso far didn't get much issues with that...
10:16leafwthe default project.clj could have, commented out, all possible examples with a one-liner explaining what they are for. Like for the "local"
10:16leafwthanksf or the help ifesdjeen
10:17ifesdjeenleafw: npnp
10:17ifesdjeenhope it does it's job :)
10:17leafwever since the break down of contrib, I have not been able to use any contrib projects.
10:17leafwso trying again
10:18uvtcleafw: jumping in to the middle of this, but if you're looking for a project.clj with all possibilities, see https://github.com/technomancy/leiningen/blob/master/sample.project.clj .
10:18DaoWenmk: no, the difference between bigint and biginteger is not just the hashcode
10:18leafwthanks uvtc
10:19uvtcleafw: y/w. Also, if you're new, you might find this useful: http://www.unexpected-vortices.com/clojure/brief-beginners-guide/
10:19mkDaoWen: what are the main differences?
10:19DaoWensorry, I was looking up a URL
10:19DaoWenhttp://grepcode.com/file/repo1.maven.org/maven2/org.clojure/clojure/1.3.0-alpha5/clojure/lang/BigInt.java
10:20DaoWenthat's the BigInt class
10:20DaoWenyou can see right at the top that it wraps both a long and a BigInteger
10:21leafwuvtc: thanks, not new to clojure, but haven't used it for 2 years
10:21leafwand now it's all different. Still no good IDE unfortunately.
10:21DaoWenmk: BigInt will use the native operations for long when possible
10:22DaoWenbut if the number gets to big then it uses the arbitrary-precision BigInteger methods to do operations like add, multiply, etc
10:23ifesdjeenleafw: not sure what would make it for a good ide for you, i use it with emacs + paredit + clojure-mode + autocomplete-mode + swank
10:23leafwlein is full of magic that I find hard to grasp. For example, a function defined in core.clj, how do I refer to it from project.clj? core.main having written (defn main ..) doesn't do it.
10:23ifesdjeenworks really really well for me
10:23leafwcore/main ?
10:24leafwifesdjeen: emacs destroys my hands. vim, eclipse, or a plain text editor I prefer.
10:24ifesdjeenah
10:24ifesdjeenwell, only problem with vim I have is that it's not playing with lips as well as emacs does
10:24DaoWenleafw: I use lein with vim
10:24mkDaoWen: I see, thanks
10:24ifesdjeenbut i do feel very comfy with it, so dunno)
10:25leafwDaoWen: I am at the moment.
10:25DaoWennice :)
10:25DaoWendo you use slime.vim?
10:25leafwDaoWen: so how does one refer to a fn named "main" in core.clj from project.clj?
10:25leafwit's not core.main
10:25leafwand not core/main
10:25xeqiprojectname.core/main ?
10:26DaoWentry that ^
10:26DaoWenyou need the fully-qualified namespace
10:26DaoWenleafw: what does the (ns) declaration look like at the top of your core.clj file?
10:26leafwproject is parse-bib, so parse_bib.core/main fails, and parse_bib.core.mains fails too
10:26DaoWentry
10:27DaoWenparse-bib.core/main
10:27DaoWen(hyphen instead of underscore)
10:27DaoWenif that doesn't work
10:28DaoWendid you :require it in your ns declaration in the current file?
10:28leafwDaoWen: the default
10:29DaoWenleafw: what exactly are you trying to do? are you trying to declare the main method in project.clj for a runnable jar or something?
10:29leafwDaoWen: parse-bib.core
10:30antoineBhow could i do a recursive call without a named function?
10:30leafwI am doing the simplest thing possible: (ns parse-bib.core) (defn main [] (println "ok"))
10:30DaoWenand you just want to call that function from another file?
10:30leafwno, I want to define main as the main function in project,clj
10:30DaoWen(another namespace)
10:30DaoWenok
10:30leafwso either lein doesn't like hyphens
10:31leafwin the project name
10:31leafwor I don't get it
10:31CheironHow to get the name of a called function? for logging purpose
10:31leafwtried all combinations
10:31DaoWenyeah, it's weird
10:31DaoWenyou actually have to declare it as (defn -main [& args] ...) in core.clj
10:31leafwthat's my experience with lein always: can't get over the simplest things. There is a set of expectations that are not written anywhere about how lein works.
10:31leafwtrying that
10:32DaoWenI guess that's the clojure magic for defining a java main method
10:32leafw(reads like static public final void main(String[] args) ....)
10:33DaoWenbut then in your project.clj you just give the class
10:33DaoWenparse-bib.core
10:33leafwstill doesn't work. So, removing the hyphen from the project name ...
10:33DaoWenalso, in parse-bib.core you need to tell it to :gen-class
10:33leafwI see: so :main is not the function, but the name of the file
10:33DaoWen(ns parse-bib.core (:gen-class))
10:33DaoWen:main is the name of the class
10:34xeqi:main is the namespace
10:34leafwfinally, it worked
10:34leafwthanks
10:34uvtcleafw: re. "set of expectations that are not written anywhere about how lein works" ... if you find that lein is making an assumption and not telling you about it, and it's not documented, I'd suggest filing a bug.
10:34leafwso lein does respect hyphens in the project name
10:34leafwit is :main in project.clj that asks not for the main function but for the class in which a function named -main exists ...
10:34CheironI'm passing a function to another function, i want to print the name of the passed function. how to do it?
10:34DaoWenI don't think these are so much lein quirks as just clojure-java interop quirks
10:35leafwuvtc: doing so
10:35DaoWenleafw: I think :main is kind of like the class manifest in a JAR file
10:35DaoWenit asks for a "main" class
10:35leafwbecause the sample.project.clj doesn't say anything about it in :main
10:36DaoWenyou could have any number of classes in a JAR with a main method with the legal signature, but you specify one as the "main" class
10:36antoineBi get it i just set a name to a fn: (fn f[a] (+ 1 (f a)))
10:36leafwDaoWne: the point here is, how is a novice user of lein ever to find out?
10:36DaoWenI've only been using lein for a couple of weeks
10:36DaoWenI googled how to make a runnable JAR
10:37DaoWenthere are lots of blog posts on the subject :)
10:38uvtcleafw: Note, there's also a #leiningen channel.
10:39Cheironwhen passing a function and parameters to macro, how to call it? ~(func ~@params) ?
10:39leafwuvtc: I hope not to have to use it, thanks
10:43DaoWenleafw: https://github.com/technomancy/leiningen/blob/preview/doc/TUTORIAL.md#uberjar
10:43DaoWenleifw: that section on the uberjar option explains everything on making a runnable jar
10:44leafwDaoWen: the point here is to use a jar from the file system
10:44leafwnot to export the project to a jar
10:44leafwturns out the :repositories is only for looking for dependencies
10:44leafwwhat a game of guessing. Second guessing the maven developer/superuser that wrote lein
10:45leafwlein is wonderful, if one doesn't want to do something out of the ordinary
10:45leafwI was hoping referring to a jar would be that
10:46leafwmaybe :javac-options would let me add a -cp
10:46DaoWenleafw: http://stackoverflow.com/questions/2404426/leiningen-how-to-add-dependencies-for-local-jars
10:47leafwuvtc: so I am moving to #leiningen, looks like the wall is high
10:47xeqi~repeatability
10:47clojurebotrepeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability
10:47leafwDaoWen: thank you. The top answer is a hack.
10:47xeqithat explains why lein doesn't want to just include jars from the file system
10:48uvtcleafw: looks like the author of lein (technomancy) is not around right now. I'd suggest bringing up your questions again next time he's around.
10:48DaoWenleafw: the second answer seems better, but I don't know how to make a private maven repo.... but it looks like the third post explains how
10:48leafwI take note. Surely there are good reasons not to depend on a jar but on a repository instead. It's just baffling to a newcomer.
10:49leafwthere is room for a book on how to create leinigen projects.
10:50uvtcA book? Maybe a booklet. Or a pamphlet. Or a leaflet. :)
10:50DaoWenleafw: I agree with you there. what if I want to use a JAR that's not in the maven repository? what if I'm using a proprietary JAR that can't be included in the repository? it seems like setting up a local repository just for one JAR in one project is a little bit overkill.
10:50leafwuvtc: no, a book, with 10-pgae chapters: a project with jars, why is (defn -main [& args]... needed, and so on.
10:50CheironHi, would you please take a look to my with-try macro attempt: http://pastie.org/4365552
10:51DaoWenleafw: https://github.com/kumarshantanu/lein-localrepo
10:51leafwDaoWen: the "hack" of ptting the jar in /lib should do it
10:51leafwso there is way
10:51leafwit is just not elegant
10:51leafwneither explained anywhere
10:51DaoWenleafw: looks like that plugin goes and make the local repo for you, and then you can add jars with a simple command
10:51uvtcleafw: writing good documentation is tricky. If you have any specific feedback on how to reorganize the lein docs to improve clarity, I'm sure technomancy would be all ears.
10:52leafwuvtc: indeed, complaining is not useful beyond a point.
10:52TimMcleafw: Don't put things in lib.
10:52TimMcIt won't work, that's why it's not mentioned.
10:53leafwTimMC: it didn't work, likely because the algo.monads-0.1.3-SNAPSHOT.jar doesn't work with clojure-1.4.0. Just found that out
10:53Cheironah, ok. e# :)
10:54uvtcCheiron: e#?
10:54leafwI am looking forward to join the priesthood of being able to use lein. Can't be that hard to use algo.monads in a clojure project.
10:54Cheiron(catch Exception e#)
10:54TimMcleafw: No, it won't work (at least in 1.x) because lib gets cleared.
10:54TimMcAre you using the 2.x preview? I came in late.
10:55leafwTimMc: using lein from 2 years ago, updated it self to 1.6 or so
10:55TimMcYeah, ./lib is a local cache. Lein 1.x will delete the contents when updating deps.
10:56uvtcleafw: Yeah, I'm not sure I'm following exactly what the problem you're having is, but if you want to use a contrib library, I put up some basic notes at http://www.unexpected-vortices.com/clojure/brief-beginners-guide/libs-management-and-use.html#using-contrib-libraries .
10:56dgrnbrghello clojurians
10:56leafwso algo.monads-0.1.1-SNAPSHOT exists, but can't run with 1.2, 1.3 or 1.4: error is Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/tools/macro__init.class or clojure/tools/macro.clj on classpath:
10:56mkCheiron: why does e# work?
10:56dgrnbrgi'm having an issue getting a namespace that uses a macro for doing dynamic codegen to compile efficientyl
10:56dgrnbrgis there a way to get the macroexpansion to occur at AOT time?
10:57Cheironi think because it generates a name, e could be bind somewhere else
10:57leafwuvtc: the program I am writing depends on algo.monads. I thought it would be nice to use lein to aleviate the dependency issues, but it is resulting in me wasting your time
10:57Cheironmk: variable capture issue of other Lisps
10:57uvtcleafw: Oh, no waste of time. :) Sorry if that came out wrong.
10:58leafwsorry, didnt mean to make it sound harsh on you, rather on me (I am fumbling with lein when I expected a smooth ride)
10:58leafwso does anybody know what clojure version would work with algo.monads?
10:59DaoWenCheiron: you are right, the e# syntax helps to avoid variable capture
10:59leafwuvtc: I see in your tutorial that the right approach is to query first maven central
10:59mkwhat is that syntax called?
10:59TimMcgensyn
10:59TimMc*gensym
11:00TimMc"generate (unique) symbol"
11:00leafwa pity maven central has 0.1.0 and not 0.1.3 for algo.monads
11:00TimMc&[`[e# e#] `[e# e#]]
11:00lazybot⇒ [[e__18236__auto__ e__18236__auto__] [e__18237__auto__ e__18237__auto__]]
11:01uvtcDaoWen: what is "variable capture"?
11:01xeqileafw: looks like the algo.monads test suite passes on >=1.2.0 http://build.clojure.org/job/algo.monads-test-matrix/
11:01DaoWenuvtc: name capture
11:01uvtcDaoWen: what is "capture"? :)
11:02DaoWenuvtc: it happens with macros. Cheirion was trying to make a try/catch-like macro
11:02leafwxeqi: thanks
11:02uvtcDaoWen: Ah. Will research further next time I'm reading about macros. Thanks.
11:02mkI'm looking at clojure.org/reader, and it has nothing about # suffix. Where are the docs on this?
11:02DaoWenuvtc: what are you reading?
11:03TimMcmk: It's really the syntax-quote that does it.
11:03leafwxeqi: maven central has 0.1.0 for algo-monads, but setting it as dependency and then "lein run" doesn't download the jar into /lib, and fails with "Could not locate clojure/algo/monads__init.class or clojure/algo/monads.clj on classpath"
11:04uvtcDaoWen: I mean that I wanted to know what the term "capture" meant, and you pointed out that it has to do with macros, and at the moment I've only skimmed the documentation on macros.
11:04leafwok "lein deps" did it
11:04leafwwould have expected that to hppen as fallback from lein run
11:05xeqileafw: that would be my expectation too, we try to make sure all reuired tasks are run in lein2
11:05mkTimMc: thanks, I see that in the docs now, where it says ends with '#'
11:05DaoWenuvtc: "capture" happens when a name declared in a macro conflicts with a name already declared in the scope where it's used, so the macro "captures" the user's attempts to reference the binding they declared--and bad stuff happens
11:05xeqinot sure how well that was done in lein1, esp not if you have n older version
11:05leafwxeqi: nice to hear there is a better version of lein in the works
11:06leafwxeqi: using lein 1.6.1.1
11:06uvtcDaoWen: Thanks. :)
11:07leafwfinally ready to go; thanks uvtc, xeqi and DaoWen.
11:15TimMcuvtc: There are two kinds of capture (maybe one has a different name): 1) Macro introduces a binding that shadows an existing lexical binding, 2) macro's introduced binding is shadowed by an internal lexical binding in the expansion.
11:15TimMcI'd be hard-pressed to come up with a good example of the second.
11:18jsabeaudryIs it new that cljsbuild triggers a compilation when a clj file changes and not only when a cljs file changes?
11:20uvtcTimMc: thanks for the info. Added to my own notes for when I dig into macros. :)
11:21DaoWenTimMc: (fn [x] (let [loop #(apply prn %&)] (loop 1)))
11:22uvtcTimMc, DaoWen : Previously, I'd used the term "capture" to refer to pieces of regexes that matched. Like \1 and $1.
11:24uvtcs/I'd used/I'd only used/
11:24DaoWenuvtc: this is a big problem in computer science--we re-use words way too much and give them way too many different meanings. I believe the "name capture" idea originally comes from the Lambda Calculus.
11:25uvtcYeah. Trouble is, if you invent too many new words, you end up with too much jargon. :)
11:25TimMcIt's a problem everywhere.
11:26DaoWenhaha, good point.
11:27DaoWenoh wow, I just realized my example was totally messed up
11:28entelhas anyone got the noir plugin to work with leinengen 2? is it even possible?
11:29DaoWenentel: you might want to try #leiningen
11:30entelDaoWen: ok thanks
11:37m0smithAny clojurescript gurus around? I am getting this not too helpful error: Exception in thread "main" java.lang.AssertionError: Assert failed: Only :refer-clojure, :require, :require-macros, :use and :use-macros libspecs supported
11:37m0smith(#{:use-macros :require-macros :require :use} k)
11:37nDuffm0smith: Can you gist (or otherwise pastebin) your ns declaration?
11:38m0smith(ns crossfire.board (use [crossfire.protocol.location :only [display open?]]))
11:38meliponehello
11:38nDuffm0smith: ...so, first, that should be :use
11:39meliponehow do a get a list of rows from an Incanter matrix?
11:39m0smithnDuff: you are a genius, thanks
11:40TimMcmelipone: Try seq.
11:41meliponeI tried seq but it still gives me a matrix back not a list of rows
11:43meliponetimmc: sorry, appearances are deceiving. it does behave like a list of rows
11:43m0smithnDuff: now I get SEVERE: crossfire.board:4: ERROR - required "crossfire.protocol.location" namespace never provided
11:44m0smithI am using cljsc, where does it expect to be compiling from?
11:48goodieboyAnyone know of a leiningen plugin that would provide the ability to download *resources* from s3, by looking at a config map in project.clj?
11:48goodieboy... s3, or some other url
11:49DaoWenmeliphone: I think the Incanter Matrix class supports the .toArray method, which returns a double[][] -- which may or may not be helpful
11:52uvtcJust added an example to http://clojuredocs.org/clojure_core/clojure.core/some-fn .
11:53uvtcIncidentally, it would be pretty cool if there were a way for the site to send an automated message every time someone added an example.
11:53uvtcI mean, an irc message to this channel.
12:10nDuffm0smith: I'd have to look at the source for the file containing crossfire.protocol.location.
12:16augustlwhen I stop and restart my "lein ring server-headless", the :session key is not present in the first request, even though the :cookies entry is there. How come?
12:16augustlin subsequent requests, the :session works fine
12:17augustlcorrection: the :session key is present, but is empty
12:17augustla minor annoyance, but still an annoyance :)
12:18technomancyhttps://twitter.com/gghhzz/status/230335904097656833 woo go clojure.org
12:18hiredmanaugustl: the defalut session store is an in memory store, you kill the process you lose it
12:18augustlhiredman: I'm using the cookie store
12:18augustlso the full session is present in the cookie
12:20augustltechnomancy: Google Closure is similar (not only in name): you basically need to buy a book
12:20augustlthe docs on the Google Closure site are abysmal
12:21hiredman*shrug*
12:22hiredmanI've gotten most of what I needed from the google closure api docs
12:22hiredmanthe real pain is often the css for the ui widgets is not really documented
12:23mabes,(doc realized?)
12:23clojurebot"([x]); Returns true if a value has been produced for a promise, delay, future or lazy sequence."
12:23mabes,(realized? (iterate inc 1))
12:23clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPending>
12:24mabesI am misunderstanding what the realized? doc string is telling me...
12:24hiredman,(realized? (next (iterate inc 1)))
12:24clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPending>
12:24hiredmanfuh
12:24hiredman,(realized? (rest (iterate inc 1)))
12:24clojurebotfalse
12:25hiredmanmabes: basically iterate doesn't produce it's fist item lazily, so it is not a lazy seq, but its rest is
12:26mabeshiredman: ah, got it.. ok, I can work with that. Thanks!
12:26technomancywooooo eldoc in nrepl.el
12:27m0smithnDuff: https://github.com/m0smith/crossfire/blob/master/src/crossfire/protocol/location.clj
12:29nDuffm0smith: ...so that's .clj, not .cljs
12:29m0smithnDuff: yes I was hoping to make a cross-compatible code base
12:29nDuffahh.
12:32m0smithwould that confuse the cljs compiler?
12:32nDuffm0smith: Yes. lein-cljsbuild will automate making .cljs copies of the .clj files you want to use in both worlds for you.
12:32nDuffm0smith: ...I do suggest using it.
12:33m0smithnDuff: many thanks
12:33technomancymmm... taste the rainbow: https://github.com/kingtim/nrepl.el/network
12:34eggsbyhey technomancy have you had problems with large output from nrepl.el ?
12:35technomancyeggsby: no, but I can't say I've used it on projects with lots of output
12:36pbostromaugustl: when you restart the server, the session is not intialized until after you make the first request, the server looks at the cookie, recognizes it, then sticks something in the session for all subsequent requests
12:36eggsbytechnomancy: for me, something as simple as: (for [x (range 0 1000)] (println x " | hi")) results in "error in process filter: could not decode object 1"
12:37technomancyeggsby: no problem here. are you on Emacs 24 and nrepl.el master?
12:37eggsbyya :(
12:37eggsbyactually just marmalade nrepl
12:38technomancythere's been a fair bit of activity since then; might try the latest
12:38eggsbywill do, thanks
12:40mkis there a swap! that returns the old value?
12:47nDuffm0smith: Pull request pending.
12:48augustlpbostrom: so even if I have a cookie session, it puts stuff in memory?
12:48nDuffOof.
12:49nDuff...ignore that, please...
12:51nDuff(...so, the "ignore that" was in reference to the first rev of the pull request)
12:51augustlI assumed the :session values were added as soon as the middleware sees the cookie
12:52TimMcmk: Not anything in core.
12:53TimMcYou could do something fancy with a side-effecting fn and another atom...
12:57mkI see. It looks like a watch might work too, at least for some purposes
12:57m0smithnDuff: I'll pull it now
13:06m0smithnDuff: that seems to have done the trick. Thanks again
13:10pbostromaugust1: you should think of the cookie and session as two separate entities, if your app/service puts some key-value pair in the cookie, it will persist in the browser when you restart the server (depending on how the cookie is configured), if you put something into the session, it will persist in the server's memory by default (although I believe you can configure alternate session stores)
13:11technomancyquestion for anyone familiar with proxies: does it make sense to have one setting for HTTP proxies and a separate one for HTTPS?
13:11Hodapptechnomancy: 'setting' in what sense?
13:12technomancyHodapp: say you'd want to use a different proxy host for HTTPS?
13:12technomancyI'm ... not really sure
13:12technomancybasically I get all these feature requests for proxy support in Leiningen and I have no idea how proxies work or how people would expect them to be set =)
13:13nDufftechnomancy: ...for a SOCKS proxy, it's typically the same one for all protocols
13:13TimMc(defn swap2! [a f & args](defn swap2! [a f] (let [old (promise)]
13:13TimMc (let [oldp (promise)
13:13TimMc f* (fn [oldv] (deliver oldp oldv) (apply f oldv args))]
13:13TimMc (swap! a f*) @oldp))
13:13technomancyApache's HTTP client uses separate http.proxyHost vs https.proxyHost settings, so presumably there's a reason for that
13:13nDufftechnomancy: ...but some shops _do_ have protocol-specific proxies rather than using SOCKS.
13:13TimMcmk: crud, I thought I had the one liner in my clipboard, but... there you go
13:13technomancynDuff: that's what I was wondering; thanks
13:14TimMcmk: Rather: https://gist.github.com/3218623
13:22m0smithnDuff: One last question I hope. When I copy the resulting .js file to my webserver directory, it is looking for a deps.js but I can't see where that is supposed to come from
13:29pbostromm0smith: I think it's a GClosure compiler thing, I get rid of it by putting this inline in the html: <script type="text/javascript"> var CLOSURE_NO_DEPS = true; </script>
13:30nDuffm0smith: set CLOJURE_NO_DEPS=true in your javascript before including it.
13:30pbostromm0smith: before loading your .js file
13:30nDuffAhh.
13:31tufflaxIs it sane to want letmulti---local multimethods in a function?
13:31m0smithThank you both. That got rid of that error.
13:32m0smithNow I just have to figure out how to get JS to call my code
13:33rplevyis jetty-util incompatible with ring-jetty-adapter, and if so does anyone know a version combination (or something) that is compatible?
13:35rplevythe stack trace is especially unhelpful here, but I get a classnotfound for org.eclipse.jetty.util.component.Destroyable
13:35weavejesterrplevy: What's jetty-util?
13:37emezeskem0smith: (defn ^:export my-fn [] ...)
13:37nDuffemezeske: last I knew, m0smith wasn't using advanced compilation (yet).
13:37emezeskem0smith: That tells the google closure compiler to make that function available to JS even when advanced optimizations are on
13:37emezeskenDuff: Well, good to get in the habit now
13:37nDuff*nod*
13:38nDuffm0smith: ...so, it should just be your.module.name.your_function(args), that is, completely normal javascript calling convention
13:40eggsbyhey thanks technomancy using the master branch fixed the problem
13:40m0smithnDuff: I look in the .js file and none of my code, namespaces, etc is in there. At least a naive search does not find it
13:47nDuffHmm -- there's an error in the source, and cljsbuild is only reporting it once, silently failing on subsequent passes. That's annoying.
13:48rplevynm I was just had the name of a class wrong because they changed it recently
13:48rplevyand jetty-utils is included already
13:49m0smithnDuff: Should I use require instead? Use is slightly more convienent is all
13:50emezeskenDuff: If you can reproduce this "only reporting an error once" problem, open a bug
13:52nDuffemezeske: Can, but not sure I have the time to build a minimal reproducer right now. Also, likely a lein-cljsbuild thing rather than a cljs thing proper.
13:53m0smithnDuff and emezeske: I was :use to include a file that defined a protocol. That would cause the error. Swtiching to :require fixed the error and makes more sense anyway
13:54technomancym0smith: whaaaaat?
13:54technomancyI don't think that's possible
13:54emezeskenDuff: Well, if you aren't willing to make a repro, it's not getting fixed, because I have never seen that problem.
13:57m0smithtechnomancy: Debuggin a cljs problem.
13:57technomancyoh, ok; I know nothing about cljs
14:13mkis a var (setting aside dynamic scope) simply an atom but with only the reset! change semantic?
14:14gtrak`mk: vars are namespaced
14:14gtrak`I guess that's the dynamic-scoped bit
14:15gtrak`but they're also carry a thread-local stack for mutation, atoms are synchronous between all threads
14:15gtrak`s/they're/they
14:16cemericksaying "X is like an atom, but without the atomicity" is a curious comparison to try to make :-)
14:16amalloycemerick: i don't think vars are missing any atomicity
14:17amalloyalter-var-root behaves like swap, and binding can't ever have contention/races
14:17mkisn't the stack only used in dynamic scope?
14:17gtrak`mk: stack is used on lookup
14:18mkbut if there's nothing put on the stack using binding, or the var isn't defined dynamic in the first place (do I have that right?), then it's simply an atom, and it's not thread-local
14:18gtrak`it's not an atom...
14:19mkgtrak`: right, I mean that it might as well be
14:19gtrak`so... why would I prefer to use (def a (atom 0)) instead of (def a 0)?
14:20mkI have no idea, at the moment
14:20foodoochanging of (def a 0) is only intended for development purposes. Isn't that the issue?
14:21Gnosis-How does one decide whether to use an atom or a ref?
14:21gtrak`it might be more a statement of intent I guess
14:21gtrak`convention
14:21amalloyGnosis-: use a ref if an atom lacks a feature you need
14:21Gnosis-ah, okay
14:22mkfoodoo: I don't know. It's a bad idea to confused def with assignment, so perhaps that convention is there to avoid misleading those new to clojure
14:22amalloythe only features i can think of are: coordinating with other refs; being able to return something other than the current value from a swap! (that one can be worked around, but it's easier to just use a ref)
14:23mkbut really, it seems like (def v ...), used to assign a new value to v, isn't that much different from (swap! ...)
14:23gtrak`swap! takes a function and does a compare-and-swap
14:23gtrak`spin-loops if it has to
14:23mkgtrak`: you're right, I meant reset!
14:23gtrak`right
14:25pbostrom_there may also be a time when you want to coordinate side effects with a single ref
14:26gtrak`looks like var roots follow volatile semantics, JLS only guarantees 32-bit reads to be atomic
14:26mkand yes, like amalloy said, alter-var-root covers swap! (and therefore compare-and-set!)
14:27gtrak`probably not a real issue if you use boxed numbers
14:27mkI was under the impression that atoms offered something in addition to vars, but really, vars are effectively atoms, and in addition they provide dynamic scope
14:28gtrak`mk: it's misleading to keep saying that
14:28gtrak`atoms and vars are implemented totally differently
14:28mkgtrak`: I welcome correction :)
14:28gtrak`and have different use-cases
14:28cemerickamalloy: Of course; s/atomicity/CAS, but that wouldn't have rolled off the keyboard as nicely.
14:28gtrak`well, you know, for these things I like to just look at the source code
14:29hiredmanvars are interned, they are linking construct, not a state management construct
14:29mkgtrak`: it doesn't matter if something is implemented + 4 1 or + 1 4, it's still the same result, unless one is faster. Vars seem to offer all of the features that atoms do, and then some
14:30mkhiredman: they seem to have everything you need in order to manage state
14:30gtrak`vars are volatiles... atoms are AtomicReferences under the hood
14:30mkgtrak`: I'm not saying that one extends the other
14:31mkgtrak`: what do you mean by volatiles?
14:31gtrak`there's a java keyword 'volatile' that offers particular memory semantics
14:31hiredmanmk: the semantics of swap! are clearly a compare and swap, alter-var-root's semantics are not really defined
14:32gtrak`I think even if semantics were the same, the argument is the same as using a global vs a local... don't
14:32hiredmanmultiple alter-var-root's from different threads can stomp on each other
14:32hiredmanvars are a linking construct
14:32mkhiredman: I don't think swap! does comparison unless you implement that in the function (which you can)
14:32hiredmanclojurebot: vars?
14:32clojurebothttp://www.slideshare.net/mudphone/fun-with-vars
14:33hiredmanclojurebot: vars |are| a linking construct
14:33clojurebotYou don't have to tell me twice.
14:33hiredmanmk: swap! is a CAS
14:33hiredmane.g. if the value of atom changes it reruns the functions on the new value
14:34augustlhow do you call a Java constructor that takes varargs? Just passing (MyThing. foo bar baz) doesn't seem to work.
14:34gtrak`augustl: into-array
14:34gtrak`varargs are arrays in java
14:34hiredmanat the jvm level vargs don't exist, the java compiler turns java varargs in to an array
14:35mkhiredman: I'm pretty sure alter-var-root does the same. "atomically alters the root binding by applying f..."
14:35augustlgtrak`: looking it up, thanks
14:36hiredmanmk: incorrect
14:36mkwhat happens if the value changes?
14:37gtrak`turns out alterRoot is synchronized anyway, that's slower than a CAS generally
14:37hiredmanmk: if you aren't going to read what I type I will also put you on ignore, I told you what happens already
14:38TimMcnDuff: map vector
14:38mkhiredman: sorry, it's possible that I missed what you said among the other messages, or didn't understand you. I'll read up
14:38TimMcnDuff: Possibility of infinite seq?
14:39nDuffTimMc: Not necessarily infinite, but big enough that memory use is a relevant concern.
14:39mkhiredman: I still don't see where you answered my question
14:40nDuffmk: I do.
14:41nDuffmk: <hiredman> e.g. if the value of atom changes it reruns the functions on the new value
14:41mkI'm not talking about atoms, I'm talking about vars
14:41nDuff...
14:41nDuffmk: you were given an example of a behavior atoms have that vars don't. That's pretty relevant.
14:42mkwe're talking about alter-var-root. Doesn't that restart, in exactly the same way as atoms do?
14:43mkI could be wrong, but that's what I'm taking the documentation to mean when it says "atomically"
14:43hiredmanno, it locks, unlike atoms
14:43aphyrWhat's the canonical way to do exponentiation in 1.3? add clojure.math.numeric-tower?
14:45foodooclojure.math is not an official library, is it?
14:46gtrak`mk: CAS is a processor instruction, much more fine-grained than locking on the var object, you might get a similar result, but the semantics and implementation aren't the same
14:46amalloyaphyr: (reduce * (repeat n b)) is pretty easy if your exponent is an integer
14:47mkI see. So vars offer all the functionality of atoms, but in some cases atoms offer better performance at the cost of potentially executing (hopefully pure) functions repeatedly
14:47aphyrYeah, kinda floored that this isn't builtin, haha
14:47foodooI usually do (Math/pow a b)
14:47gtrak`yea, that's the whole point of CAS
14:47aphyr(need something that supports the rational types)
14:47amalloyaphyr: it is built in, you are on the jvm
14:47zerokarmalefthow large would a set of bindings in a let be before being considered non-idiomatic or bad style?
14:47gtrak`it's a case of cpu manufacturers pandering to software implementers
14:48hiredman~vars
14:48clojurebotvars are a linking construct
14:48technomancyzerokarmaleft: it depends on whether you're using them all in the body or using them to construct further bindings
14:48amalloybut seriously the core lib is so huge there's no reason to pollute it with operations that are easily constructed by composing existing stuff
14:48mkit should be added to that that vars offer all the same functionality as atoms
14:48zerokarmalefttechnomancy: to construct further bindings, but the last set of bindings are also used in the body...for readability
14:49aphyramalloy: just weird that there's +, -, *, /, but expt requires changing project.clj. First language I've ever used where that was the case, haha.
14:49zerokarmaleftit just smells...imperative, in a way
14:49technomancyzerokarmaleft: in that case I'd be comfortable letting it get pretty big, but consider whether you can't rewrite it using ->
14:49foodooaphyr: well, you can still use (Math/floor x y)
14:50foodooif you are on the JVM
14:50mkwhenever vars and def are brought up, people suggest that they shouldn't be changed at runtime, hinting that the reason for this is some sort of concurrency issue ("use atoms instead when you want concurrency")
14:51mkbut vars are as safe as atoms. Potentially more safe, since they block instead of repeatedly executing.
14:51nDuffmk: If nothing else, rebinding is going to make it hard on people reading your code.
14:51hiredman~vars
14:51clojurebotvars are a linking construct
14:51technomancyno
14:51technomancythey're less safe because they don't have to be dereferenced, so you can have mutability sneak into a function that looks pure
14:52technomancydon't do it
14:52nDuff(inc technomancy)
14:52lazybot⇒ 34
14:53mktechnomancy: not sure that I follow how that might happen
14:54amalloymk: (defn f [x] (+ x config/batch-size))
14:54amalloyis (f 10) always the same value or no?
14:55jolynot referentially transparent if the var value is going to change
14:55jolythat's bitten me before
14:56technomancytechnically it's very difficult to write clojure functions that are guaranteed referentially transparent exactly because of alter-var-root and runtime-def, but for most purposes "referentially transparent unless someone does something completely daft" is perfectly fine.
14:57aphyrHow do you feel about the use of dynamically bound vars for IO, though?
14:57aphyre.g. print-dup, out, etc?
14:58technomancyaphyr: the presence of *earmuffs* in a function makes it obvious that a function isn't referentially transparent, so there's not much room for confusion
14:58mkI think I see. We want to make sure that we have an explicit @ (or deref) at the start of all such values
14:58technomancywell, and the whole IO thing of course
14:58aphyrYeah, like (prn) is definitely not referentially transparent, not even in the fixed IO sense. ;-)
15:00mkI was initially worried about what was happening when I defn'd using the repl. I was under the impression that this might put the entire program into an invalid state
15:00technomancymk: that happens in some other languages (ML-based ones in particular) since they don't have the concept of vars, your changes do not apply retroactively.
15:01technomancydifferent parts of the program will have access to a different version of your function
15:01technomancy(this is true of some Clojure constructs like defmacro and defprotocol, which is one of many reasons you should always use defn if you can)
15:02mkis this still the case in clojure, in some rare cases? for example, a thread in a long-term recurring function
15:02technomancyif it goes through a var, it's safe
15:02technomancyif it dereferences the var and holds on to the raw fn, then it will retain the old value
15:04mkok, all of this is very good to know. I take it that the problems with mutation don't apply if I'm mutating things intentionally using the repl?
15:04technomancyright; the primary reason (possibly only reason?) vars are mutable is to support interactive development.
15:05foodoothey do, because you may have suprising results. But when in doubt, restart the repl
15:06mkfoodoo: I'd like to try to know about those surprises, because if I'm using the repl to crunch a few hours of data, restarting isn't practical
15:06foodooif you have some old functions that still exist in the repl but don't exist in your code
15:07foodooand you accidentally invoke them again for whatever reason
15:07mkI take it that we covered the main ones (not going through a var, and defmacro/defprotocol)
15:08technomancyin web apps you often see stuff like (run-jetty #'myapp {:port 8080}) in order to pick up dev-time reloads of myapp
15:11mkthe way I'm thinking of it now, atoms are for the program to modify, while vars are there for the programmer; keeping in mind that changing a var might make a transparent-looking function no longer transparent, they're both safe in that changing them usually won't break clojure
15:18dnolen_mk: also if you use a def to change the value of something that should be an atom the likelihood of another Clojure programmer using your lib will diminish to zero ;)
15:18dnolen_someone should ad that case to kibit.
15:18dnolen_add
15:19ohpauleezdnolen_: It's a good idea
15:19dnolen_Raynes: even better if reheap got kibit support :) not sure if you've tried that yet.
15:19technomancykibit-as-a-service
15:19dnolen_Raynes: it would give refheap the oneup over all the other Clojure paste services.
15:19technomancydoes kibit require eval?
15:20dnolen_technomancy: no.
15:20technomancycool
15:20ohpauleeztechnomancy: no
15:20ohpauleezit's totally static
15:21technomancyoh gross, it tells you to replace single-clause if with when
15:21danlarkinyesssssssssssssssssss
15:21amalloytechnomancy: i told you, you're hugely in the minority in preferring it the other way
15:21mkdnolen_: that should never happen, assuming that the programmer knows to only use def manually, right?
15:21mk(via source, or repl)
15:21danlarkinamalloy technomancy: agreed
15:22ohpauleeztechnomancy: Why would you want it another other way?
15:22technomancyohpauleez: because use of when indicates side-effects
15:22ohpauleezYou're ticket still sits in the kibit repo for that haha
15:23dnolen_kibit (technomancy remix) ?
15:23technomancyhuh... Kibit's reader crashed; see kibit.check/read-file:java.lang.RuntimeException: Invalid token: ::friend/unauthorized-uri
15:23technomancyI guess that is a pretty weird keyword
15:24ohpauleeztechnomancy: because of a bug in clojure you can't do scoped keywords
15:25ohpauleeztechnomancy: I can *sort of* see your point about `when`, but I personally don't think of side effects when I see `when`
15:25ohpauleezI think of a clause where this is only a true branch, and nothing more
15:25qerubIs there an any? function somewhere in clojure.core? It should work like (defn any? [f seq] (reduce #(or %1 %2) (map f seq))).
15:25pjstadigdon't worry technomancy i've got your back
15:25ohpauleezhahaha
15:25aphyr(some?)
15:26technomancyohpauleez: so you think it's a design flaw that you can call if with only two args?
15:26dnolen_qerub: some, but note it doesn't return true/false
15:26uvtcohpauleez: My understanding is `when` has an implied `do`, therefore you use it when you want side-effects.
15:26pjstadigthe battle lines are drawn!
15:26ohpauleezhahah
15:26qerubdnolen_: Thanks!
15:26danlarkinpjstadig: you and technomancy are clearly wrong and you know it
15:26ohpauleezeveryone, place your bets
15:26technomancyit's not like this is a thing I made up; it's a long-standing convention even from older lisps
15:26pjstadigi know only that you are wrong, danlarkin
15:27technomancyeven used in CL, which is famous for not giving a crap about FP and side-effects
15:27aphyr(when) is easier to debug with print statements. :-P
15:27technomancyaphyr: which are (wait for it) side-effects =)
15:27amalloytechnomancy: ::foo/bar is a token that can only be read if you're eval'ing as you go :P
15:27technomancyif you need to debug in an if, use (doto x prn)
15:27amalloywhich seems like a pretty terrible choice for clojure's reader
15:27aphyrYeah, but it's not like (if is free of side effects either. :/
15:28ohpauleeztechnomancy: I totally recognize the convention, and I don't think two arg if is a design flaw
15:28technomancyaphyr: of course; if is more general
15:28aphyrif/when only clues you in as to whether the *immediate lexical scope* has side effects
15:28aphyrnot a very useful distinction in my mind :/
15:28ohpauleezI think two arg if leads to unintential bugs at times, and I think when is more readable. Implicit do or not
15:28danlarkinohpauleez +1
15:29danlarkinI think we won
15:29technomancypft
15:29ohpauleezhaha
15:29pjstadighow is when more readable than a single branch if
15:29pjstadigthey're like practically the same thing
15:29technomancyI've never seen a bug come from if; what would be an example of that?
15:29pjstadigexcept that a when can have side-effects
15:29qerubHey technomancy! Long time no see. Do you still do any Ruby nowadays?
15:29amalloytechnomancy: you probably haven't read the ten thousand SO questions on (defn ! [n] (if (zero? n) 1) (* n (! (dec n))))
15:30mkthe reason you use when instead of if is the same reason for using for ( : ) in java instead of for (int i=0;i...). By using when, you save readers having to decide each time they look at the word whether or not the branch has an else or not.
15:30technomancyamalloy: ok, how about a mistake that someone who actually knows the language would make?
15:30technomancyqerub: whoa; hi. long time.
15:30mkas a convention, neither when nor if guarantee that something will or won't have side effects
15:30technomancyqerub: I'm actually picking back up a bit of ruby for my work at heroku
15:31pjstadigmk: that would be true, except that if can have one or two branches
15:31pjstadigso it's not exactly a single/double branch split
15:31xeqiheh, I use `when` without side effects all over the place for lein's pom generation
15:32ohpauleeztechnomancy: minimal. But I still think only-true-branching is more readabe as when - especially when you're tracing through code and debugging
15:32ohpauleezfor a similar reason stated by mk
15:32ohpauleezhaha I'm also amazed at how everyone is jumping in the pit here
15:32ohpauleez:)
15:32ohpauleezThat said, I come from CL and Python, so I'm a convert
15:32mkpjstadig: sure, so use when. Then in all cases where readers see your code, they won't wonder. And if they run into an if with one arg, they can change it to a when
15:33technomancyI don't know java, so that example doesn't make sense to me
15:33pjstadigi guess the thing is that "when can have have side-effects" is more objective than "readability" arguments
15:33wingywhat do you think about backends-as-a-service such as Parse?
15:34pjstadigif all it boils down to is "readability" then is seems more sensible not to make rules couched in absolute language
15:34technomancythere's nothing more readable about it. it's a two-character token vs a four-character token
15:34mktechnomancy: using an iterating construct versus manually iterating over the array yourself. Each time you look at the latter, you have to decide if it's doing the former.
15:34ohpauleezpjstadig: I'll agree with that
15:34danlarkinthe way I read "if" is ok here comes a choice of two things
15:34danlarkinand if there aren't two things it messes up my read-flow
15:34pjstadigdanlarkin: but that's just not true
15:34technomancydanlarkin: so you're ignoring the fact that it works with one
15:35ohpauleezbut does the implicit do really make you feel that strongly about the side-effects. it's not like when is HIDING the side-effect
15:35qerubtechnomancy: Will it be frustrating to code Ruby again? I'm flirting with Clojure because it isn't a joy to code functionally in Ruby.
15:35technomancyohpauleez: it turns when into a more specific form
15:35technomancyohpauleez: if you can use that extra specificity to communicate something to the reader, you should
15:35ibdknoxdnolen_: are there thoughts on the changes needed to use the cljs analyzer on JVM Clojure? (i.e. allowing unaliased :require and naked :use)
15:35mkpjstadig: the point is that tons of people aren't even familiar with this convention. You'll have whens without sf, and lone ifs with them. So unless you already know the code, you'll have to verify anyway, so what's the use?
15:35pjstadigtechnomancy ohpauleez: and objectively so
15:35ibdknoxdnolen_: and :import
15:35ohpauleeztechnomancy: So intent. Sure, I can see that
15:36pjstadigreadability is a bit more subjective
15:36technomancymk: that's why it's good to raise awareness of the convention, because people are confused about it.
15:36technomancyqerub: it's definitely frustrating on the tooling side; things have gotten so much more complicated
15:36ohpauleezso you're objectivity about "side-effects" is really just readability based on intent
15:36technomancyand I don't even have to deal with rvm
15:36ohpauleezYou see when and you think "here come the side effects"
15:37ohpauleezdanlarkin sees when and he thinks, "he comes the truth"
15:37pjstadigi don't have heart burn over the fact that there's an if somewhere and i should be expecting to see a else clause...and oh no! it's not there! my world is crashing down! as some people seem to think
15:37qerubtechnomancy: What are you thinking of in particular? Bundler…?
15:37technomancyqerub: yeah, mostly that. I get a lot of bug reports coming from rvm, so even though I don't use it myself I still have to deal with it =\
15:38qerubtechnomancy: Oh, right; rvm and company.
15:38dnolen_ibdknox: related, stuarthallowy has brought up conditional reading ... I'm not sure exactly how the analyzer should be improved to deal w/ full Clojure ... worth figuring out
15:38pjstadigohpauleez: but when you're talking about someones thoughts you're talking about subjectivity
15:38mktechnomancy: I agree that marking sf is useful, but I think that should be marked in the function itself, not by using when to say "here come side effects... trust me"
15:38qerubtechnomancy: I like what you have done with Leiningen. It's a joy to use. Thanks!
15:38dnolen_ibdknox: also, ambrosebs has got something as well.
15:38technomancyqerub: also this tendency to just overcomplicate things; I'm working on a test suite that has a define_method inside an instance_eval just to allow for slightly more declarative test definitions, but just causes trouble down the road
15:38pjstadigit is an objective that if cannot have a then clause with a side-effect, unless you use a do
15:38technomancyqerub: thanks
15:38ibdknoxdnolen_: his is still using the JVM analyzer though, right?
15:38pjstadigor just use a when with an implicit do
15:39qerubtechnomancy: Haha, I feel your pain.
15:39technomancymk: that's a valid desire, but it entails changes to the language itself. I'm talking about working with what we've currently got.
15:40ibdknoxdnolen_: yeah, and he's making it look like the CLJS output
15:40dnolen_ibdknox: perhaps, I haven't looked at it closely. If you want to lead the discussion on this please do, as you really need this stuff, I'll definitely chime in and chip in where I can.
15:40ibdknoxdnolen_: k, I'll start up a thread later tonight
15:40dnolen_ibdknox: standardizing analyzer output, getting column data are two big things. I think column data isn't going to go anywhere without some one spending sometime to write up rationale.
15:41ohpauleez&(if true (println 1))
15:41lazybot⇒ 1 nil
15:41mktechnomancy: you're right about that, but I still worry about bugs due to trusting a misleading lone if. The convention seems to be there for the sake of efficiency, but ensuring a lack of side-effects in critical places shouldn't be made "efficient"
15:42mk(programmer efficiency)
15:42technomancy"If the value of the if form is important in this situation, then the and construct may be stylistically preferable, depending on the context. If the value is not important, but only the effect, then the when construct may be stylistically preferable." - http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node84.html
15:42ohpauleezI'm fine reading both forms, and personally I think both things when I read `when`
15:42ohpauleez"Only true branch, implicit do"
15:42technomancymk: seeing an if means you can't infer anything
15:42technomancybecause if is more general, and when is more specific
15:43mktechnomancy: oh, well in that case you're probably right
15:44scgilardithat's "and" vs "when" and I agree with it
15:44technomancyand is only for return values, when is only for side-effects, if is somewhere in between due to being more general
15:45mkon the other hand, if you mislead some people into fearing sf when there really aren't any by using (when), then not much harm is done
15:45pjstadig"As a matter of style, when is normally used to conditionally produce some side effects, and the value of the when form is normally not used."
15:45qerubBye for now!
15:45pjstadigibid.
15:45ohpauleeznice to see scgilardi ringing in :)
15:45pjstadigwhat clojure needs is an 'unless' macro
15:46scgilardi:)
15:46ohpauleezpjstadig: (the-real-when ...)
15:47ohpauleezto discourage more sideffects
15:47technomancyI think the readability argument only flies if you don't indent properly
15:47pjstadigi always found it confusing the way people used if and unless suffix conditions in ruby
15:47pjstadigespecially when the conditions were negative
15:47ohpauleezpjstadig: same
15:48pjstadigsomething unless !notFooBar
15:48technomancypjstadig: the one place I can see that making sense is "raise IOError if disconnected"
15:48ohpauleeztechnomancy: I disagree, but I also have a greater tolerance for when abuse
15:48ohpauleezeven for its return values
15:48pjstadigwell sure with an if suffix
15:48technomancybecause having a non-conditional raise makes absolutely no sense
15:48pjstadigbut unless especially with complex conditions with ands and ors is confusing
15:49technomancyagreed
15:49pjstadigi think if suffixes can actually read better sometimes
15:50pjstadigor more naturally
15:50uvtcIn Perl, I think `unless` works well for unlikely events: print "things went well, as expected." unless $catastrophe
15:51uvtcAlso, Clojure has `if-not` to use if you want `unless` ... (though, there's no implied `do` with `if-not`, fwict)
15:52ohpauleezuvtc: `when-not`
15:52Gnosis-it would be pretty simple to write an 'unless' macro...
15:52mkright, unless is for when you want to make the code seem like it's a normal part of the block, and not a special case
15:52uvtcohpauleez: Hahah. Missed that. Thanks. :)
15:53pjstadigthat's true
15:53pjstadigwhen-not is basically the 'unless' macro
15:54arohnerI use 'when' all the time in non-side-effecting code
15:55mkfor similar reasons, in c-syntax languages I end up converting long ifs which trail down to the bottom of a method or loop into if ( not condition) {... return, or break}
15:55arohnerbut IMO, one-armed ifs should be a syntax error
15:56pjstadigarohner: i would actually support that
15:57Raynesdnolen: There is an open issue for that.
15:57pjstadiglet's end all the senseless violence
15:57mattmossEverytime I see someone address ohpauleez, it sounds in my head like someone sighing, rolling their eyes and saying, "Oh, puh-lease..."
15:57ohpauleezmattmoss: That's the idea :)
15:58Raynesarohner: technomancy hates your guts.
15:58ohpauleezit's how most people address me
15:58mattmossI am Master of Obviousness. :|
15:58aphyr(if [float? x) (write-float sock x) (write-int sock x)) etc
15:58ohpauleez:)
15:58uvtcpjstadig: Yes. Can't we all just get along ... ... ... and agree to rename `not=` to `!=`. ;)
15:59aphyrWhile we're at it, rename set! to =!
16:00ohpauleezuvtc: `!` implies stateful change :)
16:00mattmoss(with-perl-noise (=! (!= ...)))
16:03uvtcohpauleez: interesting way to look at it, even though it's a leading and not a trailing `!`. Semi-related, I'd always thought that the single-quote mark implied quoting, but just yesterday learned of +'
16:04uvtcAny idea why the trailing single quote mark was chosen for that?
16:04Bronsamathematic notation?
16:04Bronsaf, f', f'' etc
16:04uvtcAhhhh..... prime.
16:04augustlhow do I add Java interop return type metadata when I already have a ^{:private true} metadata there? Normally I use #^TheReturnType
16:04uvtcHeh. Nice.
16:05Bronsa, (let [a'a'a'a' 1] a'a'a'a')
16:05clojurebot1
16:05Bronsa:D
16:07Gnosis-that's an acceptable name?
16:08uvtcGnosis-: acceptable to whom? :)
16:08amalloyif you're tarzan
16:08mkGnosis-: by the compiler, but maybe not by humans
16:08Gnosis-I meant acceptable to the compiler, haha
16:10pjstadigaugustl: ^{:tag TheReturnType :private true}
16:10amalloypjstadig: or just use both; metadata tags stack iirc
16:10mkGnosis-: technically any chars are allowed, except for a few reserved ones, and it's not clear what the reserved ones will actually be, so... most are disallowed
16:10amalloy&(meta ' ^String ^:private x)
16:10lazybot⇒ {:tag String, :private true}
16:11augustlpjstadig: is this documented somewhere? :)
16:11aphyraugustl: seem to recall it's on the java interop page
16:11augustlnothing about #^ on the java interop page
16:11Gnosis-mk: how can they be reserved if the current compiler accepts them without complaining?
16:11mkI don't see any reason that unicode shouldn't already be allowed, since there's little chance that anything reserved by clojure will come from there
16:11pjstadig,(meta '^String x)
16:11clojurebot{:tag String}
16:12augustlwhere is the ^foo ^bar meta type syntax documented btw?
16:12mkGnosis-: :: and // etc. are reserved. +'- and many others are explicitly not reserved. Most symbols will eventually not be reserved.
16:12pjstadigstacking works too
16:12pjstadig,(meta '^String ^:private x)
16:12clojurebot{:tag String, :private true}
16:12mkGnosis-: more details http://clojure.org/reader
16:12pjstadigaugustl: #^ is deprecated syntax
16:12Gnosis-pjstadig: what does '^ mean?
16:12pjstadigi guess the question is where you read that :)
16:13augustlpjstadig: ah
16:13augustlI should read the entire doc some day..
16:13augustlno idea what # actually is :)
16:13Gnosis-mk: ah, thanks
16:14pjstadigGnosis-: ' just means quote the next that is coming and in this case the next thing happens to be a type tag and you don't need a space after the quote
16:14pjstadig,(meta ' ^String ^:private x)
16:14clojurebot{:tag String, :private true}
16:14pjstadigadding a space works too
16:14pjstadigor
16:14pjstadig,(meta (quote ^String ^:private x))
16:14clojurebot{:tag String, :private true}
16:14uvtcBronsa: Gnosis- : now that you mention it, what's the opinion on using a single-quote/apostrophe in symbols, like `ted's-room` or `it's-looking-good`?
16:14pjstadigwhich is kinda what it becomes
16:14pjstadig,''^String ^:private x
16:14clojurebot(quote x)
16:14augustlI suppose this is a symptom of reading code instead of reading docs to figure out how stuff works
16:15uvtc,(let [it's-looking-good true] (when it's-looking-good (println "happy day")))
16:15clojurebothappy day
16:15pjstadigITYM, 'if' :)
16:15mkthe various special symbols are there for lazy programmers. Instead of always having to type and look at (deref a), we can write @a, and the reader replaces it
16:18tufflaxI want to implement my own data structure that shall support conj and pop. I'm using defrecord and I must specify which interface/protocol I'm implementing. So which protocol/interface supports conj and pop? Seq? Is that the name I'm looking for?
16:23mktufflax: https://github.com/clojure/clojure/tree/master/src/jvm/clojure/lang probably ipersistentcollection or something
16:25tufflaxmk thanks
16:28technomancyis it just me, or is it ironic that the clojure source uses "jvm" for its java code despite repeated insistence that the JVM and Java are not the same thing?
16:28technomancyI mean, I understand it's a hold-over from when the clr implementation was kept in the source tree, but I'm still amused by it
16:29pjstadigtechnomancy: just rename it...patches welcome
16:29mkmaybe "stuff for targetting the jvm"?
16:29gfrederickss/clojure/lava/ while you're at it
16:29pjstadighaha
16:29pjstadigpersonally i think Sybilant is a better name than Clojure
16:29pjstadigbut who am i to say
16:30hiredmanlava is really hot right now
16:30Raynestechnomancy: You'll be sorry when they start adding scala source code.
16:31technomancyRaynes: someone is actually using lein-scalac to avoid sbt
16:31mkare agents guaranteed to execute things in order of sending?
16:31technomancymakes me happy
16:32pjstadigmk: for the 'things' sent from the same thread, yes
16:33llasrammaybe best to say that agents execute things in the order received? :-)
16:33mkllasram: perhaps, though a send and receive is presumably the same thing :)
16:34mkpjstadig: will things sent from different threads be queued out of order?
16:35llasramIf that's your definition, then definitely yes -- the purpose of agents is to serialize asynchronous updates to a identity
16:37mkllasram: ok, good. I was thinking that the spec might have left open that the actions are placed in a set rather than a queue, or that one might create an agent with a priority queue
16:37mkI guess that can't be done
16:37acheng,(let [a 1] (eval (read-string "a")))
16:37clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:38acheng"Unable to resolve symbol: a in this context"
16:38tufflaxHm, IPersistentCollection specifies that cons is part of the interface but not conj, what's up with that?
16:39tufflaxI don't see any interface mentioning conj
16:39llasrammk: Ah, not that I'm aware of. You'd probably need to create your own new reference type to support that sort of thing
16:41gtrak`mk: that kind of goes against the state-change aspect of an agent, yea? sounds like you just need the worker pool part
16:41llasramTo the `future`!
16:42mattmoss,(class 'a)
16:42clojurebotclojure.lang.Symbol
16:42mkacheng: interesting - same thing for ,(let [a 1] (eval 'user/a)) I'm not sure why that happens
16:42mattmoss,(class #'a)
16:42clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>
16:42mattmoss,(let [a "a"] (class #'a))
16:42clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0)>
16:42mattmossHmm.
16:42dnolentufflax: the names in Clojure don't always reflect the names used for the Java Interfaces - look at RT.java. fwiw, the naming between fns & protocols is more consistent in ClojureScript.
16:43gfredericksmattmoss: ##(class #'clojure.core/nth)
16:43lazybot⇒ clojure.lang.Var
16:44tufflaxdnolen so my original problem: what should I put as interface in my defrecord when implementing conj?
16:44mkgtrak`: well, one might want a construct that doesn't care about the order of incoming actions, but does care about preserving state. This is different from a worker pool
16:44mattmossthanks, g
16:44dnolentufflax: whatever is in IPersistentCollection - cons + whatever else.
16:45dnolenI mean cons + whatever that interface defines
16:46amalloytufflax: you can't have a special impl of conj in a defrecord, only a deftype, afaik
16:46tufflaxdnolen I think you misunderstood me. When I'm implementing a function in a record, I must state the interface.
16:47gtrak`mk: yea, looks like agents don't guarantee execution order either
16:47tufflaxamalloy hm why not?
16:47dnolentufflax: in records you can implement methods on interfaces, and fns on protocols.
16:47dnolentufflax: and amalloy is right.
16:47amalloybecause records are maps. defrecord comes with implementations of all the map interfaces, including conj
16:47dnolentufflax: you're not allowed to customize the map behavior of records
16:48achenghm... if i have a value and a string, is it possible to let-bind the value to a variable named in the string, and then eval the string?
16:48tufflaxoh i see
16:48mattmossIf I do (defn foo [] ...) and (def f #'foo) ... both (f) and (@f) both work. Why? Is it an implicit deref without the @ ?
16:48Bronsavars are implicitly dereffed
16:48tufflaxOk then. Say I'
16:48tufflaxops, pressed enter too early :p
16:49Bronsa(during function call)
16:49tufflaxOk then. Say I'm using deftype, what interface should I state as the interface I'm implementing when I'm defining conj?
16:49mkgfredericks: regarding varless symbols, mapped directly to values without an intermediary var, I think part of the problem is that you would no longer have an explicit construct for safely working with concurrency, like (alter-var-root)
16:49mattmossBronsa: thanks
16:50gfredericksmk: alter-var-root is for NOT working safely with concurrency
16:50mkgtrak`: interesting - do you have a link to where it talks about that? (agent execution order)
16:51gfredericksI thought all sends from the same thread should execute in the same order
16:51mkgfredericks: in that case you could just use def, no? alter-var-root has a potential verification function attached
16:51Bronsamattmoss: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Var.java#L391-412
16:52achengmk: ya, alter-var-root is heavy-handed to the max. i found the only valid use case. it's all mine
16:52gtrak`mk: I was looking at this: http://stackoverflow.com/questions/5669084/is-clojures-send-asynchronous
16:52gfredericksmk: you could still do changes atomically; namespaces as a whole could be implemented as atoms
16:53mkgfredericks: if that's the case for the same thread, then why not for other threads? Don't they all use the same queue?
16:53pepijndevoswhy do zippers use metadata instead of a protocol?
16:53tufflaxdnolen amalloy: What should I put in my deftype instead of some-interface? (deftype MyDataStructure [data] some-interface (conj [this element] ...))
16:54gfredericksmk: I don't know why that wouldn't be the case; it's just non-deterministic when things happen more or less at the same time
16:54mkgfredericks: I think you're correct, and I think that I like the idea of namespaces as atoms substantially more than what we have now. I think it might be much easier to understand and think about.
16:55Bronsatufflax: you should put clojure.lang.IPersistentCollection, and replace conj with cons
16:56tufflaxBronsa ok. Will I be able to use conj then or just cons?
16:56Bronsacons of clojure.core has nothing to do with cons on the IPersistentCollection interface
16:56mkgfredericks: well... things can happen more or less "at the same time" in the same thread. Shouldn't change for extra threads, if a proper concurrent queue is used...
16:56gfrederickshow do things happen at the same time in the same thread?
16:56tufflaxbronsa ok
16:57tufflaxSo how does cons become conj then?
16:57gfredericksthe source of conj calls RT.cons I think
16:57gfredericksor RT.conj calls #cons
16:57tufflaxah ok
16:57mkis there any reason that namespace maps weren't implemented as atoms?
16:57pandeirodoes cljs not have clj->js anymore???
16:57lazybotpandeiro: Yes, 100% for sure.
16:57Bronsayes
16:58gfredericksmk: atoms didn't exist initially
16:58tufflaxthanks for clearing that up
16:58BronsaRT.conj calls #cons
16:58mkgfredericks: how do they happen at the same time in different threads, assuming we've got a concurrent queue?
16:58gfredericksmk: I mean the sends are done at the same time; obviously they go into the queue in some order but it's hard to say anything interesting about it
16:59pandeiroah oops, i am a moron, sorry
16:59pandeiroi was wanting js->clj
17:00mkgfredericks: right. But if we have that guarantee, then logging agents become much more useful, to take one example
17:02mkand if we don't have that guarantee, then priority queues can be added to agents
17:05tufflaxIf anyone have the time, please take a look at this longish question http://pastebin.com/iHGwgf6i
17:06kaoD_hi
17:06tufflaxhi
17:06kaoD_do multimethods support overloading by arity?
17:06hiredmanmultimethods support everything
17:06kaoD_(through overloaded dispatch fn, of course)
17:06kaoD_hiredman: that's good news then, I was afraid arity was fixed
17:07tufflaxhas* :P
17:12kaoD_tufflax: has?
17:15tufflaxcorrection of my previous message
17:16kaoD_oh, I thought you were correcting me :P
17:20mkthe reason agents don't guarantee ordering except in a single thread is that sends are only queued in the agent's queue at the end of a transaction, not at the actual logical time that the send occurs
17:27cmajor7does korma (transaction …) rollback on the exception?
17:29pandeirohow could i do the Array.prototype.slice.call(someArrayLikeObject, 0) trick with cljs? syntax?
17:30pandeironm, got it: (.call js/Array.prototype.slice thatArrayLikeObj 0)
17:31cmajor7I would think it does: http://dev.clojure.org/jira/browse/JDBC-11 but I am not sure whether I can use a "is-rollback?" to detect that..
17:40kaoD_is there any way to slurp stdin until EOF?
17:41kaoD_slurp itself seems to stay there waiting for more input (or maybe it's windows' fault)
17:45mk(def foo) is equivalent to (intern *ns* foo) ?
17:46S11001001kaoD_: yep it's windows's fault; how are you sending eof?
17:47kaoD_S11001001: not sending EOF, I expected Windows to append EOF after piping from an echo
17:47kaoD_though I'm probably wrong
17:48S11001001who really knows; it's windows
17:51goodieboytechnomancy: hey, i'm thinking about writing a leiningen plugin. Are there directions somewhere to do it properly for the latest leiningen?
17:53goodieboyok, i think this must be the place to look: https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md
17:53kaoD_goodieboy: I was just going to point you there
17:53technomancyyup
17:53kaoD_it's unbelievably easy
17:54goodieboykaoD_: good to know :)
17:54goodieboythanks
17:55emezeskeOnce you know about technomancy, though, it becomes believably easy
17:55Raynesgoodieboy: https://github.com/Raynes/lein-tag Here is a very simple example you can look at too.
17:55goodieboyRaynes: awesome thanks
17:56cgraytechnomancy: is writing a lein plugin for any jvm-based language essentially the same difficulty?
17:58technomancycgray: for any compiler that has an ant task (which hopefully should be all of them), yes
17:59cgraytechnomancy: ok, good to know, then I've gotta write an ant task first :)
17:59Raynestechnomancy: I thought we didn't use ant these days?
17:59technomancyRaynes: not for any of the core stuff
17:59technomancyRaynes: but lein-scalac uses it
18:00Raynescgray: Did you invent a JVM language?
18:00cgrayRaynes: I didn't but there is one being invented at my work
18:00Raynestechnomancy: You should use uncle.
18:00technomancyhar har
18:00Raynescgray: Make them stop.
18:01Raynestechnomancy: https://github.com/flatland/uncle
18:01Raynestechnomancy: I was serious.
18:01technomancyoh
18:01technomancylancet is a bit weird
18:01technomancybut I don't have any plans to develop lein-scalac further, so whatevs
18:02RaynesDude. You should totally turn lein into a complete Scala sy… oh, wait. I guess that's all there is to it, really. Just compiling Scala.
18:02RaynesIt's cool how little is necessary to make Leiningen an <insert jvm lang here> build tool.
18:03technomancywell the problem with scala specifically is the compiler is so slow that everyone ends up using the incremental compiler, and that's not hooked up to lein
18:03technomancybut it's not my problem =)
18:03Raynestechnomancy: You're a pretty cool chap.
18:04eggsbyRaynes: I had to leave the office before I got a chance to thank you last friday -- Thank you!
18:04Rayneseggsby: What did I do?
18:05eggsbyhmm, LA clojure meetup about cljs... wonder if I should go
18:05RaynesBesides my normal awesome level which doesn't necessitate thank yous.
18:05eggsbyRaynes: fixed a retarded thing I did w/ refheap :p
18:06RaynesOh.
18:06RaynesOh, right. Forgot about that.
18:06RaynesYou're lucky refheap has terrible traffic. :p
18:30muhoowhat's the trick for debugging lein2 plugins? how does one get an in-lein repl to interactively work with the plugin?
18:30muhooi.e. not the project, but lein itself.
18:30technomancymuhoo: if you have :eval-in :leiningen in project.clj, then `lein repl` in the plugin project will put you in the right place
18:31muhoofantastic, thanks!
18:32technomancyhuh; I realized I added shorthand for forcing a repl to eval-in lein without changing the project.clj in lein1
18:32technomancyoh, but you can do it with lein-assoc in 2.x
18:33muhoowhut?
18:33technomancy`lein assoc :eval-in :leiningen repl`
18:33technomancyit's a plugin that gives you a higher-order assoc task
18:33llasramOoooh
18:33technomancyyou can add arbitrary project.clj keys on the command line
18:33llasramNow *that* is fancy
18:33muhoooh https://github.com/technomancy/lein-assoc
18:33technomancy=D
18:34muhoothere is so much fancy stuff in lein these days. it's kind of disorienting
18:34technomancytempted to merge that into lein proper
18:34technomancymuhoo: higher-order tasks open up a lot of possibilities
18:34muhooya, i was stunned by how quickly raynes put together lein-pdo.
18:35Raynesmuhoo: I was stunned at how long it took me, actually.
18:35RaynesIt was harder than I thought it'd be.
18:35technomancythere's always https://github.com/technomancy/leiningen/wiki/Plugins
18:35technomancybut it's not exhaustive
18:35technomancyfor instance, Raynes forgot to add lein-pdo =
18:35technomancy)
18:36mkhow are symbols resolved? As far as I can tell, there's a special map from symbols to vars in each namespace. But is there some sort of secondary map for aliases, and requires? Are aliased symbols added to this map? Is there a separate map for vars that have been set to private?
18:37technomancy,(take 10 (ns-map *ns*))
18:37clojurebot([sorted-map #'clojure.core/sorted-map] [read-line #'clojure.core/read-line] [re-pattern #'clojure.core/re-pattern] [keyword? #'clojure.core/keyword?] [unchecked-inc-int #'clojure.core/unchecked-inc-int] ...)
18:38technomancynot sure if that includes aliases
18:38technomancyoh, there's a separate ns-aliases
18:38mkdoes that mean there's a second map, or is it just a filter?
18:39technomancypretty sure it's a separate map
18:39technomancysince an alias by itself isn't a first-class thing afaik
18:41mkhmm. When the reader hits a symbol (it is the reader that does this, right?), how many and which maps does it check before finding the var that it will assign inside the form? (it assigns the var, and not e.g. a fully qualified symbol, correct?)
18:42mkpresumably for fully qualified symbols, the answer is two maps: the global map of namespaces containing the namespace, and then the namespace itself (which is a map) for the name
18:43wingycould someone provide datomic hosting?
18:44muhooheh, (pprint (ns-map *ns*)) caused java to go to 99% cpu and nrepl to lock up
18:45muhoo*nrepl-connection* up to 38644 lines
18:45mk,(ns-map 'doesntexist)
18:45clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.Exception: No namespace: doesntexist found>
18:46mk,(in-ns 'extant)
18:46clojurebot#<Namespace extant>
18:46mk,*ns*
18:46clojurebot#<Namespace sandbox>
18:46muhooC-x C-k, problem solved
18:46mk,(in-ns 'extant) (ns-map 'extant)
18:46clojurebot#<Namespace extant>
18:47mk,(do (in-ns 'extant) (ns-map 'extant))
18:47clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ns-map in this context, compiling:(NO_SOURCE_PATH:0)>
18:47mk,(do (create-ns 'extant) (ns-map 'extant))
18:47clojurebot{ProcessBuilder java.lang.ProcessBuilder, Enum java.lang.Enum, SuppressWarnings java.lang.SuppressWarnings, Throwable java.lang.Throwable, InterruptedException java.lang.InterruptedException, ...}
18:48amalloymk: do you not own a repl?
18:49TimMcamalloy: Don't make fun of the poor!
18:49mkamalloy: publicly checking how the bot handles namespaces
18:50muhoowow, soon there will be more lein plugins than there are apps in the apple app store.
18:50mk...and making a mistake or two
18:51muhooand yet, rhickey uses ant :-/
18:52Frozenlo`o_O
18:53muhoonice, a way to use heroku without having to deal with ruby: https://github.com/technomancy/lein-heroku
18:53Frozenlo`Any recommendation regarding tests plugins?
18:53technomancymuhoo: keep in mind that's very unofficial =)
18:53RaynesI didn't find dealing with Ruby much of an issue.
18:54technomancyyeah, actually you don't even need to have rubygems installed anymore
18:58kaoD_is there any way to slurp piped stdin in windows and not wait forever for more input?
19:02technomancykaoD_: on unix EOF results in a nil return value from read-line iirc
19:02technomancynot sure about slurp
19:03kaoD_technomancy: I'm interested in stdin as a whole, not line by line... I know I can fake it but it just feels hacky
19:03technomancyyeah, but you could try it and see if it has the same problem
19:03kaoD_you're right, I'll try
19:25amalloyis there a clever way to take from a sequence up to, and including, the first item that satisfies a predicate? i think i've written that function before, but not well
19:30mkamalloy: source for take-while http://clojuredocs.org/clojure_core/clojure.core/take-while
19:32metellusamalloy: the best I can find is split-with or partition-by and then grabbing the first element from the second seq
19:34gfredericksamalloy: if nothing satisfies it returns the original?
19:34amalloygfredericks: yeah, that's the plan
19:34mkin that source I linked, put the cons in front of the when
19:35gfredericks(fn f [pred coll] (if (empty? coll) coll (let [[x & xs] coll] (if (pred x) [x] (cons x (lazy-seq (f pred xs)))))))
19:36amalloygfredericks: never use [x & xs] destructuring when consuming/producing a lazy seq, btw
19:36amalloy& xs uses next, not rest
19:36gfredericksamalloy: now I know
19:37amalloyi'm always tempted, and usually remember not to
19:38gfredericksamalloy: using core.logic for a while made writing that ^ code feel really weird
19:41mk(defn take-while' [pred coll] (lazy-seq (when-let [s (seq coll)] (cons (first s) (when (pred (first s)) (take-while' pred (rest s)))))))
19:41mkseems to work, and mimics take-while
19:42gfredericksmaybe name it take-until
19:43kaoD_I'm having a hard time realizing when to use macros or when to stick with code... (which probably means I don't understand the subject enough) any quick tips/references?
19:43mkor take-along (...the non-matching value)
19:43rbxbxkaoD_ avoid macros until it's no longer feasible to do otherwise.
19:45rbxbxkaoD_ they're a sharp (and valuable) tool which one should exercise caution in using. As to learning when it's no longer feasible to do otherwise... I guess that just comes with experience?
19:45kaoD_rbxbx: that's what I suspected
19:45kaoD_thanks
19:45technomancythe best way to learn is to try to consume a codebase that uses too many macros
19:46kaoD_technomancy: what do you mean consume?
19:46mkkaoD_: you don't need to worry that you're missing out on the magic of lisp if you're not spending time defining macros. Clojure has many constructs that set it apart as a much higher-level language, and macros are only a minor part of all that
19:46technomancykaoD_: I mean use it as a library or something
19:46rbxbxkaoD_ better yet try to fix a bug in the project's issue-tracker :)
19:47kaoD_technomancy: oh, as in "product consumer"
19:47kaoD_been there
19:47kaoD_(many times with my own macros, haha)
19:48kaoD_thanks for the insight
19:48technomancyI guess the key is you need to try to use the macros in ways that the original author didn't intend
19:50emezesketechnomancy: One of the biggest gripes I have with macro-heavy libraries is that they basically force the user to write macros to deal with them
19:50emezesketechnomancy: E.g. if you have repetition in your use of a macro that you'd like to factor out, you have to write a macro
19:51technomancyheh; yeah, infectious macros
19:51emezeskeexactly
19:51kaoD_and then... why macros? I mean, in which case are they useful? it all comes down to experience or is there any sort of pattern/well-suited task for macros?
19:52arohnerin core.logic, if I have a logic variable that is a map, how do I write the expression "(== 3 (:foo q))"?
19:52arohnerI tried the naive way and I'm getting NPE
19:53technomancykaoD_: usually if you write a macro you should do it after writing the macroless way first
19:53amalloyarohner: i don't think that's possible yet. as of recently it wasn't, anyway
19:53technomancyso people can pick which way is appropriate for their circumstances; maybe they don't care about composability and want the extra convenience
19:54kaoD_technomancy: ugh, that means double mainteinance
19:54benediktI'm using lein and emacs (+ clojure-mode) for clojure. starting the swank server with "M-x clojure-jack-in" makes it bind to 0.0.0.0. I want to bind to localhost.
19:54arohneramalloy: really? seems like it should be possible to build a fn that does that, even if it isn't built in
19:54benediktI ws discussing this here the other day but I never managed to change the bind address.
19:54technomancykaoD_: not really, the macro version needs the function version to exist anyway
19:54amalloykaoD_: wat. write the macro to use the function
19:55kaoD_lol, so obvious
19:55benedikttechnomancy: i belive you said that this is no longer the default behavior, but this is the default behavoir with the current lein.
19:55amalloyarohner: it needs hooks into the unification code
19:55technomancybenedikt: the version of lein is immaterial; it's the version of lein-swank that matters
19:55technomancybut you might want to try https://github.com/kingtim/nrepl.el instead
19:56benedikttechnomancy: right. so lein is using an outdeted version of swank?
19:56hyPiRionYou should keep the amount of macros to a minimum though, they're not first class citizens.
19:56technomancybenedikt: right
19:56benedikttechnomancy: one might argue this is an issue.
19:57benedikttechnomancy: thanks for the link, this seems useful.
19:57technomancyif you have a solution for how to retroactively fix old versions I would be glad to hear it =)
19:57benedikttechnomancy: actually, i'm working on this time machine...
19:57technomancysweeeet
19:58benediktso if one uses this nrepl.el, one isn't dependent on lein any more?
19:59benediktscratch that
19:59technomancyno, you still need lein, but you don't need any lein plugins
19:59benediktas long as it doesn't listen to 0.0.0.0 i'm happy.
20:04arohneramalloy: looks like (pred) works, as a worst case
20:04arohner(logic/pred q #(= 3 (:foo %)))
20:04arohnerwhat does "non-relational" mean, in a core.logic docstring?
20:05amalloyit's not a two-way function
20:05amalloyyou can't, eg, use that pred to *build* the map {:foo 3}, only to check that it fits after someone else has built it
20:06arohnerah, right
20:11benedikttechnomancy: this one also seems to listen to 0.0.0.0
20:14technomancyugh; crap
20:14technomancyRaynes: what the heck, man?
20:14arohnermore stupid core.logic questions. How can I write "q is not a member of [x y z]"?
20:15gfredericksarohner: "not" is not very natural
20:15gfredericksbut you can definitely say (!= q x) (!= q y) (!= q z)
20:16benedikttechnomancy: i'm leaning towards using iptables --- but thats not really a fix for the problem. Personally, I think this is the wrong default, and a dangerous one.
20:17technomancybenedikt: it definitely is. it was fixed years ago in swank, but I've only started using `lein repl` a couple weeks ago, so I didn't notice.
20:17technomancyworking on a fix
20:17benediktso lein uses a version of swank that is outdated by years?
20:17arohnergfredericks: thanks
20:18technomancyno, lein uses whatever version of swank you tell it to
20:18benediktthe is a messy swamp of tools. then why am *I* using an outdated swank version?
20:18benediktand what baout nrepl.el
20:19technomancynrepl.el is just using the built-in `lein repl` task, which I'm fixing right now
20:19technomancyI don't know how you installed lein-swank, so it's hard to say anything about that
20:19benedikttechnomancy: "lein self-install"
20:20technomancythat doesn't install lein-swank
20:20benedikt..
20:20benediktthen I dont know either!
20:20technomancyyou would have had to either put it in your user profile, a project.clj, or run `lein plugin install`
20:20benediktmost likely lein plugin install
20:21technomancythough that would only work for lein 1.x
20:21technomancyif you're using 2.x, check ~/.lein/profiles.clj
20:21benedikti am
20:22benedikt[lein-swank "1.4.3"]
20:23technomancyso does just regular `lein swank` start on localhost or 0.0.0.0?
20:23technomancymaybe it's specific to the elisp launcher?
20:23mkthe namespace can map directly to classes without first putting them in a var?
20:24technomancyhm; actually that's not right; jack-in is hard-coded to localhost
20:25benediktyes and no.
20:25benediktit opens 33804 on * and 4005 on localhost
20:25benedikt"Listening for transport dt_socket at address: 33804. \n Connection opened on localhost port 4005"
20:25technomancyoh, ok... that is cdt then
20:26technomancyI have no idea what's going on with that code =(
20:26technomancylemme see if it's easy to disable
20:26benediktwhy is that listening on all interaces?
20:26benediktinterfaces*
20:26benedikt(cdt, that is)
20:27technomancyI'm sure it's just an oversight
20:27benediktsounds like a bug :)
20:27technomancydefinitely
20:27technomancyI got all the cdt support submitted as a big pull request without any real explanation of how it works =(
20:27benediktI have to leave now, i'll happily continue when i get back
20:28mkwhere is the clojure code that resolves a var by looking things up in the namespace?
20:28technomancyok, you should be able to disable it by putting :swank-cdt false in project.clj
20:28technomancyor in your user profile
20:28casionhow would one evaluate something like '(+ 1 2)
20:28benedikttechnomancy: is my user profile ~/.leun/profiles.clj?
20:29technomancybenedikt: yeah, under the :user section of the map
20:29mk,(eval '(+ 1 2)) ;?
20:29clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
20:29technomancybenedikt: thanks for catching this and the repl issue
20:30adu,(first [1 2 3])
20:30clojurebot1
20:30casionmk: thank you
20:30adu,(first '(1 2 3))
20:30clojurebot1
20:31paxanHas anybody been able to run JUnit tests via lein successfully? I am trying lein-junit, but I must be missing some important tip in its documentation regarding how to make it work. It simply succeeds very quietly with zero regard for failing tests
20:31benedikttechnomancy: :)
20:32adupaxan: there should be a test for that
20:32paxanadu, got that plugin's src cloned. It passes its own tests :)
20:33adu:)
20:38technomancybenedikt: just pushed a fix to make the repl task bind to localhost only by default
20:40Raynestechnomancy: What did I do?
20:40technomancyRaynes: benedikt just pointed out that `lein repl` listens on 0.0.0.0 by default
20:41RaynesPretty sure I didn't have anything to do with anything related to that, technomancy.
20:41technomancywell I had to blame someone
20:43amalloytechnomancy: it's my fault: i heard someone complain about it and was like "whoa that's awful" instead of "technomancy: ^ awful"
20:48technomancyhah
20:49technomancyit could be cemerick's fault since that's what nrepl defaults to, but arguably in the context of nrepl-as-a-library it's a decent default
20:55xeqitechnomancy: what did you use to record your clojure screencast?
21:01gunsHello, I am trying to determine if Unicode characters are explicitly valid in symbols. LispReader.java is very liberal, but clojure.org/reader says "alphanumeric"
21:01gunsDoes this mean [A-Za-z0-9] or POSIX [:alnum:]?
21:05gunsFurther confusing the issue is that Clojure 1.3+ allows ' in symbols
21:08mk,(defn ↬ [a] a)
21:08clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
21:08gfredericks,(let [↬ :foo] ↬)
21:08clojurebot:foo
21:08gunsmk: the actual pattern for symbols is "[:]?([\D&&[^/]].*/)?([\D&&[^/]][^/]*)"
21:09gunsBut that includes quite a bit more than "alphanumeric"
21:09mkguns: the only reason any characters would be prohibited is because clojure reserves them
21:10gunsI've been freely using Unicode in my personal Clojure code, but someone mentioned that it is not part of the spec
21:10gunsfrom clojure.org/reader: "(other characters will be allowed eventually, but not all macro characters have been determined)"
21:10gfredericksI can't imagine there being non-ascii macro characters
21:11gfredericksmaybe because I have no imagination
21:11mkor because it might reserve them in the future. Since I doubt that ↬ and the rest would ever be reserved by clojure, I really don't see why they would be prohibited even now
21:11gunsWell, I'm happy with the status quo
21:11gfredericks#+ and #- might be coming
21:11gunsjust having a discussion about whether it's "legal" clojure code
21:11mkit's nice to see that they aren't, when it comes to code
21:12mkif someone knows a good reason not to use unicode now and assume that it won't be prohibited, I'd love to hear it
21:13gunsEven ASCII symbols like as->zs are commonly used, but don't adhere to the published definition
21:14gfredericks-> is used in clojure itself
21:14amalloymk: the main reason would be portability of your source files. if you save a file as UTF-8 (say), and someone reads it as if it were Latin-1 (say), you might have issues if one of your multi-byte characters contains a 0x20
21:15amalloyi think the clojure reader always reads files as UTF-8 now, but that's just an implementation detail; no promises about the character encoding
21:15gunsI guess if we just continue to use Unicode, clojure/core will be forced to support it indefinitely
21:15guns:)
21:16mkit's strange that > isn't listed among the permitted symbols in http://clojure.org/reader
21:16gfredericksthose docs aren't very maintained
21:17gfrederickssomebody was complaining about it not mentioning \' the other day
21:17mkI think the main problem is people saving their files in non-utf8... I don't have much sympathy for that
21:21mkguns: what are you using unicode for? I've always wanted to replace -> with →, but I'm not sure that'd go over well
21:22gunsmk: λ α β Σ, and so on for concision.
21:22gfrederickshow do those get munged?
21:23gunsI wouldn't do it in a team environment, but for myself, I have a very nice multibyte input setup
21:23gunsgfredericks: what do you mean? in the clojure symbol table?
21:23gfredericksno in class names and other java things
21:24gfredericks&((fn λ [] (fn [] :no)))
21:24gfredericks,((fn λ [] (fn [] :no)))
21:24clojurebot#<sandbox$eval27$??__28$fn__29 sandbox$eval27$??__28$fn__29@3984d9f6>
21:24gfredericks,((fn fooλbar [] (fn [] :no)))
21:24clojurebot#<sandbox$eval57$foo??bar__58$fn__59 sandbox$eval57$foo??bar__58$fn__59@4684c5b4>
21:24goodieboytechnomancy: we're using leiningen < 2, can we still use the ".lein-classpath" feature for testing plugins?
21:25gfredericksthe ?? is rather disturbing there
21:25gunsThat's true
21:25mkgfredericks: my repl shows the lambda, might be clojurebot bug
21:25gfredericksoh okay; so java must allow it
21:26gunsJava identifiers explicitly allow unicode; I'm not sure if this impacts clojure in any way
21:26guns http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8
21:26gfredericksso clojure must only munge a few reserved symbols
21:28goodieboytechnomancy: well dang, it works :)
21:28mkeclipse doesn't like ↬ in method names
21:29mkit doesn't complain when given non-english alphabets, though
21:29arohnerwith core.logic, how do I say "all elements of seq x are members of seq y"?
21:30gfredericks(everyo #(membero % y) x)
21:30gfredericksafter writing everyo
21:30gfredericksand that only works if you don't mind it succeeding multiple times for repeats
21:30arohnerhow do I write everyo? :-)
21:30arohnerI'm still uncertain about how core.logic is implemented, and what is possible
21:31gfredericks(defn everyo [goalo coll] (matche [coll] ([[]]) ([[x . xs]] (goalo x) (everyo goalo xs))))
21:32arohnergfredericks: awesome. thank you. Is there something I should have read? I've read the primer on the wiki, but I still have lots of questions
21:32mkwhy do namespaces map directly to classes, instead of classes wrapped in vars?
21:32gfredericksarohner: The Reasoned Schemer
21:33gfredericksarohner: what are your questions? I'm right this second preparing a talk on core.logic so I'm interested in that sort of thing above and beyond the normal
21:33gfredericksI should probably even take notes on your questions :)
21:34arohnerthe main thing I'd like to understand is, enough of the implementation so that it I have an intuitive understanding of how to extend it
21:34arohneri.e. I didn't know that goals were functions, or how to compose new goals
21:34arohneri.e. I don't know what's "magic" and what's "user code"
21:34gfredericksby "extend it" do you mean writing your own goals, or really really extending it?
21:34gfredericksmaybe you don't know what you mean yet
21:35arohnerright, I don't know which kinds of extension are easy, and which take serious work
21:35gfredericksk cool
21:36arohneran hour ago I was wondering, if I have a logic variable q, and q is a map, how do I write the goal "q has a key named :foo, with value 3"
21:36gfredericksholy crap
21:36gfredericksafaik you can't
21:36casionmaan, functional programming still maakes no sense to me :(
21:36arohner(pred q #(== 3 (:foo q)) worked for me
21:37gfrederickswell if your map is ground you can do that
21:37arohnerthough as amalloy pointed out, that's non-relational
21:37gfrederickscore.logic doesn't have good support for logic-variables-as-maps; you basically have to match all the keys at once which isn't very useful
21:38gfredericksthat's partly because there's not a clear way for it to solidify a partially-specified map
21:38gfredericksi.e., if you said (run 1 [q] (q-has-value :foo 12)), what should it return?
21:38gfredericks(has-value q :foo 12) I should have said
21:39arohner{:foo 12} might be reasonable
21:39arohnerin my particular case, I was selecting a map from a seq of maps
21:39gfredericks:/
21:40gfredericksalso what about (run 1 [q] (fresh [x] (has-value q x 12)))
21:40arohnerIt appears I don't have goalo
21:40gfredericksthat was an argument
21:41arohneroh, right
21:42xeqigfredericks: couldn't that use the same value of x that (run1 [q] (fresh [x] (== q [x 12]))) would?
21:42gfredericksxeqi: it could; all these things feel a little icky though
21:43gfredericksthe former because it doesn't distinguish between "this map might have had more keys" and "this map couldn't have more keys"
21:44arohnerdoes it need to? that seems like a separate constraint
21:44gfredericksI mean the value returned from run
21:46gfredericks(run 2 [q] (conde ((firsto q 7)) ((== q [7])))) return two different things
21:46muhooemezeske: it looks to me like lein-cljs plugin somehow manages to pull in support, but i can't figure out where it actually gets that or how it finds it or where it gets it from
21:47gfrederickswhile (run 2 [q] (conde ((has-key q :foo 7)) ((== q {:foo 7})))) wouldn't
21:49muhooemezeske: nm, i found it, cljsbuild (without the lein-)
22:04arohnergfredericks: I'm getting stackoverflows when I use your everyo
22:04arohner(l/run* [q] (everyo #(l/membero % [4 5 6]) q))
22:04amalloyRaynes: lazybot seems to have passed out
22:05muhoo,(l/run* [q] (everyo #(l/membero % [4 5 6]) q))
22:05clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: l, compiling:(NO_SOURCE_PATH:0)>
22:06muhoobot appears to be alive, alhough it doesn't seem to do core.logic :-)
22:06amalloymuhoo: does that look like lazybot to you?
22:06muhooit looks like a bot to me
22:07muhoo,are you a bot?
22:07clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: are in this context, compiling:(NO_SOURCE_PATH:0)>
22:07gfredericksarohner: that gives you a stack overflow?
22:07muhoo,guards
22:07clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: guards in this context, compiling:(NO_SOURCE_PATH:0)>
22:07arohnergfredericks: yes, running c.l 0.7.5
22:07muhoo,"foo"
22:07clojurebot"foo"
22:07muhooah, clojurebot
22:07muhoo#"foo"
22:08muhoowhich one is ##"foo"
22:09gfredericksarohner: it might just be that's how the infinite-answers thing manifests itself
22:09gfredericks(run 5 ...) works fine for me
22:09muhoo&"alive?"
22:10arohner_ah, yes
22:10arohner_run* .. gives stackoverflow, run 5 terminates immediately. thanks
22:11mkgfredericks: namespace's map actually is implemented as an atom, for what it's worth
22:11gfredericksmk: cool
22:14goodieboytechnomancy: is it possible to use .lein-classpath when the plugin requires dependencies that the project doesn't have?
22:15goodieboy... my plugin is using the "fs" library, but when testing in my project, "fs" can't be found
22:17casionas I don't think I have a proper grasp of functional programming yet, can someone look at this http://ideone.com/JUDLG and give me some clues on how to do it better?
22:18casionit's just a small simulation of aa very simple game i suppose
22:18casionit looks awful to me but I can't think of how else to approach it
22:20RaynesThe variety of pastebins people use in here never ceases to amaze me.
22:20Raynes:p
22:21casionheh, yeah
22:22RaynesI think it'd be fun to write a pastebin.
22:22casionI wrote that on my ipad while out on the porch, so it was already there
22:22RaynesI'd want it to look like https://www.refheap.com
22:22casionconvenient
22:22xeqiI think it'd be fun to break a pastebin
22:23cmajor7what is the use of "#{::user}"? it evaluates to a current namespace, e.g. #{current.ns/user}, but what is the purpose?
22:24Raynescmajor7: Sometimes you need there to be a difference between the :foo from the bar namespace and the :foo from the baz namespace.
22:24RaynesIt isn't particularly common though.
22:24cmajor7I am looking at "friend" roles
22:25cmajor7they are defined as #{::user ::admin ::etc}, and was wondering on how to store them in DB
22:25cmajor7I guess I can just store them as user, admin and such..
22:26cmajor7do you know the "friend"'s purpose? thx
22:26gfredericks,(name ::admin)
22:26clojurebot"admin"
22:27cmajor7gfredericks: but ,(name :admin)
22:27cmajor7is also "admin"
22:27gfredericksyep
22:29cmajor7mm… do you know why "friend" for example uses "::"?
22:29gfredericksnope
22:30cmajor7e.g. https://www.refheap.com/paste/3951
22:30gfredericksit's used as a value rather than a key?
22:30cmajor7it is a set..
22:31cmajor7what do you mean "rather than a key"?
22:31gfredericksa key in a map
22:31xeqicmajor7: in order to use `derive` to make a heirarchy the keywords need to be namespaced
22:31gfredericksI guess I can imagine a justification
22:31gfredericksooh that
22:32gfredericksthat sounds by far the most likely
22:32xeqiyou can actually have the roles be anything if I remember correctly
22:32xeqiyou just don't get the ability to `derive` a heirarchy then
22:35cmajor7xeqi: I see.. reading about it now. thank you
22:56muhoocmajor7: :: is a fully qualified symbol, no?
22:56muhoo,::foo
22:56clojurebot:sandbox/foo
22:57cmajor7right, "it" is just a "current name space forward slash it"
22:58gfredericks&(identical? (keyword "foo/bar") (keyword "foo" "bar"))
22:58gfredericks,(identical? (keyword "foo/bar") (keyword "foo" "bar"))
22:58clojurebottrue
23:03muhooemezeske: if you're around, i'm trying to figure out exactly how lein-cljsbuild pulls in cljsbuild, so i can do some checkouts stuff to work on it
23:03muhooactually, it'd be great to hear what your workflow is for working on lein-cljsbuild, i might as well start with that
23:05muhooactually, in general how to use a plugin from checkouts, might be an interesting question
23:09Raynesamalloy: You have access to the VPS too btw.
23:15amalloyyeah, but you do weird shit with lazybot and if i touch him you get annoyed
23:16technomancyis anyone still seeing the bug where C-c C-k with nrepl.el would occasionally take a few tries to go all the way through?
23:16Raynesamalloy: Dude. All I do is run ./lazybot
23:16RaynesSeriously, that's precisely all I do.
23:16technomancyI can't repro, but I can't tell if I'm just getting lucky or if the bug is gone
23:16RaynesI mean, I do it in a tmux session, but that isn't required. :P
23:17technomancydude, at least nohup it
23:17RaynesWhy?
23:17clojurebotwhy not?
23:17RaynesI stick it in a tmux session so I can attach and watch over my world.
23:18technomancyI guess if everyone has access to the tmux session it's fine
23:18RaynesWhy would anyone else need access to my tmux session?
23:18technomancyI dunno; it's fine; disregard
23:18Raynesamalloy doesn't care about lazybot's output unless it stops doing it in which case he just wants to restart it which doesn't involve my tmux session at all.
23:18Raynes:P
23:19technomancybut if you do run it outside a tmux, then you should use nohup
23:19amalloyfor what it's worth i nohup 4clojure, but i don't know why
23:19technomancyfrom seeing how clojars is deployed I found upstart to be surprisingly simple
23:19technomancyit is nice if everything works via familiar /etc/init.d scripts
23:20Raynestechnomancy: What does nohup do? Apparently I don't understand.
23:21RaynesI thought it was to make it run in the background.
23:21technomancyit prevents it from exiting when the parent process (bash in this case) terminates
23:21RaynesWhich is what tmux does for me in the first place.
23:21RaynesBut tmux never terminates.
23:21technomancyright, I meant if you run it outside tmux you need it
23:21RaynesOh, reading comprehension.
23:22technomancybut upstart is much nicer
23:22RaynesI thought you said 'inside'.
23:22amalloytechnomancy: i've also never seen a process end when my bash ends
23:22amalloyso i wonder if perhaps nohup is a relic of simpler times, when that happened?
23:22RaynesI sure have.
23:22Raynesamalloy: As a matter of fact, I've killed 4clojure like that before.
23:22technomancyit happens
23:23technomancyhttp://groups.google.com/group/clojars-maintainers/browse_thread/thread/d4149ec96316d5b1/4c66317ac3ecd9bb?lnk=gst&amp;q=upstart#4c66317ac3ecd9bb <- nice description of clojars' upstart usage from _ato
23:25technomancyI'm going to go out on a limb and say that particular nrepl.el bug is gone
23:28muhootechnomancy: nrepl.el is very very cool, thanks, i'm now switched over to using it
23:29Raynesmuhoo: Welcome to the resistance.
23:29muhootechnomancy: sorry for so brutally whacking the popups, but all the popups had turned my sessions into an experience not unlike browsing porn sites.
23:29technomancymuhoo: oh, haha; irc/github nick mismatch =)
23:29RaynesYou would know.
23:30technomancyI think you're right about the repl experience, but the fix in that pull request was just a bit too far-reaching
23:30muhooagreed, i was just in a hurry
23:31technomancymuhoo: so you actually prefer just seeing the message going to stdout vs the whole trace?
23:31muhooactually, what i've come to really enjoy is the way lein does it: a single-line clj-stacktrace summary
23:31muhooand (pst) to get the rest if needed
23:32muhoothough, a hotkey in emacs to pop up the (pst) would be slick, so as not to pollute the repl buffer with a huge stacktrace
23:32technomancywhat if clj-stacktrace omitted irrelevant frames by default?
23:32muhooi think it does already, or at least shortens them
23:32hiredmanas always, I object, who decides what is irrelevant?
23:33technomancyhiredman: I know you object =)
23:33technomancyI'm asking muhoo because it never occurred to me that the behaviour of only showing .getMessage was actually preferred by anyone
23:33muhoowell, look. i type (ns 'foobar) too many times
23:33hiredmanremoving stack traces is optimizing for ignorance, it makes a better experience for people who can't read them
23:34muhooand, a whole host of errors i make constantly in a repl, like (require foo.bar.baz) instead of (require 'foo.bar.baz)
23:34muhoodo i really need a 2-page stacktrace every time?
23:34technomancymuhoo: I'm just wondering if you're objecting to their length or their presence at all
23:35technomancyI think reply must have some magic to auto-refer clojure.repl into every ns or something... interesting
23:35muhooi'm objecting to (1) popups in general, they disorient me, and (2) huge spews when i just made a typo
23:35technomancymuhoo: sure, I'm saying what if the trace went to stdout instead
23:36technomancyand if they were shorter
23:36muhooi actually wrote a hack for noir where it sends the stacktrace to /tmp/noir-error.clj, and then i auto-revert-mode a buffer that has taht in it
23:37muhooso when i blow something up, i just go to the buffer (or have it open in another window) and look at it, and the most recent error to occur is right there looking at me, with the top frame at the top, etc. (and some context and ring-request at the bottom too)
23:38muhooi like full stacktraces, and i enjoy the way clj-stacktrace cleans them up.
23:39muhoobut i also like not *having* to look at them, when often the first line is all i need.
23:39muhoo(also nice not to have to scroll around to find the top of them, which is why i wrote that hack for noir/ring)
23:39technomancysure
23:40technomancyI think you can actually set :caught in :repl-options in project.clj if you want to tweak it
23:40muhoocool, i'll take a look at that.
23:40technomancyat least you could in 1.x; hopefully that's still possible
23:40technomancyanyway, that would let you swap between prn and pst
23:41muhoowell, i'm fully converted over to lein2 now, so i'd have to find a way that works with it
23:42technomancyI actually didn't even know that the default was just to show the exception message
23:42muhooreally? wow. you've been using swank i presume
23:43technomancyonly started paying attention to lein repl now with nrepl.el
23:46muhooi see no :caught in leiningen/sample-project.clj
23:47technomancyit might not be documented; try putting it in :repl-options
23:49muhooi'll try, but the word "caught" appears nowhere in the lein2 source
23:49technomancyyeah, it would get passed through to reply
23:55amalloytechnomancy: oh, is reply the one responsible for me no longer getting reasonable exception messages in swank?
23:55amalloyor are those not related?
23:56technomancyhrm
23:56technomancyunrelated
23:56technomancyyou may be getting bit by a clj-stacktrace bug?
23:57amalloymaybe. i've never included clj-stacktrace on purpose
23:57technomancyit comes for free
23:57technomancybecause it's too awesome not to
23:58amalloyhow can i disable it? i've had nothing but grief anytime i've had a project that uses it
23:58technomancy... what?
23:58technomancyhow ... I mean
23:59technomancywhy would you want gross normal stack traces?
23:59amalloystacktraces coming from inside clj-stacktrace's processing code, instead of from my code
23:59technomancyoh, right
23:59amalloyso that i can't track down any damn thing
23:59technomancyfirst thing would be to bug chouser to make his clj-stacktrace changes public so I stop procrastinating on the project
23:59technomancysecond thing would be to switch to nrepl.el