2015-09-21
| 00:30 | rritoch | Is there some "magic" way to call a private function from a macro? |
| 00:33 | TEttinger | rritoch: reflection? |
| 00:34 | rritoch | TEttinger: 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:34 | TEttinger | sure they would |
| 00:35 | TEttinger | reader is before the macro stage |
| 00:36 | TEttinger | ,(defmacro foo [& bars] `[~@bar]) |
| 00:36 | clojurebot | #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:36 | TEttinger | ,(defmacro foo [& bars] `[~@bars]) |
| 00:36 | clojurebot | #'sandbox/foo |
| 00:36 | rritoch | TEttinger2: 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:36 | TEttinger | ,(foo 8 9 10) |
| 00:36 | clojurebot | [8 9 10] |
| 00:37 | amalloy | rritoch: what doesn't get internet? |
| 00:37 | TEttinger | I don't know if private fns have any difference in behavior regarding whatever interning is here |
| 00:37 | amalloy | *interned |
| 00:38 | rritoch | TEttinger: 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:40 | rritoch | This 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:50 | oOzzy` | 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:43 | sobel | write it to disk |
| 03:40 | roelof | Is Living Clojure a good book to learn Clojure or can I better wait till the next release of the Brave book ? |
| 03:51 | roelof | no body here ?? |
| 03:53 | TEttinger | hey roelof |
| 03:54 | roelof | TEttinger: hello |
| 03:54 | TEttinger | I suspect living clojure is good from what I've heard here. it's a little sleepy right now |
| 03:54 | TEttinger | people in the US are asleep, mostly europeans here now I think |
| 03:55 | roelof | I already noticed |
| 03:55 | roelof | Im a European. I live in the Netherlands |
| 03:57 | roelof | I 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:58 | roelof | TEttinger: what is your oponion about this ? |
| 04:03 | ane | you don't need to choose... just learn from them all |
| 04:05 | roelof | ane it does not look right to me to do both at the same time. First Living and later Brave maybe ? |
| 04:12 | ane | i don't know, i haven't heard of living clojure |
| 04:13 | roelof | ane, thanks |
| 04:21 | clintm | nrepl doesn't start automatically - it has to be added to ~/.lein/profiles.clj or project-root/project.clj, right? |
| 04:34 | hyPiRion | clintm: it should be there by default |
| 04:35 | dm3 | is 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:37 | dm3 | C-c C-c, I guess |
| 04:40 | roelof | Can 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:42 | roelof | found it. The right answer is 2 |
| 04:42 | ianhedoesit | roelof: do you know why? |
| 04:44 | roelof | yes, conj adds a item to the end. and 2 is missing from the set and I see it in the answer |
| 04:48 | ianhedoesit | conj 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:48 | ianhedoesit | ,(conj '(1 2 3) 4) |
| 04:48 | clojurebot | (4 1 2 3) |
| 04:48 | ianhedoesit | ,(conj [1 2 3] 4) |
| 04:48 | clojurebot | [1 2 3 4] |
| 04:50 | roelof | ianhedoesit: thanks for the explanation |
| 04:52 | roelof | ianhedoesit: do you know the living clojure book |
| 04:52 | ianhedoesit | I haven't read it but I know of it. |
| 04:53 | ianhedoesit | why? |
| 04:53 | clojurebot | http://clojure.org/rationale |
| 04:56 | roelof | I try to find out if it's a good book for a absolute beginner in clojure |
| 04:58 | ianhedoesit | I 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:59 | ianhedoesit | (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:59 | roelof | ianhedoesit: oke, then I can better wait for the new edition of brave |
| 05:00 | ianhedoesit | yeah, I'd say that's a good place to start. it's easily accessible, has some good information, and is free. |
| 05:00 | roelof | or 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:01 | amalloy | why wait for a new edition? something wrong with the one before it? |
| 05:01 | ianhedoesit | amalloy: there's an update coming tomorrow (22/9) with a bunch of exercises, fixes, additions, etc. to the book. |
| 05:02 | amalloy | well, i guess one day is not too bad to wait |
| 05:02 | ianhedoesit | it might be silly to start it now and when he comes back to it tomorrow the paragraph he's on is different. |
| 05:02 | ianhedoesit | to 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:03 | roelof | thanks all, I will begin at the brave book |
| 05:04 | roelof | have all a good day |
| 05:04 | ianhedoesit | roelof: I actually learned a lot about clojure when I first started by watching Hickey's videos |
| 05:06 | roelof | ianhedoesit: you mean on this page : http://www.infoq.com/author/Rich-Hickey |
| 05:06 | ianhedoesit | and others on youtube and various websites |
| 05:06 | ianhedoesit | https://changelog.com/rich-hickeys-greatest-hits/ |
| 05:06 | ianhedoesit | https://www.youtube.com/playlist?list=PLZdCLR02grLrEwKaZv-5QbUzK0zGKOOcr |
| 05:07 | ianhedoesit | there'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:07 | roelof | thanks |
| 05:07 | ianhedoesit | yup |
| 06:32 | roelof | Hello, 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:33 | roelof | loop 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:36 | oddcully | roelof: yes, iteration is zero at first. then in the if the recur runs that expr again, but this time with (inc iteration) |
| 06:37 | roelof | oke, I was in doubt because it was wierd explained in my oponion. With a loop do I always need to use recur ? |
| 06:37 | oddcully | roelof: at some point the if prints goodbye and ends that loop. the return would be `nil` |
| 06:37 | oddcully | (the result of the print) |
| 06:38 | roelof | thanks, that part I understand, I was in doubt I was understanding the recurr part well |
| 06:40 | ianhedoesit | recur rebinds the bindings of the recursion point to the values of the expressions evaluated |
| 06:40 | oddcully | and 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:43 | roelof | oke, so I cannot use loop withhout using recur |
| 06:43 | ianhedoesit | re: 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:43 | opqdonut | why isn't recur the "best in therms of performance"? |
| 06:44 | ianhedoesit | roelof: 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:44 | opqdonut | I do agree that using higher-order-functions can simplify code, but for complex things the explicit loop is often best |
| 06:46 | ianhedoesit | I 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:47 | ianhedoesit | I 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:48 | roelof | ianhedoesit: what is then a better alternative to reccur ? |
| 06:48 | ianhedoesit | this is probably getting too far away from roelof's initial question, though, and I apologize for digressing |
| 06:49 | ianhedoesit | roelof: there's no better alternative in every situation. recur is a very useful feature and sometimes it will be your only viable option |
| 06:51 | ianhedoesit | again, I apologize as I realize now what I said was probably more confusing than helpful. |
| 06:51 | dzhus | how are you gentlemen |
| 06:52 | dzhus | is there any standard way to include git commit hash in leiningen project manifests? |
| 06:52 | roelof | ianhedoesit: no problem, Thanks for the explanation. I think I try some challenges from 4clojure to make my hands dirty |
| 06:53 | dzhus | that's what I have now http://dpaste.com/1SPBKF2, could you suggest any improvements? |
| 07:01 | oddcully | dzhus: if you rather use a git command instead of digging into the files: `git rev-parse master` |
| 07:24 | dzhus` | oddcully: how do I run an external command in Clojure? |
| 07:25 | oddcully | dzhus`: i use this: https://www.refheap.com/109798 |
| 07:27 | tdammers | question 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:27 | tdammers | is this possible? |
| 07:27 | dzhus` | oddcully: Perfect, thanks! |
| 07:36 | shem | dzhus`: another option is https://github.com/Raynes/conch |
| 07:36 | xeqi | tdammers: you could use a defrecord with the protocol or a multimethod with a hashmap |
| 07:37 | tdammers | ah, right |
| 07:54 | tdammers | hum, 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:04 | visof_ | hi guys |
| 08:04 | visof_ | can anybody help me in this problem https://gist.github.com/aibrahim/1657147ad989ac09761d ? |
| 08:04 | visof_ | how can i do this in consize and functional solution? |
| 08:04 | visof_ | conciese* |
| 09:35 | sjl | is there any documentation/writing about the the nrepl session middleware? not really what it does, but more like "why it exists" |
| 09:35 | sjl | I'm looking at implementing an NREPL server in common lisp and am trying to wrap my head around all the various parts |
| 09:35 | borkdude_ | can you have a namespace divided over a .cljs + cljc file or must everything of that namespace be in one file? |
| 09:38 | python476 | hi |
| 09:38 | python476 | anybody made a repl plugin to describe Java classes in-repl ? |
| 09:39 | sjl | as 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:39 | python476 | I'm pretty addicted to repl discovery (clojure, python and the likes) and java interop through online javadoc is a PATI |
| 09:39 | sjl | but I feel like I'm missing the bigger picture |
| 09:43 | oddcully | python476: clojure.reflect maybe? |
| 09:43 | python476 | oddcully: nice idea |
| 09:43 | ashwink005 | what is the meaning of " ^ " ? |
| 09:44 | oddcully | python476: vinyasa has several helpers around reflection: https://github.com/zcaudate/vinyasa#reflection |
| 09:45 | python476 | even a simple (:members (r/reflect <obj>)) is already a great starting point |
| 09:47 | python476 | but vinyasa looks interesting |
| 09:50 | oddcully | ashwink005: http://clojure.org/reader#The%20Reader--Macro%20characters |
| 09:51 | python476 | oddcully: found this, already so zen inducing http://stackoverflow.com/questions/17955670/equivalent-to-clojure-contribs-show |
| 09:53 | python476 | So happy, I'm shouting out loud "Duuude" |
| 09:54 | ashwink005 | oddcully, thanks! |
| 09:54 | python476 | clearly proving https://raw.githubusercontent.com/Dobiasd/programming-language-subreddits-and-their-choice-of-words/master/img/happy.png to be truly real |
| 10:05 | xeqi | sjl: 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:06 | sjl | hmm |
| 11:04 | noncom | if 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:11 | akkad | does clojure have an equivalent to progn? |
| 11:11 | sjl | akkad: do |
| 11:15 | akkad | do is dynamically scoped? |
| 11:17 | borkdude_ | @akkad do has nothing to do with dynamic or lexical scoping |
| 11:18 | borkdude_ | akkad only when you use binding do you get dynamic scoping (which you usually don't want) |
| 11:37 | visof_ | hi guys |
| 11:39 | visof_ | 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:39 | visof_ | ? |
| 11:39 | visof_ | do this to sn |
| 11:39 | visof_ | (processU (updateU sn .....) |
| 11:40 | visof_ | anybody there? |
| 11:43 | dxlr8r | didn't understand question |
| 11:43 | dxlr8r | but maybe you are looking for -> |
| 11:43 | dxlr8r | http://clojure.org/cheatsheet |
| 11:44 | visof_ | dxlr8r: what didn't you understand? |
| 11:47 | dxlr8r | everything after and including "how can" |
| 11:47 | mgaare | updateU is not called on s1? |
| 11:48 | visof_ | yeah |
| 11:48 | visof_ | updateU take two args |
| 11:48 | oddcully | reduce over a combined processU and updateU and start with process s1? |
| 11:48 | visof_ | process take one |
| 11:49 | oddcully | s/over/with/ |
| 11:51 | visof_ | oddcully: something like this (reduce (fn [x y] (updateU x processU y)) (process f) (drop 1 l)) ? |
| 11:51 | visof_ | oddcully: something like this (reduce (fn [x y] (updateU x (processU y)) (process f) (drop 1 l)) ? |
| 11:51 | mgaare | A recursive function with two arities would do the trick |
| 11:53 | oddcully | shouln't be upU and procU be swapped? |
| 11:54 | visof_ | ah hyeah |
| 11:54 | visof_ | (reduce (fn [x y] (processU (updateU x y)) (process f) (drop 1 l)) ? |
| 11:57 | oddcully | and x y swapped? |
| 13:27 | python476 | hi again |
| 13:28 | noncom | python476: hi |
| 13:28 | python476 | let'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:29 | noncom | you mean your class isn't jarred? |
| 13:29 | python476 | yeah, it's in the same folder, vanilla .class |
| 13:30 | noncom | python476: 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:30 | python476 | noncom: aight, gonna check this |
| 13:30 | noncom | you 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:30 | noncom | then you can know the right location |
| 13:31 | noncom | python476: remember to keep a copy of the original class file, because the "target" and "bin" dirs can be wiped easily |
| 13:33 | justin_smith | noncom: 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:33 | python476 | product -> project ? |
| 13:33 | noncom | will it be able to pick it up from a resource path? |
| 13:33 | justin_smith | python476: yes, sorry |
| 13:34 | justin_smith | noncom: yes, resource-paths is just another classpath entry, it's all the same to the vm |
| 13:34 | python476 | no worries, just avoiding misinterpretations |
| 13:34 | justin_smith | *just another set of classpaht entries |
| 13:37 | python476 | so if I put .class files into <project-root>/foo and declare foo in resource-paths (import foo.XXX) should work ? |
| 13:38 | justin_smith | python476: well, the relative path to the class file needs to match the package of the class |
| 13:38 | justin_smith | but yes, something like this |
| 13:38 | python476 | ok |
| 13:39 | justin_smith | but really, the project that creates that class file should be creating a jar, it makes things a lot simpler |
| 13:43 | python476 | justin_smith: maybe I wasn't clear, I wrote the java source. |
| 13:43 | python476 | it's not a dangling .class |
| 13:45 | noncom | python476: then you can even include the source into the clojure project if it belongs there |
| 13:46 | python476 | yes, I have the .java next to the .clj files in src/java-net/ |
| 13:46 | python476 | and naively thought (import 'java-net.<class>) would do |
| 13:46 | noncom | python476: have them in a separate folder, like java-src/your-package |
| 13:47 | noncom | python476: and add :java-source-paths ["java-src"] to your project clj |
| 13:47 | python476 | ok |
| 13:47 | noncom | this will make lein consider your sources |
| 13:47 | python476 | great, thanks |
| 13:49 | python476 | noncom: worked. |
| 13:50 | noncom | python476: 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:50 | python476 | good points |
| 13:51 | python476 | so far I'm happy to know that I can implement stuff in Java easily in case clojure performance is not enough |
| 13:51 | noncom | python476: oh i use this a lot sometimes, esp when doing 3d graphics |
| 13:52 | noncom | interop is so light and pleasant |
| 13:52 | python476 | your work asks for CGI ? |
| 13:52 | noncom | python476: 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:53 | noncom | i love media programming |
| 13:53 | noncom | and other programming too :O) |
| 13:53 | python476 | I'm `love` geometry related programming |
| 13:53 | python476 | -'m |
| 13:53 | python476 | got into programming after using packages like Maya and Houdini |
| 13:53 | noncom | oh, so yeah. i used java a lot in places where i had to generate/compute vertex buffers or pixels, for example |
| 13:54 | noncom | so youre doing graphics too, cool! |
| 13:54 | python476 | oh no, I just toyed with them in early 2Ks |
| 13:54 | python476 | just completely obsessed with anything related to graphics and math |
| 13:54 | python476 | even though a lot of lisp on my mind too, since they were involved with the ancestor of Mirai |
| 13:55 | noncom | oh, so i bet you gotta use much thigns like quil... |
| 13:55 | python476 | never heard of that |
| 13:56 | noncom | i love graphics & math too. been doing video mapping on psychedelics music parties. involves much of that. |
| 13:56 | python476 | oh clojure animation package |
| 13:56 | noncom | https://github.com/quil/quil |
| 13:56 | noncom | it's acrually Processing in disguise |
| 13:56 | python476 | yeah, just saw that |
| 13:57 | noncom | this https://libgdx.badlogicgames.com/ and this http://jmonkeyengine.org/ allows for much fun with 3d, graphics and stuff |
| 13:59 | python476 | ha.. bring back some memories |
| 13:59 | python476 | barely related, but I did a nurbs things using jogl back in the days |
| 13:59 | python476 | things were so crude |
| 13:59 | noncom | yeah :) now they are there, smoother :) |
| 14:00 | noncom | python476: for inspiration with quil/processing http://openprocessing.org/ |
| 14:00 | python476 | jmonkey is appealing |
| 14:00 | python476 | but nowadays I'm lazy, let's wait for a clojurescript equivalent :D |
| 14:00 | noncom | hah :) |
| 14:01 | noncom | will take long ltime sinnce web gl is far weaker |
| 14:01 | noncom | processing/quil can do web/cljs tough |
| 14:01 | noncom | *though |
| 14:01 | python476 | cool |
| 14:01 | python476 | gonna eat, bbl |
| 14:02 | noncom | python476: sure i gotta go too |
| 14:02 | noncom | good luck |
| 14:02 | python476 | thx |
| 14:07 | noncom | python476: btw looks like http://openprocessing.org/ already moved all their examples to webgl, so it's all web now! |
| 14:28 | Pupeno | How can I run another lein task, lein deps, when running lein uberjar? |
| 14:29 | oddcully | Pupeno: e.g. lein do clean, figwheel dev test |
| 14:31 | Pupeno | oddcully: mh? Sorry, I don't get it. |
| 14:32 | oddcully | Pupeno: lein do task1, task2, task3 withparam |
| 14:32 | Pupeno | I'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:33 | codefinger | Pupeno: you need to run lein deps are boot time? or build time? |
| 14:33 | codefinger | oh, reading back. i see... |
| 14:33 | Pupeno | At build time. |
| 14:34 | codefinger | Pupeno: you can set LEIN_BUILD_TASK config var. so `heroku config:set LEIN_BUILD_TASK='deps uberjar'` would that work? |
| 14:35 | Pupeno | codefinger: 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:36 | Pupeno | codefinger: thank you though, I'd look into that. |
| 14:36 | Pupeno | I'll look into that. |
| 14:36 | codefinger | i think you can do that with a profile, like here https://github.com/heroku/heroku-buildpack-clojure#uberjar |
| 15:01 | justin_smith | wait, when would uberjar ever not implicitly run the deps task? |
| 15:02 | oddcully | ¯\(°_o)/¯ |
| 16:07 | python476 | not much action on #clojure, is it always like this ? |
| 16:08 | justin_smith | python476: nope, I'm usually very active here but hammering on a deadline http://i.imgur.com/Eca8nsE.gif |
| 16:09 | python476 | stop ! |
| 16:09 | python476 | hammer time. |
| 16:09 | oddcully | python476: i thought there is some us holiday, because it's extremly silent today |
| 16:10 | justin_smith | it's the very important holiday "last full week in September, and there's a deadline coming" |
| 16:11 | python476 | right |
| 16:12 | oddcully | or they all off to slack |
| 16:19 | codefinger | i don't get slack. irc is enough for me :) |
| 16:19 | ane | what new things are coming in 1.8? |
| 16:20 | Bronsa | ane 1.8 is mostly a bugfix release |
| 16:20 | Bronsa | ane https://github.com/clojure/clojure/blob/master/changes.md |
| 16:21 | xemdetia | you can't even use slack over telnet :( |
| 16:22 | Bronsa | there's a slack irc gateway |
| 16:23 | oddcully | Bronsa: having to register and beg for entry is enough for me to ignore it |
| 16:35 | elvis4526 | Is 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:36 | hiredman | that is not what happens |
| 16:36 | mungojelly | elvis4526: i think def is evaluated every time, it's defonce that won't reevaluate |
| 16:37 | oddcully | ,(macroexpand '(defn x [])) |
| 16:37 | clojurebot | (def x (clojure.core/fn ([]))) |
| 16:38 | hiredman | each function application is evaluated as the function running with a fresh set of arguments, but the function is not evaluated again |
| 16:38 | mungojelly | elvis4526: but you shouldn't need to define things more than once, that's probably not the tool you need |
| 16:40 | justin_smith | elvis4526: when you talk about evaluating each time it's run, do you mean you want a function with no arguments? |
| 16:40 | justin_smith | because you can totally do that |
| 16:40 | justin_smith | elvis4526: 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:41 | elvis4526 | Okay, 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:41 | Bronsa | uff, Var is final, that's no fun :( |
| 16:41 | hiredman | the value of @atom is from the point in time it is run |
| 16:42 | justin_smith | elvis4526: that's true, and you need to write it differently if you want the atom lookup on function call |
| 16:42 | hiredman | which 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:43 | elvis4526 | Okay I see, that's what I mostly figured |
| 16:44 | hiredman | the behavior is the same for any kind of mutable thing |
| 16:45 | hiredman | (def a (atom 0)) (def x (+ @a 5)) (reset! a 1) x |
| 16:51 | justin_smith | elvis4526: 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:13 | Balveda-3 | If I'm doing something like (GET "/user/:id" [id] (user-info id)), how can I pass along the request as well? |
| 17:14 | hiredman | https://github.com/weavejester/compojure/wiki/Destructuring-Syntax |
| 17:14 | Balveda-3 | ah, great, thanks! |
| 17:16 | Balveda-3 | (inc hiredman) |
| 17:16 | Balveda-3 | huh, it was taken down? |
| 17:17 | oddcully | lazybot is on vacation |
| 17:39 | cmarques | clojurescript/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:43 | mungojelly | cmarques: i've never used that so idk but maybe its window context needs a hint to redraw it? |
| 17:44 | cmarques | mungojelly the way it's supposed to work is that the atom's value is bound to what the component displays |
| 17:46 | mungojelly | i 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:47 | oddcully | i 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:49 | cmarques | oddcully 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:50 | oddcully | that's my point or my question if you like. the "redraw" might depend on a change to card |
| 17:52 | mungojelly | i think maybe you need to have the state you want it to watch in a reagent atom |
| 17:52 | cmarques | oddcully not really, it would depend on a change on the atom's value. |
| 17:52 | cmarques | mungojelly yes, delete-state is a reagent atom, it's just not in the gist |
| 17:53 | oddcully | is this what you wish for or what you know, that happens |
| 17:53 | oddcully | ? |
| 17:54 | cmarques | oddcully I believe it's both |
| 17:54 | oddcully | believing is not knowing ;) |
| 17:54 | neoncontrails | cmarques: I'm glad you're asking about this, because I was about to ask a very similar question right before I noticed yours |
| 17:55 | oddcully | but i don't want to add more confusion to this |
| 17:55 | cmarques | oddcully sorry, but if I knew for sure I would not be asking for help here :-) |
| 18:00 | cmarques | neoncontrails This version does what I want: https://gist.github.com/cassiomarques/b799692d292b4a6d95cc |
| 18:01 | cmarques | Thanks for your help oddcully and mungojelly |
| 18:02 | cmarques | moving 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:06 | mungojelly | cmarques: oh ok well thanks for teaching me about reagent. is it fun should i try it? :) |
| 18:08 | cmarques | mungojelly yeah, I'm having lots of fun |
| 18:09 | sritchie | hey 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:10 | sritchie | in the js it’s just the name of a class that extends React.Component |
| 18:10 | sritchie | dnolen: not sure what I need to pass to this “component” field in the options map - the result of om/build, |
| 18:10 | sritchie | tried that, died with an error saying the component needed type “function” and had type “object" |
| 18:27 | python476 | 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:45 | neoncontrails | I 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:45 | neoncontrails | http://pastebin.com/s9PaL45t |
| 18:46 | sritchie | mfikes: hey man, qq about ambly + react native if you’re around |
| 18:47 | sritchie | mfikes: 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:47 | sritchie | which 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:47 | clojurebot | flatten 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:49 | turbofail | you 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:50 | turbofail | for does that. (for [sheet sheets row sheet cell row] (blah cell)) |
| 18:50 | {blake} | turbofail: Oh...yeah, that makes sense. =P |
| 18:50 | turbofail | (it's a little easier to read with line breaks) |
| 18:50 | {blake} | Just had that same...fail...with doseq. |
| 18:51 | cmarques | neoncontrails I believe you can use the :on-change event to update the value of the atom. |
| 18:56 | cmarques | neoncontrails something like this usually works for me https://gist.github.com/cassiomarques/2c31a2341d4a017c2a90 |
| 18:58 | neoncontrails | cmarques: Thanks, I'll try inserting this and see what happens |
| 19:00 | mfikes | sritchie: Hmm. I've not yet built anything with React Native that causes that. |
| 19:01 | sritchie | mfikes: looks like something about initiating React’s view with the bridge |
| 19:01 | sritchie | the other demos I’ve tried using JS pass the assertion on the first clause |
| 19:02 | dnolen | sritchie: hrm I really don't know |
| 19:02 | sritchie | mfikes: 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:02 | sritchie | dnolen: I think (.-type (om/build my-component-fn {})) might do it |
| 19:04 | sritchie | mfikes: do you have some nice way of dealing with “socket closed” issues at the terminal? |
| 19:08 | hlolli` | ,(defn debug [sometext] (prn sometext)) |
| 19:08 | clojurebot | #'sandbox/debug |
| 19:08 | hlolli` | ,(def quoted-func `(debug "debugtext")) |
| 19:08 | clojurebot | #'sandbox/quoted-func |
| 19:08 | hlolli` | ,(quoted-func) |
| 19:08 | clojurebot | #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:09 | hlolli` | How can I call a quoted function like that? Is it possible? |
| 19:14 | xeqi | ,(let [[f & args] quoted-func] (apply (resolve f) args)) |
| 19:14 | clojurebot | "debugtext"\n |
| 19:16 | turbofail | it's eitherwhat xeqi did, or use `eval' |
| 19:16 | hlolli` | ok nice, thanks alot! Eval, ok silly I didnt try that. |
| 19:17 | turbofail | that said, there's usually better ways to get a similar effect |
| 19:17 | hlolli` | btw, since Im new to irc, what does the ` symbol of my name hlolli mean? I thought for I while I was muted. |
| 19:18 | turbofail | your client probably appended that to your existing nick because you got disconnected, but the server hadn't timed you out yet |
| 19:18 | turbofail | and so you couldn't use your existing nick |
| 19:18 | hlolli` | ah ok, I see |
| 19:31 | hlolli` | 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:32 | hlolli` | ,(defn debug [sometext] (prn sometext)) |
| 19:32 | clojurebot | #'sandbox/debug |
| 19:34 | hlolli` | ,(defn quoted-func [] `(debug "debugtext")) |
| 19:34 | clojurebot | #'sandbox/quoted-func |
| 19:34 | hlolli` | ,(let [please-be-immuteable (debug-func)] please-be-immuteable) |
| 19:34 | clojurebot | #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:35 | hlolli` | ,(let [please-be-immuteable (quoted-func)] (prn please-be-immuteable)) |
| 19:35 | clojurebot | (sandbox/debug "debugtext")\n |
| 19:36 | hlolli` | well damn, this is actually not my case... |
| 19:36 | hlolli` | (def debug-atom (atom {:val `(debug "debugtext")})) |
| 19:37 | turbofail | so, what are you trying to preserve again? |
| 19:37 | hlolli` | ,(let [please-be-immuteable (:val @debug-atom)] (prn |
| 19:37 | hlolli` | please-be-immuteable)) |
| 19:37 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 19:38 | hlolli` | the quted symbol to a function with its arguments, that is a variable. |
| 19:38 | hlolli` | I want to fetch the function call from a atom that is muteable, but keep the value despite the atom mutating. |
| 19:38 | turbofail | ah |
| 19:39 | turbofail | well you don't want a quoted form then, you want let |
| 19:39 | turbofail | (let [debug @debug] (fn [foo] (debug foo))) |
| 19:41 | hlolli` | 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:28 | Trioxin | I just coded a clojure program that can become a super intelligence om its own given enough time governed by computational power. |
| 22:28 | Trioxin | on* |
| 22:29 | Trioxin | I call it.. GOD |
| 22:31 | Trioxin | srsly though you could code such a thing. just not enough CPU for it to be useful |
| 22:31 | stevenleeg | hey, does anyone have a hot second to help me out with getting started on unit tests with a project? |
| 22:31 | stevenleeg | I keep getting nasty namespace errors |
| 22:31 | stevenleeg | and I'm pretty sure it's a simple thing |
| 22:31 | justin_smith | stevenleeg: just ask the question, I'm sure the answer will be simple |
| 22:32 | stevenleeg | okay 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:32 | stevenleeg | which has (ns wiki.test.parser (:use clojure.test wiki.parser)) at the top |
| 22:32 | stevenleeg | and I keep getting Caused by: java.io.FileNotFoundException: Could not locate wiki/test/parser__init.class or wiki/test/parser.clj on classpath: |
| 22:33 | stevenleeg | when running lein test |
| 22:33 | justin_smith | stevenleeg: the namespace name should match the file name |
| 22:33 | justin_smith | so if the file is parser_test the ns should end in parser-test |
| 22:33 | stevenleeg | justin_smith: so it should be (ns wiki.test.parser_test ? |
| 22:33 | stevenleeg | ohhh |
| 22:33 | stevenleeg | parser-test |
| 22:33 | justin_smith | no, _ becomes - |
| 22:33 | justin_smith | right |
| 22:34 | stevenleeg | hmm same thing |
| 22:34 | stevenleeg | Caused by: java.io.FileNotFoundException: Could not locate wiki/test/parser_test__init.class or wiki/test/parser_test.clj on classpath: |
| 22:34 | stevenleeg | (ns wiki.test.parser-test |
| 22:34 | stevenleeg | even though wiki/test/parser_text.clj exists |
| 22:34 | stevenleeg | er test* |
| 22:34 | stevenleeg | oh wait |
| 22:34 | stevenleeg | sorry |
| 22:34 | stevenleeg | it's test/wiki/parser_test.clj |
| 22:34 | justin_smith | stevenleeg: if it has test in the ns name, it should be in a folder following that |
| 22:35 | justin_smith | so if it isn't in test/wiki/test/ |
| 22:35 | justin_smith | then take .test out of the ns name |
| 22:35 | stevenleeg | hmm, i thought test/wiki/parser_test.clj was the place to put it |
| 22:35 | justin_smith | stevenleeg: doesn't really matter! |
| 22:35 | stevenleeg | (I copied SQL Korma) |
| 22:35 | stevenleeg | ah okay |
| 22:35 | justin_smith | the thing that matters is that the path to the file must match the full namespace |
| 22:36 | stevenleeg | when I run lein test how does it know where to look though? |
| 22:36 | stevenleeg | right, okay |
| 22:36 | stevenleeg | that makes sense |
| 22:36 | justin_smith | lein test does a file search, then runs require based on what it finds |
| 22:36 | justin_smith | so the require doesn't find an ns that matches the file it found |
| 22:36 | stevenleeg | oohhh |
| 22:37 | stevenleeg | okay lemme read the docs on lein test, I think that'll help |
| 22:37 | stevenleeg | justin_smith: is it good practice to have something like src/wiki/test/parser_test.clj which matches up with src/wiki/parser.clj? |
| 22:37 | justin_smith | not much to read - it does a search, finds files under test/ then turns every file path into a namespace to require |
| 22:38 | stevenleeg | oh hm okay |
| 22:38 | justin_smith | stevenleeg: use a separate test directory, just make namespaces that match the file paths |
| 22:39 | stevenleeg | erg yeah |
| 22:39 | stevenleeg | okay so I switched it to (ns test.wiki.parser-test |
| 22:39 | stevenleeg | matches up with the filepath |
| 22:39 | stevenleeg | but Exception in thread "main" java.io.FileNotFoundException: Could not locate test/wiki/parser_test__init.class or test/wiki/parser_test.clj |
| 22:39 | justin_smith | stevenleeg: the leading test/ is not part of its path |
| 22:40 | stevenleeg | yesss!!!!! |
| 22:40 | stevenleeg | got it |
| 22:40 | stevenleeg | (++ justin_smith) |
| 22:40 | justin_smith | sorry, I should have been more explicit - test is on your classpath, the files path relative to the classpath must match the ns |
| 22:40 | stevenleeg | yeah that makes sense |
| 22:40 | justin_smith | so yeah, it was fairly straightforward as you guessed |
| 22:40 | stevenleeg | thanks for sticking with me there haha |
| 22:44 | Trioxin | has 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:46 | justin_smith | I doubt there is a dedicated lib, seems like you could do it with core.matrix though |
| 22:50 | sotojuan | Hello |
| 23:07 | stevenleeg | okay another probably easy question: any idea why (require 'wiki.parser-test :reload-all) wouldn't be working? |
| 23:08 | stevenleeg | when I run (run-tests 'wiki.parser-test) after modifying the file nothing is changed |
| 23:08 | justin_smith | did you rename a test? |
| 23:08 | justin_smith | because if you did, the old name still exists in that ns |
| 23:09 | stevenleeg | ah yeah |
| 23:09 | stevenleeg | I actually commented out a test |
| 23:09 | stevenleeg | and it was still running |
| 23:09 | stevenleeg | I was wondering if that were the case |
| 23:09 | justin_smith | right, because the namespace doesn't get destroyed with a reload |
| 23:09 | justin_smith | but you can destroy a namespace explicitly if needed |
| 23:09 | stevenleeg | okay sweet, that makes sense |
| 23:10 | stevenleeg | how can I do that? |
| 23:10 | justin_smith | ,(apropos "destroy") |
| 23:10 | clojurebot | () |
| 23:10 | justin_smith | I always forget the name |
| 23:10 | justin_smith | ,(apropos "purge") |
| 23:10 | clojurebot | () |
| 23:10 | justin_smith | ,(find-doc "destroy") |
| 23:10 | clojurebot | nil |
| 23:10 | justin_smith | hrmph |
| 23:11 | justin_smith | one moment |
| 23:11 | justin_smith | ,(apropos "remove") |
| 23:11 | clojurebot | (clojure.core/remove clojure.core/remove-all-methods clojure.core/remove-method clojure.core/remove-ns clojure.core/remove-watch) |
| 23:11 | justin_smith | ,(doc remove-ns) |
| 23:11 | clojurebot | "([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace." |
| 23:11 | justin_smith | that's the one! |
| 23:12 | stevenleeg | oh nice |
| 23:12 | stevenleeg | so (remove-ns 'wiki.test-parser) |
| 23:12 | justin_smith | that should do it, yea |
| 23:12 | stevenleeg | awesome |
| 23:12 | stevenleeg | thanks again justin_smith! |
| 23:12 | stevenleeg | you're saving me tonight haha |
| 23:13 | justin_smith | heh |