#clojure logs

2015-06-14

01:54ianyis there a reason why defing a transducer (def a (map inc)) works in clojure but not in clojurescript?
01:55laggybitiany: really old cljs version?
01:57ianylaggybit: latest ones. transducers work, but you can't def them. eg. (sequence (map inc) [1 2 3]) works in clojurescript, but not (def a (map inc)).
02:00laggybitiany: hmm, that's interesting
02:01laggybitiany: got a repo that shows that behavior?
02:03ianylaggybit: unfortunately no, just experimenting with cljs. so this is not by design? you can def a transducer in clojurescript?
02:04laggybitiany: as far as I know, yes
02:04ianylaggybit: aight thanks, at least i know it's a problem on my end now.
02:05justin_smithiany: odd, I don't have a cljs project handy right now - can you put a transducer in a let binding? in an atom?
02:10ianyjustin_smith: oh wait. it does work. i looked at the output and thought it was an error message. sorry.
02:10justin_smiththat's a relief
02:10laggybitphew
02:12ianysilly me.
03:10elvis4526Hello! I'm trying to understand multimethods. It's like OOP in the sense that OOP dispatch the method call based on the object, correct ?
03:18amalloymultimethods are polymorphism, which is just one of the many features that are glued together under the heading "OOP"
03:26elvis4526amalloy: alright thanks
03:29elvis4526amalloy: Is there a way to provide a default fn when nothing match the dispatch value ?
03:29elvis4526ah I think I can achieve that with :default inside defmethod
04:46kaffeeboehnchenOk, so I created a new file in src/project (leiningen project) and when I get an error that the namespace fails to require itself because of a null pointer?
04:50kaffeeboehnchenEven with just "(ns my-name.space)" -> Failed trying to require my-name.space with: java.lang.NullPointerException
04:51laggybitkaffeeboehnchen: what's the path to that file?
04:53kaffeeboehnchenlaggybit: src/my_name/space.clj
04:54kaffeeboehnchenin my real code its src/project_mox_server/api.clj and (ns project-mox-server.api)
04:55kaffeeboehnchenI have other files in the namespace that are working without a problem.
04:55kaffeeboehnchenhttps://paste.xinu.at/L6D4/ maybe some of the deps?
04:56laggybitoh, it's not empty
04:56kaffeeboehnchen?
04:56laggybitright, try removing all the requires
04:56kaffeeboehnchensame without the requires and use :(
04:57laggybiton a fresh repl?
04:59kaffeeboehnchenlaggybit: restarted ligth table (I have no clue how to restart the connected repl) and it works :)
04:59kaffeeboehnchenthanks
04:59laggybitthat's a relief
04:59clojurebotI don't understand.
04:59kaffeeboehnchenWhat could have caused that?
05:00laggybitI have absolutely no idea
05:00kaffeeboehnchenOk. Thank you very much. :)
05:00elvis4526I'm trying to write a macro that use the java interop
05:01elvis4526Does the dot have a special value inside a macro?
05:02laggybitelvis4526: it's a special form
05:02elvis4526i'm gonna pastebin it.
05:05elvis4526http://pastebin.ca/3027779
05:05elvis4526I would expect the macro to expand to (.controller [...])
05:06laggybitooh
05:06elvis4526why it doesn't ?
05:09laggybitit actually does
05:09elvis4526what ?
05:09elvis4526can you paste how you called it exactly ?
05:09laggybitbut that's also a macro, which would expand to . app controller
05:11TEttinger,(macroexpand '(+ 1 Math/PI))
05:11clojurebot(+ 1 Math/PI)
05:11TEttingerhaha
05:11TEttingerwat
05:12elvis4526I don't understand. The (.) macro isn't suppose to be expanded when using (macroexpand), right ?
05:12elvis4526and (. app controller) is not what I want
05:12TEttingerI'm attempting to implement clojure-style macros now, in a lua interpreter
05:12TEttingerwhy not?
05:12TEttinger,(. Math sin 0)
05:12clojurebot0.0
05:13laggybitit is, (.controller app) becomes (. app controller)
05:13TEttinger,(.sin Math 0)
05:13clojurebot#error {\n :cause "No matching method found: sin for class java.lang.Class"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching method found: sin for class java.lang.Class"\n :at [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53]}]\n :trace\n [[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53]\n [clojure.lang.Reflector invokeInstanceMethod...
05:13laggybittry macroexpand-1 on it
05:13elvis4526ohshit so (macroexpand) expand on more than one level ?
05:13laggybityes
05:13elvis4526what's the difference than between macroexpand-all and macroexpand ?
05:13laggybitif you want a single pass, macroexpand-1 does that
05:14TEttingerdot space will actually work even on static methods, dot,nospace will as .sin did, break
05:14TEttingerbut dot space has more complicated rules for how it calls what, so static methods are best called with Math/sin or equivalent
05:16elvis4526anyway - thanks !
05:17laggybitelvis4526: macroexpand and macroexpand-1 don't expand subforms
05:17laggybitelvis4526: macroexpand-all does
05:18TEttingerso I'm a bit confused right now. when are macros expanded in a normal clojure program, and at what point does ~ or unquote get the value of what it unquotes?
05:23ConfusionIn core.logic, you usually use something like (l/run* [a] (l/== a 3)). Now instead of a formula with 'a', I have a formula with a generated symbol. How can I pass the generated symbol to l/run* ? Simply (l/run* [my-symbol-reference] my-logic-formula-with-symbol) doesn't work, as that results in 'my-symbol-reference being literally present in the expanded macro. However, I don't understand how to write a macro whose output is (l/run* [my-sy
05:23Confusionmbol] my-logic-formula-with-symbol)
05:24TEttingeroh boy, macro macros
05:25TEttingerConfusion: you are in for either hair-pulling or a lot of fun, http://amalloy.hubpages.com/hub/Clojure-macro-writing-macros
05:26ConfusionYeah, I was afraid of that, *diving in, send a search party if I'm not back in an hour* :P
05:26amalloyare these formulas generated at compile time or runtime?
05:27TEttingeramalloy! what are you doing up?
05:27amalloyand why are you allowing the symbol chosen to be different? if you are producing these formulas, you can simply require that the goal always be named q or whatever, with no loss of generality
05:27TEttingerI had some macro questions that I think should be quick for you to answer, if you have the time amalloy
05:27amalloyyou can always ask
05:28TEttingermainly... uh... I am having a hard time figuring out what the question is
05:28TEttingerI guess at the basic level, when are macros expanded?
05:28TEttingeris it a phase before the evaluation of the fns?
05:29amalloyTEttinger: the answer will make you laugh
05:29amalloy"at macroexpansion time"
05:29TEttingerindeed.
05:29TEttingerwhen is macroexpansion time, in the process of compiling a clojure program?
05:29amalloyreally it is closely related to compile time
05:30amalloygenerally the compiler does things one form at a time. for each form, it checks to see if it's a macro call, and if so expands it. then it does that recursively, finding all macro subforms and expanding them too. then, it compiles the fully-expanded top-level form
05:31amalloyoften, forms are evaluated right after being compiled, but not always
05:31TEttingerwhat if a macro call expands to another macro call?
05:32TEttingerso the other question is, when does unquote have access to the actual values of the unquoted symbol?
05:32amalloythat's the recursive part
05:32amalloywhatever form a macro expands to, it's as if you wrote that fomr by hand
05:32amalloyso, if it expands to some other macro, it's just like you wrote that macro by hand; of course this means that it is expanded too
05:33amalloythe other question is more vague. what do you mean "actual values of the unquoted symbol"?
05:33TEttingerbecause unquoting something like (def foo (slurp "foo.txt")), then later getting ~foo in a macro... will it be nil? will it be the value of foo when the macr is called?
05:35TEttinger(def foo (slurp "foo.txt")),(defmacro foo-get [] `(str ~foo)),(foo-get)
05:35amalloyTEttinger: the stuff that happens in ` and ~ is, mechanically, totally unrelated to how macros are expanded. it will help you to not think of them as the same thing
05:35TEttingeroh boy.
05:35amalloyyou can syntax-quote outside of macros, or write macros without syntax quoting
05:36TEttingeryes
05:36amalloythey just *tend* to be in the same place
05:36TEttingerI have actually done this
05:36amalloyso. once you have your mental model for how macroexpansion works, and for how `~ works, you can answer your own questions
05:36TEttingerI'm just unsure how the macro call can have runtime values
05:36amalloyeg, try writing out by hand what `(str ~foo) is short for
05:37amalloyand then thinking about how that would work, as a macro definition
05:37TEttinger(list 'clojure.core/str '~clojure.core/foo) ; guessing here?
05:38amalloyno, how could '~ be there in the expansion?
05:38TEttinger,`(str ~*clojure-version*)
05:38clojurebot(clojure.core/str {:major 1, :minor 7, :incremental 0, :qualifier "master", :interim true})
05:38amalloyyou can even ask clojurebot to do it for you
05:38amalloy,'~(str ~foo)
05:38clojurebot(clojure.core/unquote (str (clojure.core/unquote foo)))
05:38amalloyer
05:38amalloy,'`(str ~foo)
05:38clojurebot(clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/str)) (clojure.core/list foo)))
05:38amalloywell of course that is totally illegible because of the seq/concat junk
05:39amalloybut it is the same as (list `str foo)
05:39TEttingerwell it has quote around str, so I was wondering if that was the same as 'str
05:39amalloysure. `str is 'clojure.core/str
05:40TEttingerohhhh
05:40TEttingeryou meant the '~ digraph
05:40TEttingernot the two characters ' and ~
05:40amalloyyes
05:40TEttinger,'`(str ~*clojure-version*)
05:40clojurebot(clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/str)) (clojure.core/list *clojure-version*)))
05:41TEttingerso the version that's produces by '` , that's what a macro returns, am I right?
05:41TEttinger*produced
05:42amalloyremember, ` is nothing to do with macros
05:43amalloy(defmacro foo [x] (f x)) is called like a function named foo, which is run at compile time instead of runtime
05:43amalloyand since you can already reason about how functions behave, such as (list `str foo), you can reason abotu how (defmacro blah [foo] (list `str foo)) will behave
05:44amalloyeg, foo will be the symbol '*clojure-version*
05:45amalloyanother way to play with this, rather than calling macroexpand, is to just do it without macros: (defn blah [foo] (list `str foo)), and then quote the arguments every time you call blah: (blah '*clojure-version)
05:47TEttingerso the reason I'm asking is, I'm attempting to implement macroexpansion in my clojure-like lisp targeting lua
05:48TEttingerI want to do it in a way that's very close to clojure (# suffix for autogensym was tricky with my parser, so it's a $ prefix instead, otherwise same)
05:49TEttingerhowever if I don't get a better grasp on, uh, what I'm doing, it will be the blind leading the blind when anyone tries to use this language
05:54laggybitTEttinger: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L6758
05:55Confusionamalloy, the expressions are parsed from a language. Users may choose (== a 3) or (== flibbly-di-floop 3). I know which ones are free and my current approach is to replace them in the logic expressions themselves, keep a mapping of the replacements, so I can report back what the solutions are.
05:56ConfusionSo initially, I basically have: expressions + a list of strings that are the known free variable names. And I want to pass that to l/run*
05:57amalloyif you know which ones you need to test for, why can't you just write (or expand to) (run* [q] (== q [a b c d e]) (...expressions with a, b, c, d, and e...))?
05:57TEttingerlaggybit: uh... this is very hard to understand. for one, ObjExpr fexpr = (ObjExpr) analyze(C.EXPRESSION, RT.list(FN, PersistentVector.EMPTY, form), "eval" + RT.nextID());
05:57TEttingerfexpr has a very very different meaning than what is used here
05:57amalloyand i guess also add a (fresh [a b c d e]) around that
05:58TEttingerfor another, holy crap that is like all references to other parts of core.clj's implementation
05:58laggybitTEttinger: this is clojure's actual implementation of eval
05:59laggybitif you're looking for a reference, this is it
05:59Confusionamalloy, If a need to replace variables by symbols a, b, c ..., I wouldn't I still need to generate a finite list of symbols to replace the variables with? So wouldn't I still be stuck with a list of symbols to put in??
05:59amalloyno, you can just use the symbols the user gave you
05:59amalloyit doesn't have to be abcde
06:00TEttingerlaggybit, I'm not looking to copy clojure's JVM implementation, for one thing lua doesn't even HAVE try/catch/finally
06:00ConfusionWell, those may clash with other symbols in the environment?
06:00Confusionamalloy, and they are entered as strings, resolved into symbols, so I would then need to pass those symbols (constructed from the strings) in... wouldn't I run into the same problem then?
06:01amalloyi think that is unlikely, but i suppose it's not impossible
06:01TEttingerI'm trying to have similar behavior, but the implementation is going to be VERY different
06:01amalloyConfusion: okay so here is the thing. you are doing this at runtime, and you need data that exists only at runtime (the users' expressions)
06:01amalloythat stuff doesnt exist at macroexpansion time, which is compile time, so you cannot have access to it
06:02TEttingeramalloy: that actually answers some of my questions too, as an aside
06:02amalloyif you want to splice runtime expressions into a brand-new core.logic expression, at runtime, you have no real choice but to use eval. this doesn't exactly solve your problem, since you'll have to generate the same code to pass to eval that you would have to macroexpand to anyway
06:03TEttingerstrings are magic, though. strings are life
06:03laggybitTEttinger: you should certainly be able to get identical behaviour, thoough of course the implementation will be quite different
06:04TEttingerlaggybit, it's just, that was line 6758 of the file. I'm not going to be able to understand all of Compiler.java in a meaningful period of time
06:04Confusionamalloy, yes, I've been trying to have the macro generate a form containing an eval... but I couldn't get things to work
06:05amalloythat's not right. there is no point writing a macro that expands to eval. you might as well just write a function that calls eval
06:06ConfusionAh, of course
06:08Confusion(I still have to figure out to what extent a macro differs from calling eval on a function that generates a list (that is supposedly evaluable of course). I figured things like symbol generation might only be available inside a defmacro)
06:09amalloyConfusion: there is no difference except that one of them runs at compile time and the other at runtime
06:09amalloyas i was telling TEttinger, the fancy stuff done by ` is totally divorced from macroexpansion. you can do it in functions too, it's just a shorthand for writing code that outputs lists
06:10julianlevistonHey all. Optimisation question… https://www.refheap.com/102534
06:10julianleviston… wondering if there’s a faster way to store updated keys as meta-data… (this is my “dirtying-“ variant of assoc, or other fns)
06:12Confusionamalloy, ok, the fancy stuff is provided by `, that's convenient :)
06:18TEttingeramalloy, I think I may be figuring out some questions that may be more clear. A macro receives its args as quoted symbols. when a macro is expanded, if anything in its body is unquoted, that unquote acts just like it does in a fn, and so, if I understand this right, the expanded macro will contain an identifier that is not quoted, so when the code that the macro expanded to is evaluated, THEN it looks up what that identfi
06:19ConfusionGot it!
06:19TEttingerall right! woo Confusion!
06:20ConfusionThanks amalloy, TEttinger, justin_smith (for some necessary advice last week)
06:20TEttingerjustin_smith is full of advice all the time
06:20TEttinger(inc amalloy)
06:20TEttinger(inc justin_smith)
06:21TEttingerhm, no lazybot
06:31mmeixI'm just contemplating switching from Reagent to Rum for my SVG-driven music-UI - someone have experience with it? (Datascript sounds quite interesting too...)
06:34julianlevistonmmeix: all I know is rum is more agnostic as to how it approaches things, in particular with theis cursors. Have you had a look at freagent? While it’s experimental, it actually doesn’t use react, so you can do a lot faster animation rendering stuff in it, from what I’ve reen. Depends - why switch?
06:37mmeixI'm early in development, just building graphic functions. so far everything is hiccup-like without user interaction so far, so it's open, and I just found some praises for Rum, and datascript seems to be a good fit for this project. Thanks for the hint re freagent, will look it at
06:41mmeixah, it's called freactive
06:43julianlevistonhaha sorry yes. <sigh> my brain!
06:43mmeixnp :-)
06:43julianlevistonit doesn’t help that there are like about 7 of these for CLJS alone… let alone all the similar pure JS ones.
06:44julianlevistonIt’ll be interesting to see Om next whenever that’s likely to come out…
06:45julianlevistonmmeix: why can’t you use datascript with reagent? I see no reason.
06:45mmeixof course ...
06:46mmeixit seems to play rather well with Rum, that's what I read
06:46mmeixjust looking around
06:46julianlevistonmmeix: I don’t know what that means, but ok :)
06:47mmeixmy English might be a bit Austrian, sorry ...
06:47mmeixthanks for thoughts :)
06:47julianlevistonmmeix: sorry, that sounded a bit dismissive. Just not sure how it will play better or worse with any of the rest of the cljs world…
06:47julianlevistonmmeix: maybe because it has the same author?
06:47mmeixyes
06:48julianlevistonmmeix: no worries.
07:11TEttingermmeix, I would not have guessed that your English was anything other than "fluent"
07:12mmeixleo.org is open constantly ...
07:13TEttingerit's been kinda odd, in #libgdx, which is a java game lib channel (also has clojure bindings!), there are constantly coders coming in with a very very poor grasp of English, but that trait seems rare in #clojure
07:14mmeixmaybe gamers are a bit different sociologically :P
07:15TEttingerI did have one memorable debugging session, across the atlantic. There was a definite language gap, he was in France, and he offered to host a TeamViewer session so I could edit his complex Eclipse/Gradle project. Fun times, navigating a French version of Windows XP (may have been vista or 7 with an older look) despite not knowing any French
07:16TEttinger(I managed to get it working after about an hour and a half of this, he had an 8 hour deadline that was coming up fast)
07:16mmeixah, the French ... la Grande Nation is particularily fond of its language ...
07:16mmeixwow. this is one heroic story!
07:16TEttingerbut man. gradle is such an inferior tool to leiningen
07:17TEttingerit's still marginally better than Maven
07:17mmeixIs Boot a really better alternative? for someone still learning, I mean ...
07:18TEttingerthe issue was he had a gradle project synced to eclipse, but needed to get the project to see certain maven jars. any changes to eclipse, next time he updates gradle ever, changes disappear.
07:18mmeix(Datascript seems to lend itself to my project - I guess this will be this afternoon's read ...)
07:18TEttingerI needed only to install maven, install the jars in his cache
07:19mmeixthat sounds like a panic situation, yes
07:19TEttingerand get gradle to see the local repo
07:19TEttingeryes
07:19TEttingerI'm glad the guy was nice about it!
07:19mmeixhe must owe you a box of beer or two ...
07:20TEttingerwith a name like Muhammad, I kinda doubt it, but I don't drink either, heh
07:20mmeix:-)
07:22mmeixmy wife and me, we're emptying a bottle of wine over the course of three days or so, so ...
07:27noogaI'd gladly empty a bottle of wine over ztellman/gloss because I'm completely stuck :F
07:27noogaanyone had experience with implementing binary protocols in clj?
07:31mmeix(not this learner ...)
07:32TEttingernooga, from what I understand gloss is the way to do it.
07:32TEttingerI have never used gloss though
07:32TEttingerztellman is not here right now, I suspect it is early morning wherever he is located
07:33noogaTEttinger: I know it is because it works really well with aleph+mainfold and these things are awesome
07:33noogabut then I have problem describing a legacy protocol with stupidly constructed headers
07:34noogaand gloss doc doesn't give me any ideas on how to proceed
07:35noogaI guess I'll hang out until I can bother ztellman :D
12:23mmeixhow do I sort by a given key order? Say I have [:foo :baz :bar :foo] and I want it sorted by :baz, :bar, :foo
12:24mmeix==> [:baz :bar :foo :foo]
12:25mmeix(the example in https://clojuredocs.org/clojure.core/sort-by is not helpful, or I don't get it...)
12:30mmeixnever mind, just found it: (sort-by (juxt :baz :bar :foo) ...)
12:31mmeixno ...
12:31jjttjj,(doc sort-by)
12:31clojurebot"([keyfn coll] [keyfn comp coll]); Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array."
12:32jjttjjso sort just calls the keyfn on whatever you're sorting and orders the result by the result of that fn
12:32jjttjj*sort-by i mean
12:33mmeixyes, so far I understand
12:35mmeixah, ok
12:38mmeixso:
12:38justin_smith,(defn bad-shuffle [c] (sort-by (fn [& _] (rand)) c))
12:38clojurebot#'sandbox/bad-shuffle
12:38mmeix,(let [c [:foo :baz :bar :foo], comp {:baz 0 :bar 1 :foo 2}] (sort-by #(% comp) c))
12:38clojurebot(:baz :bar :foo :foo)
12:39justin_smith,(bad-shuffle (range 100))
12:39clojurebot(18 78 26 53 56 ...)
12:40mmeixso is giving a map with keys and "weights" a good solution?
12:40mmeix(as a comparator, I mean)
12:40justin_smithmmeix: yes, that will work - but you can simplify that code
12:40mmeixhow?
12:40clojurebotwith style and grace
12:40justin_smith,(let [c [:foo :baz :bar :foo], comp {:baz 0 :bar 1 :foo 2}] (sort-by comp c))
12:40clojurebot(:baz :bar :foo :foo)
12:41justin_smithbecause hash-maps are callable
12:41mmeixah!
12:41mmeixgreat!
12:41justin_smithif you think of the mathematical definition of a function, it should make sense that maps are functions
12:41justin_smithalso, comp is an iffy name, because it is already a quite useful function
12:41mmeixyes, I just forgot ...
12:41justin_smith(doc comp)
12:41clojurebot"([] [f] [f g] [f g & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."
12:41mmeixyes, ofcourse
12:42justin_smithmmeix: eg. in that case I would likely call the map "weights"
12:42justin_smithor perhaps "ordering"
12:43mmeix,(def myorder {:baz 0 :bar 1 :foo 2})
12:43clojurebot#'sandbox/myorder
12:43mmeix,(sort-by myorder [:foo :baz :bar :foo])
12:43clojurebot(:baz :bar :foo :foo)
12:43mmeixthanks!
12:43noncom|2for some reason i cannot find some repositories that i've uploaded earlier to clojars
12:44noncom|2i've noticed it when lein failed to fetch the deps on a new machine
12:44noncom|2i also cannot find the repositories on clojars website
12:44mmeixlein clean?
12:44noncom|2what could that have happened to them?
12:44noncom|2lein clean does not help.. i even removed all lein and maven related stuff from the pc and did all again
12:45noncom|2what's strange is that clojars web interface does not show the jars also
12:48mmeix,(inc justin_smith)
12:48clojurebot#error {\n :cause "Unable to resolve symbol: justin_smith in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: justin_smith in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol:...
12:48mmeixugh
12:48mmeix(inc justin_smith)
12:49vivekramaswamyHello all, quick question, I was trying an example from "Living Clojure" book which requires the library, camel-snake-kebab.core, which I added in my project.clj file as [camel-snake-kebab "0.3.1" ], after this I gave the command lein deps, bit still keep getting the error when I give this command (:require [camel-snake-kebab.core :as csk]) any ideas?
12:49vivekramaswamyI get the error class not found
12:51noncom|2could you please paste the exact exception stack trace here? https://www.refheap.com/
12:51vivekramaswamysure
12:55noncom|2vivekramaswamy: and give us a link! :)
12:55noncom|2s/a/the
12:59vivekramaswamyhttps://www.refheap.com/102550
13:01noncom|2vivekramaswamy: hmmm... can you also show your project.clj?
13:03vivekramaswamyhttps://www.refheap.com/102551
13:04vivekramaswamyI have tried with both version 0.2.4 as given in the book and 0.3.1 both give the same error
13:04noncom|2vivekramaswamy: hmmm all looks fine... strange
13:06noncom|2what does lein-deps give you?
13:06noncom|2i mean "lein deps"
13:07noncom|2vivekramaswamy: what IDE do you use?
13:08vivekramaswamyEmacs + cider
13:09noncom|2vivekramaswamy: i use CCW + Eclipse, and it fetches the dep ok. However, upon launching the repl, i get this warning: https://www.refheap.com/102552
13:10noncom|2it might be that your IDE prevents hooking up of this library due to the warning
13:10noncom|2consider adding the recommended :exclusions param
13:10vivekramaswamywhen I use the 0.2.4 version it gives me no error but when I use 0.3.1 I get a bunch of warning which I have posted here https://www.refheap.com/102553
13:11vivekramaswamyyeap I used the exclusion as suggested [camel-snake-kebab "0.3.1" :exclusions [org.clojure/clojure] ]
13:11noncom|2nothing?
13:11noncom|2i would advice you asking this question again on #leiningen
13:11noncom|2all this is pretty strange
13:11vivekramaswamyok will do
13:11noncom|2today here is not many ppl
13:12noncom|2maybe someone on leiningen will be there
13:12vivekramaswamylet me go there, as this error is whacking me up for the last 2 hours
13:17noncom|2vivekramaswamy: btw, is your library in your local maven repo ?
13:17noncom|2i mean, does it get downloaded at least?
13:19vivekramaswamylet me check
13:20vivekramaswamyyes it does get downloaded, I can see them in the repository directory
13:23noncom|2and if in your project do just "lein repl"
13:23noncom|2and then require the lib?
13:23noncom|2i mean, "lein repl" from terminal
13:23noncom|2not emacs
13:24vivekramaswamyyeap I did just that
13:24noncom|2same?
13:26vivekramaswamyuser=> (:require [camel-snake-kebab.core :as csk])
13:26vivekramaswamyCompilerException java.lang.ClassNotFoundException: camel-snake-kebab.core, compiling:(/private/var/folders/c7/wqsnz32j6xq9wzd1mjcj13cw0000gn/T/form-init1232222862510638668.clj:1:1)
13:30justin_smithvivekramaswamy: :require only works inside the ns form
13:30justin_smithon the top level, it's require, and you need to quote the args
13:30justin_smith(require '[camel-snake-kebab.core :as csk])
13:33noncom|2ah, that's what!
13:33vivekramaswamyThanks a ton justin, that works in my local repl, when I compile the code in emacs, I still get the error that class was not found this is what I am using in my code (:require [camel-snake-kebab.core :as csk])
13:33noncom|2sorry, did not think you were using this form outside of (ns)
13:33noncom|2:)
13:35vivekramaswamy(ns serpent-talk.talk
13:35vivekramaswamy (:require [camel-snake-kebab.core :as csk]))
13:35vivekramaswamyok I got it, that was the mistake I was doing
13:36noncom|2justin_smith: can you imagine, i find that a couple of jars i pushed to clojars are missing from there? haven't run into that issue?
13:36vivekramaswamyThanks a ton noncom, and justin for your help
13:36noncom|2vivekramaswamy: yeah, sorry, it was just that :D
13:36justin_smithnoncom|2: I've never had that happen
13:46mmeixI do find, that :require, require, :refer, use ...etc. is a bit confusing for beginners
13:47justin_smithmmeix: I think it's helpful to remember they are all functions
13:47mmeixyeah, but :require as a function name is not intuitive
13:47mmeixfor example
13:47justin_smithmmeix: no, I mean require, refer, use, etc. are all functions, and the keyword version just calls those
13:48mmeixyes, of course
13:48mmeixit's confusing anyway, if you begin ...
13:50mmeixand in the Style Guide it says " In the ns form prefer :require :as over :require :refer over :require :refer :all. Prefer :require over :use; the latter form should be considered deprecated for new code."
13:50mmeixand lot of example code uses "use", so it needs some time to sort this out
13:51justin_smithyeah, and a lot of old timers haven't heard the news that use is deprecated
13:51mmeixnever mind, it was just one of those things, which was quite unclear in the beginning
13:51mmeixwere
13:52justin_smithmmeix: oh, I agree that those things are confusing to newcomers
13:52mmeixone ,ore form the Style Guide:
13:52mmeix"Avoid the use of namespace-manipulating functions like require and refer. They are entirely unnecessary outside of a REPL environment. "
13:53mmeixcauses additional head scratching
13:53justin_smithmmeix: on the other hand, the way clojure uses namespaces is very different from most languages (and better), so I think it would be worse if namespace stuff was intuitive... it would simply delay the shock of getting used to an unfamiliar system
13:53mmeixbut a low price to pay for proper namespace isolation, of course!
13:54mmeixagreed
13:56justin_smithmmeix: and my experience coming from common lisp / scheme / ocaml where library usage is similar was much easier. But I think there is an inherent difficulty of learning how proper namespacing works that can't just be fixed by changing syntax or naming of things.
13:56mmeixI can see that
13:56justin_smithand I had the same difficulty and confusion coming from the C world to those languages
13:57mmeixI guess I will give the namespace chapter another good read today, won't hurt ...
13:58justin_smithmmeix: what helped for me was looking at the various clojure functions which work with namepsaces
13:58mmeixgood idea - thanks!
13:58justin_smithmmeix: ns-publics, resolve, ns-refers
13:59justin_smithonce you see how namespaces are structured, and how that structure is manipulated by the familiar require etc., I think it starts to make more sense
13:59justin_smith(it's a simple structure)
13:59mmeixyeah ...
13:59justin_smith,(ns-publics *ns*)
13:59clojurebot{}
14:00justin_smith,(def a 0)
14:00clojurebot#'sandbox/a
14:00justin_smith,(ns-publics *ns*)
14:00clojurebot{a #'sandbox/a}
14:00mmeixI see
14:00justin_smith,(ns-refers *ns*)
14:00clojurebot{primitives-classnames #'clojure.core/primitives-classnames, +' #'clojure.core/+', decimal? #'clojure.core/decimal?, restart-agent #'clojure.core/restart-agent, sort-by #'clojure.core/sort-by, ...}
14:00justin_smiththat one probably requires your own repl, and pprint
14:01justin_smithmmeix: here's another neat one:
14:01justin_smith,(apropos #"^ns-")
14:01clojurebot(clojure.core/ns-aliases clojure.core/ns-imports clojure.core/ns-interns clojure.core/ns-map clojure.core/ns-name ...)
14:01mmeixuff
14:02mmeixok, saving those lines for further analysis
14:02justin_smithapropso is a decent way to "bootstrap" your understanding of hte language :)
14:02justin_smith*apropos
14:02mmeixhte?
14:02mmeixthe
14:02mmeixok
14:02justin_smithhaha, I'm a terrible typist
14:02mmeixsorry
14:04mmeix(looking up function apropos)
14:04justin_smithrelated is find-doc
14:04mmeixI see
14:04justin_smithapropos searches names of vars, find-doc searches doc strings
14:05justin_smith(doc apropos)
14:05clojurebot"([str-or-pattern]); Given a regular expression or stringable thing, return a seq of all public definitions in all currently-loaded namespaces that match the str-or-pattern."
14:05justin_smith(doc find-doc)
14:05clojurebot"([re-string-or-pattern]); Prints documentation for any var whose documentation or name contains a match for re-string-or-pattern"
14:05mmeix,(apropos "comp")
14:05clojurebot(clojure.core/*compile-files* clojure.core/*compile-path* clojure.core/*compiler-options* clojure.core/comp clojure.core/comparator ...)
14:05mmeixgreat
14:06justin_smith,(find-doc "compose")
14:06clojurebotnil
14:06justin_smith,(find-doc "composition")
14:06clojurebot-------------------------\nclojure.core/comp\n([] [f] [f g] [f g & fs])\n Takes a set of functions and returns a fn that is the composition\n of those fns. The returned fn takes a variable number of args,\n applies the rightmost of fns to the args, the next\n fn (right-to-left) to the result, etc.\n-------------------------\nclojure.core/extend\n([atype & proto+mmaps])\n Implementations of p...
14:06mmeix,(find-doc "keyword")
14:06clojurebot-------------------------\nclojure.core/agent\n([state & options])\n Creates and returns an agent with an initial value of state and\n zero or more options (in any order):\n\n :meta metadata-map\n\n :validator validate-fn\n\n :error-handler handler-fn\n\n :error-mode mode-keyword\n\n If metadata-map is supplied, it will become the metadata on the\n agent. validate-fn must be nil or a side-...
14:06mmeixhelpful!
14:06mmeixthanks
14:07mmeixah, and
14:07justin_smithwow, find-doc keyword would be a lot of output
14:07mmeix,(source juxt)
14:07clojurebotSource not found\n
14:07mmeix,(source "juxt")
14:07clojurebot#error {\n :cause "java.lang.String cannot be cast to clojure.lang.Symbol"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.Symbol"\n :at [clojure.core$ns_resolve invoke "core.clj" 4214]}]\n :trace\n [[clojure.core$ns_resolve invoke "core.clj" 4214]\n [clojure.core$ns_resolve invoke "core.clj" 4211]\n [clojure.core$resolve invoke "core...
14:07TMA,(source 'juxt)
14:07clojurebot#error {\n :cause "clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol"\n :at [clojure.core$ns_resolve invoke "core.clj" 4214]}]\n :trace\n [[clojure.core$ns_resolve invoke "core.clj" 4214]\n [clojure.core$ns_resolve invoke "core.clj" 4211]\n [clojure.cor...
14:08mmeix,(source max)
14:08clojurebotSource not found\n
14:08justin_smith,(source juxt)
14:08clojurebotSource not found\n
14:08justin_smithhrmph :)
14:08justin_smithworks in the repl
14:08mmeixyes
14:08TMA&(source juxt)
14:08justin_smith~lazybot |is| sometimes here.
14:08clojurebotA nod, you know, is as good as a wink to a blind horse.
14:08mmeix#(source juxt)
14:09justin_smithmmeix: that would be ##(source juxt) but that only works with lazybot, who is somewhere else being lazy right now
14:09mmeixhowever - good tips as always
14:11mmeixtoday I discovered Datascript
14:11mmeixwhich seems a good thing to use in my project
14:11mmeixbut docs are rare
14:17mmeixDatomic learning first, of course
14:17mmeixstuff for weeks still ahead :-)
14:58skelternetGah! just figured out I've been getting bit by keyword scoping for roles in friend.
15:14mmeixQuestion: I'm trying to dsipatch a multimethod on a vector of three values, like [3 true false] - is there a way for a method to ignore one of this values, like in [3 true _]?
15:14mmeix(not sure, if the question is clear...)
15:20justin_smithmmeix: a dispatch function for a method can do anything a function can do, because it is a function
15:20justin_smith,(defmethod speak (partial take 2))
15:20justin_smitherr
15:20clojurebot#error {\n :cause "Unable to resolve symbol: speak in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: speak in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: speak in this...
15:20justin_smith,(defmulti speak (partial take 2))
15:20clojurebot#'sandbox/speak
15:21justin_smith,(defmethod speak [:big :dog] [_] :WOOF)
15:21clojurebot#object[clojure.lang.MultiFn 0x11a090b0 "clojure.lang.MultiFn@11a090b0"]
15:21justin_smith,(speak [:big :dog :whatever])
15:21clojurebot:WOOF
15:22Bronsadaily reminder I dislike a lot the new default unreadable object printer
15:22justin_smithBronsa: any particular reason? just because of how errors show up in this channel now?
15:23Bronsajustin_smith: no i'm talking about the #object thing, not #error. that is clojurebot-specific i think
15:24Bronsajustin_smith: it's too verbose for human consumption
15:24justin_smithBronsa: that's how all my exceptions print with newer clojure versions, just asked because I actually find the whole #error thing a bit noisy for the channel
15:24justin_smithBronsa: agreed
15:25Bronsajustin_smith: really? i just tried with 1.7.0-master and http://sprunge.us/OiNW
15:26justin_smithBronsa: weird - I am definitely getting #error with my project - maybe it would go away if I updated to the latest master
15:26Bronsajustin_smith: maybe it's nrepl vs clojure.repl?
15:26Bronsaclojure.main, that is
15:27justin_smithBronsa: I have seen the behavior in both (I use both kinds of repl)
15:27Bronsajustin_smith: nevermind something broken at my end
15:28Bronsaand it's my brain. mvn package is not mvn install
15:28justin_smithahh, so with a newer one you see the same?
15:28Bronsayeah
15:46TimMcH4ns: lein-diff is making progress!
15:53H4nsTimMc: nice! i'll not be hacking much in this coming week, but i'll have a look at it for sure. it's about time that we slash our monolith into pieces and get our project.clj's in order.
16:01TimMcThere, `lein diff HEAD~4 HEAD` now works if you install the plugin. :-D
16:01TimMcAssumes git and assumes project.clj in current directory (or root of project? not sure.)
16:05TimMchttps://github.com/timmc/lein-diff
16:11amalloyTimMc: this includes transitive dependencies, or no?
17:22underplankHi all. Im trying to run tests using cider in emacs. I using the C-c M-, command and although its running the tests, once I modify them it doesnt re-run the changes. Any ideas why? Cider 0.8.2
17:26underplankHmm… ok.. seemed to have sorted it out by adding a cider auto-refresh hook.
17:34mearnshhaving some problems with netty/aleph, seems like i need to set the underlying maxFramePayloadLength of the netty WebSocket08FrameDecoder, not sure if that's possible? https://www.refheap.com/102558
18:08underplankOk now, it seems that cider connects but does open up the repl.
18:47mearnshi solved my problem for now, realized i can cut down the size of the frames i'm sending over ws.
18:50gfredericksis str the cleanest way to distinguish 0.0 from -0.0?
19:12laggybitgfredericks: (= (Math/copySign 1.0 0.0) (Math/copySign 1.0 -0.0))
19:12gfredericks,(= (Math/copySign 1.0 0.0) (Math/copySign 1.0 -0.0))
19:12clojurebotfalse
19:12gfredericks,(Math/copySign 1.0 -0.0)
19:12clojurebot-1.0
19:12gfrederickslaggybit: nice!
19:12laggybit^^
19:45Surgois there some way I can have pr-dup able to print java objects that implement Serializable, without having to write my own implementation for the multimethod? it feels like someone else must have had this problem before
19:46Surgogah, there's a second part to that of course, print them in a way that they can be read-string'ed back in :)
19:53saeedSarpasIs there anyone here who has tried scientific simulation using clojure?
20:19TimMcamalloy: Yes, lein-diff compares transitive deps. I'd like to expand it to compare plugins and profiles as well, maybe even projects.
20:41gfredericks,(Math/scalb 1.0 -1022)
20:41clojurebot#error {\n :cause "More than one matching method found: scalb"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: More than one matching method found: scalb, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.IllegalArgumentException\n :message "More than one matching method ...
20:41gfredericks,(let [^Double x 1.0] (Math/scalb x -1022))
20:41clojurebot#error {\n :cause "Can't type hint a local with a primitive initializer"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.UnsupportedOperationException: Can't type hint a local with a primitive initializer, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.UnsupportedOperationException\n :message "...
20:41gfredericksO_O
20:42gfredericks,((fn [^Double x] (Math/scalb x -1022)) 1.0)
20:42clojurebot2.2250738585072014E-308
20:42gfredericks^ is that really what it takes?
20:42gfredericks,(let [x (double 1.0)] (Math/scalb x -1022))
20:42clojurebot#error {\n :cause "More than one matching method found: scalb"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: More than one matching method found: scalb, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.IllegalArgumentException\n :message "More than one matching method ...
20:42gfredericks,(Math/scalb (double 1.0) -1022)
20:42clojurebot#error {\n :cause "More than one matching method found: scalb"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: More than one matching method found: scalb, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.IllegalArgumentException\n :message "More than one matching method ...
20:42TimMcWhat even is a scalb?
20:42gfredericksdunno it's whatever
20:43gfredericksthe problem is there's two sigs, one takes double and one takes float
20:43gfredericksthere appears to be no way of calling it with unboxed math
20:43gfredericksthis is not remotely a blocker for me it just surprised me that I couldn't call it
20:43TimMcThe successor to scala, I guess.
20:46TimMc,(loop [d ^double (identity 1.0)] (Math/scalb d -1022)) ;; gfredericks: duh
20:46clojurebot2.2250738585072014E-308
20:46gfrederickssmells like boxing to me
20:47TimMc*Obviously* you want to erase type info and then re-apply it. :-)
20:49gfredericksI just wrote a totally different version of rationalize https://github.com/gfredericks/doubles/blob/master/src/com/gfredericks/doubles.clj#L91-97
20:51gfredericksarguably less useful, but at least more honest
21:05TimMcgfredericks: That 2047 is bothering me as an unnamed constant. I think you should create a library twenty-forty-seven.
21:06gfrederickswhat? a library for every number? when would it stop!!??
21:07gfredericksthink of the children
21:07TimMcwhich children
21:07TimMcHow many are there?
21:07TimMcPlease express the answer as a library.
21:07gfredericksI have two and you have one, so at least three
21:07TimMcwow, that's a lot of children
21:07gfredericksI refuse to make a library because of the children
21:14skelternetI have spent the afternoon tying routes into knots with friend and oauth2.
21:15skelternetI think I have somehow tried to protect the oauth2callback endpoint so it is in a redirect loop.
21:16TimMcSounds secure! ;-)
21:21skelternetheh. Yeah.
21:40cschephey can someone help me understand logging? I installed hbs recently to my web project, and started getting a bunch of "SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"."
21:40cschepso do I need to install l4j AND use clojure.tools logging?
21:41cschepOR what is what?
21:41cschepand do I need to have a log4j.properties file?
21:51cschepshoot, got disconnected. can canyone explain how slf4j / l4j / clojure.tools logging come together? or i guess just.. if one of my dependencies needs it.. how I can satisfy that dependency?
22:22skelternetcschep, I have only some guesses based on using slf4j in Java, not clojure. I hope someone more knowledgable answers you.
22:27skelternetIf I recall correctly, slf4j is an API that purposefully does not specify an implementation. You may need to find an implementation and add it to your project's dependencies.
22:28skelternetagain, I have yet to get my mind wrapped around logging in clojure.
22:28skelternetIt should be a fun problem to tackle async logging and using the MDC.
22:51cschepskelternet thanks for replying, i added both l4j and logging from clojure.tools, and then added an l4j.properties file
22:51cschepseems to be working..
22:51cschep:)
22:52skelternetcool beans
23:21skelternetclojurescript is a strange animal