2014-05-22
| 00:22 | dbasch | technomancy: one reason to have web documentation is that you cannot use doc to search |
| 00:22 | technomancy | dbasch: you can use apropos though |
| 00:23 | dbasch | technomancy: if you know that if exists |
| 00:24 | dbasch | and it won’t help you with things like “concatenate strings in clojure" |
| 00:24 | technomancy | right; you have IRC for that =D |
| 00:25 | technomancy | anyway, you won't find that from autogenerated HTML docs |
| 00:25 | dbasch | but then we have to help beginners instead of talking about random stuff :) |
| 00:25 | dbasch | you might if enough people use those terms to link to them |
| 00:26 | jweaver | sometimes talking about random stuff is helping beginners ;-). |
| 00:44 | jweaver | So, is everything we type in Clojure a data literal? The code "is" the data? I'm doing a lot of reading on Clojure (learning), and I've read this a number of times. I'm not sure I grok it though |
| 00:45 | arrdem | jweaver: welcome to homoiconic languages. |
| 00:46 | amalloy | jweaver: yes. for example, (+ 1 2) is a list, containing a symbol and two numbers |
| 00:46 | jweaver | What is written, is the actual AST... is that a fair statement? |
| 00:46 | amalloy | when the compiler evaluates that, you get 3; but before evaluation, it's a list |
| 00:46 | jweaver | Ahh |
| 00:47 | amalloy | jweaver: eh. not really, re ASTs |
| 00:47 | jweaver | Wow |
| 00:48 | jweaver | Well, since it's data, it's like the AST itself right? I mean, it's not trasnformed or anything |
| 00:50 | amalloy | it's a tree, but it's not really *the* AST. there are lots of other things in an AST, since those are generally produced by the compiler as an intermediate structure |
| 00:51 | jweaver | Ok |
| 00:53 | jweaver | After years of Java OO/Imperative, I'm opening up my mind as much as possible =). It seems simple, very simple. I'll definitely be putting some night time hours into study and practice. |
| 00:54 | jweaver | ("it" being clojure) |
| 00:54 | tolstoy | jweaver: A colleague is going through a similar thing. |
| 00:54 | tolstoy | jweaver: Recently, he decided to fire up .Net to make a simple web app and found himself saying, "Man, this is a lot of typing." |
| 00:55 | jweaver | tolstoy: Any words of advice? |
| 00:55 | jweaver | haha =). Nice. |
| 00:56 | tolstoy | Advice? Hm. Start simple? Write lots of tiny apps that do the one "part" you're interested in, then start putting them together later? |
| 00:57 | dbasch | to be fair, web apps are almost always a lot of typing |
| 00:58 | quizdr | you can save a ton of typing in Clojure by learning all the functions in clojure.core. if you don't know about some of them, you can accidentally end up writing your own to do the same thing. |
| 00:58 | tolstoy | Yep. But he told us the story illustrating that despite himself, he kinda crossed a line. |
| 00:58 | dbasch | one day we may not have to use a tree to represent a rectangular screen anymore, that might save some typing |
| 00:59 | tolstoy | quizdr: I do that all the time. Just the other day I realized that my "loop/recur" thing was solved with "every?". ;) |
| 01:00 | jweaver | quizdr: I'll keep that in mind, the clojure docs seem like a good guide (referencing these docs: http://clojure.github.io/clojure/clojure.core-api.html) |
| 01:00 | jweaver | Of course, I end up googling everything anyway. |
| 01:01 | quizdr | very rarely is loop/recur necessary |
| 01:02 | jweaver | Wowah... core.clj is 1 giant file? So I take it breaking these up into separate files has little or no benefit? |
| 01:02 | jweaver | (and by giant, I mean only ~7k lines in total file size) |
| 01:02 | tolstoy | quizdr: Yeah. I generally only use it to get an idea down if I don't know what I really want. More and more: reduce does it all. |
| 01:03 | quizdr | i watched an interesting c++ talk by an Adobe engineer yesterday, and even in a language like that he insisted that one should never use raw loop and rely on simple built-in functions instead (of which c++ has quite many now that resemble functional list comprehension) |
| 01:18 | Fare | I'm trying to use reflection to access clojure from java |
| 01:19 | Fare | and actually, even before then, I'm trying to run some code using clojure |
| 01:34 | yedi | expectations test framework seems refreshing |
| 01:49 | servo | https://www.refheap.com/85760 |
| 01:49 | servo | #dark |
| 01:50 | arrdem | reasonable, but yes a bit dark |
| 02:01 | servo | the paradigm of looking at the world as a set of entities that have an ability to do something is pretty powerful |
| 02:01 | servo | i mean both protocols and reducers leverage this |
| 02:02 | servo | isn't the definition of a collection an entity that has the ability to be reducible? |
| 02:06 | amalloy | servo: that defrecord Human isn't very thread-safe |
| 02:06 | TEttinger | amalloy: a noose is an unsafe thread for humans too |
| 02:07 | servo | amalloy: can you give me an example of a scenario in which state would cause that record to perform unexpectedly? |
| 02:07 | servo | s/state// |
| 02:08 | amalloy | pretty much anytime two threads are working with it at once. for example: health is 1, alive is true. two threads both try to hit it for 5. they both discover that it's alive. then they both take away 5 hp, so it's down to -9. then they both see that health is negative so they both toggle alive, and the monster briefly dies before coming back to life |
| 02:08 | amalloy | or, i guess it's a human, not a monster |
| 02:09 | amalloy | really just imagine two threads progressing through this function in parallel, each executing the same lines at the same time. you don't need any corner cases to mess this one up |
| 02:10 | servo | ah |
| 02:10 | servo | thank you |
| 02:10 | amalloy | good news, though, sorta: it's *impossible* to keep two separate atoms in sync in a thread-safe way |
| 02:10 | amalloy | so your design was not much worse than any other |
| 02:11 | servo | so ideally i would use refs with dosync correct? |
| 02:11 | amalloy | i'd use one atom, which is a map containing both health and alive. but refs wouldn't be unreasonable |
| 02:12 | servo | that is one thing i often ponder; whether to use one big referenceable identity for state or to split it up into many |
| 02:13 | mange | servo: Why do you need "alive" to be a separate atom? Can something have positive health and be dead? (Or negative health and be alive?) |
| 02:13 | servo | i've seen where people use one symbol and call it "state" and it represents entire state of application, not sure how idiomatic that is |
| 02:14 | mange | And when I said "atom" there, let's all just pretend I said "value". |
| 02:14 | servo | mange: i wanted to use a predicate function :) |
| 02:15 | mange | (comp neg? :health) wasn't any good? |
| 02:16 | mange | ... With a deref. |
| 02:16 | servo | pedantry aside, yes, that would have worked ;) |
| 02:17 | mange | Yeah, I'm fairly wrong there on the fine details. Sorry about that. |
| 02:21 | noncom | servo: storing all state under one variable is perfectly ok |
| 02:22 | noncom | usually one atom |
| 02:23 | quizdr | servo that is quite idiomatic; afterall, Om, a widely used Clojure(script) library, just does that: a single atom for the entire app |
| 02:23 | servo | cool |
| 02:24 | quizdr | i think the question comes down to what is more manageable, both for you as a dev but also for the system. multiple atoms that are related to each other can get messy. a single atom is tight. |
| 02:27 | servo | as noted above, i have learned that even two atoms can get messy fairly quickly |
| 02:42 | amalloy | even one atom can get messy fairly quickly |
| 03:00 | quizdr` | true dat |
| 03:09 | owl-v- | if i'm programming clojure app in embedded system, what is effective way of representing trees and traverse it? |
| 03:24 | vijaykiran | owl-v-: clojure.walk, perhaps ? |
| 03:25 | vijaykiran | owl-v-: there's this - http://www.ibm.com/developerworks/library/j-treevisit/index.html (not sure if it is outdated a bit) |
| 05:14 | numberten | why is this a thing |
| 05:15 | numberten | ,('test 1 "wat") |
| 05:15 | clojurebot | "wat" |
| 05:16 | numberten | ,('symbol :a :b) |
| 05:16 | clojurebot | :b |
| 05:16 | numberten | ,(and :a :b) |
| 05:16 | clojurebot | :b |
| 05:17 | Glenjamin | ,[('test {'test :a} "wat") ('test {'not-test :a} "wat")] |
| 05:17 | clojurebot | [:a "wat"] |
| 05:17 | vijaykiran | ,(doc and) |
| 05:17 | clojurebot | "([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true." |
| 05:17 | vijaykiran | ,(false? :a) |
| 05:17 | clojurebot | false |
| 05:18 | Glenjamin | symbol's IFn is basically (get) |
| 05:18 | Glenjamin | ,(doc get) |
| 05:18 | clojurebot | "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present." |
| 05:18 | numberten | don't understand |
| 05:21 | vijaykiran | numberten: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Symbol.java#L127 |
| 05:22 | vijaykiran | ('blah 1 3) is invoking symbol as the function get |
| 05:22 | numberten | i see |
| 05:22 | numberten | ,(get :a :b) |
| 05:22 | clojurebot | nil |
| 05:22 | numberten | ,(get 'wat :a :b) |
| 05:22 | clojurebot | :b |
| 05:22 | vijaykiran | yup |
| 05:22 | numberten | that's really strange |
| 05:23 | Glenjamin | it allows you to try and get a value from a map, and not blow up when you don't get a map |
| 05:23 | numberten | i assume that's so you can use (symbol coll) |
| 05:23 | numberten | as shorthand for get |
| 05:23 | Glenjamin | yes |
| 05:24 | Glenjamin | ,({'a :b} 'a) |
| 05:24 | clojurebot | :b |
| 05:24 | Glenjamin | ,('a {'a :b}) |
| 05:24 | clojurebot | :b |
| 05:24 | Glenjamin | ,(nil 'a) |
| 05:24 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0:0)> |
| 05:24 | Glenjamin | ,('a nil) |
| 05:24 | clojurebot | nil |
| 05:24 | numberten | makes sense |
| 05:25 | Glenjamin | using the symbol/keyword's IFn is "safer" than calling the map, and shorter than (get) |
| 05:25 | numberten | i keep forgetting that dispatch is only a matter of the type of the first argument |
| 05:25 | numberten | so ,('a 1 2) was tripping me out |
| 06:13 | Vinzent | reiddraper, hi, could you please take a look at this slightly modified version of `for-all` which I find handy to use? If it looks ok to you, I can send you a patch |
| 06:13 | Vinzent | https://www.refheap.com/85769 |
| 06:23 | clgv | Vinzent: I think that would be only usefull if the let binding can be used in the next for-all binding |
| 06:24 | clgv | Vinzent: but for that it is probably better to have a different macro based on for-all |
| 06:28 | peterdon | (def x 1 y 2) |
| 06:28 | peterdon | sorry |
| 06:29 | Vinzent | clgv, yeah it would be cool, although I'm not quite sure how to implement that. Anyway, the version I pasted is just a way to get rid of repetitive (and ...) blocks, since they are required almost in every spec anyway |
| 06:35 | clgv | Vinzent: implicit `and`? I doubt that this is a good idea |
| 06:37 | clgv | Vinzent: in clojure a list of forms in a macro indicates a `do` somewhere in the macro which indicates either side effects or a programming error |
| 06:39 | Vinzent | clgv, I wouldn't agree it's a general rule. It's only valid for defn-like macros. |
| 06:40 | Vinzent | Though, it's arguable whether for-all is (and should be) such one. |
| 06:41 | clgv | Vinzent: I don't know of any exception concerning control flow macros. |
| 06:43 | clgv | when you test your implementation the properties you test should be explicitly visible |
| 06:46 | wunki | is it possible to get the `var` of a function? |
| 06:48 | clgv | wunki: from a function instance? |
| 06:48 | wunki | clgv: I want to get the var in middleware, so it's a handler function |
| 06:48 | clgv | wunki: for functions created via `defn` you can reconstruct the complete symbol and resolve it |
| 06:49 | wunki | clgv: with ns-resolve? |
| 06:49 | clgv | wunki: reconstructi it from the class name Iwanted to say ^^ |
| 06:49 | Vinzent | clgv, in my mind, for-all is closer to defroutes-like macros than to control flow ones. You pass a list of properties, not just an arbitrary body. |
| 06:50 | clgv | Vinzent: well that is not how it is implemented and documented so I doubt that. for a test it is certainly defining the control flow similarly to a doseq |
| 06:53 | Vinzent | clgv, sure, I'm talking about the version I pasted, not the one which is currently there. They are not backwards-compatible in this regard |
| 06:54 | clgv | Vinzent: I dont think it is useful to have the implicit `and` since this will only lead to accidental errors. |
| 06:55 | clgv | the point of the test is to convince you or your stakeholders that your implementation works as specified. so I'd try to minimize errors in the test code ;) |
| 06:56 | Vinzent | clgv, implicit and is an implementation detail; you just pass a number of properties to be checked using the provided generators. Think of it as an equivalent of clojure.test/are or something. |
| 06:57 | clgv | yeah well, even there you have to use the `ara` |
| 06:57 | clgv | `are` |
| 07:02 | Vinzent | clgv, and here you have to use `for-all` :) The only way I see it can lead to accidental errors is breaking backwards compatibility and possibly confusing people used to the old version, which is of course a perfectly valid point. |
| 07:06 | clgv | Vinzent: I doubt that for-all will be changed like that. maybe a helper macro is included if you manage to convince anyone that it is actually usefull |
| 07:10 | Vinzent | clgv, well, yeah, that's why I just wanted reiddraper to take a look -- maybe it's not that handy at all for other people as it is for me. |
| 07:13 | quizdr` | why the source for async's >! show basically nothing but an assert? https://github.com/clojure/core.async/blob/65b2d6c81350ba8b4bb3a8b82ad45ba984c0037c/src/main/clojure/clojure/core/async.clj#L118 |
| 07:15 | mpenet | it's a catch-all for people using it outside of go blocks, I guess in go blocks it gets rewriten |
| 07:15 | Vinzent | quizdr`, I guess all the work is done in the go macro |
| 07:15 | quizdr` | interesting, so the go block sees the symbol >! and uses that for its logic |
| 07:29 | clgv | quizdr`: https://github.com/clojure/core.async/blob/65b2d6c81350ba8b4bb3a8b82ad45ba984c0037c/src/main/clojure/clojure/core/async/impl/ioc_macros.clj#L976 |
| 07:52 | noncom|2 | can i somehow change the directory where clojure looks for ns files when executing (require) ? |
| 07:53 | Vinzent | noncom|2, :source-paths in your project.clj, if you want this for the whole project |
| 07:53 | agarman | or you can use the load function directly |
| 07:54 | agarman | ,(doc load) |
| 07:54 | clojurebot | "([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise." |
| 07:54 | agarman | there's also load-file |
| 07:55 | opensourcegeek | hi guys - i'm a newbie with clojure, just started hacking some stuff together. how can I get :b from ({:a 1, :b ({:label "boo" :name "foo"})} :b) => this throws ArityException Wrong number of args (0) passed to: PersistentArrayMap. I know it is something to do with parens after :b |
| 07:55 | noncom|2 | so, a few corrections: 1) i am not using lein in this current setup :) and 2) the (load) seems like all paths must be relative either to the CP or the current ns path... umm |
| 07:55 | noncom|2 | ,(doc load-file) |
| 07:55 | clojurebot | "([name]); Sequentially read and evaluate the set of forms contained in the file." |
| 07:55 | noncom|2 | hmm |
| 07:55 | noncom|2 | this looks like the solution |
| 07:56 | numberten | ,(take 3 (iterate (fn [m] (let [i (rand-int (count m))] (dissoc m i))) {0 :a 1 :b 2 :c})) |
| 07:56 | clojurebot | ({0 :a, 1 :b, 2 :c} {0 :a, 2 :c} {0 :a, 2 :c}) |
| 07:56 | numberten | shouldn't the third map have only 1 element in it? |
| 07:57 | noncom|2 | ,(:b {:a 1, :b ({:label "boo" :name "foo"})}) |
| 07:57 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentArrayMap> |
| 07:57 | opensourcegeek | I can fix it with (:b {:a 1, :b '({:label "boo" :name "foo"})}) |
| 07:57 | Vinzent | opensourcegeek, ({:label "boo" :name "foo"}) is wrong, you want [{:label "boo" :name "foo"}] |
| 07:57 | noncom|2 | opensourcegeek: the problem is that the {} in the list is treated like a function |
| 07:57 | noncom|2 | you either have to use [] instead of () or '() |
| 07:58 | opensourcegeek | , but it is sent by clj-http |
| 07:58 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: but in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 07:58 | agarman | opensourcegeek: either what Vinzent said or '() instead of () |
| 07:59 | opensourcegeek | but when I do (http/get "http://x.com/" {:as :json}) then I get the response automatically coerced to something like above |
| 07:59 | Vinzent | opensourcegeek, read about clojure evaluation process. When clojure encounters a list, it treats its first element as a function. So (1 2 3) is a perfectly valid list, but you'll get an error if you try to evaluate it. ' suspends evaluation, so '(1 2 3) will return just the list (1 2 3) itself. |
| 08:00 | opensourcegeek | (require '[clojure.data.json :as json]) |
| 08:01 | opensourcegeek | @Vinzent, I totally get that - but if the library sends me data structure which has embedded parens what do i do? |
| 08:02 | Vinzent | opensourcegeek, don't copy it from the repl :) or quote it if you do |
| 08:02 | agarman | data won't be evaluated unless you tell clojure to evaluate it |
| 08:02 | opensourcegeek | ahhh - makes sense sorry |
| 08:02 | agarman | opensourcegeek: if you want to copy it into the repl |
| 08:02 | llasram | ,(clojure.edn/read-string "(:foo :bar :baz)") |
| 08:02 | clojurebot | #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.edn> |
| 08:03 | agarman | opensourcegeek: quote it with ' |
| 08:03 | llasram | ,(require 'clojure.edn) |
| 08:03 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 08:03 | llasram | hmph |
| 08:03 | llasram | ,(read-string "(:foo :bar :baz)") ;; don't dot this for untrusted data |
| 08:03 | clojurebot | (:foo :bar :baz) |
| 08:03 | opensourcegeek | its repl that's printing after evaluating it? - makes sense thanks guys |
| 08:05 | amatsu | I'm trying to transform ["a" "b" "c"] into {:a {:b "c"}}. Is there an easy way to do this? I couldn't find a way to express this with loop+recur. |
| 08:06 | llasram | amatsu: It's not entirely clear what you're trying to achieve from that example. More details? |
| 08:06 | wunki | anyone familiar with fnhouse? |
| 08:06 | Vinzent | amatsu, assoc-in + butlast is the first which comes to mind |
| 08:06 | CookedGr1phon | if that's your exact example, then (defn f [[a b c]] {(keyword a) {(keyword b) c}}) |
| 08:07 | CookedGr1phon | more info if you want something more general |
| 08:09 | Vinzent | amatsu, although, if the collection is always a vector, it's much better to use peek and pop |
| 08:11 | noncom|2 | ok so about 15 minutes ago we found that (load) and (load-file) functions would allow me much customization in choosing where from the load the files. but still, what about (require) ? can i change its behavior? |
| 08:11 | noncom|2 | the reason is that i do not want to modify the existing code, which already has normal (ns) declarations and replace it with (load) or (load-file) thingie |
| 08:12 | agarman | noncom|2: have you read (doc require)? |
| 08:12 | noncom|2 | ,(doc require) |
| 08:13 | clojurebot | "([& args]); Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Use :require in the ns macro in preference to calling this directly. Libs A 'lib' is a named set of resources in classpath whose contents... |
| 08:13 | agarman | noncom|2: it's too long for irc |
| 08:13 | agarman | noncom|2: run it in your own repl |
| 08:13 | noncom|2 | ok |
| 08:13 | Vinzent | noncom|2, you probably should use some classpath managing tool. Maybe clojure.java.classpath will do, but I can't help you much further |
| 08:14 | llasram | noncom|2: What's your ultimate goal? |
| 08:16 | noncom|2 | i have some clojure code in its normal form, but I have to load and run it all from a java app, what means that I use Compiler.load() things and such. leiningen is also not an option for the reason |
| 08:16 | noncom|2 | while Compiler.load() loads file a namespace, problems begin when that namespace requires some other ones |
| 08:17 | noncom|2 | i thought maybe there are some variables in RT that can be altered to help Clojure locate the namespaces |
| 08:17 | llasram | noncom|2: Ok. What actually want to do is `require` things from the class path, just like normal |
| 08:17 | noncom|2 | llasram: yes, but how do I change the classpath so that require will find the files on the classpath? |
| 08:18 | noncom|2 | i was looking for that and did not find anything.. |
| 08:18 | llasram | Run the JVM with the correct `-cp` option or `CLASSPATH` environment variable? |
| 08:19 | llasram | And then you load the Clojure code by calling `require` via the Java Clojure API: https://github.com/damballa/parkour/blob/master/src/java/parkour/hadoop/Mappers.java#L15 |
| 08:19 | noncom|2 | llasram: not really an option... because 1) it is Dalvik, not a regular JVM 2) the location(s) is(are) not known at the launch time :) |
| 08:19 | llasram | There a more formal interface in Clojure 1.6, if you're using only 1.6+ |
| 08:21 | llasram | noncom|2: Ah. You might want to mention that first next time :-p |
| 08:21 | noncom|2 | llasram: yeah, I was thinking along similar lines as you point out in the example, but requiring the nss from Java also won't work because it presumes that I know what are the namespaces. I only know the "entry point" namespace which then in turn uses (require) |
| 08:21 | noncom|2 | actually it uses (ns name-of-it (:require ...) ) just like usual |
| 08:22 | CookedGr1phon | noncom|2: so are your generating dex at runtime and then want to require it? |
| 08:22 | llasram | I'm about 90% certain that you need to AOT compile the project then ->DEX the generated JVM byte code |
| 08:22 | noncom|2 | yes, looks like it. at least Compiler.load() creates a dex |
| 08:22 | llasram | And all attempts at runtime loading of Clojure source will utterly fail |
| 08:22 | CookedGr1phon | llasram: not so |
| 08:22 | noncom|2 | no-no, all works ok |
| 08:23 | llasram | Interesting |
| 08:23 | llasram | How? |
| 08:23 | noncom|2 | i successfully load a single file |
| 08:23 | CookedGr1phon | there's a dexer built in to the clojure android clojure fork |
| 08:23 | noncom|2 | the only problem that i can't make (require) look for files where i want |
| 08:23 | llasram | Ah |
| 08:23 | llasram | Interesting |
| 08:23 | llasram | OOC which project is that in? |
| 08:23 | noncom|2 | clojure-android |
| 08:23 | noncom|2 | by sattvik |
| 08:23 | CookedGr1phon | noncom|2: have you looked at where the repl puts its generated dex? |
| 08:24 | llasram | Oh, there's a Clojure fork which includes the DEX support |
| 08:24 | llasram | Interesting |
| 08:24 | llasram | Apparently I'm finding things very interesting this morning :-) |
| 08:24 | noncom|2 | the repl puts the generated dex files where i tell it to put them :) there is a *compile-path* var which i have to set manually in order for Compiler.load() to work at all. i could also use Neko, but for now i am minimal |
| 08:25 | noncom|2 | but *compile-path* has nothing to do with (require) or classpath |
| 08:26 | noncom|2 | all these things should be easily configurable, i just cant find how.. spent some time digging the sources but don't have an answer yet |
| 08:26 | noncom|2 | llasram: good morning :) |
| 08:27 | CookedGr1phon | noncom|2: I take it you've looked at the neko.compilation namespace for clues already? |
| 08:28 | CookedGr1phon | isn't that all you need to be able to run require statements? |
| 08:29 | noncom|2 | CookedGr1phon: yes I have looked there. I did not use it, but visually i can tell it does not have the solution. It only sets *compile-path* - that's already what I am doing by myself |
| 08:30 | CookedGr1phon | and the system property clojure.compile.path |
| 08:30 | noncom|2 | i believe that altering the (require) behaviour is not an android-specific thing, it is general for Clojure |
| 08:31 | noncom|2 | CookedGr1phon: hmmmmm I might have missed that one |
| 08:44 | noncom|2 | CookedGr1phon: so, tried the clojure.compile.path and no, it won't work, the error message says "Could not locate blablabla on classpath:" - with nothing following the colon |
| 08:44 | noncom|2 | or it is just the exception colon, nvm |
| 08:44 | noncom|2 | but anyway |
| 08:44 | noncom|2 | "not found on classpath" |
| 08:48 | noncom|2 | CookedGr1phon: so I guess I will have to recursively scan the dir and (load-file) all the files in it first... can't think of another solution.. .except for trying to make a patch for clojrue-android, but diverging from the main here is not a good idea, I suppose... |
| 09:32 | sojacques | Hello everyone! |
| 09:33 | sojacques | I have a question regarding sessions (for web development) |
| 09:33 | sojacques | What is the suggested library to deal with those |
| 09:33 | mdrogalis | sojacques: Fire away. |
| 09:33 | sojacques | ? :) |
| 09:33 | sojacques | Most resources I found mention sandbar, but it has not been updated for more than a couple years |
| 09:34 | sojacques | and I have a bit of trouble while dealing with Ring sessions (I use Compojure) |
| 09:34 | mdrogalis | sojacques: Yeah, Sandbar is ancient. I think Ring itself has some support for sessions, or you can try Luminous or Pedestal. |
| 09:34 | mdrogalis | sojacques: Ah, got'cha. |
| 09:34 | sojacques | mdrogalis: Thank you, I'll have a look! |
| 09:34 | mdrogalis | What seems to be the trouble? |
| 09:35 | sojacques | Let me write a little gist to show you |
| 09:35 | mdrogalis | Sure. |
| 09:39 | sojacques | mdrogalis: better, just found this http://narhinen.net/2013/09/25/Sessions-with-compojure.html |
| 09:40 | sojacques | What I have a trouble to grasp is: Is it possible to do this without using "response" ? |
| 09:40 | mdrogalis | I seriously hate defroutes. A lot. |
| 09:41 | sojacques | I'm totally open to any alternative! |
| 09:42 | mdrogalis | I don't do a lot of web development. Luminous did seem pretty okay last I looked though. |
| 09:42 | sojacques | so far, I've been using defroutes because I thought this was the idiomatic way of having composable routes |
| 09:42 | sojacques | Will be checking into this! |
| 09:43 | mdrogalis | Ah, yeah. I mean I don't really see anyone doing it another way, but it's this nasty macro def'ed smack in the middle of the code. That could easily be a data construct. |
| 09:45 | sojacques | I'm quite new to web development in Clojure, been doing server management tools & data analysis / stats so far |
| 09:45 | sojacques | so I'm a bit lost here and there |
| 09:46 | mdrogalis | sojacques: Understood - sorry, I'm just ranting a bit. You have good tools, you'll pick it all up pretty quickly. |
| 09:46 | sojacques | I'm reading the doc of Luminus, looks like it will totally do the job |
| 09:46 | sojacques | Thanks! |
| 09:47 | justin_smith | also, using sessions with ring is very easy - it pretty much comes down to using the session middleware, and then putting / getting session data under the :session key in the request and response |
| 09:49 | justin_smith | in fact I will commonly construct my response object as a series of transformations of the request |
| 09:50 | mdrogalis | No prob bob. |
| 10:03 | aelse | , (use '[clojure.java.shell :only [sh]]) (sh "free") (sh "top" "-bn1") |
| 10:03 | clojurebot | nil |
| 10:03 | aelse | , (use '[clojure.java.shell :only [sh]]) (sh "free") (sh "top" "-bn1") |
| 10:03 | clojurebot | nil |
| 10:03 | pentester_ | i want to break you |
| 10:03 | pentester_ | echo hi |
| 10:03 | lazybot | hi |
| 10:04 | pentester_ | nil |
| 10:04 | pentester_ | aelse: what r u trying to do ? |
| 10:04 | pentester_ | what language is that |
| 10:04 | aelse | clojure |
| 10:05 | pentester_ | how i can write a hello world in clojure? |
| 10:05 | teslanick | (prn "hello world") |
| 10:05 | teslanick | ,(prn "hello world") |
| 10:05 | clojurebot | "hello world"\n |
| 10:06 | pentester_ | it sucks ..? |
| 10:06 | teslanick | What? |
| 10:06 | clojurebot | What is sampling a random integers betwen 2, 12 s..t. P(X = i) = (7-|i-7|)/36 |
| 10:06 | pentester_ | helpme |
| 10:06 | pentester_ | help |
| 10:06 | pentester_ | !clojure |
| 10:06 | pentester_ | clojure |
| 10:06 | aelse | , help |
| 10:06 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: help in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:06 | pentester_ | , ? |
| 10:06 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ? in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:07 | teslanick | What do you need help *with*? |
| 10:07 | pentester_ | teslanick: lol |
| 10:07 | pentester_ | trying to learn clojure |
| 10:07 | clgv | teslanick: better use println |
| 10:07 | aelse | , (. (Runtime/getRuntime) exec "ls") |
| 10:07 | clojurebot | #<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:07 | clgv | pentester_: get one of the books then ;) |
| 10:07 | pentester_ | , ('kill me') |
| 10:07 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: me' in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:07 | teslanick | pentester_: stop. |
| 10:07 | pentester_ | , (scanf "hello world") |
| 10:07 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: scanf in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:07 | aelse | , (use '[clojure.java.shell :only [sh]]) |
| 10:07 | clojurebot | nil |
| 10:07 | pentester_ | teslanick: y u need me to stop? |
| 10:08 | aelse | , (println (:out (sh "cowsay" "Printing a command-line output"))) |
| 10:08 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 10:08 | teslanick | Because this isn't your own personal repl to stomp on. |
| 10:08 | aelse | , (println (:out (sh "cat" "-" :in "Printing input from stdin with funny chars like ' \" $@ & "))) |
| 10:08 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 10:08 | aelse | , (sh "pwd" :dir "/home/ics/icsdev") |
| 10:08 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 10:08 | pentester_ | , (println (ls)) |
| 10:08 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ls in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:09 | clgv | aelse: you wont get shell access on clojurebot ;) |
| 10:09 | pentester_ | , (sh "ls") |
| 10:09 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 10:09 | pentester_ | , (sh "echo *") |
| 10:09 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 10:09 | pentester_ | , (sh "find /") |
| 10:09 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 10:09 | pentester_ | why it keep deny me? |
| 10:09 | pentester_ | , (sh "date") |
| 10:09 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 10:09 | teslanick | Because clojurebot/lazybot are both sandboxed. |
| 10:09 | clgv | because there is a sandbox which blocks the underlying functionality of `sh` |
| 10:09 | aelse | , (sh "date;echo hi") |
| 10:10 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 10:10 | aelse | okay lets think outside the box |
| 10:10 | aelse | zsh |
| 10:10 | pentester_ | or csh? |
| 10:10 | clgv | ,(println (java.uti.Date.)) |
| 10:10 | clojurebot | #<CompilerException java.lang.ClassNotFoundException: java.uti.Date, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:10 | pentester_ | , (csh "ls") |
| 10:10 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: csh in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:10 | clgv | ,(println (java.util.Date.)) |
| 10:10 | clojurebot | #inst "2014-05-22T14:05:00.215-00:00"\n |
| 10:10 | CookedGr1phon | aelse: pentester_ go try to break this instead and stop spamming our channel http://clojurescript.net/ |
| 10:10 | CookedGr1phon | or at least do it in a private message, you won't get through to anything useful |
| 10:11 | aelse | CookedGr1phon, it has been done |
| 10:11 | pentester_ | i want to play here .. |
| 10:12 | pentester_ | how to execute command in java? |
| 10:12 | pentester_ | rather than using sh .. |
| 10:13 | CookedGr1phon | try typing /quit to exit out into a shell and then you can enter destructive commands to your heart's content |
| 10:13 | clgv | pentester_: you didn't learn anything from your attempts before? |
| 10:13 | pentester_ | clgv: just little |
| 10:13 | aelse | pentester_, http://nelsonmorris.net/2012/09/06/breaking-lazybot-out-of-clojail.html |
| 10:14 | pentester_ | aelse: thanks .. |
| 10:14 | sojacques | justin_smith: Sorry, just saw your reply about sessions |
| 10:14 | sojacques | justin_smith: -> in fact I will commonly construct my response object as a series of transformations of the request -> Isn't the usually a String? |
| 10:14 | pentester_ | the language is not promising , and java are breakable by default .. |
| 10:14 | aelse | , (:out (clojure.java.shell/sh "whoami")) |
| 10:14 | clojurebot | #<CompilerException java.lang.ClassNotFoundException: clojure.java.shell, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:15 | aelse | , (clojail.jvm/jvm-sandbox (fn [] (:out (clojure.java.shell/sh "whoami"))) nil) |
| 10:15 | clojurebot | #<ClassNotFoundException java.lang.ClassNotFoundException: clojail.jvm> |
| 10:15 | sojacques | justin_smith: I started from this type of examples: https://github.com/weavejester/compojure |
| 10:19 | pentester_ | , (:out (clojure.java.lang.Runtime.exec "whoami")) |
| 10:19 | clojurebot | #<CompilerException java.lang.ClassNotFoundException: clojure.java.lang.Runtime.exec, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:20 | pentester_ | can someone explain me the return response from clojurebot? |
| 10:20 | pentester_ | (. (Runtime/getRuntime) exec "your-command-line-here") |
| 10:20 | pentester_ | , (. (Runtime/getRuntime) exec "your-command-line-here") |
| 10:20 | clojurebot | #<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:21 | clgv | pentester_: just stop it. there is a sandbox that prevents you from accessing the shell or files or start new processes |
| 10:21 | clgv | pentester_: start your own repl locally and try there |
| 10:21 | pentester_ | clgv: stop it? isn't this a challenge which require us to break it? |
| 10:22 | clgv | pentester_: you can do that by privately talking to clojurebot |
| 10:22 | pentester_ | kk |
| 10:27 | quizdr` | anyone know a good list of all the various interface one could use with reify to have a type extended? |
| 10:28 | quizdr` | Like IFn etc |
| 10:29 | clgv | quizdr`: the clojure/lang/ directory on github? ;) |
| 10:30 | clgv | quizdr`: without a specific goal you won't get better answers |
| 10:31 | quizdr` | clgv i'm just trying to understand what the basic Java terms would be since I guess you must use them when workign with reify, and I'm curious how it all works |
| 10:32 | clgv | quizdr`: can't follow you... |
| 10:33 | clgv | quizdr`: if you have a specific interop scenario you just use the needed interface with `reify` |
| 10:33 | quizdr` | i was going through a very basic Om tutorial and right away it was using reify so I figured I better learn what's going on there. IFn, etc are Java terms that don't really have meaning for me. So I was looking for a list of other similar terms so I could look up all the various kinds of reify I am likely to encounter |
| 10:34 | clgv | Om is a ClojureScript library, so you shouldnt be forced to learn java ;) |
| 10:34 | clgv | quizdr`: clojure.lang.IFn is a Clojure(Script) implementation detail |
| 10:35 | quizdr` | sure, but it is also used a lot with reify, so it's one of those implementation details I should know about |
| 10:35 | llasram | clgv: I wouldn't say that. As of Clojure 1.6 it's part of the official JVM public API |
| 10:35 | clgv | llasram: but from his point of view it remains some implementation detail ;) |
| 10:36 | clgv | quizdr`: I dont think a list of all java interfaces would help you at all for learning CLJS and Om ;) |
| 10:37 | quizdr` | well a lot of the reify examples are Java not JS so it would help me understand those tutorials, which would help me understand reify |
| 10:38 | llasram | All reify does is return an instance of an anoymous type which implements the specified interfaces/protocols |
| 10:38 | clgv | quizdr`: but to understand reify you do not need a list of available interfaces ;) |
| 10:38 | arrdem | lol @ pentester_ |
| 10:39 | quizdr` | is reify essentially doing the same thing as extend-type, except that the type is anonymous? that is, it's like a single instance of a type that you would not likely re-use? |
| 10:41 | llasram | quizdr`: s,extend-type,deftype, and s,like re-use,need to refer to by type name, But otherwise yes |
| 10:42 | clgv | llasram: lol you need that search-replace feature of lazybot which seems to be turned off ;) |
| 10:42 | llasram | Each instance of `reify` in your code produces a distinct anonymous type at compile-time. Each invocation of the compiled expression produces one instance of that type |
| 10:43 | quizdr` | ok, looking at more examples now |
| 10:43 | llasram | clgv: Eh. I'm not sure a bot repeating w/ replacement would really be that helpful |
| 10:44 | clgv | llasram: well he did this some time ago. |
| 10:45 | pkothbauer | Can anyone help with a simple core.logic noob question? Check this gist: https://gist.github.com/pkothbauer/b77dead2a024055c4dcf |
| 10:50 | quizdr` | has anyone used Datomic with Heroku? |
| 11:07 | justin_smith | quizdr`: I'll bet technomancy will have some input on that |
| 11:39 | CookedGr1phon | Is there such a thing as a first in-last out buffer in core.async? |
| 11:40 | justin_smith | CookedGr1phon: that's the same as last in first out right? |
| 11:40 | CookedGr1phon | yeah |
| 11:43 | CookedGr1phon | so is tehre a last in first out channel buffer? |
| 11:44 | justin_smith | I don't find one, but I think you could make something that behaves that way by pairing up an in channel and an out channel with a vector that you push and pop on respectively based on the channel activity |
| 11:45 | justin_smith | (with special case for empty of course...) |
| 11:50 | CookedGr1phon | that could work, thanks |
| 11:51 | clgv | a dropping stack channel sounds like an exotic use case |
| 11:53 | pbostrom | I have a seq of no arg fns, I want to call each fn in the seq, is there an alternative to (map #(%) (fn1 fn2 fn3)), i.e. is there an actual named function that does #(%) |
| 11:54 | llasram | pbostrom: nope |
| 11:54 | clgv | pbostrom: no, that is as short as you can get |
| 11:54 | clojurebot | Roger. |
| 11:54 | llasram | clojurebot: no, that? |
| 11:54 | clojurebot | Cool story bro. |
| 11:54 | llasram | clojurebot: that? |
| 11:54 | clojurebot | that is weird |
| 11:54 | clgv | see clojurebot agrees ;) |
| 11:55 | llasram | clojurebot: that? |
| 11:55 | clojurebot | that is weird |
| 11:55 | CookedGr1phon | pbostrom: have you looked at juxt |
| 11:55 | clgv | and what about lazybot??? |
| 11:55 | lazybot | clgv: Yes, 100% for sure. |
| 11:55 | CookedGr1phon | pbostrom: fairly sure you could just do ((juxt fn1 fn2 fn3)) |
| 11:55 | CookedGr1phon | or ((apply juxt [fn1 fn2 fn3])) |
| 11:56 | clgv | not much shorter though ;) |
| 11:56 | llasram | I think mapping with #(%) is clearer |
| 11:56 | clgv | and not lazy if that was the intention |
| 12:10 | rasmusto | (inc applyjuxt) |
| 12:10 | lazybot | ⇒ 1 |
| 12:19 | pbostrom | clgv, CookedGr1phon, llasram : thanks, wasn't sure if there was an actual 'call' function |
| 12:21 | justin_smith | ,((apply juxt [+ *])) |
| 12:21 | clojurebot | [0 1] |
| 12:23 | clgv | ,(map (memfn invoke) [+ *]) |
| 12:23 | clojurebot | (0 1) |
| 12:24 | clgv | not very idiomatic though |
| 12:25 | gfredericks | ,(map deliver [+ *]) |
| 12:25 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/deliver> |
| 12:26 | clgv | ,(#(% %) identity) |
| 12:26 | clojurebot | #<core$identity clojure.core$identity@1555d95> |
| 12:29 | clgv | why does ('a 1) work anyway? I though only keywrds are supposed to look up themselves in maps |
| 12:31 | gfredericks | because symbols are also supposed to |
| 12:35 | clgv | gfredericks: what for? |
| 12:35 | clgv | same reason as for keywords? because they are usually not mention when the keyword map access rule is stated |
| 12:37 | clgv | several times already I called a symbol with one argument instead the corresponding function and did not notice immediately - not before debugging (functions are specified in the configuration as symbols) |
| 12:38 | lxol | list |
| 12:40 | gfredericks | clgv: I assume the same reason, just with a lot less expected use; but I could imagine it being useful for dealing with forms as data a lot |
| 12:41 | clgv | gfredericks: well currently I am aware to check if I forgot to resolve the symbol to the function if I get nil from the evaluation. |
| 12:44 | gfredericks | clgv: I didn't quite understand that |
| 12:44 | clgv | gfredericks: ##('a :anything) |
| 12:44 | lazybot | ⇒ nil |
| 12:44 | clgv | ,('inc :anything) |
| 12:44 | clojurebot | nil |
| 12:45 | gfredericks | sure; I just couldn't tell if that was a question or an objection or something |
| 12:46 | clgv | gfredericks: the realization that I forgot to resolve the function again and did not get an immediate error annoyed me ;) |
| 12:47 | clgv | I had to track down the resulting NPE ... |
| 12:47 | gfredericks | ah right |
| 12:51 | gfredericks | hey here's a fun nrepl middleware |
| 12:52 | gfredericks | provide an erlc-style alternative to *1 *2 *3 where evals get absolute numbers |
| 12:52 | gfredericks | so you can reference arbitrarily old stuff |
| 12:52 | arrdem | oh nice! |
| 12:52 | arrdem | gfredericks: link? |
| 12:52 | gfredericks | it's in my head |
| 12:53 | gfredericks | "here's" == "here's an idea I just thought of" |
| 12:53 | arrdem | wolfram notebook style :P |
| 12:53 | arrdem | I like |
| 12:53 | arrdem | dbasch: does your tipping site have a way to put bounties on a project? |
| 12:53 | gfredericks | you could also provide some sort of GC mechanism, if you could detect uses |
| 12:54 | gfredericks | dammit Var is a final class |
| 12:55 | gfredericks | I wonder what would happen if you interned something other than a var in a namespace |
| 12:55 | l1x | https://twitter.com/ML_Hipster/status/438418306769244160 |
| 12:59 | clgv | ,(intern *ns* 'foo 42) |
| 12:59 | clojurebot | #'sandbox/foo |
| 12:59 | clgv | ,foo |
| 12:59 | clojurebot | 42 |
| 13:00 | clgv | ,(-> *ns* ns-interns 'foo type) |
| 13:00 | clojurebot | clojure.lang.PersistentList |
| 13:00 | clgv | ,(-> *ns* ns-interns (get 'foo) type) |
| 13:00 | clojurebot | clojure.lang.Var |
| 13:00 | clgv | gfredericks: ^^ |
| 13:07 | gfredericks | ,(.mappings *ns*) |
| 13:07 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: mappings for class clojure.lang.Namespace> |
| 13:09 | gfredericks | I bet mucking with the mappings map of a namespace could let you do some pretty ninja stuff |
| 13:09 | gfredericks | lazy vars for one |
| 13:12 | gfredericks | ,(-> *ns* class .getDeclaredFields (->> (filter (comp #{"mappings"} (memfn getName))) first) (.get *ns*)) |
| 13:13 | clojurebot | #<AtomicReference {primitives-classnames #'clojure.core/primitives-classnames, +' #'clojure.core/+', Enum java.lang.Enum, decimal? #'clojure.core/decimal?, restart-agent #'clojure.core/restart-agent, ...}> |
| 13:13 | gfredericks | ,(-> *ns* class .getDeclaredFields (->> (filter (comp #{"mappings"} (memfn getName))) first) (.get *ns*) deref) |
| 13:13 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.util.concurrent.atomic.AtomicReference cannot be cast to java.util.concurrent.Future> |
| 13:31 | adilaaw | free valide cc plz |
| 13:43 | clgv | ,(-> *ns* class .getDeclaredFields (->> (filter (comp #{"mappings"} (memfn getName))) first) (.get *ns*) .get) |
| 13:43 | clojurebot | {primitives-classnames #'clojure.core/primitives-classnames, +' #'clojure.core/+', Enum java.lang.Enum, decimal? #'clojure.core/decimal?, restart-agent #'clojure.core/restart-agent, ...} |
| 14:46 | arrdem | someone convince me not to just convert this entire AST to a pointer shared transient structure |
| 14:46 | rasmusto | don't do it! |
| 14:47 | arrdem | rasmusto: that's not convincing tho. |
| 14:47 | rasmusto | arrdem: I tried. |
| 14:47 | arrdem | the from a usability and a performance standpoint I should totally do this with in place mutability. |
| 14:48 | arrdem | no reason to eat an O(N) tree traversal when I could do an O(1) pointer update. |
| 14:48 | Bronsa | arrdem: if it makes you feel better internally in t.a.j I sometimes use an atom to avoid walking the AST needlessly |
| 14:49 | arrdem | Bronsa: I'm gonna take a break, breath, and then probably build a fully transient AST from your nice output. I'm sorry. |
| 14:49 | Bronsa | sounds exciting. |
| 14:49 | arrdem | I'll let you know when I shoot my foot off |
| 14:50 | splunk | anybody know how to declare a new type in core.typed? Suppose you wanted a `Path` that a subtype of `String`, and not merely an alias for a String |
| 14:50 | arrdem | splunk: I don't, but #typed-clojure may |
| 14:50 | splunk | arrdem: awesome thanks |
| 14:50 | amalloy | you're looking for haskell's newtype in core.typed? |
| 14:51 | splunk | amalloy: mmm, I think data Foo = Foo String in Haskell |
| 14:51 | splunk | but I don't really actually know Haskell |
| 14:51 | splunk | I think that'll create a Foo using a String, but henceforth that Foo != that String, I think? |
| 14:52 | amalloy | yes, although i'd use newtype instead of data there, probably |
| 14:52 | splunk | I love that I learn more about Haskell walking in here :) |
| 14:52 | splunk | thx |
| 14:52 | amalloy | it's an interesting idea. i dont know enough about core.typed to tell you whether it's possible; it seems a bit tricky |
| 14:53 | llasram | It does seem like it's conceptually possible though -- it'd all just be type-checking time fiction |
| 14:57 | arrdem | hyPiRion: I'm probably pushing my luck but so be it |
| 14:58 | hyPiRion | arrdem: I just find it funny that people complain about printers when I've tried to fix a printer driver the whole day as the university printer refuses to print my master's pdf. |
| 14:59 | technomancy | it took me two days to get my laser at home working |
| 14:59 | splunk | I'm super hopeful core.typed will work out, I think it has a lot of potential to alleviate some of the heavy mocking and stubbing that's going on in the dynamic language world |
| 14:59 | pkothbauer | Hi! Anyone with familiarity of core.logic are to answer a newbie question? http://stackoverflow.com/q/23811409/3506009 |
| 14:59 | pkothbauer | *care to answer* |
| 15:00 | hyPiRion | arrdem: and you're not pushing your luck, you have no chance of convincing bitemyapp either way :p |
| 15:00 | cbp` | pkothbauer: you can try posting on the mailing list if no one helps you here |
| 15:00 | arrdem | hyPiRion: at some point I'm gonna give in to my desire to countertroll |
| 15:01 | hyPiRion | technomancy: funny thing is, it works fine at home |
| 15:01 | pkothbauer | @cbp okay thanks! |
| 15:12 | yedi | i read somewhere that I should look at sigmas like the for loops they are and now they're so easy to read |
| 15:22 | cbp | not a for loop, a for comprehension :-p |
| 15:27 | Fare | Hi. |
| 15:28 | Fare | I'm trying to use reflection to load & call clojure from java, and am getting a null pointer exception at my first call to Symbol.intern. |
| 15:28 | Fare | Do I need to somehow initialize Clojure first? And if so, how do I do that? |
| 15:29 | Fare | or am I just calling it wrong? |
| 15:30 | Fare | probably just calling it wrong |
| 15:32 | stuartsierra | Before the public Java API in Clojure 1.6, you had to "initialize" the Clojure runtime by referencing the class clojure.lang.RT in your code. |
| 15:32 | cbp | Fare: are you using 1.6? |
| 15:34 | Fare | yes, 1.6 |
| 15:34 | Fare | I managed to call Symbol.intern. Now having "fun" with Var.intern. |
| 15:34 | cbp | oh |
| 15:35 | llasram | If you're using 1.6, no need to do that |
| 15:35 | llasram | https://github.com/clojure/clojure/blob/master/changes.md#21-java-api |
| 15:35 | llasram | Although you shouldn't need to call Var.intern even on older versions |
| 15:37 | Fare | and failing to find read-string — in which namespace is it? |
| 15:38 | Fare | and how do I ask the repl? |
| 15:39 | llasram | In the REPL you can refer to the var to see it's namespace |
| 15:39 | llasram | ,#'read-string |
| 15:39 | clojurebot | #'clojure.core/read-string |
| 15:39 | waynr | is there a simple way to get the 'uberjar' task to prefer locall installed/cached copies of dependency jars? |
| 15:40 | Fare | Caused by: java.io.FileNotFoundException: Could not locate clojure/core__init.class or clojure/core.clj on classpath: |
| 15:41 | llasram | Fare: Well that's fun :-) |
| 15:41 | Fare | interestingly, the second time I try to intern the Var, it works! |
| 15:41 | Fare | WTF |
| 15:42 | Fare | clojure-1.6.0.jar |
| 15:43 | waynr | hmm maybe :offline true |
| 15:43 | Fare | but of course, if I try to call it, I get: Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/read-string |
| 15:44 | arrdem | do you know if the clojure core has been loaded yet? there's still init code that does that which may need to be invoked. |
| 15:44 | Fare | arrdem, how do I tell? and how do I load it? |
| 15:45 | Fare | if clojure needs to be initialized... oops |
| 15:45 | arrdem | clojure.lang.RT.doInit() |
| 15:45 | llasram | You really shouldn't need to call that yourself |
| 15:46 | llasram | Just use the clojure.java.api.Clojure class, or methods on clojure.lang.RT for <1.6 |
| 15:47 | cbp | ClassCastException appointment.tree.Schedule cannot be cast to appointment.tree.Schedule |
| 15:47 | llasram | Static initializers will ensure clojure.core is loaded before you try to access its functions |
| 15:47 | cbp | hmm yes indeed makes sense |
| 15:47 | Bronsa | cbp: double evaluation of deftypes probably |
| 15:47 | cbp | Bronsa: ah |
| 15:49 | Fare | maybe there's a problem with my class loader? |
| 15:50 | llasram | Fare: Can you gist the actual code you're trying to run? |
| 15:51 | Fare | llasram: I can even copy/paste it all. It's a trivial test program that uses a URLClassLoader and reflection to (1) load clojure.jar, (2) extract references to read-string and eval, and (3) tries to use them to hello world with clojure. |
| 15:51 | Fare | a bit like clojure.java.api.Clojure, but using reflection because it's all dynamically loaded. |
| 15:57 | llasram | Ok -- let's see it :-) |
| 15:58 | Fare | where is the right place to paste it? |
| 15:59 | llasram | refheap.com or a github gist |
| 16:00 | Fare | http://paste.lisp.org/+322O |
| 16:00 | arrdem | seriously. refheap in future. |
| 16:00 | Fare | to use it, just edit the URL to your clojure.jar |
| 16:01 | Fare | and watch it fail :-( |
| 16:05 | llasram | Fare: Yeah, I believe you are circumventing everything which would cause `clojure.core` to be loaded |
| 16:05 | llasram | The good news is that I don't believe there's any good reason to be doing so |
| 16:06 | Fare | llasram, whatever I'm doing or failing to do is out of ignorance |
| 16:06 | Fare | that's my first java program |
| 16:06 | llasram | In your `var` method, just reflection-invoke the `Clojure.var` or `RT.var` instead of manually fiddling with namespaces |
| 16:07 | llasram | Invoking a static method of either of those classes will cause the static initializers to run which actually get Clojure rolling |
| 16:07 | llasram | Nope |
| 16:08 | llasram | THat's a namespace, not a class |
| 16:08 | Fare | oh |
| 16:08 | llasram | And (unless I'm mistaken), the ClassLoader.loadClass method does not cause the class's static initializers to run |
| 16:09 | Fare | how do I run the initializers? |
| 16:10 | llasram | Creating an instance of the class or invoking a static method will do the trick. Passing `true` as a second arg to the loadClass method may also work |
| 16:10 | llasram | There the boundaries of my knowledge end |
| 16:13 | Fare | ok — but (1) which class(es) should I thus be instantiating? |
| 16:13 | Fare | regarding passing true: test.java:90: loadClass(java.lang.String,boolean) has protected access in java.lang.ClassLoader |
| 16:15 | llasram | Ok. So just call `Clojure.var` instead of doing the manually fiddling |
| 16:16 | joegallo | perhaps consider http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#forName%28java.lang.String%29 (and the other arity that allows you to pass a ClassLoader) |
| 16:17 | llasram | Ah! Good call |
| 16:19 | Fare | joegallo, my understanding is that forName will not use my URLClassLoader |
| 16:20 | Fare | oh wait, there is another function of same name and different arity |
| 16:20 | joegallo | why wouldn't it? you can pass a classloader as the third arg to the second arity... |
| 16:26 | Fare | yes, yes, yes, I was reading the docs for the wrong method |
| 16:27 | Fare | still, I get the same error: Caused by: java.io.FileNotFoundException: Could not locate clojure/core__init.class or clojure/core.clj on classpath: at clojure.lang.RT.load(RT.java:443) |
| 16:31 | benkay | i'd like to run just one test with clojure-test-mode in emacs, any protips? |
| 16:31 | benkay | oh clojure-run-test >.< |
| 16:34 | benkay | grr but clojure-test-run-test seems to not handle fixtures? |
| 16:35 | llasram | A known outstanding issue, generally perceived to be a problem with the way clojure.test does fixtures |
| 16:35 | benkay | oh :( |
| 16:35 | llasram | Fare: Yeah, I'm at a loss. OOC why the wacky URLClassLoader fun? |
| 16:36 | benkay | thanks llasram. any workarounds? |
| 16:36 | Fare | Solution was here: http://dev.clojure.org/jira/browse/CLJ-260 |
| 16:36 | llasram | benkay: Pretty much just the obvious ones -- either don't use fixtures, or always run all tests in a namespace |
| 16:36 | Fare | Thread.currentThread().setContextClassLoader(loader); |
| 16:37 | benkay | okay. thanks llasram ! |
| 16:39 | llasram | Fare: Cool. |
| 16:40 | Fare | one more thing, though: clojure's print("hello world") went to /dev/null :-( |
| 16:40 | Fare | how do I configure the clojure stdin/stdout? |
| 16:40 | technomancy | are you sure it's not just buffered? |
| 16:40 | technomancy | try flushing or printing a newline |
| 16:41 | Fare | out.println(ReadEval("(* 6 7)")); does print 42 |
| 16:41 | amalloy | i bet he knows it went to /dev/null because he's readnig /dev/null from another process and saw the output |
| 16:41 | Fare | but ReadEval("(print \"Hello, World!\\n\")"); doesn't seem to do anything |
| 16:46 | technomancy | amalloy: there should be something that's the opposite of /dev/null |
| 16:46 | technomancy | instead of sending output to no file, it sends it to *every* file |
| 16:47 | amalloy | technomancy: when you read from it, you get whatever input you were hoping for |
| 16:47 | technomancy | I bet plan9 supports this. |
| 16:48 | dbasch | technomancy: you need /dev/pi, just read and wait until you find what you want |
| 16:51 | hyPiRion | dbasch: wouldn't that break like, literally all copyrights in the world? |
| 16:52 | dbasch | hyPiRion: worse, you could be jailed for possesion of all kinds of illegal information |
| 16:52 | jcromartie | I tried to use Clojure in an Atlassian plugin… but that is not going to fly apparently |
| 16:52 | hyPiRion | jail all the things |
| 16:54 | arrdem | literally infinite sentence! |
| 17:05 | jcromartie | I'm not sure but I don't think this is going to work... |
| 17:05 | jcromartie | making an uberjar of the dependencies for Atlassian plugins... |
| 17:05 | jcromartie | that's just overkill |
| 17:06 | arrdem | true story: one time I made a single jar with all the dependencies and package jars for Eclipse |
| 17:12 | rasmusto | hrm, I'm getting a stack overflow in my loop/recur... |
| 17:13 | rasmusto | my recur step is uh, conj onto a vector, take the rest of a lazy seq, and update a map |
| 17:13 | arrdem | source or you're just raving like I am |
| 17:14 | amalloy | $google stackoverflow clojure prime sieve dbyrne |
| 17:14 | lazybot | [recursion - Recursive function causing a stack overflow - Stack ...] http://stackoverflow.com/questions/2946764/recursive-function-causing-a-stack-overflow |
| 17:14 | amalloy | ^ for rasmuto |
| 17:15 | rasmusto | amalloy: I wonder what my equivalent "filter" is |
| 17:15 | amalloy | it's probably concat |
| 17:15 | arrdem | definitely concat |
| 17:15 | rasmusto | k |
| 17:16 | rasmusto | I have update-in, zipmap, but yeah |
| 17:16 | arrdem | lazy-seqs ftw |
| 17:16 | rasmusto | concat probably :D |
| 17:16 | amalloy | rasmusto: if you pasted the code it would be a matter of seconds to identify |
| 17:17 | rasmusto | amalloy: https://www.refheap.com/b8a1eda51a44aee5b9907eddf |
| 17:18 | amalloy | what the shit |
| 17:18 | amalloy | but yes, it's your merge-with concat |
| 17:18 | amalloy | instead, use vectors and merge-with into |
| 17:19 | rasmusto | amalloy: okay |
| 17:19 | rasmusto | amalloy: what "what the shit" btw? |
| 17:19 | amalloy | it's huge and messy |
| 17:19 | rasmusto | I know it's a bit weird :p |
| 17:19 | rasmusto | hah, ok |
| 17:19 | arrdem | rasmusto: helper functions man |
| 17:19 | rasmusto | rgr, this is a first pass |
| 17:20 | arrdem | :+1: do it then do it right. I need that tattooed to my forearms where I can see it when I type. |
| 17:20 | rasmusto | arrdem: another thing, allllways start with a loop/recur |
| 17:23 | dbasch | see the comment at the bottom of http://clojuredocs.org/clojure_core/clojure.core/vals |
| 17:23 | dbasch | why should that be true? |
| 17:23 | dbasch | “Functions keys and vals return sequences such that (= (zipmap (keys m) (vals m)) m)" |
| 17:24 | dbasch | does anything guarantee that to be always true? |
| 17:24 | arrdem | dbasch: keys is (map first <map>), vals is (map second <map>), zipmap is (into {} (map vector key-seq val-seq)) |
| 17:24 | arrdem | dbasch: intuitively it must be a round trip operation |
| 17:25 | amalloy | dbasch: rich said it once, so it's true. for some reason nobody wants to put it in any official docs |
| 17:25 | dbasch | arrdem: in theory you cannot guarantee order |
| 17:26 | arrdem | dbasch: sure, but key/value order is not guranteed on maps |
| 17:26 | dbasch | what made me think about this is the ugly implementation of map-values here http://aphyr.com/posts/312-clojure-from-the-ground-up-modeling |
| 17:26 | arrdem | dbasch: you could argue that the internal structure depends on insertion order reasonably in which case I'll mutter mumbo jumbo about hashing based equality and pray to Rich that it keeps working. |
| 17:27 | dbasch | which could be a one-liner with (zipmap (keys m) (map f (vals m)) |
| 17:28 | amalloy | dbasch: i do prefer the way aphyr does it to using zipmap, although 'for is a lot nicer than map |
| 17:28 | amalloy | (into {} (for [[k v] m] [k (f v)])) |
| 17:29 | dbasch | that is a long post |
| 17:30 | arrdem | that is also guaranteed to use transients in the map construction for what it's worth, although the values will be computed strictly. |
| 17:30 | arrdem | dbasch: fun one tho |
| 17:31 | dbasch | yes, it’s a good post |
| 17:31 | arrdem | orbital insertion maneuvers in Clojure aw man... :D |
| 17:31 | dbasch | this is not so great, it was on HN earlier http://elegantcode.com/2014/04/29/clojure-kata-3-roman-numerals-2/ |
| 17:32 | dbasch | the most convoluted way of converting to roman numerals I’ve seen |
| 17:36 | jcromartie | woah… (defn camelCaseNames ?) |
| 17:36 | jcromartie | no |
| 17:39 | dbasch | if I worked at github I’d write a script to find the longest java class names in all their repos |
| 17:40 | gfredericks | dbasch: probably generated |
| 17:40 | dbasch | maybe InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState |
| 17:40 | amalloy | oh man, roman numerals. three years ago i wrote https://github.com/amalloy/claudius/blob/master/src/claudius/core.clj - pretty funny |
| 17:43 | gfredericks | oh are we showing off old clojure code |
| 17:43 | dbasch | mildly interesting interview question: given a dictionary, find all the words that are valid roman numerals |
| 17:44 | ztellman | dbasch: that's a regex construction question, right? |
| 17:44 | gfredericks | here's some project euler code I found from probably fifty years ago: https://www.refheap.com/85808 |
| 17:44 | gfredericks | that has to be some of the first clojure code I wrote |
| 17:44 | dbasch | ztellman: is it? here, I’ll erase the board for you :P |
| 17:45 | ztellman | dbasch: ha, I don't have the time right now to dig into it, I was just wondering if it required going higher up Chomsky's hierarchy |
| 17:45 | dbasch | ztellman: http://stackoverflow.com/questions/267399/how-do-you-match-only-valid-roman-numerals-with-a-regular-expression |
| 17:45 | gtrak | amalloy: cake template.. lol |
| 17:45 | ztellman | ha |
| 17:45 | gtrak | actually I never got a chance to use it. |
| 17:46 | dbasch | I’d just want to see how the person thinks, because it could be solved in different ways |
| 17:47 | gfredericks | (defn roman-numeral? [word] (re-find #"X" word)) |
| 17:47 | rasmusto | those ))) triangles are so cute :) |
| 17:47 | gfredericks | rasmusto: I was just wondering to myself where on earth I would have gotten the idea to do that |
| 17:47 | amalloy | gfredericks: i was reading that thinking like "wow he sure is defining a lot of functions, how can you possibly need all of these to solve one euler problem" |
| 17:47 | gfredericks | surely I had read somebody else's clojure code by then |
| 17:47 | gfredericks | amalloy: and I gave them all great names like p16 |
| 17:47 | amalloy | well, it was before i got that far |
| 17:48 | gfredericks | oooh I had a prelude didn't I |
| 17:48 | rasmusto | gfredericks: I do it sometimes, since I haven't fully embraced structural editing and like to move full lines of code around |
| 17:48 | gfredericks | that would be amusing if there was an euler problem that needed all of those functions |
| 17:48 | amalloy | i was like, what problem needs fibonacci numbers, conversion to binary strings, factorial, and prime factorization |
| 17:48 | amalloy | and palindromes! |
| 17:48 | SegFaultAX | amalloy: Reading what now? I missed the link. |
| 17:49 | amalloy | SegFaultAX: some code gfredericks wrote when he was an infant. https://www.refheap.com/85808 |
| 17:49 | rasmusto | oh, just noticed the (defn [] p12 (println ...)) |
| 17:49 | dbasch | gfredericks: a semi-cryptic scrolling game of life https://www.refheap.com/85809 |
| 17:49 | arrdem | https://www.refheap.com/85808#L-30 tearz |
| 17:49 | SegFaultAX | Hah. Those parens, yo... |
| 17:50 | gfredericks | arrdem: what aspect of that are we weeping over? |
| 17:50 | arrdem | hey at least all that code is easy to compile :P |
| 17:50 | arrdem | gfredericks: the apply over a huge sequence, but I guess the core * uses reduce so it works out |
| 17:51 | gfredericks | not too huge |
| 17:51 | SegFaultAX | arrdem: Yea in fairness that's basically a mathematical translation of factorial. |
| 17:51 | amalloy | arrdem: huh? (apply * (take n (iterate inc 1))) is a reasonable way to multiply stuff |
| 17:51 | gfredericks | what kind of numbers do you pass to factorial? |
| 17:52 | amalloy | gfredericks: integers |
| 17:52 | arrdem | gfredericks: ones with units and exponents :D |
| 17:52 | rasmusto | 3.14! |
| 17:52 | gfredericks | thaht was a question for arrdem about why he thought it was a long sequence |
| 17:52 | amalloy | i guess the alternative would be to accept your possible joke setup: "I dunno, gfredericks. What kind of numbers *do* you pass to factorial?" |
| 17:53 | gfredericks | dominoes!!! |
| 17:53 | amalloy | ,(apply *' (range 10000)) |
| 17:53 | clojurebot | 0 |
| 17:53 | amalloy | ,(apply *' (range 1 10000)) |
| 17:53 | clojurebot | 2846259680917054518906413212119868890148051401702799230794179994274411340003764443772990786757784775815884062142317528830042339940153518739052421161382716174819824199827592418289259787898124253120594659962598670656016157203603239792632873671705574197596209947972034615369811989709261127750048419884541047554464244213657330307670362882580354896746111709736957860367019107151273058728104115864056128116... |
| 17:53 | arrdem | lololol |
| 17:53 | amalloy | large sequences are fine |
| 17:53 | SegFaultAX | ,(source clojure.core/*') |
| 17:53 | clojurebot | Source not found\n |
| 17:54 | arrdem | SegFaultAX: line 967 |
| 17:55 | gfredericks | amalloy: yeah at some point the bigint multiplication will take more time than the sequence overhead eh |
| 17:55 | amalloy | pretty damn quickly, i would guess |
| 17:55 | amalloy | ,(time (dorun (range 1 100000))) |
| 17:55 | clojurebot | "Elapsed time: 67.798386 msecs"\n |
| 17:55 | arrdem | quick add more zeros |
| 17:55 | amalloy | ,(let [xs (doall (range 1 100000))] (time (apply *' xs))) |
| 17:55 | clojurebot | Execution Timed Out |
| 17:56 | amalloy | apparently bigints are big |
| 17:57 | gfredericks | soooo big |
| 17:57 | gfredericks | ,(let [xs (doall (range 1 10000))] (time (apply *' xs))) |
| 17:57 | clojurebot | "Elapsed time: 329.470126 msecs"\n284625968091705451890641321211986889014805140170279923079417999427441134000376444377299078675778477581588406214231752883004233994015351873905242116138271617481982419982759241828925978789812425312059465996259867065601615720360323979263287367170557419759620994797203461536981198970926112775004841988454104755446424421365733030767036288258035489674611170973695786036701... |
| 17:58 | gfredericks | ,````foo |
| 17:58 | clojurebot | (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/seq)) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/concat)) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/list)) (clojure.core/list (clojure.core/seq #))))) (clojure.core/list (clojure.core/seq (clojure.core/concat (clo... |
| 17:58 | gfredericks | ,``foo |
| 17:58 | clojurebot | (quote sandbox/foo) |
| 17:59 | gfredericks | I'm just wondering to myself if there's a way to rewrite ` so it works the same for cases that matter but doesn't have exponential blowup |
| 19:11 | cbp | Does anyone have an interval tree implementation laying around? :-P None of the ones i found on the internets seem to work well. |
| 19:12 | master_op | hello , i'm new in clojure, i want to some a values of a hashmap like this {:a 1 :b 2} |
| 19:12 | master_op | i want to get 3 as result |
| 19:12 | technomancy | ,(apply + (keys {:a 1 :b 2})) |
| 19:12 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number> |
| 19:12 | Fare | load-string is what I wanted! how do I join strings in Java? |
| 19:12 | technomancy | derp |
| 19:12 | technomancy | ,(apply + (vals {:a 1 :b 2})) |
| 19:12 | clojurebot | 3 |
| 19:12 | cbp | Guess I gotta dust off that algo book |
| 19:12 | master_op | thks |
| 19:13 | cbp | :-( |
| 19:15 | dbasch | Fare: the old way was to create a StringBuffer and append to it, there might be a better way now |
| 19:16 | amalloy | dbasch, Fare: these days StringBuffer is little used; StringBuilder is preferred for building strings (StringBuffer is more like for built strings that you want to mutate) |
| 19:17 | dbasch | amalloy: I think StringBuilder is not thread safe or something like that |
| 19:17 | cbp | StringBuffer isnt threadsafe |
| 19:17 | dbasch | probably doesn[t matter in this case |
| 19:18 | cbp | er |
| 19:18 | cbp | i mean yes STringbuilder isnt threadsafe |
| 19:20 | amalloy | dbasch: that's sorta why it's preferred. don't pay for synchronization overhead when all you're doing is incrementally building a string locally |
| 19:20 | amalloy | just like how Vector was superseded by the unsynchronized ArrayList and so on |
| 19:24 | arrdem | forget synchronization overhead you don't pay for rendering the entire string to a single byte buffer until you choose to. StringBuilder uses ropes and has awesome concat performance because of it. Building the string at the end is a single O(N) buffer copy which is cheap compared to buffer resizing. |
| 19:36 | dbasch | in a way I’m glad I’m starting to forget Java :P |
| 19:36 | dbasch | a couple of years ago I saw a preview presentation of the functional features in Java 8 and thought it looked really ugly |
| 20:09 | justin_smith | it's ugly but imho it is soo much better than what was there before |
| 20:09 | justin_smith | I even managed to use a reduce in some java code the other day |
| 20:10 | justin_smith | (faint praise, I know) |
| 20:11 | Fare | Hi! |
| 20:11 | Fare | how do I call System.out.println from clojure? |
| 20:12 | beamso | println |
| 20:12 | Fare | (.out System) is an error |
| 20:12 | justin_smith | ,(.println System/out "hello") |
| 20:12 | clojurebot | nil |
| 20:13 | beamso | justin_smith: i used java 8 streams the other day as well. having to call .stream() to get something to call .map() or .reduce() on was weird. same with calling .collect to get a list back. |
| 20:13 | justin_smith | println will be more likely to use the current clojure output stream |
| 20:13 | Fare | why is System/out and not System.out ? |
| 20:13 | justin_smith | Fare: static method on the class |
| 20:14 | justin_smith | ,System/out |
| 20:14 | clojurebot | #<PrintStream java.io.PrintStream@1411c67> |
| 20:14 | justin_smith | err.. static field that is |
| 20:14 | justin_smith | println being the static method on that static field |
| 20:15 | justin_smith | beamso: yeah, it is awkward, but it's better than what we could do in java 7 |
| 20:15 | justin_smith | ,(println "Fare: this is what you should actually use) |
| 20:15 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading string> |
| 20:15 | justin_smith | err |
| 20:15 | justin_smith | ,(println "Fare: this is what you should actually use") |
| 20:15 | clojurebot | Fare: this is what you should actually use\n |
| 20:16 | justin_smith | $source println |
| 20:16 | lazybot | println is http://is.gd/ewuFP7 |
| 20:17 | Fare | justin_smith, thanks a whole lot |
| 20:17 | Fare | I'm learning both Java and Clojure at the same time |
| 20:17 | justin_smith | ahh, that's tricky |
| 20:17 | justin_smith | I learned clojure first, and am finally learning java right now (for career reasons) |
| 20:18 | Fare | I just completed my very first Java program: it dynamically loads clojure.jar and load-string's the arguments. |
| 20:23 | Fare | I'm just not sure what is the best way to specify where the jar is located. Right now, it's hardwired in the source code... meh |
| 20:23 | Fare | what would "best practices" be for parsing arguments, using environment variables, and/or hardwiring a default? |
| 20:24 | Fare | ideally, the default would be decided at compile-time but not hardwired in the source code. |
| 20:25 | turbofail | the "best practice" i believe is to use clojure.tools.cli, which is a separate library |
| 20:26 | turbofail | https://github.com/clojure/tools.cli |
| 20:26 | technomancy | for one or two args it's fine to just apply hash-map on a bunch of strings |
| 20:26 | technomancy | and merge it into a defaults map |
| 20:27 | technomancy | but if you want proper --help output you should use a library |
| 20:28 | justin_smith | also consider a config.edn file |
| 20:28 | justin_smith | edn is easy to hand edit, super easy to parse |
| 20:29 | justin_smith | or config.json if you want it to be less easy but more widely recognized by human users |
| 20:31 | hiredman | if only there was a configuration library that could use either |
| 20:31 | hiredman | https://github.com/sonian/carica/ |
| 20:31 | technomancy | carica takes CLI args? |
| 20:34 | hiredman | no idea |
| 20:52 | lemonodor | it’s not done yet, but this does package level command-line flags, and reads flags from files: https://github.com/wiseman/clj-gflags |
| 20:52 | lemonodor | sort of a port of google’s gflags library, if you know that. |
| 21:00 | justin_smith | ,(merge-with (partial merge-with merge-with) {:a 0 :b {:c 1}} {:b {:c {:d 2}}} {:b {:c {:d {:e 3}}}}) Fare I tried to show you this on ##java lol |
| 21:00 | clojurebot | {:b {:c {:d {:e 3}}}, :a 0} |
| 21:03 | amalloy | justin_smith: i wanna see a version that works for depths of up to six |
| 21:05 | justin_smith | (apply (fn m [& maps] (if (every? map? maps) (apply merge-with m maps) (apply f maps))) maps) |
| 21:05 | justin_smith | blatantly stolen |
| 21:06 | amalloy | nono, that works for arbitrary depth |
| 21:06 | amalloy | it should break for depths 7+ |
| 21:06 | amalloy | (i was teasing you for presenting a solution that works for up to depth 3 instead of the general solution) |
| 21:07 | justin_smith | yeah, I figured |
| 21:08 | amalloy | is it really just (merge-with (partial merge-with (partial merge-with ...)))? |
| 21:09 | woah | so, would you guys say that it is a requirement to know java to write good clojure or clojurescript? |
| 21:09 | amalloy | (nth (iterate (fn [f] (partial merge-with f)) merge) 5), maybe. it's starting to look like a fixed point |
| 21:11 | amalloy | yeah, it totally is. that's neat |
| 21:16 | arrdem | woah: nope |
| 21:17 | justin_smith | it helps to be able to read the docs for whichever backend you are targeting, (and to understand the VM) but clojure does a good job of working standalone |
| 21:17 | woah | cool |
| 21:17 | mdeboard | Dunno where to ask this question, but has anyone seen any good responses to cemerick's "Distributed Systems and the End of the API"? |
| 21:19 | mdeboard | I thought it was a really good introduction to CRDTs but want to read other viewpoints on the "demise of the API" bit |
| 21:19 | catern | also interested in that |
| 21:19 | catern | I am* |
| 21:22 | arrdem | danneu: you realize that paste of your *coin config was public, right? |
| 21:22 | beamso | mdeboard: maybe look at the HN thread for discussion/further reading points : https://news.ycombinator.com/item?id=7735141 |
| 21:28 | mdeboard | beamso: Hey, thanks |
| 21:36 | Fare | lemonodor, thanks a lot! |
| 21:36 | Fare | I realize that since it's flags for the small java runtime that loads clojure, though, it can't be written in clojure. |
| 21:43 | danielcompton | mdeboard I saw some negative comments here https://twitter.com/cemerick/status/466999122139299840 |
| 21:45 | mdeboard | danielcompton: Thanks |
| 21:45 | mdeboard | Would be nice if people would qualify their pooping-upon |
| 21:46 | danielcompton | mdeboard FWIW, I didn't agree with them |
| 21:46 | mdeboard | I mean I'm sur ethey have reasons, I just want to hear them haha |
| 21:46 | danielcompton | mdeboard nothing has been announced so I don't think those comments were very fair |
| 21:46 | danielcompton | (dec so) |
| 21:46 | lazybot | ⇒ -15 |
| 21:47 | mdeboard | who's so |
| 21:55 | danielcompton | mdeboard someone who keeps messing up the highlighting in my IRC client |
| 21:59 | mdeboard | danielcompton: lol |
| 22:01 | arrdem | mdeboard: downvoting him is our traditional equivalent to kicking that beater car you hate after you get out. |
| 22:01 | mdeboard | is this a real person |
| 22:01 | arrdem | nobody has cared enough to find out, but last time I tried it didn't respond to pings |
| 22:02 | mdeboard | how does he mess up your highlighting? I'm in the emacs/rcirc master race |
| 22:02 | arrdem | erc-nick-highlight picks up on him when used as a substring in normal conversation. |
| 22:02 | nullptr | hmm, i always assumed this channel just hated stack overflow |
| 22:03 | mdeboard | haha |
| 22:03 | mdeboard | that's so, so annoying |
| 22:03 | nullptr | ha, i'd never noticed the so highlighting until now |
| 22:03 | nullptr | (dec so) |
| 22:03 | lazybot | ⇒ -16 |
| 22:04 | technomancy | now you can never unsee it |
| 22:04 | arrdem | (dec so) |
| 22:04 | lazybot | ⇒ -17 |
| 22:06 | mdeboard | rcirc |
| 22:06 | mdeboard | do it. |
| 22:06 | mdeboard | You know you want to. |
| 22:06 | beamso | irssi ftw. |
| 22:08 | nullptr | erc is so simple though |
| 22:09 | nullptr | it's so easy to fix |
| 22:10 | quizdr | (dec so) |
| 22:10 | lazybot | ⇒ -18 |
| 22:10 | seangrove | So easy |
| 22:10 | seangrove | Not so simple |
| 22:10 | nullptr | hmm, that did work actually |
| 22:10 | nullptr | (add-to-list 'erc-keywords '("\\bso\\b" erc-default-face)) |
| 22:14 | Raynes | I don't think of ERC as either simple or easy. |
| 22:16 | danielcompton | circle dec'ing so on #clojure |
| 22:16 | seangrove | Raynes: Well, it's there. Definitely there. |
| 22:18 | justin_smith | (dec so) |
| 22:18 | lazybot | ⇒ -19 |
| 22:18 | mdeboard | ERC == Stockholm Syndrome |
| 22:19 | quizdr | (dotimes [n 400] (dec so)) lolrotflaghxbcs |
| 22:22 | quizdr | I see a lot of David Nolen's tutorials use Google Closure directly to manage quirks between browsers. Anyone know if his Om (or the underlying React) is also doing this automatically? |
| 22:22 | quizdr | Or is it wise to continue using Closure even with those libraries? |
| 22:23 | nullptr | react isn't, i don't think the om core is either -- but, closure is "in the box" already so i don't see any reason not to use aspects of it which provide value |
| 22:24 | quizdr | so the goog.dom ns is alsways going to be there because of how cljs works, right? |
| 22:24 | nullptr | i'm not aware of a compilation path that doesn't make closure library available |
| 22:25 | nullptr | that said, it would be unwise to consume goog.dom in a non-browser cljs application :) |
| 22:25 | danielcompton | nullptr like a node cljs app? |
| 22:25 | nullptr | yeah |
| 22:29 | ddellacosta | quizdr: the only closure lib Om uses is goog.ui, for generating ids, as far as I know |
| 22:29 | quizdr | entering the js world where so many libraries interact with the DOM it is confusing to know which play nice with each other. |
| 22:34 | ddellacosta | quizdr: generally it shouldn't be a problem unless the library is crap and writing stuff to the global namespace. But getting a dom element from one and using it with another is no big deal. |
| 22:35 | ddellacosta | quizdr: of course, using react means you have to be clear on where in the render cycle you're using external dom libs, but they all behave the same in that sense |
| 22:36 | quizdr | ddellacosta thanks. wrapping my head around it all. i think i've settled on Om with maybe just the CSS portion of Bootstrap or PureCSS.io |
| 22:39 | ddellacosta | quizdr: yeah, (in reference to bootstraps js widgets) I've done some integration with google closure widgets and I've found its better to lean as heavily on Om/React as you can, mostly because there are assumptions of use when using UI widgets with standard JS libs that the React render cycle can confound |
| 22:39 | ddellacosta | quizdr: it's not so much about dom libs conflicting with each other than the basic model of rendering being fundamentally different |
| 22:41 | quizdr | ddellacosta for example there are some nice JS drop-down menus in the various UI libraries I've looked at. But I'd be worried about mixing third-party JS with Om, at least at first |
| 22:41 | ddellacosta | quizdr: yeah, it can be challenging to get working smoothly. Usually those kinds of widgets have to live in a world of their own and interact with your Om components using channels. |
| 22:42 | ddellacosta | quizdr: but good to see if you can do stuff without widgets first...then add them only when they present a clear win as far as avoiding developing stuff from scratch (is my philosophy) |
| 22:43 | quizdr | perhaps the curve of integrating them is no less than the time spent writing your own menu, for example |
| 22:45 | ddellacosta | quizdr: yeah, I mean, the problem is that there is just less impedance mis-match if you can do things "the Om way." For example, setting state and taking advantage of the natural render update cycle to effect UI updates is really powerful. Once you start using external widgets, you can start to find yourself needing to directly modify the DOM more and more, depending on how you need to integrate stuff...again, this |
| 22:45 | ddellacosta | is just based on my experience w/Google closure widgets. |
| 22:47 | quizdr | do i understand correctly that Om can re-render part of a DOM while another part is currently being interacted with by the user? Such as a text field being typed in while something else updates due to AJAX callback or whatever |
| 22:51 | ddellacosta | quizdr: I mean, I wouldn't put it that way--in one sense Om is really simple, it's just responding to updates to the underlying data structures |
| 22:52 | ddellacosta | quizdr: It doesn't "know" that a user is interacting with the DOM in any meaningful sense. |
| 22:52 | quizdr | so what happens when your page gets a callback that needs to be rendered and the user is interacting with the page; is it queued? |
| 22:55 | beamso | i think what you're asking is more about if and how the user's interaction changes the om state |
| 22:55 | quizdr | it will probably become clear as I build out some basic stuff first |
| 22:56 | beamso | i know for one of the things that you've mentioned, autocomplete, jquery ui gives you configuration and the hooks to link back into your form. |
| 22:56 | ddellacosta | quizdr: as far as I understand, if that callback updates data that is associated with an Om component, Om will trigger a React update |
| 22:58 | ddellacosta | quizdr: if the user is interacting with the page and that causes a change to the data, that will just be triggered as it happens. So yeah, things get queued basically. But if multiple app-data/state changes happen within a single render cycle, they will get batched, as far as I know. |
| 22:59 | quizdr | ok |
| 22:59 | quizdr | i've got some learning to do |
| 22:59 | quizdr | you use async a lot in your Om stuff? |
| 22:59 | ddellacosta | quizdr: play with it, read the source, it will become more clear. :-) |
| 22:59 | quizdr | watched several asyn vids yesterday, looks amazing even for JS |
| 23:00 | ddellacosta | quizdr: I use core.async extensively in my Om code...I probably couldn't write Om components without it. It's a key part of it |
| 23:00 | quizdr | dnolen is an async evangelist and i've been watching his presentations. quite interesting indeed. |
| 23:01 | ddellacosta | quizdr: yeah, core.async is crazy cool. I've been using it for half a year and still feel like I haven't tapped its potential yet |
| 23:02 | quizdr | an on JS it's like half the power as on JVM but that shows how well thought the API is and the implementation to allow both environments access to it |
| 23:02 | ffmpegleg | mind linking one of those vids? |
| 23:03 | quizdr | ffmpegleg just search youtube for dnolen and you'll see the titles. anything with async |
| 23:03 | quizdr | or maybe search "david nolen" |
| 23:03 | quizdr | ffmpegleg his blog is full, and i do mean fulllll, of many many examples of it in clojurescript across many applications and difficulty levels |
| 23:04 | quizdr | for starters: http://swannodette.github.io/2013/11/07/clojurescript-101/ |
| 23:04 | ffmpegleg | thanks :) |
| 23:04 | quizdr | when i saw the illusion of multithreading in the browser he demonstrated, it just blew my mind. |
| 23:06 | ddellacosta | also, Timothy Baldridge (one of the core.async main authors) just posted some videos recently about core.async: https://groups.google.com/forum/#!topic/clojure/6g7WSr41z_Y |
| 23:07 | mdedetrich | quizdr: its not multithreaded, its concurrent programming |
| 23:07 | mdedetrich | *multithreading |
| 23:07 | mdedetrich | they are separate things, a lot of people confuse them |
| 23:08 | quizdr | mdedetrich i know it's not multihreaded, but as pointed out in the demos, it gives JS programmers an illusion of doing things normally associated with multithreading (and concurrency) even though threads are not supported in the browser |
| 23:09 | quizdr | ddellacosta good link thanks. looks like most of the videos are a buck to watch, but probably worth it |
| 23:09 | ddellacosta | quizdr: oh, are they? sorry didn't realize |
| 23:10 | mdedetrich | true, I guess my general point is that people conflate concurrent programming with multithreading, concurrent programming is an abstract concept where as multithreading is a feature of the hardware |
| 23:10 | quizdr | ddellacosta some are free, but frankly it's worth a buck |
| 23:10 | quizdr | i saw Tim's async presentation from 2013 on youtube (i think) and he's a good presenter |
| 23:10 | beamso | free : http://www.youtube.com/watch?v=enwIIGzhahw |
| 23:10 | ffmpegleg | just looked at the 10,000 processes one -- think I need to get into Om |
| 23:11 | ddellacosta | mdedetrich: I think you could reasonably state that core.async provides the illusion of multithreading in the browser, even if core.async is fundamentally about concurrent programming |
| 23:11 | quizdr | though I wonder if I am in the minority of watchers who need to pause a video for several moments and rewind sometimes to really know what they are talking about! |
| 23:11 | ddellacosta | quizdr: no, I do that too! |
| 23:11 | quizdr | beamso yes that's the one I'm talking about |
| 23:12 | mdedetrich | ddellacosta: I think its more accurate to say that core.async provides an abstract model that is typically used in multthreading applications, but it amounts to the same thing |
| 23:12 | quizdr | ddellacosta if i was actually present at these conferences i'd probably not get so much out of them because i just don't have the experience (and probably the brainpower) to follow these presentations in real-time with the presenters |
| 23:12 | ddellacosta | mdedetrich: yes, I mean, I think we're quibbling here. The main point is just that core.async makes the single-threaded nature of JS not matter so much |
| 23:13 | quizdr | as was said on a recent episode of "Silicon Valley", "You guys are arguing over which metaphor to use to express that you actually agree with each other." |
| 23:13 | mdedetrich | well yeah, I think core.asyncs great achievment is it brings general concurrent concept to JS |
| 23:13 | mdedetrich | quizdr: this is the internetz, we are supposed to argue! |
| 23:14 | mdedetrich | but in all honestly, core.async is amazing |
| 23:15 | ddellacosta | mdedetrich, quizdr: yeah, haha...I actually hate that kind of argumentative thing. Especially when people are pretty much in agreement |
| 23:15 | ddellacosta | but agreed, core.async is the bee's knees |
| 23:15 | quizdr | so which one is it then??? is it "amazing" or is the "bee's knees" make up your minds already!! |
| 23:16 | ddellacosta | quizdr: definitely the bee's knees, I don't know about all those other superlatives. ;-) |
| 23:16 | quizdr | off topic, are you in Tokyo or a different city? What's the air quality like in Japan or Tokyo? is a big city mesh of pollution as in so many other places? |
| 23:22 | ddellacosta | quizdr: sorry, didn't see your question. I'm in Tokyo. The air quality is good, except some days when we get winds from China...haha |
| 23:25 | quizdr | as i get older i find myself looking for lively places with good air. Singapore's jumps around a lot due to fires from Sumatra and Malaysia |
| 23:26 | ddellacosta | quizdr: ah. Yeah, Tokyo's not bad, really |
| 23:26 | ddellacosta | I don't have numbers for you or anything, but it's good |
| 23:26 | ddellacosta | I've got the windows open right and a pleasant breeze comes in here and there. It's a bright sunny day. |
| 23:26 | quizdr | i'm going to have to check it out there. trying to make it around the region as much as i can in case i leave this part of the world some day |
| 23:29 | yedi | so i want to make a group text chatting app in the browser, does anyone have any pointers / resources i can look at with regards to dealing with the concepts of "time" in distributed real time apps. I.E. how to determine the ordering of messages |
| 23:30 | quizdr | yedi lots of chats are asynchronous, such as IRC in fact, and timing is not always the same for different participants. messages aren't guaranteed to be in a strict order |
| 23:31 | Frozenlock | yedi: timestamps? (or would that fail if the user has a misconfigured clock?) |
| 23:31 | yedi | so the order of messages on two different clients can differ |
| 23:31 | ivan | yedi: show messages in the the order the server received them? |
| 23:31 | quizdr | yedi often yes. it depends how important this is to you. |
| 23:31 | quizdr | for casual cases, i wouldn't expect ordering to be so important |
| 23:31 | ivan | yedi: oh, distributed |
| 23:33 | ddellacosta | yedi: maybe start here? http://en.wikipedia.org/wiki/Lamport_timestamps |
| 23:34 | ddellacosta | Lamport is the man as far as this stuff is concerned |
| 23:34 | ddellacosta | check the date on that paper at the bottom...1978 |
| 23:34 | quizdr | ddellacosta 1978 is also when CSP was announced, the foundation of core.async |
| 23:35 | ddellacosta | quizdr: really? didn't know that, cool |
| 23:35 | quizdr | good year! i was also born that year. omg what is happening right now |
| 23:35 | ddellacosta | heh |
| 23:36 | yedi | ddellacosta: thanks for the link |
| 23:37 | ddellacosta | np |
| 23:39 | mdeboard | god how did |
| 23:39 | mdeboard | Everything's coming up lamport for me tonight |
| 23:42 | en16m4666 | does lisp code work in clojure? |
| 23:43 | en16m4666 | any1 want to share clojure code on a sudoku puzzle solver |
| 23:44 | sjy | en16m4666: well, clojure is a lisp dialect. so the answer is 'yes' in a sense, but lisp dialects are not necessarily mutually intelligible... |
| 23:44 | rritoch | Hi, I have a q? and I'm not sure if this is the best place for it. Is it possible to gen-class a static constructor? |
| 23:44 | ddellacosta | en16m4666: 1) not directly 2) https://gist.github.com/swannodette/3217582 |
| 23:45 | en16m4666 | word brah |
| 23:45 | mdedetrich | en16m4666: although clojure is technically a lisp dialect, its quite different from the other lisps |
| 23:46 | mdedetrich | I mean basic lisp is so 'low level' (if that makes sense) that calling clojure a lisp dialect isn't really useful |
| 23:46 | rritoch | The reason I ask is this project (https://github.com/rritoch/clj-nativedep) which helps with loading native dependencies seems to require that loading occurs in static constructors so up till now all implementations are depending on a java jar that contains classes with static constructors. |
| 23:50 | quizdr | maybe someone can help me understand these cljs async basics in this small snippet: https://www.refheap.com/85823 My first question is where does this go block actually reside in the system? it's clearly a piece of state that the program has access to |
| 23:52 | ddellacosta | rritoch: sorry, not a java interop expert...sometimes you get llasram or somebody around who knows this stuff well though... |
| 23:54 | beamso | a constructor isn't static. do you mean a factory method? |
| 23:55 | rritoch | ddellacosta: thanks I'll keep my eye open for llasram |
| 23:56 | rritoch | beamso: See https://github.com/rritoch/WarpCTL/blob/master/extra/JADL-SDK/build/java/src/com/vnetpublishing/swig/adl/jadl_sdk.java#L13 which is a static constructor, and utilizing the clj-nativedep library |
| 23:58 | beamso | that's a static initialisation block, not a constructor. |
| 23:59 | rritoch | beamso: Ok... Call it what you will, can it be created in a Clojure gen-class? |