#clojure logs

2015-07-17

01:25crocketIs it possible to embed clojure plugins or python plugins in a clojure program?
01:25crocketIs it simple?
01:42sm0kegoog.require could not find: cljs.core
01:43sm0keanyone else saw this
01:43sm0kepretty vague question i know
02:08jyu1I have a func (defn a ([x] x)),how to add a new branch in runtime, become (defn a ([x] x) ([x y] (+ x y))
02:09jyu1thanks at advanced
02:11sm0kei am not sure if that is possible
02:12sm0kea macro can do it though by overwriting the function
02:19jyu1a macro used currently, `(def ~name (~name ~@p)) . it is used to curry, but I want to keep the original def
02:20jyu1and another problem is that the macro must be used in the same namespace with the func
02:24sm0kesounds tricky, i guess you can use multimethods to add new dispatch at runtime
02:24sm0kenot sure if it would work
02:25jyu1the background like this
02:25jyu1(defcurrable piece-name->id "get the mapped id from the piece name" [entity-name piece-name] [piece-name-ids] (-> (piece-name-ids) (get-in [entity-name piece-name])))
02:26jyu1a macro is defined , defcurrable
02:26jyu1it has 2 parameter vector [entity-name piece-name] [piece-name-ids]
02:27jyu1the former is the params, and the later is that dependencies
02:28jyu1and curry the func with dependencies at the top level function.
02:30jyu1(cur piece-name->id sc/piece-name->id #(b/get-state :piece-name-ids))
02:30jyu1so i need not pass the dependencies everywhere
02:31sm0kejyu1: are you aware of `partial` in clojure?
02:31jyu1i see
02:31sm0keseems like you want that
02:31sm0ke,((partial + 2) 3)
02:31clojurebot5
02:32jyu1i use closure to do this instead.
02:32jyu1(defmacro defcurrable "define the currable function, p is the params to be curried" [name doc p p1 body] `(defn ~name ~doc ~p1 (fn ~p ~body)))
02:35jyu1actually it is the problem how to inject dependencies.
02:36sm0keit sounds very fragile to change function definition at runtime
02:36sm0kei mean you do it all the time in repl
02:36sm0kebut thats for dev
02:36sm0kei wouldnt try that stunt in production
02:36sm0kebut ymmv of course
02:38jyu1https://github.com/weejulius/imdb/blob/master/src/imdb/core.clj, https://github.com/weejulius/imdb/blob/master/src/imdb/schema.clj, you will see I have to inject lots of dependencies to the functions.
02:38jyu1sorry, it is hard for me to state well. thanks for your advice.
02:39sm0kewow that is something
02:39sm0keis still dont understand, why can you use something like (def new-fun (partial old-fun some-val)) ?
02:40sm0ke(def new-new-fun (partial new-fun other-val))
02:40sm0keand so on
02:42jyu1I understand partial. but that is not the key. no matter partial or curry, or others, i just want to inject dependencies a better way.
02:45jyu1i find a useful article, http://ekosz.github.io/2012/08/22/overriding-functions-in-clojure.
02:50jyu1you see the format of all my functions, a->b, for example entity-id->entity, it is used to get entity by id, but actually this func will depend on lots of others, I use defcurrable macro to seperate them in the parameter list, and inject the dependencies in the top level function.
02:51jyu1i am thinking a way to simpify the injection.
03:07Phoh4angCan somebody explain me why we have clojure.test and cljs.test? Why can't it be a single namespace?
03:14crocketIf I invoke '(assoc config :appenders (get-default-appenders (:log-file config)))', (:log-file config) becomes nil in get-default-appenders.
03:14crocketWhy?
03:14clojurebothttp://clojure.org/rationale
03:15crocketIs it a bug in assoc?
03:16crocketNo, it's not.
03:16crocketThe bug is somewhere else.
03:17crocketIt was my bug.
03:18kungicrocket: of course it was :-) The First Rule of Programming: It's Always Your Fault
03:21crocketIt seems every bug is stupid.
03:21crocketkungi, not always.
03:21crocketThat assumes everyone else doesn't make bugs.
03:21H4nscrocket: the more experienced you are, the more likely it becomes that you run into bugs made by others
03:21kungicrocket: it assumes that standard library functions which everyone uses every day are not broken.
03:22H4nscrocket: the likeliness that you discover a bug in some piece of code is inversely proportional to its number of users
03:22H4nscrocket: the likeliness that the bug is your own is always much larger than the likeliness of a bug in someone elses code.
03:24crocketMutations introduce bugs.
03:24crocketI mean code mutations done by a coder.
03:33crocketHow do I package a leiningen project with an executable?
03:33crocketI wish a shell script was generated that delegates to an uberjar.
03:37H4nscrocket: chmod +x uber.jar; ./uber.jar
03:38crocketH4ns, does that really work?
03:38kungiH4ns: really?
03:38H4nsfolks. why don't you just give it a try?
03:39kungiH4ns: It sounds to easy to be true :-)
03:39dstocktonsuperh4ns
03:39crocketH4ns, It doesn't work.
03:39H4nsdstockton: i hope you know the reference :)
03:40H4nscrocket: then your operating system does not support it. it works on linux.
03:40kungiI get an exec format error when I try this
03:40dstocktonpeep show ;)
03:40H4nsdstockton: +1
03:40H4nsreminds me, they were supposed to release another season.
03:41crocketWhy does leiningen raise my CPU temperature when it start up?
03:41H4nskungi/crocket: it is possible that you need to install something so that the exec handler for jar files is installed in your distribution. i tried this on centos 7 and there it worked.
03:41oddcullys/linux/some &/
03:41dstocktonyes, end of the year i think H4ns
03:42H4nsdstockton: so looking forward to it :)
03:42dstocktonme too, will probably be the last
03:42Phoh4angcrocket: because java is slow and greedy for your cpu and memory
03:42H4nsdstockton: even the longest adolescence has to end at some point.
03:43Phoh4angI actually hope someday we will have lein running in a nodejs. Not sure if it's eve possible though
03:43TEttinger$google lein-bin
03:43lazybot[Raynes/lein-bin · GitHub] https://github.com/Raynes/lein-bin
03:43crocketFor some people, adolescence ends in 30s.
03:43H4ns(inc TEttinger)
03:43lazybot⇒ 62
03:43TEttingerthanks!
03:44kungi(inc TEttinger)
03:44TEttingerlein-bin only will work if java is on your path though
03:44lazybot⇒ 63
03:45TEttingerif you want to work around that (java isn't put on the path by default on windows with the JRE installer), you may need a openjdk bundler.
03:45TEttinger$google lein-packr
03:45lazybot[Packr-generated exe prints nothing, does nothing #33 - GitHub] https://github.com/libgdx/packr/issues/33
03:45TEttingergah
03:46oddcullyhehe
03:46crocketlein-bin
03:46TEttingerhttps://github.com/tommyettinger/lein-packr
03:47TEttingerlein-bin is pretty cool, it just appends the jar contents as a big string into a combination .bat and .sh file (it's valid syntax for both)
03:47TEttingerso it's less than 1K larger than the uberjar I think
03:53H4nsi'd still like to know why ./uber.jar works for me
03:53oddcullybecause you have configured in your kernel, that you allow alternative exec to happen
03:54H4nsoddcully: that much i gather - but as i have not done that explicitly, i'd like to know what needs to be done if it does not work.
03:55oddcullyyeah, i guess your distribution has done that for you
03:55H4nsoddcully: yes, that much i had guessed.
03:55oddcullyyou could look, what files get installed with your jdk or the supporting package
03:55wasamasaecho '#!/bin/bash' > uber.sh; echo 'java -jar uber.jar' >> uber.sh; chmod +x uber.sh; ./uber.sh
03:55lazybot'#!/bin/bash' > uber.sh; echo 'java -jar uber.jar' >> uber.sh; chmod +x uber.sh; ./uber.sh
03:55wasamasa...
03:56wasamasanot lazy enough
03:58oddcullywasn't there even a a target in lein for that shebank version? or is the openjdk shipping a tool for it?
04:01oddcullyH4ns: couldn't for the life not remember the name... looked it up in kernel config: binfmt_misc is the module for it
04:01H4nsoddcully: right at this moment i found that binfmt must be the keyword for searching, thanks! :)
04:02oddcullyH4ns: in your kernel source: Documentation/java.txt
04:03wasamasaawesome: https://github.com/Raynes/lein-bin/blob/master/src/leiningen/bin.clj#L20-L24
04:15crocketIs anyone interested in writing a DDNS client in clojure?
04:15crocketI wrote a simple one.
04:15crockethttps://github.com/crocket/clj-ddns-client
04:18kwladykaWhat do you think about Clojure doesn't have types for data. What with big projects with many programmers. How they know what function will return if it doesn't have type. And what if somebody will change "id" to "uid", it need to change all code which use that functions, but how to find it in code without types.
04:20Fuivash7kwladyka: see core.typed or prismatic/schema
04:21kwladykaFuivash7, thx.
04:21kwladykaSo it is additional library
04:21kwladykabut what about idea?
04:22kwladykaidea of Clojure without types
04:22kwladykais it good or not when project has many programmers
04:22kwladykaand code is changing, what functions return is changing
04:22kwladykaand other program has to know what function return
04:23H4nskwladyka: please design your sentences before you type and send them to the channel.
04:23kwladykait is hard to explain :P
04:23H4nskwladyka: there are languages which support strong static typing, and those cater for those that believe that strong types are the only way to write reliable software.
04:24Fuivash7kwladyka: personally, I would like to see a clojure with a rich type system. Today's type systems are still pretty restrictive though, so it's hard to get it right. As for "code is changing, how do programmers stay sane" question, I believe it's somewhat more of an organizational problem.
04:25kwladykaH4ns, but how it looks in Clojure? I don't have experience like that in Clojure and i was talking about that with my friend yesterday. I couldn't explain him how Clojure programmers deal with changes what function return.
04:26H4nskwladyka: one good approach is not to change the contract of a function without making sure that all uses are updated. another good approach is documentation. also preconditions, tests, code inspection, discipline.
04:26Fuivash7microservices
04:27Fuivash7Right?
04:27kwladykaFuivash7, yes but for example with strong types when you change "id" to "uid" for User you can easy find all places in code which use User and check it. What will you do in Clojure?
04:27H4nsFuivash7: microservices are a way to contain the mess in smaller units :)
04:27crocketkwladyka, Clojure has other measures to enforce interface integrity.
04:28H4nskwladyka: i will do textual replacements. i've done that for many years, and while it sometimes sucks, it is by no means a chore.
04:28crocketHowever, haskell has better guarantees of interface integrity.
04:28Fuivash7H4ns: yep, that's what we programmers do, lol
04:28H4nskwladyka: i see how people love the convenience of their integrated type safe refactoring, but i've been living without that forever, so i'm not missing it.
04:29kwladykabut maybe the topic what i am talking about it is not problem in reality? My Clojure programmers don't have problem with changes like that. I don't know.
04:29crocketClojure's immutable data structures help you reason about code a lot more than usual static typing techniques.
04:29H4nskwladyka: besides, smarter refactoring tools for clojure are available, i just don't feel that i need them.
04:29crocketkwladyka, ^^
04:30Fuivash7kwladyka: you will feel pain. It's just my opinion though.
04:30kwladykaFuivash7, feel pain if/when what? :)
04:30H4nskwladyka: programming is making trade-offs all the time. use one thing, you'll not get what the other one supplies.
04:31crocketH4ns, Rich Hickey would say microservices do not necessarily pull apart components.
04:31H4nsalso, programming is not about "being right", but about "getting stuff done" mostly.
04:31crocketgetting stuff done and maintaining
04:31Fuivash7kwladyka: if you have a zillion klocs of clojure code and you *have to* change all :id to :uid but only for Users. It seems like a stupid task for me though, not something you'll do in a real-world application.
04:31crocketWhen it comes to maintaining, code integrity matters.
04:32crocketThat's where clojure comes in.
04:32H4nsthat's where tests come in much more than any language choice.
04:32kwladykaFuivash7, yeah example is maybe not the best
04:33kwladykaFuivash7, but the problem in that situation is to find all places which use Users data.
04:34Fuivash7H4ns: everytime I hear something like 'programming is not about "being right", but about "getting stuff done"' I get that strange sad painful feeling in my stomach.
04:34kwladykaFuivash7, and GUI support for that operation
04:35H4nsFuivash7: life becomes much easier when you accept that.
04:35kwladykaFuivash7, but the true is programming is for business.
04:36kwladykaprogramming and programmers without business don't exist
04:36Fuivash7kwladyka: well, after all you can use namespaced keywords, datomic-style. I don't know about GUI; cursive and ccw probably support such refactorings.
04:37Fuivash7H4ns: I guess so, but for me it sounds like "life becomes much easier when you don't think about morals or ethics of your decisions". It's kinda true, but still feels wrong.
04:39H4nsFuivash7: it is not wrong. programming is not a science, it is an art form. it is highly dependent on fads and on technology available at a certain point. the programmer always makes tradeoffs, some deliberately, some unconscious.
04:40kwladykaFuivash7, on the end of rational thinking you have to care about how people feel and about they morale so even if you don't think about your inner morals or ethics rational thinking still win. So like in coding when you think about deliver product and maintenance still you have to care about quality and do thinks right :)
04:41kwladykai think it is more about which thinks in head should come first, about priority :)
04:42crocketIs it safe to execute "java -Xmx20m -XX:MaxMetaspaceSize=40m -jar target/uberjar/clj-ddns-client-0.1.2-standalone.jar"?
04:42crocketI'm not sure how small clojure programs could handle 20 megabytes of heap.
04:43crocketThe program is at java -Xmx20m -XX:MaxMetaspaceSize=40m -jar target/uberjar/clj-ddns-client-0.1.2-standalone.jar
04:43crocketoops
04:43crocketThe program is at https://github.com/crocket/clj-ddns-client
04:44Fuivash7H4ns: I can't say I don't agree with you. On the other hand, something inside me keeps telling me that it is exactly this point of view which leads us to crappy industry standards, flash-player, the 12309 bug still popping out on some linux boxes and people who still write desktop applications in C. I'm just grumbling though.
04:44crocketIt seems a small clojure program is stable with 20MB of heap and 40MB of metaspace for a while.
04:45crocketWould it throw an OutOfMemory exception anytime soon?
04:45H4nsFuivash7: i envision a future in which programming will no longer be an art form, but a standardized activity that people can actually rely on. we're not there yet, by any means, though.
04:45Fuivash7kwladyka: yeah, you right about priority, that's the point.
04:47crocketIt currently consumes 146MB of memory despite 20MB of heap and 40MB of metaspace.
04:47crocketWhat am I missing?
04:47Fuivash7H4ns: in order to make it possible we human probably have to replace our natural language with an artificial, totally precise one, so that requirements can be communicated effeciently. I kinda like the idea, you know.
04:47H4nsFuivash7: either we become robots or the robots become us.
04:49kwladykaFuivash7, if i know the true reason why software looks like a mess inside in many cases are managers not programmers and not assertive programmers. Managers push managers and they push lower managers and... ... and they push programmers to deliver more and more in shorter time.
04:50kwladykaprogrammers do mess job, and month by month they do more mess and write slower and slower and all doesn't make sense :)
04:51Fuivash7H4ns: GLORY TO ROBOTS! KILL ALL HUMAN! I'm not sure though whether this phrase is used outside russian language or not, lol.
04:53Fuivash7kwladyka: the other side of problem is that in order to become a surgeon you have to study for almost a ten years, and in order to become a programmer, you know, you have to write code, that's all. Anyway, I think we are a little off-topic here, and people actually have question about clojure and jvm...
04:55kwladykaFuivash7, yeah but only one reason why people let programmer without experience write code is... not so big consequence like in surgery :) ok then end off-topic. Unfortunately i can't help with this question about clojure and jvm...
04:58Fuivash7kwladyka: well when the robots will finally take out the consequences will be exactly the same, if not worse, lol. as for jvm memory consumption, I'm not sure either but I suspect there is a minimum allowed value for the maxmetasize.
04:58Fuivash7crocket: ^^^ can't find a proof though
05:07Pupeno_So, in Clojure I cannot call a function unless it was defined *above* in the file?
05:08H4nsPupeno_: you can use "declare" if you want to use a symbol before defining it.
05:08crocketFuivash7, 40MB was about the minimal metaspace size.
05:11Fuivash7Pupeno_: clojure evaluates your files just like you would input the forms in the REPL, so it's by design, not "lazy programmers don't care enough to write multipass compiler" or whatever.
05:12Fuivash7crocket: maybe it's the jvm itself eating the other memory.
05:14jaenQuick question, when you use schema & coercions the order is coerce -> validate, which is useful if you, say, have incoming JSON data you want to hydrate into Clojure datastructures. But I couldn't find any way to switch the order to validate -> coerce, which would be useful to validate the shape of an API request before turning it into JSON. Is anyone aware of such a feature in schema offhand?
05:33crocketHow can I deamonize a clojure app without jsvc?
05:33crocketWithout apache commons daemon.
06:11wasamasawhy not let your init handle that
06:11wasamasait's been specifically engineered for that task!
06:15kwladykais any function which turn [x y] into x y?
06:16TEttingerkwladyka: sorta, not really
06:16TEttinger,`(~@[+ 1 2])
06:16clojurebot(#object[clojure.core$_PLUS_ 0x67a5eb90 "clojure.core$_PLUS_@67a5eb90"] 1 2)
06:16TEttinger,`(~@[3 1 2])
06:16clojurebot(3 1 2)
06:17kwladykaso is any better way to write https://www.refheap.com/344128913896a0746f47df8e4 ?
06:17TEttinger~@ only works in a syntax-quote, and there is no multiple return in clojure
06:17clojurebotRoger.
06:17TEttingerapply
06:18wasamasakwladyka: why not destructure judiciously?
06:18oddcullykwladyka: why not destrcuture?
06:18oddcullylerl
06:18wasamasakwladyka: return a vector and let the function dealing with it do the work
06:18TEttinger,(apply str [1 2])
06:18clojurebot"12"
06:18TEttingerif that's a two-element collection, apply will work fine
06:20kwladykaso how it should looks, i am a little confuse
06:21oddcullykwladyka: use [r c] instead of size, then replace your first/last calls with r and c
06:22oddcully,(let [[c r] '(:a :b)] (str c r))
06:22clojurebot":a:b"
06:22kwladykaoh... but is there a way to not use "let"?
06:22oddcullyor go with the apply
06:23oddcullybut you already use `let`?
06:23oddcullyor do what TEttinger suggested: (apply handle-resize (t/get-size term))
06:23kwladykayes, but i am thinking is it a way to not use let, do this in one line
06:24kwladykahmm
06:25tgoossensif (def b [a 2]) why does (let b a) gives "IllegalArgumentException let requires a vector for its binding in com.ooliba.tablescript.processor:1"
06:26oddcullymaybe (let [b a]) ?
06:27tgoossensit should return 2
06:27tgoossensinteresting
06:27kwladykaapply looks good, thank you
06:27oddcullythe error is about the let not getting a [] as first argument
06:29kwladykatgoossens, did you read https://gist.github.com/john2x/e1dca953548bfdfb9844 ?
06:30tgoossenskwladyka, nope thanks
06:30tgoossensi'll take a look at it
06:30tgoossensbecause i don't understand why it doesn't work oddcully
06:30kwladykatgoossens, it is good, i learned from that site
06:32tgoossensif (def b [(symbol "a") 2])
06:32tgoossensthen b is a vector
06:32tgoossensthen why
06:32tgoossens(let b a)
06:32tgoossenssays the first argument is not a vector
06:33kwladykatgoossens, because let [x 1 y 2] not let x 1 y 2
06:34kwladykatgoossens, read this site which i linked, this is precise describe
06:34tgoossenskwladyka, ok :)
06:34kwladykaand of feel free to ask :)
06:34kwladyka*of course
06:34tgoossensthanks
06:39crockethi
06:39crocketHow do I make a comment? ';' or ';;'?
06:40tgoossenskwladyka, i think i will be needing macros
06:40tgoossensof course it doesn't work
06:40namracrocket: one ';' is enough for a comment
06:41namracrocket: but you might use multiple to distinguish between code sections etc, for that you can take a look at that style guide -> https://github.com/bbatsov/clojure-style-guide#comments
06:41H4ns; for comments on the same line as code, ;; for comments interspersed with code, ;;; for top-level block comments
06:42crocketnamra, emacs clojure-mode indents ';' incorrectly.
06:42crocketThus, I just use ';;' in emacs clojure-mode.
06:45crocketH4ns, Where do I find the guide line?
06:46H4nscrocket: what do you mean? https://github.com/bbatsov/clojure-style-guide#comments ?
06:48kwladykatgoossens, i don't know what are your trying to do
06:52kwladyka(t/move-cursor term (first @terminal-size) (last @terminal-size)) <- how to write more readable? only with "let [[cols rows] @terminal-size]"? (t/move-cursor term #([%1 %2])@terminal-size) doesn't work because of ClassCastException chess_challenge.console_draw$pause$fn__2040 cannot be cast to java.lang.Number lanterna.terminal/move-cursor (terminal.clj:155)
06:54oddcully(let [[cols rows] @terminal-size] (t/move-cursor term cols rows))
06:58kwladykaoddcully, but is it possible without let?
06:58kwladykahmm but it is good enough i think
07:44tgoossenskwladyka, are you still here?
07:50kwladykatgoossens, yes
07:55tgoossenskwladyka, this illustrates what I want https://gist.github.com/tgoossens/9e4f6237d06ecbb0ceed
08:02kwladykatgoossens, hmm still i am not sure what you want achieve
08:03tgoossenskwladyka, basically a list containing symbols and i want to replace certain symbols by a value after which I eval the list
08:03tgoossensi could convert it to string and replace
08:03kwladykatgoossens, you did def var with char "a" and "b" and you did def quation with char '+ '1 'a 'b and i dont understand why and what you want to do with that
08:03tgoossensbut that seems not ideal
08:04kwladykatgoossens, if i understand you want replace one element of list with another value?
08:05kwladykatgoossens, let is for something else
08:05tgoossens'(+ a b a )
08:05tgoossensreplace a by 1
08:05tgoossensb by 2
08:07kwladykatgoossens, hmm anyway why do you need that change? where you use that?
08:09tgoossenskwladyka, basically: the user gives an expression string "a+b", by a parser converted to '(+ a b) Then I want to assign valuesto a and b
08:10tgoossenskwladyka, important to know i'm not making a calculator
08:10tgoossensthe user gives me "a+b" and expects to get a clojure function with two inputs that returns the sum
08:12kwladykatgoossens, you could find the position of a and b and use http://clojuredocs.org/clojure.core/replace
08:12kwladykatgoossens, i guess maybe there is shorter way, but i don't know now
08:12tgoossensi was trying with macro's
08:12tgoossensbut i don't understand them well enough yet
08:13kwladyka(replace '{0 ZERO, 1 ONE, 2 TWO} '(This is the code 0 1 2 0))
08:13kwladyka(This is the code ZERO ONE TWO ZERO)
08:13kwladyka,(This is the code ZERO ONE TWO ZERO)
08:13clojurebot#error {\n :cause "Unable to resolve symbol: This in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: This 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: This in this co...
08:13kwladyka,(replace '{0 ZERO, 1 ONE, 2 TWO} '(This is the code 0 1 2 0))
08:13clojurebot(This is the code ZERO ...)
08:13tickingtgoossens: if you want to write a user facing programming language, translation to clojure is not a good idea
08:14tickingtgoossens: if it doesn't have to be expandable not making it expandable is generally a good idea
08:14tickingtgoossens: especially if the alternative means, being able to inject arbitrary clojure code
08:14tgoossenskwladyka, seems to work :)
08:16tgoossensticking, basically what I have to do is to process some SQL like query given by the user: "SELECT age+1 FROM people". Where people will be a "table" in memory (no database involved)
08:16tgoossensand i need to convert 'age +1' to a clojure function in order to apply it to the data structure in memory
08:17tgoossensticking, but your point seems valid
08:18tickingI'd create a ast with instaparse and than evaluate that with a treewalker
08:26kwladykatgoossens, why no use sql memory database?
08:27noncom,(map #([%]) [1 2 3])
08:27clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector>
08:27noncomwhy? ^
08:28noncom,(map (fn[a] [a]) [1 2 3])
08:28clojurebot([1] [2] [3])
08:29crocket,(println "bitch")
08:29clojurebotbitch\n
08:29crocket,(print "bitch")
08:29clojurebotbitch
08:30snowell,(map vector [1 2 3])
08:30clojurebot([1] [2] [3])
08:30snowellnoncom: ^
08:30crocket(into [] '(1 2 3))
08:30snowellI mean…that doesn't really answer your question, but it's at least nicer than defining a new fn :D
08:31crocket,(into [] '(1 2 3))
08:31clojurebot[1 2 3]
08:31crocket,(into "" \b \i)
08:31clojurebot#error {\n :cause "java.lang.Character cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Character cannot be cast to clojure.lang.IFn"\n :at [clojure.core$transduce invoke "core.clj" 6583]}]\n :trace\n [[clojure.core$transduce invoke "core.clj" 6583]\n [clojure.core$into invoke "core.clj" 6601]\n [sandbox$eval174 invoke "NO_SOURCE_FILE" 0...
08:31crocket,(join "" \b \i)
08:31clojurebot#error {\n :cause "Unable to resolve symbol: join in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: join 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: join in this co...
08:31crocket,(clojure.string/join "" \b \i)
08:31clojurebot#error {\n :cause "Wrong number of args (3) passed to: string/join"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (3) passed to: string/join"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 40]\n [sandbox$eval221 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compi...
08:31crocket,(doc clojure.string/join)
08:31clojurebot"([coll] [separator coll]); Returns a string of all elements in coll, as returned by (seq coll), separated by an optional separator."
08:31crocket,(clojure.string/join [\b \i])
08:31clojurebot"bi"
08:32crocket,(clojure.string/join [\b \i \t \c \h])
08:32clojurebot"bitch"
08:33kwladykais it possible to clearn repl console?
08:33kwladyka*clean
08:33kwladykaand i mean about chars on console not vars and namespace
08:34gfredericksC-a C-k?
08:34kwladykanope, i am using intellij repl
08:34noncomkwladyka: there is a tiny button on the console
08:34noncomdon't remember how it looks
08:34kwladykaoh there iss a button!
08:34noncomprobably something with an "x"
08:35kwladykait is icon of trash :)
08:35noncomoh ok :)
08:35kwladykashould be rubber
08:36noncomkwladyka: in eclipse it is http://joxi.ru/DrlavXzIXoqWmP
10:09tgoossens Using instaparse (example from readme) i convert infix "2+2" to AST and with instaparse/transform to (+ 2 2) which then gets evaluated. However i'm interested in getting '(+ 2 2) instead of 4. How do i do that
10:14crocketCan I put (* 3 1000) in an .edn file?
10:23TimMctgoossens: Just don't eval it? I'm confused about where eval is happening automatically. Perhaps a link?
10:26tgoossensI edited the source code of instaparse transform
10:26tgoossensTimMc,
10:27tgoossensThe eval seems to happen in the recursion step
10:27tgoossens(apply ... ...)
10:27tgoossens(apply x y) i replaced that by (cons x y)
10:27tgoossensI'll propose in the project to include such a thing in apiµ
10:34TimMcI'm not familiar with instaparse, so this is all very mysterious to me.
10:35TimMcI don't know why a parsing lib would include eval.
10:35tgoossensTimMc, it should be decomplected :)
10:36justin_smithcrocket: yes, but it would be a list
10:36TimMctgoossens: Can you show me where it does this?
10:36tgoossensyes
10:36tgoossensone moment
10:36tgoossensTimMc, https://github.com/Engelberg/instaparse/blob/master/src/instaparse/transform.clj line 36
10:37tgoossensreplace 'apply' by 'cons' and problem is solved
10:38TimMcOh, that's not eval -- that's just tree transform stuff.
10:39TimMcInstead of passing :add + to insta/transform, why not pass :add (partial list '+)?
10:40tgoossensinteresting
10:40TimMc(There's probably a nicer way of writing that.)
10:41tgoossensTimMc, Hey man. thanks a lot! :)
10:41justin_smithTimMc: you probably want (partial cons '+) to get the right output, but same idea
10:41tgoossensNevertheless
10:41tgoossensI did not expect my tree to be evalutated
10:44crocketjustin_smith, An unevaluated list
10:44crocket'(* 3 1000)
10:44crocketShit, it's difficult to pronounce "an unevaluated list"
10:44justin_smithcrocket: right
10:45justin_smith,'(* 3 1000)
10:45clojurebot(* 3 1000)
10:54TimMctgoossens: Hmm, I think the readme is pretty clear in that example that transform is being used for evaluation.
10:55tgoossensTimMc, i noticed now :p
10:55TimMcOK :-)
10:57tgoossensTimMc, A common error of mine. Assuming too quickly what it (should) does
11:01crocketIs there a way to string a value through a dynamic set of functions?
11:01crocketIf the set was static, I could use '->' macro.
11:01justin_smithcrocket: comp
11:02justin_smith,((comp :c :b :a} {:a {:b {:c 42}}})
11:02clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: }>
11:02justin_smitherr
11:02crocketok!!!
11:02crocketThat is it!!!
11:02justin_smith,((comp :c :b :a) {:a {:b {:c 42}}})
11:02clojurebot42
11:02justin_smithcrocket: yeah, it's like -> but backward, and doesn't do things like macros
11:04justin_smithcrocket: maybe you want ##(((comp (partial apply comp) #(reverse %&)) :a :b :c) {:a {:b {:c 42}}})
11:04lazybot⇒ 42
11:04crocketIs there an equivalent of (apply comp (reverse x))?
11:05justin_smith,(def (comp (partial apply comp) #(reverse %&)) pmoc)
11:05clojurebot#error {\n :cause "First argument to def must be a Symbol"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: First argument to def must be a Symbol, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.RuntimeException\n :message "First argument to def must be a Symbol"\n :at [cloju...
11:05justin_smitherr
11:05justin_smith,(def pmoc (comp (partial apply comp) #(reverse %&)))
11:05clojurebot#'sandbox/pmoc
11:05justin_smithcrocket: pmoc, of course!
11:06justin_smithin all seriousness, nothing built in as far as I know
11:07justin_smithprobably better as (defn pmoc [& fs] (apply comp (reverse fs)))
11:10justin_smithalso, thrush might be a better name than pmoc for it
11:14crocketHow do I string a value through a series of functions that only touch the value under a certain condition?
11:14justin_smithsounds kind of like cond->
11:15justin_smithbut you need a non-macro version, right?
11:15crocketmaybe?
11:15crocketNo
11:15crocketI don't care
11:15justin_smithcond-> might be your thing then
11:15justin_smith(doc cond->)
11:15clojurebot"([expr & clauses]); Takes an expression and a set of test/form pairs. Threads expr (via ->) through each form for which the corresponding test expression is true. Note that, unlike cond branching, cond-> threading does not short circuit after the first true test expression."
11:16MattWestIf the conditional depends on the value of your threaded value, you may rather use a function which has the conditional built in, since cond-> doesn't use the threaded value.
11:16crocketjustin_smith, However, I need when-let!!
11:16crocketcond-> doesn't emulate when-let
11:18justin_smithsome-> stops at the first nil result (if any)
11:18justin_smith,(-> {} :a inc)
11:18clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [clojure.lang.Numbers ops "Numbers.java" 1013]}]\n :trace\n [[clojure.lang.Numbers ops "Numbers.java" 1013]\n [clojure.lang.Numbers inc "Numbers.java" 112]\n [sandbox$eval47 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compiler eval "Compiler.java" 6792]\n [clojure.lang.Compiler eval "Compiler.java" 67...
11:18justin_smith,(some-> {} :a inc)
11:18clojurebotnil
11:18justin_smith,(some-> {:a 1} :a inc)
11:18clojurebot2
11:18crocketDoes some-> help me?
11:19justin_smithcrocket: well, when-let doesn't proceed if a value is nil
11:19justin_smiththat's how they are similar
11:19crocketI don't test for the value in the middle.
11:19crocketI test for another value
11:20justin_smithsounds like you want a plain old function
11:20justin_smithor maybe a few functions
11:20crocket(cond-> value (cond a) (action a) (:key value2) (action b))
11:21crocket(cond-> value (cond a) (action a) (:key value2) (action-b (:key value2))
11:21crocketI want to remove duplication of (:key value2)
11:21crocket(cond-> value (cond a) (action a) (:key value2) (action-b (:key value2)))
11:21crocketjustin_smith, ^^
11:23crocketThe second condition's value could be used in the second form.
11:25justin_smithfor the (:key value2) part, how is that related to a / (action a) ?
11:25justin_smithin that it only gets executed if the first part was?
11:26crocketjustin_smith, The actual code is https://www.refheap.com/106665
11:26justin_smithoh, so this works?
11:27crocketjustin_smith, I haven't tested yet.
11:28justin_smithOK, looks like that should work
11:28justin_smithsince your conditions don't use the threaded value, as MattWest mentions
11:29crocketjustin_smith, How would you remove duplication of (:logfile options)?
11:29justin_smithcrocket: I would do that in the destructuring on line 2
11:30crocketSo brilliant
11:30justin_smith[{logfile :logfile verbose :verbose :as options} :options log-config :log-config}]
11:30justin_smithsomething like this
11:30justin_smithin fact you likely don't need the :as options part
11:35crocketjustin_smith, [{{:keys [verbose log-file]} :options arguments :arguments} log-config]
11:36crocketThis compiles.
11:36justin_smithyeah, that works too
11:36danielpcoxHey All, what does it mean when proxy throws "Exception Incompatible return types clojure.core/most-specific (core_proxy.clj:23)"?
11:36justin_smithcrocket: usually, as soon as I do any nesting I stop using :keys altogether, for better or worse
11:37justin_smithdanielpcox: sounds like you are trying to proxy something but you got one of its method signatures wrong
11:38danielpcoxjustin_smith: i did this: (proxy [App] [])
11:38justin_smithso a proxy that implements no methods and takes no constructor args?
11:39danielpcoxjustin_smith: well, i was originally trying to proxy a scala abstract class that extends this one, and got the same error, so i just started cutting things out of the scala class until i figured out which one of its parents was causing the trouble
11:40justin_smithoh, scala
11:40justin_smithinterop with scala is... not easy
11:40danielpcoxjustin_smith: does this look like it should be proxyable with no constructor args? https://twitter.github.io/util/docs/index.html#com.twitter.app.App
11:41danielpcoxjustin_smith: i'm sort of earning the right to work with Clojure by implementing a framework my company has already developed in Scala :)
11:41justin_smithdanielpcox: OK< but scala has some extra "stuff" that isn't part of the vm, and in order to extend it you have to satisfy it and it's weird and hard to interact with outside the scala language
11:42justin_smithyou're much better off accessing clojure stuff from scala, that's much simpler, because clojure is much more "vanilla" in its usage of the jvm
11:44danielpcoxjustin_smith: i feel you. it has been pretty frustrating so far. but if i can figure out how to use this Scala framework they wrote from Clojure, I get to program in Clojure.
11:44justin_smithdanielpcox: another options would be to make a small adaptor in scala, that can have an instance of a vanilla jvm interface injected, and then you could inject something written in clojure
11:45danielpcoxhmmm… that might be a possibility
11:45justin_smithdanielpcox: I'm not saying it's bad to use scala from clojure, just that scala does a great job of making it much more difficult than it should be
11:46justin_smithwhereas clojure stays "closer to the metal", so one direction of interop is much easier than the other
11:46danielpcoxthanks justin_smith, i'll try going the adaptor route
11:47justin_smithdanielpcox: also, I hope your plot to integrate clojure succeeds!
11:48danielpcoxjustin_smith: :) so do i!
11:49crocketLet's assume I have {:appenders {:file-appender '(rotor/rotor-appender)}}
11:50justin_smithcrocket: why a list with a symbol in it? that's really kind of weird
11:50crocketHow do I associate :debug to :level in the map at the second position of the list?
11:50crocketThe reulst would be {:appenders {:file-appender '(rotor/rotor-appender {:level :debug})}}
11:50crocketI'm constructing a function call.
11:51justin_smithcrocket: does someone eval the list eventually? ahh
11:51crocketI'm constructing a function call in a nested map
11:52justin_smith,(update-in {:appenders {:file-appender '(rotor/rotor-appender)}} [:appenders :file-appender] concat [{:level :debug}])
11:52clojurebot{:appenders {:file-appender (rotor/rotor-appender {:level :debug})}}
11:52crocketNo
11:52crocketIt could be either {:appenders {:file-appender '(rotor/rotor-appender)}} or {:appenders {:file-appender '(rotor/rotor-appender {:a :b)}}
11:52crocketSo, I can't just concat.
11:54crocketjustin_smith, Can you think of a clever trick?
11:56justin_smith,(update-in {:appenders {:file-appender '(rotor/rotor-appender)}} [:appenders :file-appender] #(list (first %) (assoc (second %) :level :debug)))
11:56clojurebot{:appenders {:file-appender (rotor/rotor-appender {:level :debug})}}
11:56justin_smith,(update-in {:appenders {:file-appender '(rotor/rotor-appender {:a :b)}} [:appenders :file-appender] #(list (first %) (assoc (second %) :level :debug)))
11:56clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
11:56justin_smithoops
11:56scriptorso the idea is to add that map to the list?
11:56justin_smith,(update-in {:appenders {:file-appender '(rotor/rotor-appender {:a :b})}} [:appenders :file-appender] #(list (first %) (assoc (second %) :level :debug)))
11:56clojurebot{:appenders {:file-appender (rotor/rotor-appender {:a :b, :level :debug})}}
11:56justin_smithscriptor: update if present, create if not
11:57justin_smithsecond / assoc have that behavior when combined
11:57justin_smith,(assoc nil :a 0)
11:57clojurebot{:a 0}
11:57justin_smith(second [])
11:57justin_smith,(second [])
11:57clojurebotnil
11:57scriptorjustin_smith: and by update you mean append?
11:57justin_smithwhat?
11:57clojurebotwhat is short for ,(doc ...)
11:57scriptorsorry, that was for crocket ^
11:58justin_smithscriptor: by update I mean add keys if there is a map
11:58justin_smithscriptor: there is no appending there
11:58crocketjustin_smith, I think you could use deconstructuring.
11:58clojurebotNo entiendo
11:58justin_smithcrocket: sure, any usage of first/second can likely be replaced with a destructure
11:59scriptorwell, there is appending if you need to create the map, right?
11:59scriptorfrom '(rotor/rotor-appender) to '(rotor/rotor-appender {:a :b})
11:59justin_smithscriptor: it unconditionally creates a two element list
11:59justin_smithno matter what the input was
12:00justin_smith,(update-in {:appenders {:file-appender '(rotor/rotor-appender {:a :b})}} [:appenders :file-appender] (fn [[h t]] (list h (assoc t :level :debug)))
12:00clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
12:00justin_smith,(update-in {:appenders {:file-appender '(rotor/rotor-appender {:a :b})}} [:appenders :file-appender] (fn [[h t]] (list h (assoc t :level :debug))))
12:00clojurebot{:appenders {:file-appender (rotor/rotor-appender {:a :b, :level :debug})}}
12:01justin_smith,(update-in {:appenders {:file-appender '(rotor/rotor-appender)}} [:appenders :file-appender] (fn [[h t]] (list h (assoc t :level :debug))))
12:01clojurebot{:appenders {:file-appender (rotor/rotor-appender {:level :debug})}}
12:02crocketjustin_smith, https://www.refheap.com/106666
12:03crocketThis is some dirty trick.
12:03crocketNo one is going to understand this except me.
12:03justin_smithcrocket: you'll get better performance if instead of (eval '(rotor/rotor-appender {})) you do (#(apply (first %) (rest %)) [rotor/rotor-appender {}])
12:04justin_smithcrocket: also, that won't work, because '(+) doesn't have the callable function + inside, it has the callable symbol '+ inside
12:04justin_smith,('+ 42 1)
12:04clojurebot1
12:04justin_smithLOLOL
12:04justin_smithsymbols invoke get, and the second arg acts as the "default value" if they are not found in the first arg
12:05justin_smithso you really don't want '(rotor/rotor-appender), unless you also plan to use resolve, which is silly and slow
12:05crocketjustin_smith, I don't care about performance much.
12:05justin_smith,((resolve '+) 42 1)
12:05clojurebot43
12:05crocketfast enough
12:06justin_smithcrocket: but seriously, I gave you an alternative above that isn't slow
12:06justin_smiththat does the same thing
12:06justin_smith,(#(apply (first %) (rest %)) [+ 41 1])
12:06clojurebot42
12:06justin_smithskip the quoting part, then you don't need the resolve part
12:07crocketI'm so stupid
12:08justin_smithyou're just new to the language, and to this style of coding
12:08justin_smithcrocket: in general, avoid using the symbol for something if all you plan on doing is looking it up later
12:09justin_smithunless you think it should have a diferent value later...
12:14crocketjustin_smith, I'm trying to build a function call.
12:14crocketSo, it's like macro
12:14crocketI'm going macro.
12:14justin_smithcrocket: why? why do it that way when you can just pass in a function then call it?
12:15crocketI want to build a data structure that I can call later in a one swoop.
12:15crocketIt is built dynamically and sequentially.
12:15justin_smithcrocket: sure, my apply example above does that
12:15crocketI realized that I could just build a function call..
12:16crocketIt is simpler.
12:17justin_smiththe thing you pasted won't actually work, because `() will just return the fully qualified symbols, you'd still need eval, or the marginally better resolve, but you don't need either if you pass in the actual funciton then use apply
12:17crocketjustin_smith, https://www.refheap.com/106667
12:18justin_smithOK, but that still doesn't do the part where the appender gets called, that's what I'm talking about
12:19crocketjustin_smith, Will it not work?
12:20justin_smithcrocket: what you have now will return a list starting with a symbol. to invoke rotor/rotor-appender you either need to use eval, or resolve + apply, or (my preferred option) pass in the function itself and just use apply
12:21crocketThe function could be anything.
12:21justin_smithcrocket: sure it courld. eval and resolve are usually signs there is a problem with your design, unless you are building a compiler or interpreter of some sort.
12:22justin_smith*could
12:23crocketSo
12:23crocketWhat do you recommend?
12:23justin_smithcrocket: cleanest option, pass the function that constructs your logger, and your config, each under their own key in the map, and use apply to create the logger
12:23crocketThere is only one argument.
12:24crocketactually
12:24justin_smith,((fn [{:keys [f arg]}] (f arg)) {:f inc :arg 41}) ; if you know the arg count, that's even better
12:24clojurebot42
12:25crocketDo you mean it's better to have {:appenders {:file-appender {:fn #'rotor/rotor-appender :arg {:path "ok.log" :maxsize 500}}}}?
12:25justin_smithright
12:25justin_smiththen you can do a clean update-in to add keys to the arg
12:25crocketDamn
12:25crocketI originally went for that design.
12:25justin_smithand then call the fn with the arg later
12:25justin_smithhaha
12:25crocketAnd, I wanted to remove :fn and :arg.
12:25justin_smithit's the best option
12:25crocketThey looked dirty.
12:25justin_smithresolve and eval are dirtier
12:54kwladyka,(key {[1 1] :king})
12:54clojurebot#error {\n :cause "clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry"\n :at [clojure.core$key invoke "core.clj" 1494]}]\n :trace\n [[clojure.core$key invoke "core.clj" 1494]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compiler e...
12:54kwladykawhy?
12:54clojurebotwhy is Why
12:54snowellBecause {[1 1] :king} is a Map, not a Map entry
12:55snowellWhat are you expecting it to return?
12:55kwladyka[1 1]
12:55kwladyka,(key (first {[1 1] :king}))
12:55clojurebot[1 1]
12:55kwladykabut this works
12:55snowellBecause (first <map>) returns its first map entry
12:56kwladykawhat is difference between map an map entry?
12:56snowellA map is a collection of (key, value) entries
12:56snowellYou can use keys and vals to get all the keys/vals in a map
12:56kwladykaoh because is one position map and i didn't see the point
12:56kwladykaok i got it
12:57snowellOr you can get an individual entry (like with first) and find its key or val with… key or val
12:58kwladykathx
12:58snowellnp
13:11justin_smith,(key (find {[1 1] :king}) [1 1])
13:11clojurebot#error {\n :cause "Wrong number of args (1) passed to: core/find"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/find"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compiler e...
13:11justin_smith,(key (find {[1 1] :king} [1 1]))
13:11clojurebot[1 1]
13:12justin_smithkwladyka: you may want something more like {:position [1 1] :piece :king} unless you expect the one hash map to represent the whole board
13:12justin_smithand you could use group-by or map to go from the one representation to the other
13:17crocketDoes :or in a map destructuring form lead to detection of nil values?
13:18justin_smithcrocket: it doesn't test for nil/false, just whether the key is present
13:19justin_smith,(let [{x :x :or {x 2}} {:x nil}] x)
13:19clojurebotnil
13:19justin_smith,(let [{x :x :or {x 2}} {}] x)
13:19clojurebot2
13:20crocketIt seems :or detects presence of a key.
13:20justin_smithcrocket: that's exactly what I just said
13:40xonevHi there, I was just reading this http://swannodette.github.io/2013/07/12/communicating-sequential-processes/. And this caught my interest: "JavaScript promises don't solve the inversion of control problem - callback hell is unnested but it's still callback hell." Does anyone know of additional articles that explain that assertion?
13:41justin_smithxonev: I know swannodette hangs out here and on #clojurescript as dnolen if you have a specific question.
13:41justin_smithxonev: the alternative being offered is surely core.async (which uses channels to replace callbacks)
13:42justin_smithany good core.async intro should compare the channel using version with the ugly callback based alternative
13:42xonevthanks justin_smith, I will ask in #clojurescript, since it would be more on-topic there. I'm just trying to understand the problem better; I already like the solution
13:43justin_smithxonev: well, core.async is definitely on topic here too (just 'cause we have threads doesn't make it not useful)
13:45xonevok, well I think my main question is how do promises not solve the inversion of control problem? For example, this article claims otherwise: http://blog.getify.com/promises-part-2/
13:46crocketok
13:46crocketjustin_smith, https://github.com/crocket/clj-ddns-client
13:47crocketis the product of the hard work I did today.
13:48crocketIs it possible to load a .clj file dynamically on the run?
13:48crocketIf it was, then I could load clojure plugins on the run.
13:48crocketHot plug in
13:48amalloyhis section about loss of trust is just bizarre. if you write someAsyncFunction(function () {runMyProgram;}), then it's true you're at the mercy of someAsyncFunction. but...that's true even for someSyncFunction(10);! you never know, maybe it chooses not to return at all, just hijack the thread forever, or print a bunch of alerts
13:53TimMcamalloy: Yeah, from my quick read, it's a misplaced argument.
13:53TimMcI'd be *much* more concerned about someone forgetting to call a callback or something like that.
13:54justin_smithcrocket: load-file
13:56justin_smithTimMc: amalloy: I find any talk of "trust" in the context of pervasively mutable languages hilarious
13:57justin_smith"you passed a collection to this function, this is a loss-of-trust situation"
14:00TimMcwindow.undefined = 4
14:01TimMcif (undefined = foo()) { ... }
14:01bjaerr, undefined is a singleton in js?
14:02bjareminds me of `True = 0` in python
14:02TimMcHmm, this used to wreak havoc with websites, but I guess now you can't actually write to window.undefined.
14:04TimMcAh well, you can still set JSON = 11
14:05justin_smithhaha, I like that one
14:57sm0kewith new cljs upgrade i see a weird problem in my application
14:58sm0kewith advanced optimization intergration with a js library seems to break
14:58sm0kewhich is working fine with no optimization!
14:59dnolenBronsa: http://dev.clojure.org/jira/browse/TRDR-28 perf patch for cljs.tools.reader
15:00sm0kejs library is codemirror, and specifically the (.getValue codemirror) now returns nil/empty
15:01amalloysm0ke: advanced optimization renames all members to short names, so it's renamed getValue to something like q, but the library you're including hasn't participated in that optimization
15:02amalloyyou need to provide some kind of externs or whatever, so that it knows that cna't be optimized away, or use aget to get out the property via a string
15:02dnolenamalloy: goog.object/get recommended now, trying to get everyone off aget for Object stuff
15:03sm0keamalloy: i am using the library as extern itself so names are not mangled
15:03sm0keit used to work fine before upgrade
15:04sm0kei double checked that by searching for getValue in the compiled js
15:06sm0keI am kind of clueless on this, specially since i am not able to get brepl working for advanced as well
15:12Bronsadnolen: thanks, can you also take a look at https://github.com/clojure/tools.reader/commit/8330f773e6ecdab0edeaca824a4724ff75433304 and see if there are type-hints missing?
15:13dnolenBronsa: the performance enhancements really don't come down to type hints
15:13dnolenBronsa: that commit looks non-trivial wrt perf implications
15:14dnolenwould need to rebase and rerun benchmarks & profiles, and likely rewrite that code
15:15Bronsadnolen: ouch. those changes on resolve-ns and resolve-symbol are needed to support auto-qualifying on of symbols and keywords in syntax-quote
15:16dnolenBronsa: makes sense but if you want the perf patch you'll just have to leave cljs.tools.reader alone for the time being.
15:17Bronsadnolen: I already applied the perf patch, that commit is on top of that. I can revert it if you think it'll cause performance issues but that code (or a different impl of it) will eventually need to be committed
15:18dnolenBronsa: oh ok!
15:18Bronsadnolen: I'm fine with letting you take over cljs.tools.reader btw if that works best for you
15:18dnolenBronsa: I think we should add a simple benchmark hardness to track regressions
15:19dnolenBronsa: no happy for you to lead but I think we should have a benchmark - like parsing cljs.core
15:19dnolenThen you know the implication of a commit
15:20dnolens/hardness/harness
15:56Bronsadnolen: yeah definitely. I'll take a look at how cljs benchmarks stuff and add some -- I don't have time to do any work until late Monday though so if you were planning on cutting a cljs release depending on the new t.r release I'm sorry but you'll have to wait a until early next week
15:57dnolenBronsa: nah no plans yet, still working through bootstrapping stuff
15:57Bronsaok cool
15:57dnolenBronsa: I think a simple script that does before & after patch would be better than what ClojureScript currently does
15:57dnolenreading cjls.core is sufficiently non-trivial
15:58dnolenBronsa: are you OK with this being a bash script? I don't mind putting it together since it would be useful to me too
15:58Bronsayeah consuming the core ns is how I always benchmarked tools.reader/tools.analyzer & tools.emitter :)
15:58Bronsadnolen: sure
15:58dnolenBronsa: ok I will put something together
16:01celwellHello, how could I get all the arguments passed to a function? Particulary, I need retrieve them while in a macro.
16:08justin_smith,(defmacro psychic [& args] (println &form))
16:08clojurebot#'sandbox/psychic
16:09justin_smith,(psychic :weird, :how :did :you :know?)
16:09clojurebot(psychic :weird :how :did :you ...)\n
16:09justin_smithcelwell: does that give you what you need?
16:12justin_smithcelwell: or do you mean you have a function, then you want to access its args in a macro call inside that function? because that would be very hygeinic and I wouldn't recommend it even if it was possible
16:12celwellYeah the latter
16:13celwellI have macro "catch-notify" that is basically: `(try ~@body (catch Exception e (send-email (str e))))
16:13justin_smithI think clojure's scoping rules are too strict to do that without explicitly passing the args in
16:13celwellI would like to include all the args of parent function in teh email
16:14celwella bad idea then?
16:14justin_smithyeah, I think that would involve some implementation defails if it is possible at all
16:14celwellah ok
16:14celwellthanks
16:15justin_smithI mean I understand that's a reasonable functionality to want but I don't think clojure offers a good way to do it, because that would also allow a bunch of stupid things we don't want
16:15justin_smithspoopy action at a distance
16:15celwellYeah, now that I think about it, it would need a secondary macro or something to cover the original function and that would be bad
16:15amalloyyou can't distinguish between args to the parent function and locals introduced by something else
16:16justin_smithcelwell: you could do like prismatic/schema and make your own version of defn wrapping the original
16:16amalloybut it is not too hard to look at &env if you want to include all the locals
16:16justin_smithamalloy: is there even a way to get at that stuff without relying on implementation details?
16:16amalloyjustin_smith: you only need the keys of &env
16:16amalloywhich is fine
16:16justin_smithintersting
16:17amalloythe problem is that then you're holding onto the head of all locals, which can change behavior; and even if that doesn't break things, trying to print one of them might, because it could be infinite
16:17justin_smith,(defmacro psychic [& args] (println &env))
16:17clojurebot#'sandbox/psychic
16:17amalloy,(defmacro locals [] (into {} (for [k (keys &env)] [`'~k k])))
16:17clojurebot#'sandbox/locals
16:17justin_smith,(let [x 1] (weird))
16:17clojurebot#error {\n :cause "Unable to resolve symbol: weird in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: weird 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: weird in this...
16:17amalloy,(let [x 1] ((fn [y] (env)) 2))
16:17clojurebot#error {\n :cause "Unable to resolve symbol: env in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: env 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: env in this conte...
16:17justin_smith,(let [x 1] (psychic))
16:17clojurebot{x #object[clojure.lang.Compiler$LocalBinding 0x76d03c52 clojure.lang.Compiler$LocalBinding@76d03c52]}\n
16:18amalloy,(let [x 1] ((fn [y] (locals)) 2))
16:18clojurebot{x 1, y 2}
16:18justin_smithfascinating
16:19celwellBut if you're saying it might cause unexpected issues, I'm probably going to not use it. The point of this macro is to notify of problems, not create them... ha
16:20justin_smithcelwell: I don't think it will cause unexpected issues actually, I'm glad people aren't doing complicated tricks using &env, but your usage and getting some data from &env sounds fine
16:20justin_smithI think I knee-jerked a bit on it
16:23amalloyi think it will cause unexpected issues, for the reasons i said
16:24celwellamalloy: Not sure if this is acceptable place to mention, but do you know of any Clojure developers looking for work? My Beverly Hills based startup is looking...
16:24amalloyme? just ask #clojure; this is the most likely place to find such people
16:25celwellWell I know you're in Santa Monica
16:26justin_smiththat reminds me, I know about some contract work in the pdx area, simple stuff hitting APIs and cleaning up the data, if anyone in this area is looking.
16:35blake_I'm in the Valley. I hate the Beverly Hills commute. =P
16:36celwellblake_: hit me up when Elon's done with the Hyperloop
16:36blake_celwell: Ha! If they'd put some money into flying cars...
16:55celwellSorry, I'm not able to retrieve those private messages sent to me. Emacs irc issues. My email: chris@purpledelivery.com
16:56xemdetiaIT'S A RUSE
16:58mkblake_: what someone really needs is to put some money into developing a way to work on things without needing to commute
16:59blake_mk: Such a thing would require a massive NETwork, INTERconnecting people globally!
16:59justin_smithoddly I am not receiving any private messages regarding my job mention - it's legit, hit me up if you are looking
16:59mkblake_: haha. Let's just wait for your flying cars.
17:01blake_justin_smith: Well, but is it inside or outside the inundation zone? =P
17:30elvis4526What's the best way to execute a "timeout" in clojure? Like waiting 30 seconds and then proceed with some SEXP?
17:32justin_smithelvis4526: with core.async there's timeout, in regular clojure code you can use something like (let [cancel (delay :stop)] (future (Thread/sleep 30000) (when-not (realized? cancel) (do-it))) cancel) returning the "cancel" delay and doing the thing if nobody forces its value
17:32justin_smith(before 30 seconds pass, of course)
17:42elvis4526I don't mind using core.async - timeout seems to be the thing I'm looking for, thanks (again) !
17:44kwladykaif i am using one file only to test and this file doesn't have any test but it is to convert results to more human readable form should i put this file into test/app_name/file.clj or in another place?
17:44kwladykawhat best practise say about that?
17:52elvis4526I think your test should be named file_test.clj, but otherwise yes its the "standard" place to put tests
17:56kwladykaelvis4526, but this file has 0 test
17:57kwladykaelvis4526, i use in only in repl to convert thing to more human readable when i am verify manually code
17:57kwladykaso it is something not common
18:00ed-gkwladyka, put it in a directory other than your src/ and include that dir using the :profiles { :dev ... } in project.clj
18:01ed-gI use :profiles { :dev { :source-paths "dev" ...} ...}
18:01ed-gif you call it user.clj it will automatically be in all your repls
18:02kwladykaed-g, so it is better to put file in "dev" folder then "test" folder if purpose of this code is manual tests? :)
18:03kwladykaexactly this code draw solutions on screen in graphical form
18:07kwladykaed-g, thx
18:23roman_quick question: is there is any easy way to test exceptions on macro expansion time?
18:28roman_nvm: found a way, eval and syntax quote for the win
20:56reutermjWhat ides do you guys use? Im getting fed up with light table
21:01Bronsareutermj: give cursive a try
21:01reutermjCool I love intellij. Ill try it
21:18elvis4526Cursive is probably the best thing next to CIDER.
21:20elvis4526my only complain would be the cljs support... the autocomplete and code analysis is pretty weird :4
21:25reutermjim a game developer so cljs doesnt excite me too much
21:26TEttingerreutermj: are you using play-clj by any chance?
21:26TEttingerit's a good one
21:31reutermjbits and pieces of it
21:32reutermjbut there are several parts of the api that it doesnt expose so Im having to write my own wrapper
21:50viperatiI'm worried about investing more of my time in learning Clojure professionally. 6 years after 1.0 and there are only 11 jobs listed on indeed.co.uk for title:clojure compared with 321 for title:scala. I think Clojure is by far the best language out there but it seems destined to remain a niche player like Erlang. OK if you have job stability but as a freelancer looking for clients it's becoming a no-op for me.
21:52viperatiAnyone else freelancing as a Clojure developer?
21:54justin_smithviperati: I was until pretty recently, I got a lead for a freelance job today actually, but had to turn it down
21:56viperatijustin_smith: Which part of the world are you in?
21:56justin_smithviperati: portland, oregon
21:58viperatijustin_smith: The London job scene is very much skewed towards Scala for some reason. Maybe due to all the financial companies who feel Scala is closer to their Java comfort zone. I dunno.
21:58justin_smith~scala
21:58clojurebotUnfortunately the standard idiom of consuming an infinite/unbounded resource as a stream can be problematic unless you're really careful -- seen in #scala
21:59justin_smithclojurebot: that's a pretty dumb factoid
21:59clojurebotGabh mo leithscéal?
21:59viperati:)
22:00viperatijustin_smith: Do you think it's that most Java shops just can't cope with the parens or something?
22:00justin_smithhe has better ones: 19:00 <clojurebot> scala uses UTF-17
22:00justin_smithviperati: no idea
22:00TEttingerclojurebot: scala is http://scalaz.github.io/scalaz/scalaz-2.9.0-1-6.0.1/doc.sxr/scalaz/Kleisli.scala.html
22:00clojurebotIk begrijp
22:01TEttingerclojurebot: scala is http://nurkiewicz.github.io/talks/2014/scalar/img/list-scala.png
22:01clojurebotIn Ordnung
22:01TEttinger~scala
22:01clojurebotscala is http://scalaz.github.io/scalaz/scalaz-2.9.0-1-6.0.1/doc.sxr/scalaz/Kleisli.scala.html
22:04TEttingerviperati: I think Clojure has an unusually high usage amount in SF/Bay Area, and maybe Austin, TX. I could easily be wrong, I have never been to Austin.
22:05TEttingerI'm mostly judging by people here, there seems to be a high bay area presence
22:05justin_smiththere's a decent amount of clojure stuff going on on the west coast US, all around
22:05justin_smithfigures all the hip(ster|ie)s would be using it mostly
22:06TEttingerTijuana has a great clojure job market too. did I say clojure, I meant drugs
22:07justin_smithTEttinger: as long as it isn't donkeys
22:07TEttingerheh
22:08TEttingerI'm glad the violence of the drug cartels seems to be going down in mexico. a distant relative of mine was killed when he went from his home in El Paso across the border for the day to buy a car for cheap. gunned down for looking out of place.
22:08justin_smithwow
22:08TEttinger(not sure his name, very very distant)
22:08justin_smithI'm sorry to hear that
22:08TEttingeryeah it was just shocking
22:08reutermjSo, everyone who I know that uses java/scala is too afraid of leaving the comfort of oo
22:09reutermjAlso static types systems
22:09justin_smithI heard there was a flare up caused by the reduced marijuana sales (coming from the colarado, oregon, washington legalization), with less business there was more fighting over what was left supposedly
22:09TEttingerreutermj, it's interesting. I am moving fluidly between Clojure and Java these days
22:09TEttinger(same application, eventually, the Java's a lib)
22:09justin_smiththey are afraid the clojure cartel is gonna put their heads on a LOGO turgle
22:10justin_smith*turtle
22:10TEttingerhaha
22:10TEttingerbetter call Rich
22:11reutermjTEttinger yeah I feel like once youve done both for a while it's pretty easy
22:11reutermjbut going in is scary
22:12TEttingerreutermj: there's something you could show a javadev, not sure who in here made it... it's quite good
22:12TEttingerhttps://github.com/rschmitt/dynamic-object
22:12TEttingerhttps://github.com/rschmitt/collider
22:16reutermjTEttinger those are pretty cool.
22:17reutermjBut, arent they more targeted at clojure programmers that need to interface with clojure from java?
22:17reutermjnot getting java programmers into clojure?
22:17TEttingerthe first is aimed at getting clojure techniques into java programming
22:17TEttingerimmutable data, easy data construction, clojure-like API
22:18TEttingerthe second I am not sure. it doesn't seem to use clojure's data structures verbatim
22:19TEttingerseems aimed at clojure style while programming java
22:20TEttingerreutermj: so right now I'm working on SquidLib, which a friend of mine originally made as a Java library for roguelikes (text-based, top-down, @ is the player, # is a wall, etc.). I'm realizing that Swing for rendering is going to cause problems if the rendering gets too complex (layered panels of chars, animations for things like water tiles that need to render more often)
22:21reutermjSwing is actually so bad if you want to make games
22:21TEttingerSwing was fine for 2 panels, but I'm working on something with 5 translucent panels...
22:21TEttingeryep
22:21reutermjit has super unpredictable performance between jvms and os
22:21whompis it better to do (lazy-seq (cons 1 (f ...))) or (cons 1 (lazy-seq (f ...)))?
22:21reutermjlike you have no clue what it will hardware accelerate
22:21TEttingerdo you have any recommendations for hardware-accelerated truetype font rendering?
22:22reutermjI like cons l (lazy-seq
22:22reutermjbut I think they essentially do the same thing
22:22whompwhat are the pros and cons?
22:22whompok, because 4clojure enforced the former in http://www.4clojure.com/problem/168
22:22reutermjlibgdx has really good truetype fonts
22:22TEttingeryeah, gdx-freetype
22:23TEttingersquidlib at one point had a libgdx renderer but it was really hard to set up a project to use it
22:23reutermjIm a huge fanboy of Mario and his work, so I'm sorry if that isnt the answer youre looking for
22:24reutermjI really dont know of any standalone ones, aside from using something like openc
22:24TEttingerah, it's fine. if there's a good way to use libgdx without the project structure (as in, as a real library not a framework thing), I'd be very interested
22:24reutermjopencl
22:24TEttingerOpenCL? the compute language?
22:24reutermjyeah
22:25reutermjyou can do the calculations for the vector graphics on there and read them into a bytebuffer
22:25TEttingerahhhh
22:25reutermjim sure you can find some kernels out there that do it, and just use something like lwjgl for access
22:26TEttingerI think all I really need is something like Cairo and/or Pango...
22:27reutermjbut as for not using the whole libgdx framework. all you need is the gdx, gdx-lwjgl, and gdx-lwjgl-natives jars
22:27reutermjand you should be golden
22:28reutermjyou could always look into lwjgl 3
22:28reutermjit has multi window support
22:40crockethi
22:40crocketCan anyone suggest better names for functions on https://www.refheap.com/106679 ?
22:44crocketassoc-in-cond2, assoc-in-cond3
22:50justin_smith,(defn haha [] (->> 'clojure.core ns-publics keys shuffle (take 2) (#(str (first %) '-in- (second %))) symbol))
22:50clojurebot#'sandbox/haha
22:50justin_smith,(haha0
22:50clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
22:51justin_smith,(haha)
22:51clojurebotratio?-in-remove-all-methods
22:51justin_smith,(haha)
22:51clojurebotbit-and-not-in-delay?
22:51justin_smith,(haha)
22:51clojurebotmapcat-in-<
22:51justin_smith,(haha)
22:51clojurebotThrowable->map-in-bit-shift-left
22:51justin_smith,(haha)
22:51clojurebotdefonce-in-restart-agent
22:51justin_smithsorry, for some reason that name pattern just became really oddly comical to me
22:51justin_smith,(haha)
22:51clojurebotwhen-in-keyword
22:51justin_smith,(haha)
22:51clojurebotbooleans-in-map-indexed
22:52justin_smithmaybe nobody else finds it funny, but I am sure TEttinger understands
22:52justin_smith(this is what happens when I have tequila)
22:52justin_smith,(haha)
22:52clojurebotseque-in-aset-double
22:53reutermjman I wish this is what happens when I have tequila
22:53reutermjI just start crying when I have tequila
22:54justin_smithreutermj: it might be a dosage thing
22:54justin_smith,(haha)
22:54clojurebotbigint-in-send-off
22:54justin_smith,(haha)
22:54clojurebotsome->>-in-var-set
22:54reutermjtrue my normal dosage is half a bottle of jose cuervo
22:54justin_smith,(repeatedly 20 haha)
22:54clojurebot(find-keyword-in-re-seq pop-in-bit-and-not drop-in-find-var definline-in-* eval-in-rational? ...)
22:55crocketjustin_smith, Do you mean assoc-in-cond2 and assoc-in-cond3?
22:55TEttingerthat's great justin_smith
22:55justin_smithcrocket: I'm just being silly, I'm sure those are totally sensible functions
22:55justin_smith,(repeatedly 20 haha)
22:55clojurebot(get-thread-bindings-in-unchecked-short defn-in-*suppress-read* conj!-in-key unchecked-negate-int-in-map? sorted-map-by-in-identical? ...)
22:55crocketHow do I make https://www.refheap.com/106680 simpler?
22:56justin_smithI could almost imagine seeing sorted-map-by-in-identical? in a real codebase
22:57crocketjustin_smith, Does sorted-map-by-in-identical help advance my purpose?
22:57justin_smithnot at all, it's a joke
22:57crocketjustin_smith, How would you make https://www.refheap.com/106680 simple?
22:58crocketI want to convert {:appenders {:appender-id {:fn fn :arg-map arg-map}}} to {:appenders {:appender-id (fn arg-map)}} in a simple way.
22:58justin_smithfor what it does, that looks just fine to me
22:58TEttingercrocket, I'm looking at it, and I think there's a way
22:58justin_smithperhaps reduce-kv
22:59crocketReplacing (fn) with #()
22:59TEttingerhm, that actually looks pretty straightforward now that I read it again
23:02crocketTEttinger, Can you write it simpler with reduce-kv?
23:04justin_smith,(update {:appenders {:appender-id {:fn inc :arg-map 41}}} :appenders #(reduce-kv (fn [m k {:keys [fn arg-map]}] (assoc m k (fn arg-map))) % %))
23:04clojurebot{:appenders {:appender-id 42}}
23:04TEttingerassuming you're on clojure 1.7 :)
23:05justin_smithyes, otherwise update :appenders becomes update-in [:appenders] but the rest works
23:05crocketDamn
23:05TEttinger(inc justin_smith)
23:05crocketclojour 1.7
23:05lazybot⇒ 277
23:05TEttingerclimbing fast!
23:06justin_smith(karma amalloy)
23:06justin_smith(identity amalloy)
23:06lazybotamalloy has karma 287.
23:13crockethttps://www.refheap.com/106681 contains two versions of reify-appenders.
23:13crocketWhich one do you think is better?
23:14crocketIn my opinion, the latter has more beautiful shape.
23:14crocketI mean it has a better appearance.
23:14reutermjI have to agree, I think the latter is more pretty
23:15justin_smithalso it does less work, by doing the repeated updates at one level, rather than repeated nested updates, if that matters
23:15justin_smith(that's a small difference here I am sure)
23:16justin_smithbbl reading a book
23:19amalloyjustin_smith: sorry, i'm dictator for life. it's in the charter
23:19crocketjustin_smith, With your help, I got https://github.com/crocket/clj-ddns-client/blob/master/src/clj_ddns_client/core.clj
23:21crocketI couldn't have written in in such an elegant fashion in java.
23:22crocketI couldn't have written it in such an elegant fashion in java.
23:22reutermjbut could you have written it as concise in brainfuck?
23:22TEttingerhaha
23:22TEttingerAPL
23:22reutermjthat's the real question
23:33crocketreutermj, I don't know brainfuck.
23:33reutermjbe glad