2016-05-21
| 00:41 | tolstoy | ,(map type (map quote [1 2 *])) |
| 00:41 | clojurebot | #error {\n :cause "Unable to resolve symbol: quote in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: quote in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: quote in this... |
| 00:42 | tolstoy | ,(map type (map #(quote %) [1 2 *])) |
| 00:42 | clojurebot | (clojure.lang.Symbol clojure.lang.Symbol clojure.lang.Symbol) |
| 03:20 | DoubleMan | Freeware Videogame for windows http://www.indiedb.com/games/unlimited-runner/downloads/unlimited-runner-v10 |
| 03:22 | dysfun | ,(map type '[1 2 *]) |
| 03:22 | clojurebot | (java.lang.Long java.lang.Long clojure.lang.Symbol) |
| 03:22 | dysfun | tolstoy: ^^ |
| 03:22 | tolstoy | Eh? |
| 03:23 | dysfun | i admit i was confused for a moment by the output of yours til i ran it through in my head |
| 03:23 | tolstoy | I was just wondering if quoting a vector quoted each element of the vector. |
| 03:24 | tolstoy | ,(+ '1 '2) |
| 03:24 | dysfun | yes, but it won't change the type of it if you do it like i did |
| 03:24 | clojurebot | 3 |
| 03:25 | tolstoy | Right. My attempt was to see what _would_ change the type of it. |
| 03:25 | DoubleMan | Freeware Videogame for windows http://www.indiedb.com/games/unlimited-runner/downloads/unlimited-runner-v10 |
| 03:25 | dysfun | (map type '['1 2]) |
| 03:25 | dysfun | ,(map type '['1 2]) |
| 03:25 | clojurebot | (clojure.lang.PersistentList java.lang.Long) |
| 03:25 | dysfun | wut? |
| 03:26 | tolstoy | Huh. |
| 03:26 | dysfun | i don't even... |
| 03:26 | dysfun | ,(type '1) |
| 03:26 | clojurebot | java.lang.Long |
| 03:27 | dysfun | (type (first '['1])) |
| 03:27 | dysfun | ,(type (first '['1])) |
| 03:27 | clojurebot | clojure.lang.PersistentList |
| 03:28 | tolstoy | Maybe it expands '1 to (quote 1) then quotes that, so it's a list? |
| 03:29 | dysfun | ,'['1] |
| 03:29 | clojurebot | [(quote 1)] |
| 03:29 | tolstoy | ,(type '(quote 1)) |
| 03:29 | clojurebot | clojure.lang.PersistentList |
| 03:39 | TEttinger | wowza. wowza. bo-bowza. I need to test Clojure and Lein with this, but I'm getting what appear to be much better startup times using a subset of the modular JRE from JDK 9 |
| 03:39 | TEttinger | http://zulu.org/zulu-9-pre-release-downloads/ |
| 03:39 | dysfun | sweet :) |
| 03:40 | TEttinger | not quite instant with a GUI app, but much better than Zulu 8, which is basically the same as Oracle Java 8 |
| 03:40 | dysfun | the gui stuff is huge |
| 03:40 | TEttinger | I have a compact1 profile that's 20 MB |
| 03:40 | TEttinger | maybe 30, not sure |
| 03:40 | TEttinger | 30 |
| 03:42 | dysfun | i know some people who deploy a compact1 to production |
| 03:42 | dysfun | as an 'agent' process |
| 03:45 | tolstoy | What does that modular stuff mean? A smaller set of classes such that it doesn't take as long to find the one you want to load? |
| 03:46 | TEttinger | I know only that it allows you to make smaller JREs for distribution, which is very relevant on Mac's App Store |
| 03:46 | dysfun | essentially there are three compact build profiles. each one has progressively more of the stdlib included |
| 03:46 | TEttinger | I think it also helps with speed, though I didn't expect it to |
| 03:46 | TEttinger | oh no |
| 03:46 | TEttinger | not that dysfun |
| 03:47 | TEttinger | that's the "baby's first project jigsaw" that they were making for JDK 8 |
| 03:47 | dysfun | and as i recall, a compact profile has fewer problems with distribution rights |
| 03:48 | tolstoy | Why would fewer classes make things faster? |
| 03:48 | TEttinger | compact3 doesn't have AWT or Swing, for example. I just successfully used a module for desktop and base only, I made it with this command |
| 03:48 | TEttinger | bin\jlink.exe --exclude-files=*.diz --vm=server --modulepath jmods/ --addmods java.desktop --output ../desktop/ |
| 03:48 | TEttinger | (windows) |
| 03:48 | dysfun | well they've since expanded the build profiles so it's not just libraries but configuration |
| 03:48 | dysfun | i don't know how far down the rabbit hole they've gone though |
| 03:48 | TEttinger | java.desktop actually has less than compact1 by default, you can easily add compact1 in it |
| 03:49 | TEttinger | not sure what the difference is between base and compact1 |
| 03:53 | TEttinger | oh nice. "bin\java -jar leiningen-2.6.1-standalone.jar" starts up in under a second, and this computer has a rather worn-out HDD |
| 03:53 | TEttinger | that's with a compact3 JRE |
| 03:54 | tolstoy | Do you need a JDK with lein to compile stuff? |
| 03:54 | TEttinger | not sure! |
| 03:54 | TEttinger | javac isn't in this... or is it... |
| 03:55 | TEttinger | Ilikethisanother.gif |
| 04:07 | TEttinger | so in lein, how would I print the classpath? |
| 04:07 | dysfun | lein cp |
| 04:17 | TEttinger | damn... `lein` gives a huge stacktrace. Caused by: java.lang.ClassNotFoundException: sun.misc.Launcher |
| 04:19 | TEttinger | sun.misc should be present... |
| 04:34 | TEttinger | it seems it's present but no longer public on Java 9 |
| 04:38 | dysfun | yay! |
| 08:06 | dimon_ | after I compile my app with "lein uberjar", I get 2 files my_app.jar and my_app.1-0.1.0-SNAPSHOT.jar |
| 08:06 | dimon_ | what's the difference between them? |
| 08:06 | dimon_ | which one should I deploy to a server? |
| 08:07 | dimon_ | my_app.jar is 8 times smaller |
| 08:10 | Empperi | dimon_: uberjar |
| 08:10 | Empperi | the larger one |
| 08:11 | Empperi | the difference is the larger one has all it's dependencies included |
| 08:11 | dimon_ | I see, thx. |
| 08:11 | Empperi | the smaller one has none, you'd have to include those as separate jar packages and include them via classpath in order to execute your application |
| 08:12 | Empperi | might make sense if you'd have tons of applications running in the same server which used the exact same dependencies |
| 08:12 | Empperi | *might* |
| 08:12 | Empperi | you could end up in trouble when updating one of the apps and bumping dependencies for that - then all of your apps would get the dependencies udpated too (after reboot) |
| 11:16 | Furrane | hello |
| 13:23 | msenol | hi guys |
| 13:23 | msenol | can someone help me to call this code in clojure REPL? |
| 13:23 | msenol | http://stackoverflow.com/a/20517459/2760951 |
| 13:24 | msenol | I am new to clojure, I don't know much about java interop |
| 13:25 | ridcully_ | something along: (.browse (Desktop/getDesktop) (.toURI thefile)) |
| 13:25 | msenol | ok thx ridcully_ |
| 13:26 | dysfun | and (File. my-uri) |
| 13:26 | msenol | ok one more question |
| 13:26 | msenol | how can I import Desktop in REPL? |
| 13:27 | dysfun | do you know the full class name? |
| 13:27 | dysfun | (import '[foo.bar.ns Desktop]) |
| 13:27 | msenol | java documentation says full class name |
| 13:27 | msenol | java.awt.Desktop |
| 13:28 | dysfun | (import '[java.awt Desktop]) |
| 13:28 | msenol | wow it is working. thx a lot dysfun |
| 13:28 | dysfun | np :) |
| 14:21 | Gh0stInTheShell | So I have this program here: http://pastebin.com/5DCMjmbP |
| 14:22 | Gh0stInTheShell | I made it myself and it's not very good. The algorithm for finding pi is optimized but intentionally horrible. |
| 14:22 | Gh0stInTheShell | and when I run it on the jvm it pauses noticably for depth values of 5000 |
| 14:23 | Gh0stInTheShell | but when I run it with a depth of 50 million on clojurescript it takes 300 msecs |
| 14:24 | Gh0stInTheShell | Hello ClojureScript! |
| 14:24 | Gh0stInTheShell | core.cljs:150 "Elapsed time: 301.400000 msecs" |
| 14:24 | Gh0stInTheShell | core.cljs:150 3.1415926735902504 |
| 14:24 | Gh0stInTheShell | And so that is blowing my mind a little bit. |
| 14:25 | dysfun | try running it with reflection warnings enabled and see if you get any enlightening messages |
| 14:25 | dysfun | if not, it's going to take a while to analyse and figure out what's supoptimal |
| 14:26 | Gh0stInTheShell | dysfun: For the JVM? |
| 14:26 | dysfun | yes |
| 14:27 | Gh0stInTheShell | OKay will check that out |
| 14:27 | Gh0stInTheShell | The algorithm is bad on purpose, didn't expect cljs to handle it either |
| 14:27 | Gh0stInTheShell | cljs is so fast it fixes bad *algorithms* ;) |
| 14:28 | dysfun | i expect when you run with reflection warnings you will see what it is so much slower |
| 14:28 | Gh0stInTheShell | okay checking it out |
| 14:28 | dysfun | cljs will not have to pay those penalties |
| 14:28 | ridcully_ | JS only has one number format. java many. as dysfun suggested, you might have to dig deeper into what is happening behind the scenes |
| 14:29 | Gh0stInTheShell | But, I mean, my function is written as pure Lispy as I could make it, had to use recur. It frightens me to have to worry about all this Java stuff ;) |
| 14:30 | dysfun | clojure had to make a few compromises to sit on top of the jvm |
| 14:30 | Gh0stInTheShell | I'm exploring and I thank you all for your direction and will look into what slows it down on the JVM. |
| 14:30 | Gh0stInTheShell | :) |
| 14:30 | dysfun | things getting unneccesarily boxed by default was an important one |
| 14:31 | dysfun | reflection was another. the java compiler will never generate a reflection lookup unless you manually write the code for it |
| 14:31 | dysfun | but we wanted to have a nice dynamic language where things just work |
| 14:31 | dysfun | and the cost of that is that occasionally they don't and it's a pain in the arse figuring out why |
| 14:32 | Gh0stInTheShell | Well, you have that (a nice dynamic language where things just work). I <3 Clojure. It is one of my 5 pillars of world domination. |
| 14:33 | Gh0stInTheShell | Now if I could just learn the stuff. :) |
| 14:33 | dysfun | there are much better resources these days than when i learned clojure |
| 14:33 | dysfun | where are you learning from? |
| 14:33 | Gh0stInTheShell | dysfun: My mind. The docs |
| 14:34 | Gh0stInTheShell | dysfun: Talks at Clojure West and Clojure Conj and Strange Loop |
| 14:34 | dysfun | the docs aren't really of the quality we'd like them to be yet |
| 14:34 | Gh0stInTheShell | dysfun: on youtube mostly but sometimes in person |
| 14:34 | Gh0stInTheShell | dysfun: They're okay :) |
| 14:34 | dysfun | i find some of those talks great for e.g. trying to understand what a single library is about |
| 14:34 | dysfun | but i don't know about learning clojure from them |
| 14:35 | Gh0stInTheShell | Or making robots fly around in my unicorn editor! |
| 14:35 | dysfun | you could read some code :) here's some of mine https://github.com/irresponsible/ |
| 14:35 | Gh0stInTheShell | Well I know lisp and scala and java and stuff, clojure seems to be coming pretty naturally |
| 14:35 | Gh0stInTheShell | I read code |
| 14:35 | Gh0stInTheShell | to help |
| 14:37 | Gh0stInTheShell | BUt I really might just be becoming a cljs programmer because I like the speed of javascript but hate the language itself. And I know how lots of people feel about that in this channel and I'm okay with that and unwilling to abandon a possible way for me to stop writing java for work also. |
| 14:37 | Gh0stInTheShell | The trouble with the java I write for work is it's all for Dalvik/ART |
| 14:37 | Gh0stInTheShell | But Clojure proper still might bail me out. ;) |
| 14:38 | vermiculus | hi all :) question: what's the convention in clojure for testing your test suite? |
| 14:38 | dysfun | if you have to use the jvm, clojure is absolutely my favourite tool |
| 14:38 | ben_vulpes | vermiculus: testing your test suite? |
| 14:38 | dysfun | vermiculus: do you mean "running your tests"? |
| 14:38 | vermiculus | dysfun: nope… |
| 14:38 | vermiculus | i.e. I have a few small functions that I use in my tests to make them readable |
| 14:39 | vermiculus | ideally, I need to be able to test that they work |
| 14:39 | dysfun | oh. just write the tests afterwards |
| 14:39 | ben_vulpes | stick them in test/project/test_util.clj |
| 14:39 | ben_vulpes | then write test/project/test_test_util.clj |
| 14:39 | ben_vulpes | ... (:require test-util)) (deftest test-my-util-fn ...) |
| 14:39 | tolstoy | If the test-utils are used in lots of tests, isn't that good enough? |
| 14:39 | dysfun | yes yes, very silly |
| 14:39 | vermiculus | ben_vulpes: yeah, I was thinking something along those lines |
| 14:39 | Gh0stInTheShell | but who tests the tests fot the tests? |
| 14:40 | Gh0stInTheShell | s/fot/for |
| 14:40 | vermiculus | Gh0stInTheShell: good point; we must go deeper! |
| 14:40 | ben_vulpes | "my tests are the integration tests for my test utilities" |
| 14:40 | Gh0stInTheShell | (inc vermiculus) |
| 14:40 | dysfun | i see all of these crap jokes i've heard a million times and they make me feel old |
| 14:40 | vermiculus | dysfun: they never get any less funny for me :) |
| 14:40 | Gh0stInTheShell | dysfun: If you've heard them a million times you are old |
| 14:40 | dysfun | i'm not even old. |
| 14:41 | Gh0stInTheShell | :) |
| 14:41 | vermiculus | ,(/ (* 3 1000000) 60 60 24 7 364.24) |
| 14:41 | clojurebot | 0.013618266693162365 |
| 14:41 | tolstoy | I kinda lean towards tbaldridge's stance: test the interfaces of the large-grained concerns. |
| 14:41 | Gh0stInTheShell | They never get old for me either. Especially if they're about recursion or self-referentiality. Or Unix/Linux. :) |
| 14:42 | vermiculus | technically, dysfun doesn't have to be more than a year old. |
| 14:42 | dysfun | i heard a particle physicist joke the other day. it was even worse |
| 14:42 | vermiculus | dysfun: ooh, do tell :) |
| 14:42 | dysfun | a higgs boson went to church but was stopped at the door by the minister. "i'm sorry, but you can't visit mass" "but i am the creator of all mass!" |
| 14:43 | vermiculus | o |
| 14:43 | vermiculus | that's bad |
| 14:43 | dysfun | yes, it is very bad |
| 14:43 | vermiculus | XD |
| 14:43 | tolstoy | Maybe remove the punchline and it's slightly better? |
| 14:43 | dysfun | i was waiting for the punchline for a few seconds before i realised it wasn't coming |
| 14:44 | dysfun | or "cat-ions are puss-itive" is pretty bad too |
| 14:45 | Gh0stInTheShell | lol |
| 14:45 | dysfun | no. that was many things but it was not lol |
| 14:45 | Gh0stInTheShell | lmao |
| 14:46 | Gh0stInTheShell | literally about to fall out of the chair |
| 14:46 | ben_vulpes | where do you find the answers for your chem homework? |
| 14:46 | ben_vulpes | in the solute-ions manual |
| 14:49 | TimMc | Though... testing the tests sometimes does reveal scary things. |
| 14:49 | vermiculus | TimMc: how so? |
| 14:49 | TimMc | *cough*midje*cough* |
| 14:49 | dysfun | actually, rewriting midje tests in clojure.test has put me off midje |
| 14:49 | vermiculus | midje? |
| 14:49 | clojurebot | #<RuntimeException java.lang.RuntimeException: Invalid token: :> |
| 14:50 | TimMc | I still like midje, but some of the behavior is a little too unintuitive. |
| 14:50 | dysfun | there were way many more failures than i expected, and i don't mean in my new tests |
| 14:50 | ben_vulpes | TimMc: does midge still do that thing where it runs the tests on compile? |
| 14:50 | TimMc | Yes. |
| 14:50 | ben_vulpes | fuck |
| 14:50 | ben_vulpes | that |
| 14:50 | ben_vulpes | noise |
| 14:51 | TimMc | I feel like it could very easily be switched to not do that. |
| 14:51 | TimMc | dysfun: Midje tests are like (fact ...) at the top level, and that's when they execute their bodies -- unlike clojure.test's deftest, which is defined and then later called. |
| 14:52 | dysfun | yes. why is this a problem? |
| 14:52 | Gh0stInTheShell | ,(double (pi 50)) |
| 14:52 | clojurebot | 3.16119861298705 |
| 14:52 | TimMc | It means, among other things, that you cannot skip a test or run just one very easily. |
| 14:52 | Gh0stInTheShell | ,(double (pi 500)) |
| 14:52 | clojurebot | 3.143588659585787 |
| 14:52 | TimMc | tihnk it also means you cannot load a midje test file for analysis without running the tests. |
| 14:53 | dysfun | clojure static analysis is a joke anyway |
| 14:53 | TimMc | No, I've gotten good use of eastwood, or tools to map the namespaces and var usages. |
| 14:54 | dysfun | hrm. well those won't be needed on your test suite anyway |
| 14:56 | TimMc | Not true. |
| 14:57 | TimMc | Just because you don't use static analysis doesn't mean it's a good idea to make an entire toolset difficult to use. |
| 14:57 | TimMc | We can't always know in advance what we want... |
| 14:57 | dysfun | that is true, but i've tried static analysis of clojure a few times and i've never found it adds a great deal |
| 14:58 | TimMc | I have a tool that, given a git diff, shows me a visual graph of the namespaces involved. |
| 14:59 | TimMc | I use that when I'm reviewing a pull request because it allows me to start with the low-level changes and work my way up. |
| 14:59 | dysfun | tools.namespace can do that and i'd hardly call what it does static analysis |
| 14:59 | TimMc | It involves loading clojure files. |
| 14:59 | TimMc | You're the one that called it static analysis. :-P |
| 14:59 | dysfun | and reading a single form out of them... |
| 14:59 | ben_vulpes | midge + reloaded is an utter misery. |
| 15:00 | TimMc | I'll be expanding the tool to include var dependencies. |
| 15:00 | ben_vulpes | moreover running /all of an ns' tests/ on compile is a similar misery. |
| 15:01 | ben_vulpes | also it's another cutesy test runner, which i'm just sour on in principle. |
| 15:01 | TimMc | no wait |
| 15:02 | TimMc | The thing I'm doing will not involve loading the files, it really is static analysis and this is irrelevant. |
| 15:02 | TimMc | Eh, I don't remember the stuff it actually interferes with. :-) |
| 15:02 | tolstoy | ben_vulpes Where's the fancy DSL that helps spin up servers, throw a ton of concurrent requests against them, and make sure a "real" database is on the other end. |
| 15:02 | ben_vulpes | > spin up servers |
| 15:02 | ben_vulpes | > in muh tests |
| 15:02 | ben_vulpes | > wut |
| 15:03 | TimMc | End-to-end tests. |
| 15:03 | Gh0stInTheShell | ,(time (pi 5000)) |
| 15:03 | clojurebot | #error {\n :cause "Unable to resolve symbol: pi in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: pi in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: pi in this context"... |
| 15:03 | ben_vulpes | tolstoy: fixturing? |
| 15:03 | ben_vulpes | and custom aws integration? |
| 15:04 | ben_vulpes | i honestly have no idea what you're banging on about. |
| 15:04 | tolstoy | ben_vulpes I guess it was my back-handed way of saying that these DSLs look appealing when you're testing purely functional code, but my problems are integration. |
| 15:04 | TimMc | ben_vulpes: I guess what I'd like is a library of stuff like midje has, but done in a more imperative way like clojure.test does. |
| 15:04 | Gh0stInTheShell | ,(time (double (pi 2000))) |
| 15:05 | clojurebot | "Elapsed time: 2399.306607 msecs"\n3.142092403683528 |
| 15:05 | ben_vulpes | i used some 'bdd' thinger once |
| 15:06 | ben_vulpes | abstractions bit me though |
| 15:06 | Gh0stInTheShell | clojurebot is awesome :) |
| 15:06 | ben_vulpes | and i don't actually want to test form submissions |
| 15:06 | TimMc | I hate having to run everything through set and sort and other normalization chains because that makes the tests harder to read -- you have to think "OK, now which part of this is normalization and which part is the test subject?" |
| 15:07 | TimMc | Being able to say (contains [:a :b :c] :in-some-order) is *fantastic* for concision. |
| 15:07 | TimMc | But I'd really be fine with (contains foo [:a :b :c] :in-some-order) -- just make it explicit. |
| 15:08 | dysfun | i wonder if any of the other test frameworks steal any of the good bits from midje for the clojure.test model yet |
| 15:08 | TimMc | Midje: The Good Parts |
| 15:09 | dysfun | so i started trying to port midje to cljs |
| 15:09 | TimMc | dysfun: If you find one, let me know! |
| 15:09 | ridcully_ | are there any more popular ones beside c.t and midje? |
| 15:09 | dysfun | first problem: it depends on a module whose tests are written in midje |
| 15:09 | TimMc | haha |
| 15:09 | dysfun | "ah. yes. i can see that being a problem" -- marick |
| 15:11 | tolstoy | ridcully_ https://github.com/jaycfields/expectations |
| 15:12 | dysfun | i was a bit saddened when i had to drop midje. until i found all those bugs in my midje test suite. that was pretty disturbing |
| 15:15 | dysfun | "simply require expectations and your tests will be run on JVM shutdown, no call to any 'run' function is necessary." |
| 15:15 | dysfun | wut? |
| 15:17 | dysfun | that's even more broken than midje |
| 15:18 | mr-foobar | hi all. what is the difference between clojure channels and a message bus ? I am trying to understand the technical / implementation differences. |
| 15:18 | dysfun | message bus is a very overloaded term |
| 15:19 | dysfun | and by clojure channels, i presume you mean core.async channels |
| 15:19 | mr-foobar | Yes. I am using the term Message Bus from the perspective of topics / publish / subscribe. |
| 15:20 | dysfun | okay, well there is no pubsub mechanism built into channels, but it is possible to build one using channels as the basis for it |
| 15:20 | mr-foobar | core.async seems be the same from the outside chnanels / put / take. |
| 15:20 | dysfun | there are several functions in core.async that could help |
| 15:21 | mr-foobar | I understand the usage part. I just am not able to understand how they are different. |
| 15:21 | dysfun | channels are basically simple queues of messages, conceptually |
| 15:22 | dysfun | well pubsub requires that you publish topics that can be subscribed to |
| 15:22 | ridcully_ | isn't there pub and sub in core.async? |
| 15:23 | dysfun | yes, but not built in to channels |
| 15:23 | mr-foobar | dysfun: ah good point. topics need to be explicit. |
| 15:24 | dysfun | a pubsub system actually performs logic for distribution |
| 15:24 | mr-foobar | they are not values as channels which can be passed around but more like strings. |
| 15:24 | dysfun | a channel is a dumb thing |
| 15:24 | dysfun | it's just a plain queue that you queue data in |
| 15:26 | dysfun | for instance, rabbitmq has you define various queues and then 'exchanges'. depending on which exchange you post to, it will be distributed to zero or more queues |
| 15:26 | dysfun | each queue in rabbitmq is t |
| 15:26 | dysfun | hus a single subscription to a 'topic' |
| 15:27 | dysfun | whereas core.async channels are analogous just to the queue part of my rabbitmq analogy |
| 15:27 | mr-foobar | yup. got it ! |
| 15:27 | dysfun | cool :) |
| 15:28 | mr-foobar | I suppose a Bus topic is more discoverable than channels. |
| 15:29 | mr-foobar | With core.async I remember having to use a global map of pre-defined channels. |
| 15:29 | dysfun | well a bus is a discoverability mechanism :) you can implement your own if you like, or you can use core.async's |
| 15:31 | mr-foobar | I was watching https://channel9.msdn.com/Shows/Going+Deep/Hewitt-Meijer-and-Szyperski-The-Actor-Model-everything-you-wanted-to-know-but-were-afraid-to-ask and I ended up at CSP and clojure.async :) |
| 15:33 | mr-foobar | I think CSP is more easier to approach than the actor model which is a bit recursive. |
| 15:34 | dysfun | hah, you'll have fun debugging core.async and wondering where the stack traces are ;) |
| 16:09 | msenol | hi guys |
| 16:09 | msenol | I want to access values defined via intern function, in -main method |
| 16:09 | msenol | here is my code |
| 16:09 | msenol | https://bitbucket.org/snippets/msenol86/kKRpj |
| 16:09 | msenol | it gives error |
| 16:09 | msenol | Caused by: java.lang.RuntimeException: No such var: chap-9.core/yyy |
| 16:14 | TEttinger | you didn't show that you had declared an ns when that was run, should I assume you're in the ns chap-9.core ? |
| 16:15 | TEttinger | ,(doc intern) ; let's see here... |
| 16:15 | clojurebot | "([ns name] [ns name val]); Finds or creates a var named by the symbol name in the namespace ns (which can be a symbol or a namespace), setting its root binding to val if supplied. The namespace must exist. The var will adopt any metadata from the name symbol. Returns the var." |
| 16:18 | msenol | yes Tettinger I am in chap-9.core |
| 16:18 | msenol | I am adding the namespace thing into bitbucket snippet one minute |
| 16:19 | msenol | ok added |
| 16:21 | TEttinger | can you try (println yyy) instead of the ns and then yyy? |
| 16:22 | msenol | Caused by: java.lang.RuntimeException: Unable to resolve symbol: yyy in this context |
| 16:23 | TEttinger | this is where I hope justin_smith or amalloy is around |
| 16:24 | msenol | ok thx :) |
| 16:24 | amalloy | *ns* isn't bound after compilation is done |
| 16:24 | amalloy | so you're interning stuff into clojure.core |
| 16:26 | msenol | ummm ok |
| 16:26 | amalloy | but i guess it never even gets to that point |
| 16:26 | amalloy | because the intern only happens at runtime, and you try to resolve the var at compile time |
| 16:26 | msenol | oh |
| 16:27 | msenol | is there a way to force it to resolve at runtime? |
| 16:27 | msenol | instead of at compile time? |
| 16:28 | amalloy | yes, you can call (resolve 'yyy) or whatever |
| 16:28 | msenol | oh ok |
| 16:28 | amalloy | ,resolve |
| 16:28 | clojurebot | #object[clojure.core$resolve 0x23fd5492 "clojure.core$resolve@23fd5492"] |
| 16:28 | msenol | thank yout very much amalloy :) |
| 16:28 | msenol | also thank you very much TEttinger |
| 16:29 | TEttinger | yw, also thanks amalloy! |
| 16:34 | msenol | a little problem :) |
| 16:34 | msenol | #'user/yyy |
| 16:34 | justin_smith | I thought *ns* was typically user |
| 16:34 | msenol | resolve returns that |
| 16:34 | msenol | how can i get the value of it |
| 16:34 | dysfun | @ |
| 16:34 | justin_smith | msenol: @ |
| 16:34 | justin_smith | which is shorthand for deref |
| 16:34 | msenol | wow |
| 16:34 | msenol | thx |
| 16:34 | msenol | all |
| 16:35 | msenol | I am asking these questions here becaue it is diffucult to test stuff when you are workin with -main method. you have to call lein run everytime |
| 16:35 | msenol | it is not easy as repl |
| 16:35 | msenol | again thx a lot all |
| 16:36 | justin_smith | msenol: there are very few things that are not identical in a repl vs. running from a file, and you can call -main from your repl |
| 16:36 | msenol | oh ok |
| 16:36 | msenol | clojure is great |
| 16:36 | msenol | thx for tip justing_smith :) |
| 16:42 | amalloy | justin_smith: notably though *ns* is different |
| 16:43 | amalloy | and that is exactly what msenol is toying around with atm |
| 16:43 | justin_smith | ahh, right |
| 16:45 | justin_smith | msenol: why not provide a symbol instead of *ns* when using intern? |
| 16:47 | msenol | justin_smith: umm I want to add a value to current namespace, how can I use a symbol for that? |
| 16:47 | msenol | justin_smith: should I provide a symbol to produce another namespace? |
| 16:48 | justin_smith | msenol: if you want to put a var in a specific namespace, yes |
| 16:48 | msenol | oh ok |
| 16:48 | msenol | justin_smith: I want to make something similar to scrapy library in python |
| 16:49 | justin_smith | because *ns* at runtime in normal runs is typically user (it's even user in repls, until you make clojure switch to sometthing else) |
| 16:49 | msenol | justin_smith: in scrapy u can do this scrapy 'www.google.com' |
| 16:49 | msenol | justin_smith: and after that you can access to google.com page using variable "response" in scrapy shell |
| 16:50 | msenol | justin_smith: I want to build something like that |
| 16:50 | justin_smith | yeah, we tend to avoid things like this in clojure, preferring locality of reference rather than creating values indirectly |
| 16:51 | msenol | justin_smith: ok thx a lot |
| 16:52 | justin_smith | msenol: it would be possible to make a function that creates a var in your current namespace, but it's not simple, and the most straightforward way probably involves passing in the namespace that should get this new var - but why not use a composite return value (or just a return value) rather than an automatic var creation? |
| 16:53 | justin_smith | code that uses return values is much more predictable |
| 16:55 | msenol | justin_smith: yeah in first version of the function it returns a value and you have to assign it to a var in repl |
| 16:55 | msenol | (def parsed-html (my-parser ("www.google.com"))) |
| 16:55 | msenol | justin_smith: it was working in this way |
| 16:55 | justin_smith | I assume there are extra parens there, but yeah |
| 16:55 | msenol | justin_smith: but I try to make it user friendly like scrapy |
| 16:56 | msenol | justin_smith: yeah one extra paren sorry |
| 16:56 | amalloy | msenol: that's not really user-friendly, it's just python-style |
| 16:56 | msenol | amalloy: ok :) |
| 16:56 | amalloy | a clojure style would be to have the function return a value, and then you call other functions on that value |
| 16:57 | amalloy | possibly you def it to a var, possibly not |
| 16:57 | msenol | yeah, but I want to design a shell, so when user calls my program in command-line like this: |
| 16:57 | msenol | scrapy-clojure "www.google.com" |
| 16:57 | msenol | then user will put into a shell |
| 16:58 | msenol | after that user can call functions predefined (which works on www.google.com html) |
| 16:58 | msenol | like |
| 16:58 | msenol | (css-select "div#some_div") |
| 16:58 | msenol | and it returns a node or list of nodes |
| 16:59 | justin_smith | OK, in that case you could make sure that the vars you create are interned into the shell's primary namespace - that should be simple enough |
| 17:00 | msenol | justin_smith: oh ok. so I should create a namespace for my shell. thank you very muc |
| 17:00 | justin_smith | msenol: yeah - you could even use the main ns you are already using - just make sure to explicitly provide that ns symbol as an arg to intern - to ensure that definitions end up there |
| 17:01 | msenol | justin_smith: ok I understood |
| 17:02 | msenol | you guys are great |
| 19:29 | jumanji | hi guys how do you reduce a list of maps via a specific key value? I tried it here but not sure if I'm doing it correctly : http://stackoverflow.com/questions/37369012/clojure-given-a-list-of-maps-get-the-total-sum-value-of-a-specific-key-value |
| 19:29 | TEttinger | this is one of those things that I think gets solved easily with a transducer |
| 19:30 | Lewix | is there an easy wha to add an index to repeat |
| 19:30 | Lewix | ,(repeat 5 "lewix") |
| 19:30 | clojurebot | ("lewix" "lewix" "lewix" "lewix" "lewix") |
| 19:30 | TEttinger | repeatedly takes a 0-arg fn. what I would do is a map on range |
| 19:31 | TEttinger | ,(map #(str "lewix" %) (range 5)) |
| 19:31 | clojurebot | ("lewix0" "lewix1" "lewix2" "lewix3" "lewix4") |
| 19:37 | Lewix | TEttinger: thanks it's neat |
| 20:32 | ob_ | hi is there any facility for showing docs within clojure repl? |
| 20:34 | Lewix | ob_: (doc foo) |
| 20:34 | Lewix | ,(doc doc) |
| 20:34 | clojurebot | "([name]); Prints documentation for a var or special form given its name" |
| 20:34 | ob_ | ty Lewix |
| 21:05 | ealfonso | how do I ask lein to take a dependency from a local jar? |
| 23:17 | tolstoy | Heh. That question. ;) Reminds me of struggling with what to do with an Oracle JDBC jar. |