#clojure logs

2015-09-21

00:30rritochIs there some "magic" way to call a private function from a macro?
00:33TEttingerrritoch: reflection?
00:34rritochTEttinger: It's a clojure function, not a class. I know you can #'some-ns/private-fn but I'm not sure that reader macros work in macros, and/or if they work the same way.
00:34TEttingersure they would
00:35TEttingerreader is before the macro stage
00:36TEttinger,(defmacro foo [& bars] `[~@bar])
00:36clojurebot#error {\n :cause "Unable to resolve symbol: bar in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: bar in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: bar in this conte...
00:36TEttinger,(defmacro foo [& bars] `[~@bars])
00:36clojurebot#'sandbox/foo
00:36rritochTEttinger2: Ok, thanks. I'll try it. I want the function private because it's just calling a static class method but I don't want to use the qualified name because it doesn't get "interned" that way (at least in previous versions of clojure)
00:36TEttinger,(foo 8 9 10)
00:36clojurebot[8 9 10]
00:37amalloyrritoch: what doesn't get internet?
00:37TEttingerI don't know if private fns have any difference in behavior regarding whatever interning is here
00:37amalloy*interned
00:38rritochTEttinger: No, the reason I want it private is that it really isn't meant to be part of the API. The only reason I'm making the function is to avoid the use of the fully qualified name since the classloading for fully qualified names is different since they're not interned.
00:40rritochThis way I can :import the class and call it's method using the private wrapper function, the API is providing a macro and it isn't likly the macro user will have the class I need imported.
00:50oOzzy`Is there an easy way to export an environment variable from clojure at runtime? I have a client - server application and want to share the port of the api, which is allocated dynamicly by the system.
02:43sobelwrite it to disk
03:40roelofIs Living Clojure a good book to learn Clojure or can I better wait till the next release of the Brave book ?
03:51roelofno body here ??
03:53TEttingerhey roelof
03:54roelofTEttinger: hello
03:54TEttingerI suspect living clojure is good from what I've heard here. it's a little sleepy right now
03:54TEttingerpeople in the US are asleep, mostly europeans here now I think
03:55roelofI already noticed
03:55roelofIm a European. I live in the Netherlands
03:57roelofI doubt between the Living book and do 4clojure and the kata's or waiting on the next release of Brave which what I heard will also have many exercises
03:58roelofTEttinger: what is your oponion about this ?
04:03aneyou don't need to choose... just learn from them all
04:05roelofane it does not look right to me to do both at the same time. First Living and later Brave maybe ?
04:12anei don't know, i haven't heard of living clojure
04:13roelofane, thanks
04:21clintmnrepl doesn't start automatically - it has to be added to ~/.lein/profiles.clj or project-root/project.clj, right?
04:34hyPiRionclintm: it should be there by default
04:35dm3is there a way in CIDER to eval a form in the containing namespace without switching the NS of the repl? E.g. the repl is in <user>, but I want to eval a form in <dev>
04:37dm3C-c C-c, I guess
04:40roelofCan someone help me figure out what the right answer is here : (= #{1 2 3 4} (conj #{1 4 3} __)) I thought it would be #{ 1 2 3 4} but according to 4clojure is not the right answer
04:42roeloffound it. The right answer is 2
04:42ianhedoesitroelof: do you know why?
04:44roelofyes, conj adds a item to the end. and 2 is missing from the set and I see it in the answer
04:48ianhedoesitconj actually adds to the most efficient place. for vectors it's at the end, but for lists it's at the front. the important thing that that question is trying to help you learn is that set equality isn't determined by order
04:48ianhedoesit,(conj '(1 2 3) 4)
04:48clojurebot(4 1 2 3)
04:48ianhedoesit,(conj [1 2 3] 4)
04:48clojurebot[1 2 3 4]
04:50roelofianhedoesit: thanks for the explanation
04:52roelofianhedoesit: do you know the living clojure book
04:52ianhedoesitI haven't read it but I know of it.
04:53ianhedoesitwhy?
04:53clojurebothttp://clojure.org/rationale
04:56roelofI try to find out if it's a good book for a absolute beginner in clojure
04:58ianhedoesitI don't know if I'd recommend it for you yet. I actually just spent a couple hours the other day in the local book store and skimmed most of the "main" clojure books (which are them all, really). it looks nice, it's a short book, has good examples it seems, but it's not a "learning-to-program" book.
04:59ianhedoesit(I'm not insinuating that you don't know how to program, but there are some more basics it seems like you could cover before diving into some of that book.)
04:59roelofianhedoesit: oke, then I can better wait for the new edition of brave
05:00ianhedoesityeah, I'd say that's a good place to start. it's easily accessible, has some good information, and is free.
05:00roelofor can you recommend a better book with a lot of exercises so I can also make my hands dirty and not only read things
05:01amalloywhy wait for a new edition? something wrong with the one before it?
05:01ianhedoesitamalloy: there's an update coming tomorrow (22/9) with a bunch of exercises, fixes, additions, etc. to the book.
05:02amalloywell, i guess one day is not too bad to wait
05:02ianhedoesitit might be silly to start it now and when he comes back to it tomorrow the paragraph he's on is different.
05:02ianhedoesitto be fair, there's obviously nothing wrong with going through it now. nothing in the book is outdated or wrong and it's still a great free resource.
05:03roelofthanks all, I will begin at the brave book
05:04roelofhave all a good day
05:04ianhedoesitroelof: I actually learned a lot about clojure when I first started by watching Hickey's videos
05:06roelofianhedoesit: you mean on this page : http://www.infoq.com/author/Rich-Hickey
05:06ianhedoesitand others on youtube and various websites
05:06ianhedoesithttps://changelog.com/rich-hickeys-greatest-hits/
05:06ianhedoesithttps://www.youtube.com/playlist?list=PLZdCLR02grLrEwKaZv-5QbUzK0zGKOOcr
05:07ianhedoesitthere's a bit of overlap in the three links (including yours), but there's plenty of good content to get into the mindset of clojure.
05:07roelofthanks
05:07ianhedoesityup
06:32roelofHello, im reading the brave book online and I want to be sure that I understand it. We have a loop here(http://www.braveclojure.com/do-things/#4_3__loop)
06:33roelofloop is taking care that a loop is intialized. Then I see reccur .It reccur takes care that the loop is running again with the new value of iteration
06:36oddcullyroelof: yes, iteration is zero at first. then in the if the recur runs that expr again, but this time with (inc iteration)
06:37roelofoke, I was in doubt because it was wierd explained in my oponion. With a loop do I always need to use recur ?
06:37oddcullyroelof: at some point the if prints goodbye and ends that loop. the return would be `nil`
06:37oddcully(the result of the print)
06:38roelofthanks, that part I understand, I was in doubt I was understanding the recurr part well
06:40ianhedoesitrecur rebinds the bindings of the recursion point to the values of the expressions evaluated
06:40oddcullyand the second part of that link there leaves something important out: not only is loop/recur better in performance, but it also prevents a stack overflow (if you use 300000 instead of 3 in that if)
06:43roelofoke, so I cannot use loop withhout using recur
06:43ianhedoesitre: performance, keep in mind that recur isn't the best in terms of performance and can often be written in a more functional way using map/filter/reduce/etc.
06:43opqdonutwhy isn't recur the "best in therms of performance"?
06:44ianhedoesitroelof: loop is only an optional binding spot for recur. i.e. you can use recur without loop but you can't use loop without recur
06:44opqdonutI do agree that using higher-order-functions can simplify code, but for complex things the explicit loop is often best
06:46ianhedoesitI would say it's fairly safe for me to assert that recur is not the best performance for any certain task. the way it's stated in brave clojure just makes it a bit ambiguous as to what "much better performance" means.
06:47ianhedoesitI think the more important thing to know about recur is that it is the only non-stack-consuming looping construct in Clojure. there's a time and place for it just as there's a time in place for using various higher order functions or a recursive function, etc.
06:48roelofianhedoesit: what is then a better alternative to reccur ?
06:48ianhedoesitthis is probably getting too far away from roelof's initial question, though, and I apologize for digressing
06:49ianhedoesitroelof: there's no better alternative in every situation. recur is a very useful feature and sometimes it will be your only viable option
06:51ianhedoesitagain, I apologize as I realize now what I said was probably more confusing than helpful.
06:51dzhushow are you gentlemen
06:52dzhusis there any standard way to include git commit hash in leiningen project manifests?
06:52roelofianhedoesit: no problem, Thanks for the explanation. I think I try some challenges from 4clojure to make my hands dirty
06:53dzhusthat's what I have now http://dpaste.com/1SPBKF2, could you suggest any improvements?
07:01oddcullydzhus: if you rather use a git command instead of digging into the files: `git rev-parse master`
07:24dzhus`oddcully: how do I run an external command in Clojure?
07:25oddcullydzhus`: i use this: https://www.refheap.com/109798
07:27tdammersquestion here; suppose I have a protocol, and I have a function that returns a hashmap. I want that return value to match the protocol, but ideally, I would keep it as just a hashmap.
07:27tdammersis this possible?
07:27dzhus`oddcully: Perfect, thanks!
07:36shemdzhus`: another option is https://github.com/Raynes/conch
07:36xeqitdammers: you could use a defrecord with the protocol or a multimethod with a hashmap
07:37tdammersah, right
07:54tdammershum, this is weird... I have a type that extends a protocol, and everything works, until I put a value of that type into a hashmap and pull it out again elsewhere; then clojure complains that there is no implementation of method :foobar of my protocol
08:04visof_hi guys
08:04visof_can anybody help me in this problem https://gist.github.com/aibrahim/1657147ad989ac09761d ?
08:04visof_how can i do this in consize and functional solution?
08:04visof_conciese*
09:35sjlis there any documentation/writing about the the nrepl session middleware? not really what it does, but more like "why it exists"
09:35sjlI'm looking at implementing an NREPL server in common lisp and am trying to wrap my head around all the various parts
09:35borkdude_can you have a namespace divided over a .cljs + cljc file or must everything of that namespace be in one file?
09:38python476hi
09:38python476anybody made a repl plugin to describe Java classes in-repl ?
09:39sjlas far as I can tell just by banging my head against the code, the session middleware's main purpose is to basically wrap the eval middlware so you can sent stdin or an interrupt later
09:39python476I'm pretty addicted to repl discovery (clojure, python and the likes) and java interop through online javadoc is a PATI
09:39sjlbut I feel like I'm missing the bigger picture
09:43oddcullypython476: clojure.reflect maybe?
09:43python476oddcully: nice idea
09:43ashwink005what is the meaning of " ^ " ?
09:44oddcullypython476: vinyasa has several helpers around reflection: https://github.com/zcaudate/vinyasa#reflection
09:45python476even a simple (:members (r/reflect <obj>)) is already a great starting point
09:47python476but vinyasa looks interesting
09:50oddcullyashwink005: http://clojure.org/reader#The%20Reader--Macro%20characters
09:51python476oddcully: found this, already so zen inducing http://stackoverflow.com/questions/17955670/equivalent-to-clojure-contribs-show
09:53python476So happy, I'm shouting out loud "Duuude"
09:54ashwink005oddcully, thanks!
09:54python476clearly proving https://raw.githubusercontent.com/Dobiasd/programming-language-subreddits-and-their-choice-of-words/master/img/happy.png to be truly real
10:05xeqisjl: it also provides a way to store and recall dynamic variables like *1 *2 etc. https://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/middleware/interruptible_eval.clj#L222 + https://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/middleware/session.clj#L132
10:06sjlhmm
11:04noncomif i deploy my application as a war to tomcat, can my application have state and ticking clock inside? or is it required to be strictly stateless?
11:11akkaddoes clojure have an equivalent to progn?
11:11sjlakkad: do
11:15akkaddo is dynamically scoped?
11:17borkdude_@akkad do has nothing to do with dynamic or lexical scoping
11:18borkdude_akkad only when you use binding do you get dynamic scoping (which you usually don't want)
11:37visof_hi guys
11:39visof_if i have two methods called, updateU, processU, and list = [s1 s2 s3], how can i achieve this (processU (updateU s3 (processU (updateU s2 (process s1)))))
11:39visof_?
11:39visof_do this to sn
11:39visof_(processU (updateU sn .....)
11:40visof_anybody there?
11:43dxlr8rdidn't understand question
11:43dxlr8rbut maybe you are looking for ->
11:43dxlr8rhttp://clojure.org/cheatsheet
11:44visof_dxlr8r: what didn't you understand?
11:47dxlr8reverything after and including "how can"
11:47mgaareupdateU is not called on s1?
11:48visof_yeah
11:48visof_updateU take two args
11:48oddcullyreduce over a combined processU and updateU and start with process s1?
11:48visof_process take one
11:49oddcullys/over/with/
11:51visof_oddcully: something like this (reduce (fn [x y] (updateU x processU y)) (process f) (drop 1 l)) ?
11:51visof_oddcully: something like this (reduce (fn [x y] (updateU x (processU y)) (process f) (drop 1 l)) ?
11:51mgaareA recursive function with two arities would do the trick
11:53oddcullyshouln't be upU and procU be swapped?
11:54visof_ah hyeah
11:54visof_(reduce (fn [x y] (processU (updateU x y)) (process f) (drop 1 l)) ?
11:57oddcullyand x y swapped?
13:27python476hi again
13:28noncompython476: hi
13:28python476let's say I have a file core.clj (ns java-net.core), and a Java class FS.class, how do I use it in core.clj
13:29noncomyou mean your class isn't jarred?
13:29python476yeah, it's in the same folder, vanilla .class
13:30noncompython476: well, never tried it, but i think that if you put it in the correct path under the "target" folder of your project or "bin" folder, you'll be able to import it as usual
13:30python476noncom: aight, gonna check this
13:30noncomyou can create some example class, have the path to it be specified in :java-source-paths in your project.clj, run lein and see where it actually puts it
13:30noncomthen you can know the right location
13:31noncompython476: remember to keep a copy of the original class file, because the "target" and "bin" dirs can be wiped easily
13:33justin_smithnoncom: python476: don't put it under target, that directory is made to be whiped clean. Put it under the classpath under some other top level (perhaps add a new resource-paths entry to your product for that directory tree)
13:33python476product -> project ?
13:33noncomwill it be able to pick it up from a resource path?
13:33justin_smithpython476: yes, sorry
13:34justin_smithnoncom: yes, resource-paths is just another classpath entry, it's all the same to the vm
13:34python476no worries, just avoiding misinterpretations
13:34justin_smith*just another set of classpaht entries
13:37python476so if I put .class files into <project-root>/foo and declare foo in resource-paths (import foo.XXX) should work ?
13:38justin_smithpython476: well, the relative path to the class file needs to match the package of the class
13:38justin_smithbut yes, something like this
13:38python476ok
13:39justin_smithbut really, the project that creates that class file should be creating a jar, it makes things a lot simpler
13:43python476justin_smith: maybe I wasn't clear, I wrote the java source.
13:43python476it's not a dangling .class
13:45noncompython476: then you can even include the source into the clojure project if it belongs there
13:46python476yes, I have the .java next to the .clj files in src/java-net/
13:46python476and naively thought (import 'java-net.<class>) would do
13:46noncompython476: have them in a separate folder, like java-src/your-package
13:47noncompython476: and add :java-source-paths ["java-src"] to your project clj
13:47python476ok
13:47noncomthis will make lein consider your sources
13:47python476great, thanks
13:49python476noncom: worked.
13:50noncompython476: cool. but remember that java sources cannot be easily recompiled while in REPL (unless you use vinyasa or something similar) so repl restart is requried to incorporate changes of java files into the runtime
13:50python476good points
13:51python476so far I'm happy to know that I can implement stuff in Java easily in case clojure performance is not enough
13:51noncompython476: oh i use this a lot sometimes, esp when doing 3d graphics
13:52noncominterop is so light and pleasant
13:52python476your work asks for CGI ?
13:52noncompython476: yeah. i used to work in a company that does this. now i work on personal/side projects that involve opengl, shaders, sound and stuff..
13:53noncomi love media programming
13:53noncomand other programming too :O)
13:53python476I'm `love` geometry related programming
13:53python476-'m
13:53python476got into programming after using packages like Maya and Houdini
13:53noncomoh, so yeah. i used java a lot in places where i had to generate/compute vertex buffers or pixels, for example
13:54noncomso youre doing graphics too, cool!
13:54python476oh no, I just toyed with them in early 2Ks
13:54python476just completely obsessed with anything related to graphics and math
13:54python476even though a lot of lisp on my mind too, since they were involved with the ancestor of Mirai
13:55noncomoh, so i bet you gotta use much thigns like quil...
13:55python476never heard of that
13:56noncomi love graphics & math too. been doing video mapping on psychedelics music parties. involves much of that.
13:56python476oh clojure animation package
13:56noncomhttps://github.com/quil/quil
13:56noncomit's acrually Processing in disguise
13:56python476yeah, just saw that
13:57noncomthis https://libgdx.badlogicgames.com/ and this http://jmonkeyengine.org/ allows for much fun with 3d, graphics and stuff
13:59python476ha.. bring back some memories
13:59python476barely related, but I did a nurbs things using jogl back in the days
13:59python476things were so crude
13:59noncomyeah :) now they are there, smoother :)
14:00noncompython476: for inspiration with quil/processing http://openprocessing.org/
14:00python476jmonkey is appealing
14:00python476but nowadays I'm lazy, let's wait for a clojurescript equivalent :D
14:00noncomhah :)
14:01noncomwill take long ltime sinnce web gl is far weaker
14:01noncomprocessing/quil can do web/cljs tough
14:01noncom*though
14:01python476cool
14:01python476gonna eat, bbl
14:02noncompython476: sure i gotta go too
14:02noncomgood luck
14:02python476thx
14:07noncompython476: btw looks like http://openprocessing.org/ already moved all their examples to webgl, so it's all web now!
14:28PupenoHow can I run another lein task, lein deps, when running lein uberjar?
14:29oddcullyPupeno: e.g. lein do clean, figwheel dev test
14:31Pupenooddcully: mh? Sorry, I don't get it.
14:32oddcullyPupeno: lein do task1, task2, task3 withparam
14:32PupenoI'm deplying to Heroku, which automatically runs lein uberjar. I need to run lein deps before or after that for my app to run.
14:33codefingerPupeno: you need to run lein deps are boot time? or build time?
14:33codefingeroh, reading back. i see...
14:33PupenoAt build time.
14:34codefingerPupeno: you can set LEIN_BUILD_TASK config var. so `heroku config:set LEIN_BUILD_TASK='deps uberjar'` would that work?
14:35Pupenocodefinger: good to know. I'll do that if I can't figure out another way, but I'd like to express the fact that lein deps need to run in my app, not in Heroku's configuration. If I deploy to a different Heroku app or a different server, that would fail and it's a bit obscure.
14:36Pupenocodefinger: thank you though, I'd look into that.
14:36PupenoI'll look into that.
14:36codefingeri think you can do that with a profile, like here https://github.com/heroku/heroku-buildpack-clojure#uberjar
15:01justin_smithwait, when would uberjar ever not implicitly run the deps task?
15:02oddcully¯\(°_o)/¯
16:07python476not much action on #clojure, is it always like this ?
16:08justin_smithpython476: nope, I'm usually very active here but hammering on a deadline http://i.imgur.com/Eca8nsE.gif
16:09python476stop !
16:09python476hammer time.
16:09oddcullypython476: i thought there is some us holiday, because it's extremly silent today
16:10justin_smithit's the very important holiday "last full week in September, and there's a deadline coming"
16:11python476right
16:12oddcullyor they all off to slack
16:19codefingeri don't get slack. irc is enough for me :)
16:19anewhat new things are coming in 1.8?
16:20Bronsaane 1.8 is mostly a bugfix release
16:20Bronsaane https://github.com/clojure/clojure/blob/master/changes.md
16:21xemdetiayou can't even use slack over telnet :(
16:22Bronsathere's a slack irc gateway
16:23oddcullyBronsa: having to register and beg for entry is enough for me to ignore it
16:35elvis4526Is there a way to make a def expression act the same way as a defn? (i.e it gets evaluated again each time its runned)
16:36hiredmanthat is not what happens
16:36mungojellyelvis4526: i think def is evaluated every time, it's defonce that won't reevaluate
16:37oddcully,(macroexpand '(defn x []))
16:37clojurebot(def x (clojure.core/fn ([])))
16:38hiredmaneach function application is evaluated as the function running with a fresh set of arguments, but the function is not evaluated again
16:38mungojellyelvis4526: but you shouldn't need to define things more than once, that's probably not the tool you need
16:40justin_smithelvis4526: when you talk about evaluating each time it's run, do you mean you want a function with no arguments?
16:40justin_smithbecause you can totally do that
16:40justin_smithelvis4526: but we don't have anything that would act like a def but re-calculate its value magically when you use it, and that's intentional
16:41elvis4526Okay, I was asking because I have something like this (def myfunction (partial anotherfunction @atom)) and when using (myfunction) somewhere else I was under the impression that the value of @atom was determined when creating the partial, and not when I execute (myfunction)
16:41Bronsauff, Var is final, that's no fun :(
16:41hiredmanthe value of @atom is from the point in time it is run
16:42justin_smithelvis4526: that's true, and you need to write it differently if you want the atom lookup on function call
16:42hiredmanwhich in the case of that def is when the code is compileded and run either in the repl or out of a file via the compiler
16:43elvis4526Okay I see, that's what I mostly figured
16:44hiredmanthe behavior is the same for any kind of mutable thing
16:45hiredman(def a (atom 0)) (def x (+ @a 5)) (reset! a 1) x
16:51justin_smithelvis4526: for your usage it's simple enough, just define a regular function instead of using partial, then the deref will happen as part of the function call
17:13Balveda-3If I'm doing something like (GET "/user/:id" [id] (user-info id)), how can I pass along the request as well?
17:14hiredmanhttps://github.com/weavejester/compojure/wiki/Destructuring-Syntax
17:14Balveda-3ah, great, thanks!
17:16Balveda-3(inc hiredman)
17:16Balveda-3huh, it was taken down?
17:17oddcullylazybot is on vacation
17:39cmarquesclojurescript/reagent question: I'm trying to create a "delete" button that changes to a cancel/confirm button when clicked, but it never changes. Here is the code https://gist.github.com/cassiomarques/0b7c5ba7576bb847b872 Thanks!
17:43mungojellycmarques: i've never used that so idk but maybe its window context needs a hint to redraw it?
17:44cmarquesmungojelly the way it's supposed to work is that the atom's value is bound to what the component displays
17:46mungojellyi don't even know what context that's talking to. oh it's javascript in a browser? but often in those things you don't actually see changes unless you notify the thing that redraws stuff, because it's being lazy and assuming everything stays the same
17:47oddcullyi don't use reagent either, but based on other react based frameworks experience: why should it redraw this component, if the input is a card and you change an seaminly unrelated atom?
17:49cmarquesoddcully the input is a card but it would be used later (to actually delete the card). For now, I just want to implement the UI.
17:50oddcullythat's my point or my question if you like. the "redraw" might depend on a change to card
17:52mungojellyi think maybe you need to have the state you want it to watch in a reagent atom
17:52cmarquesoddcully not really, it would depend on a change on the atom's value.
17:52cmarquesmungojelly yes, delete-state is a reagent atom, it's just not in the gist
17:53oddcullyis this what you wish for or what you know, that happens
17:53oddcully?
17:54cmarquesoddcully I believe it's both
17:54oddcullybelieving is not knowing ;)
17:54neoncontrailscmarques: I'm glad you're asking about this, because I was about to ask a very similar question right before I noticed yours
17:55oddcullybut i don't want to add more confusion to this
17:55cmarquesoddcully sorry, but if I knew for sure I would not be asking for help here :-)
18:00cmarquesneoncontrails This version does what I want: https://gist.github.com/cassiomarques/b799692d292b4a6d95cc
18:01cmarquesThanks for your help oddcully and mungojelly
18:02cmarquesmoving the atom to the component was done more for organization, it does not change the behaviour. What did the trick was having another dom element wrapping the part of the code that contains the different states, while changing the "sub components" to be just arrays rather than functions.
18:06mungojellycmarques: oh ok well thanks for teaching me about reagent. is it fun should i try it? :)
18:08cmarquesmungojelly yeah, I'm having lots of fun
18:09sritchiehey dnolen, qq on Om - I’m trying to interact with React Native and having trouble with one of the required properties to a NavigatorIOS
18:10sritchiein the js it’s just the name of a class that extends React.Component
18:10sritchiednolen: not sure what I need to pass to this “component” field in the options map - the result of om/build,
18:10sritchietried that, died with an error saying the component needed type “function” and had type “object"
18:27python476 it's impressive how time changes things. Until years after quitting college, which was heavy on Java. It's only after seeing module implementations in python and then javascript that I get java (and clojure) packaging schemes.
18:45neoncontrailsI have a similar question to cmarques's. I have a working calculator app thingy. Right now the only way to interface with it is through HTML buttons, and I'd like to extend this to also take valid keyboard inputs. Am I correct in assuming that requires watching for a different kind of event than my render loop is currently looking for? (:on-key-press instead of :on-change?)
18:45neoncontrailshttp://pastebin.com/s9PaL45t
18:46sritchiemfikes: hey man, qq about ambly + react native if you’re around
18:47sritchiemfikes: I’m trying to create a NavigatorIOS, just following a basic demo, and seeing this *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'put reactNavSuperviewLink back'
18:47sritchiewhich points to this https://github.com/facebook/react-native/blob/master/React/Views/RCTNavigator.m#L442
18:47{blake}So...nesting "for" gets me nested structures, which I don't want.
18:47{blake}flatten?
18:47clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
18:47{blake}hehehe
18:48{blake}I'm scanning a spreadsheet for formulae: for [sheet... for [row ... for [cell...
18:49{blake}Just want a flat thing back and wondering. But for seems like the right thing.
18:49turbofailyou just want a sequence of cells?
18:50{blake}turbofail: Nah, a sequence of formulae. Though I might do the same thing with cells later on, I s'pose.
18:50turbofailfor does that. (for [sheet sheets row sheet cell row] (blah cell))
18:50{blake}turbofail: Oh...yeah, that makes sense. =P
18:50turbofail(it's a little easier to read with line breaks)
18:50{blake}Just had that same...fail...with doseq.
18:51cmarquesneoncontrails I believe you can use the :on-change event to update the value of the atom.
18:56cmarquesneoncontrails something like this usually works for me https://gist.github.com/cassiomarques/2c31a2341d4a017c2a90
18:58neoncontrailscmarques: Thanks, I'll try inserting this and see what happens
19:00mfikessritchie: Hmm. I've not yet built anything with React Native that causes that.
19:01sritchiemfikes: looks like something about initiating React’s view with the bridge
19:01sritchiethe other demos I’ve tried using JS pass the assertion on the first clause
19:02dnolensritchie: hrm I really don't know
19:02sritchiemfikes: things are working well, other than that! the dev cycle’s a little painful on simulator crashes, but it looks like the work you guys are doing is just going to make that better and better
19:02sritchiednolen: I think (.-type (om/build my-component-fn {})) might do it
19:04sritchiemfikes: do you have some nice way of dealing with “socket closed” issues at the terminal?
19:08hlolli`,(defn debug [sometext] (prn sometext))
19:08clojurebot#'sandbox/debug
19:08hlolli`,(def quoted-func `(debug "debugtext"))
19:08clojurebot#'sandbox/quoted-func
19:08hlolli`,(quoted-func)
19:08clojurebot#error {\n :cause "clojure.lang.Cons cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.Cons cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval70 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval70 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval70 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java"...
19:09hlolli`How can I call a quoted function like that? Is it possible?
19:14xeqi,(let [[f & args] quoted-func] (apply (resolve f) args))
19:14clojurebot"debugtext"\n
19:16turbofailit's eitherwhat xeqi did, or use `eval'
19:16hlolli`ok nice, thanks alot! Eval, ok silly I didnt try that.
19:17turbofailthat said, there's usually better ways to get a similar effect
19:17hlolli`btw, since Im new to irc, what does the ` symbol of my name hlolli mean? I thought for I while I was muted.
19:18turbofailyour client probably appended that to your existing nick because you got disconnected, but the server hadn't timed you out yet
19:18turbofailand so you couldn't use your existing nick
19:18hlolli`ah ok, I see
19:31hlolli`The reason I wanted to quote is because I wanted to have immuteable version of the function call. So (#'sandbox/debug "debugtext") would be stored even tough I would change quoted-func. I'll maybe give an example...
19:32hlolli`,(defn debug [sometext] (prn sometext))
19:32clojurebot#'sandbox/debug
19:34hlolli`,(defn quoted-func [] `(debug "debugtext"))
19:34clojurebot#'sandbox/quoted-func
19:34hlolli` ,(let [please-be-immuteable (debug-func)] please-be-immuteable)
19:34clojurebot#error {\n :cause "Unable to resolve symbol: debug-func in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: debug-func in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: deb...
19:35hlolli` ,(let [please-be-immuteable (quoted-func)] (prn please-be-immuteable))
19:35clojurebot(sandbox/debug "debugtext")\n
19:36hlolli`well damn, this is actually not my case...
19:36hlolli`(def debug-atom (atom {:val `(debug "debugtext")}))
19:37turbofailso, what are you trying to preserve again?
19:37hlolli`,(let [please-be-immuteable (:val @debug-atom)] (prn
19:37hlolli` please-be-immuteable))
19:37clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
19:38hlolli`the quted symbol to a function with its arguments, that is a variable.
19:38hlolli`I want to fetch the function call from a atom that is muteable, but keep the value despite the atom mutating.
19:38turbofailah
19:39turbofailwell you don't want a quoted form then, you want let
19:39turbofail(let [debug @debug] (fn [foo] (debug foo)))
19:41hlolli`Ok just what I thought. But then I realised that this question was actually from the strart meaningless because this is in a function that is constantly being recalled so it will constantly look up the value from atom, so I need a middle-man atom clearly. Anyhow forget my question, thanks anyway.
22:28TrioxinI just coded a clojure program that can become a super intelligence om its own given enough time governed by computational power.
22:28Trioxinon*
22:29TrioxinI call it.. GOD
22:31Trioxinsrsly though you could code such a thing. just not enough CPU for it to be useful
22:31stevenleeghey, does anyone have a hot second to help me out with getting started on unit tests with a project?
22:31stevenleegI keep getting nasty namespace errors
22:31stevenleegand I'm pretty sure it's a simple thing
22:31justin_smithstevenleeg: just ask the question, I'm sure the answer will be simple
22:32stevenleegokay cool. so I have a file src/wiki/parser.clj that I'm trying to test and the test file test/wiki/parser_test.clj
22:32stevenleegwhich has (ns wiki.test.parser (:use clojure.test wiki.parser)) at the top
22:32stevenleegand I keep getting Caused by: java.io.FileNotFoundException: Could not locate wiki/test/parser__init.class or wiki/test/parser.clj on classpath:
22:33stevenleegwhen running lein test
22:33justin_smithstevenleeg: the namespace name should match the file name
22:33justin_smithso if the file is parser_test the ns should end in parser-test
22:33stevenleegjustin_smith: so it should be (ns wiki.test.parser_test ?
22:33stevenleegohhh
22:33stevenleegparser-test
22:33justin_smithno, _ becomes -
22:33justin_smithright
22:34stevenleeghmm same thing
22:34stevenleegCaused by: java.io.FileNotFoundException: Could not locate wiki/test/parser_test__init.class or wiki/test/parser_test.clj on classpath:
22:34stevenleeg(ns wiki.test.parser-test
22:34stevenleegeven though wiki/test/parser_text.clj exists
22:34stevenleeger test*
22:34stevenleegoh wait
22:34stevenleegsorry
22:34stevenleegit's test/wiki/parser_test.clj
22:34justin_smithstevenleeg: if it has test in the ns name, it should be in a folder following that
22:35justin_smithso if it isn't in test/wiki/test/
22:35justin_smiththen take .test out of the ns name
22:35stevenleeghmm, i thought test/wiki/parser_test.clj was the place to put it
22:35justin_smithstevenleeg: doesn't really matter!
22:35stevenleeg(I copied SQL Korma)
22:35stevenleegah okay
22:35justin_smiththe thing that matters is that the path to the file must match the full namespace
22:36stevenleegwhen I run lein test how does it know where to look though?
22:36stevenleegright, okay
22:36stevenleegthat makes sense
22:36justin_smithlein test does a file search, then runs require based on what it finds
22:36justin_smithso the require doesn't find an ns that matches the file it found
22:36stevenleegoohhh
22:37stevenleegokay lemme read the docs on lein test, I think that'll help
22:37stevenleegjustin_smith: is it good practice to have something like src/wiki/test/parser_test.clj which matches up with src/wiki/parser.clj?
22:37justin_smithnot much to read - it does a search, finds files under test/ then turns every file path into a namespace to require
22:38stevenleegoh hm okay
22:38justin_smithstevenleeg: use a separate test directory, just make namespaces that match the file paths
22:39stevenleegerg yeah
22:39stevenleegokay so I switched it to (ns test.wiki.parser-test
22:39stevenleegmatches up with the filepath
22:39stevenleegbut Exception in thread "main" java.io.FileNotFoundException: Could not locate test/wiki/parser_test__init.class or test/wiki/parser_test.clj
22:39justin_smithstevenleeg: the leading test/ is not part of its path
22:40stevenleegyesss!!!!!
22:40stevenleeggot it
22:40stevenleeg(++ justin_smith)
22:40justin_smithsorry, I should have been more explicit - test is on your classpath, the files path relative to the classpath must match the ns
22:40stevenleegyeah that makes sense
22:40justin_smithso yeah, it was fairly straightforward as you guessed
22:40stevenleegthanks for sticking with me there haha
22:44Trioxinhas anyone ever done lattice QCD programming in clojure? I can't find any. I guess maybe I could find some java library and that would be easy to use?
22:46justin_smithI doubt there is a dedicated lib, seems like you could do it with core.matrix though
22:50sotojuanHello
23:07stevenleegokay another probably easy question: any idea why (require 'wiki.parser-test :reload-all) wouldn't be working?
23:08stevenleegwhen I run (run-tests 'wiki.parser-test) after modifying the file nothing is changed
23:08justin_smithdid you rename a test?
23:08justin_smithbecause if you did, the old name still exists in that ns
23:09stevenleegah yeah
23:09stevenleegI actually commented out a test
23:09stevenleegand it was still running
23:09stevenleegI was wondering if that were the case
23:09justin_smithright, because the namespace doesn't get destroyed with a reload
23:09justin_smithbut you can destroy a namespace explicitly if needed
23:09stevenleegokay sweet, that makes sense
23:10stevenleeghow can I do that?
23:10justin_smith,(apropos "destroy")
23:10clojurebot()
23:10justin_smithI always forget the name
23:10justin_smith,(apropos "purge")
23:10clojurebot()
23:10justin_smith,(find-doc "destroy")
23:10clojurebotnil
23:10justin_smithhrmph
23:11justin_smithone moment
23:11justin_smith,(apropos "remove")
23:11clojurebot(clojure.core/remove clojure.core/remove-all-methods clojure.core/remove-method clojure.core/remove-ns clojure.core/remove-watch)
23:11justin_smith,(doc remove-ns)
23:11clojurebot"([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace."
23:11justin_smiththat's the one!
23:12stevenleegoh nice
23:12stevenleegso (remove-ns 'wiki.test-parser)
23:12justin_smiththat should do it, yea
23:12stevenleegawesome
23:12stevenleegthanks again justin_smith!
23:12stevenleegyou're saving me tonight haha
23:13justin_smithheh