#clojure logs

2015-09-18

03:12roelofHello, I try to do some challenges from codeingames. One of them I have to move a person on a screen but as far as I know Clojure variables are imutable
03:12roelofHow can I change the x and Y coordinates for that person ?
03:16namraroelof: did you look at play-clj
03:16namrait uses a global gamestate
03:17namraand a modified version is returned by any function
03:17roelofnamra: I did not. Where can I find it
03:17namraroelof: https://github.com/oakes/play-clj --- there you go
03:19namraok it passes an entities vector to the fns and you may return a modified version of this vector with your desired changes which will become the new gamestate
03:19rritochroelof: If you need thread safety, see refs & atoms, if you don't, see make-array/aset as arrays are mutable.
03:19roelofnamra : oke, after a quick look I see that I can use the inc and dec functions.
03:21namraor you do as rritoch says but play-clj is the more functional approach but also require more memory
03:22roelofthanks, I will look into that also, Do one of you know if the book brave and true is talking about this ?
03:22namraabout atoms, immutability etc?
03:23namracertainly it's a very nice introductory text you can get a feel from it because it's based on the authors blog posts
03:24namraroelof: http://www.braveclojure.com/
03:24roelofno, about make-array
03:27namradon't know if he does in the book, but not in the blog articels
03:27roelofoke, I will look. In a few days a new version is due, so I wait for that
03:40oddcullyroelof: isn't coding game basically reading stdin and printing the results? it would help if you could link to that problem
03:41namraoddcully: but you still have to handle the gamestate, like the position of the character in the world
03:41namrain a pure oo language you just would call a threadsafe method on an object to change the coordinates
03:42oddcullyi am aware of that. but what i remember from codinggame is not that sophisticated
03:42namrayou could also do that in clojure, but when you want to keep it functional you stay with immutability
03:43namraand that means the gamestate is mangled by functions which return a modified version
03:43namraso it about handling gamestate
03:44namrabut i don't know the mentioned site so you might be right that it can be done simpler
05:31mash333gonna play ps4
05:32mash333sorry wrong ping:)
07:09borkdude_fun trick question: why does this return an empty seq? (remove (comp zero? :questions) ({:questions 1} {:questions 0}))
07:10oddcullyborkdude_: because maps are functions
07:11borkdude_correct
07:12mavbozo,(remove (comp zero? :questions) ({:questions 1} {:questions 0}))
07:12clojurebot()
07:12mavbozo,(remove (comp zero? :questions) '({:questions 1} {:questions 0}))
07:12clojurebot({:questions 1})
07:13mavbozothat one quote i missed
07:13oddcully,({{:questions 0} 1} {:questions 0})
07:13clojurebot1
08:45mungojellyhow can i get callbacks from a sqlite database instead of having to poll it?
08:52mavbozomungojelly, do you use clojure.java.jdbc library?
08:52mungojellymavbozo: i'm trying to learn how to use it right this moment
08:54mungojellysqlite isn't smart enough to have the changes i'm interested in ready for me, is it? the best i can do is watch for the db file to be touched and then search to see if what i'm interested in has changed?
08:54mungojellysorry i don't understand databases (obviously)
08:55mavbozoah, so you want to get notification from the sqlite is something changes?
08:55Wild_Catare you attempting to use sqlite as a message queue of sorts?
08:55mungojellymy task i'm practicing on is to respond to things that happen in firefox, which are stored apparently in sqlite databases
08:56mungojellyi want the most recent youtube videos i've gone to, which is a simple enough query i can figure that out with this jdbc docs i'm sure, but should i just poll periodically or what? :/
08:57Wild_Catmungojelly: are you doing this from a separate process, or from within Firefox?
08:57Wild_Catif 1. then yes, you do. If 2. I don't know.
08:57mavbozosince clojure/java.jdbc don't have notification api, you have to do long polling
08:57mungojellyi'd also like to use databases as message queues! that seems like a sensible strategy in general. except apparently you have to poll for changes. oh hey yeah maybe firefox has a hook for me, i'll check that out. :)
09:12anecould anyone review the clojure wikipedia article a bit, i've been improving it here and there
10:13jonathanjis there a function in Clojure core that does this: (defn just-call-f [f & rest] (fn [& ignored] (apply f rest)))?
10:14jonathanj(constantly #(apply f arg1 arg2)) is possibly the same?
10:15justin_smithjonathanj: if arg2 is a collection holding the rest of the args to f, I guess
10:16jonathanjactually, i guess my constantly thing isn't quite the same
10:20sdegutisI'm planning to make a library that's API-compatible with Compojure but builds up data structures instead of function composition, for easier inspection and to get rid of the function/var-caveat. Would anyone here be interested?
10:26justin_smithsounds like a good plan, but I can't commit time (at least this month...). Also there should be a dev-time "interpreted" mode where it follows the data structure every time, and a prod "compiled" mode where it can route more efficiently
10:28sdegutisjustin_smith: ahh good idea for efficiency
10:29sdegutisjustin_smith: anyway it seems like it should actually be a simple lib, I expect it could be done in an hour or so, by making use of a lot of still-applicable public functions in Compojure (and possibly using Clout for the rest)
10:29sdegutisI plan to do this just to fix the var-bug I'm having to work around in our app. I'll make it open source in case anyone else is interested.
10:32skeuomorfgrimoire returning server errors for anyone else?
10:32Bronsayup
10:32justin_smithskeuomorf: on and off, but it works with a refresh...
10:32Bronsaarrdem: ^
10:32justin_smith(for me)
10:33skeuomorfI see
10:33arrdemskeuomorf: sorry just broke it, working on it.
10:33justin_smithhttp should have a "insert coin to continue" error
10:33arrdemhttps://twitter.com/arrdem/status/644881749395177472
10:33justin_smith*an
10:33arrdemjustin_smith: lol that's gonna be the next thing...
10:33skeuomorfarrdem: No worries, thanks for working on it :)
10:33arrdemthank me later :P
10:34skeuomorf(inc ardem)
10:34skeuomorferr
10:34skeuomorf,(inc arrdem)
10:34clojurebot#error {\n :cause "Unable to resolve symbol: arrdem in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: arrdem in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: arrdem in t...
10:34skeuomorf(inc arrdem)
10:34skeuomorfBOT, WHERE ART THOU?
10:34justin_smithskeuomorf: lazybot has been even less reliable than grimoire
10:34skeuomorfjustin_smith: It appears so :)
10:34skeuomorfarrdem: lol
10:34arrdemjustin_smith: I'm offended by that my uptime was perfect all summer until today
10:35justin_smithheh, sorry, bad wording :P
10:35arrdemlazybot goes down more than my old AOL line
10:36skeuomorfwell, it's *lazy*
10:39justin_smitharrdem: oh wait, it exists but isn't implemented, 402
10:40oddcullyhehe
10:40arrdemjustin_smith: what exists?
10:40oddcullythe http status code for "insert coin"
10:40justin_smithhttp status "insert coin to continue"
10:40arrdemalso added an nginx redirect for grimoire intil I get stuff working again
10:41sdegutishehehe http://i.ytimg.com/vi/z5kGR3TZnqk/maxresdefault.jpg
10:41sdegutisarrdem: nice error message :D
10:41justin_smithalso noticed, there's a lemongrab status code - 406 NOT ACCEPTABLE
10:41sdegutisRemember when that pic used to actually appear on TVs? It was around the same time you actually had to turn a physical dial to change channels.
10:42oddcullyugh saw that one enough for a (yester)day
10:42Bronsa418 I'M A TEAPOT, always the best http status code
10:42justin_smithit's true
10:42arrdemit is known
10:43justin_smithtwitter's 420 ENHANCE YOUR CALM is also good (though not standard)
10:43Bronsaapparently twitter used to return a 420 Enhance Your Calm
10:43Bronsaheh
10:45Bronsaarrdem: FYI you can add a ns alias with c.c/alias too
10:46arrdemBronsa: oh the new notes?
10:46arrdemthanks I'll fix that in a minute
10:54arrdemugh bug in a bash script somewhere caused that
10:54arrdemGrimoire is back up
10:55oddcullywoohoo
10:55arrdemskeuomorf: fix'd
10:56skeuomorfarrdem: YAY, thanks :)
10:56skeuomorf(inc arrdem)
10:56skeuomorfGODDAMN YOU BOT, STOP BEING LAZY
10:57slawohey guys, beginner question here
10:57slawowhy is it that in nREPL, I can't do (set! clojure.pprint/*print-right-margin* 140)
10:58slawoAnd get a IllegalStateException Can't change/establish root binding of: *print-right-margin* with set clojure.lang.Var.set (Var.java:221)
10:58oddcullytime for dutifulbot
10:58slawoIt would seem to me that *print-right-margin* is meant to be changed/rebound
10:58arrdemusefulbot
10:58slawobut it is stubborn
10:59slawohaving found this in a gist: https://gist.github.com/djKianoosh/2653859
10:59oddcullylazbot can go to slack }:P
10:59skeuomorf^
10:59slawoit looks dodgy
11:24gfredericksjcrossley3: ping
11:34roelofis the author of brave and true sometimes here ?
11:43diphtherialhello; this is probably a stupid question, but i've installed ultra in an attempt to give myself a colorized REPL, but when i start up 'lein repl' it looks pretty much the same
11:44diphtherialis there some special way to launch the repl that enables ultra? i've added the parts specified in the readme to my ~/.lein/profiles.clj file, by the way
11:45diphtherial(i'm also using OS X, if that matters)
12:01stuartsierraslawo: You can only `set!` a Var which currently has a thread-local binding in effect.
12:01stuartsierraThe REPL creates thread-local bindings for a bunch of common Vars such as *warn-on-reflection*.
12:02stuartsierraYou can still create your own local binding around calls to pprint with `binding`.
12:07sdegutisstuartsierra: hey glad to see you're here; just wanted to say that Component is really well designed
12:10stuartsierrathank you
12:11slawostuartsierra: thanks, I'll give it a go!
12:28sdegutisIs there some Clojure-specific way of creating an #inst that's a given day (like 9/18/2015 at midnight)?
12:29carkh(clojure.core.match/match [[:bar :baz]] [([:bar & r] :as m)] m) -> [:bar]
12:30carkhis that a bug or am i not understanding it ?
12:31carkhi was expecting [:bar :baz]
12:34sdegutiscarkh: Yeah I would have expected [:bar :baz] too...
12:34sdegutiscarkh: Oh no wait, you have too many outer-parentheses I think.
12:34sdegutis,(clojure.core.match/match [[:bar :baz]] ([:bar & r] :as m) m)
12:34sdegutisTry that.
12:34clojurebot#error {\n :cause "clojure.core.match"\n :via\n [{:type java.lang.ClassNotFoundException\n :message "clojure.core.match"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[java.net.URLClassLoader$1 run "URLClassLoader.java" 366]\n [java.net.URLClassLoader$1 run "URLClassLoader.java" 355]\n [java.security.AccessController doPrivileged "AccessController.java" -2]\n ...
12:35sdegutiscarkh: Oh wait no, just remove the & and it works as expected
12:35carkhit says : Pattern rows must be wrapped in []
12:35sdegutiscarkh: (clojure.core.match/match [[:bar :baz]] [([:bar r] :as m)] m) ==> [:bar :baz]
12:36sdegutisAnd r becomes :baz
12:36sdegutisAnd m becomes [:bar :baz]
12:36carkhright, but the thing is, i need to take several rest arguments in the real code
12:37carkhthat's just a minimal test case
12:37sdegutisAh. Hmm, it seems that https://github.com/clojure/core.match/wiki/Basic-usage suggests you should use the :seq keyword or something?
12:38carkhchecking it, but i did see & in this document
12:38sdegutisYeah this doc has & too, along with :seq
12:38sdegutisBut :seq isn't working for me.
12:39carkhi have a match without the :as pattern
12:39carkhand i can have the :as pattern working without the &
12:39carkhlooks like there is some problem with the interraction of the 2
12:40sdegutisSorry I can't figure it out :/
12:41carkhi still can rebuild the vector, i was hoping to avoid that as it's in a rasius server which will get many requests a second
12:41carkhradius*
12:41carkhthanks anyways =)
12:46sdegutiscarkh: You might be able to find some people in the commit history in this channel and ask them?
12:46carkhyep, ping dnolen !
12:46sdegutisYeah that guy.
12:47carkhlooks like any clojure related thing ends up with him =P
12:50dnolencarkh: fortunately that's the not the case
12:50carkhdnolen: =)
12:51dnolenjust looks like a bug, file an issue, even better if you submit a patch
12:51carkhdnolen: there is no issue thing on github
12:51dnolencarkh: Clojure libraries don't use GitHub for issues, JIRA
12:51dnolenhttp://dev.clojure.org/jira/browse/MATCH
12:52carkhahyes ok thanks will do
13:02carkhsdegutis: just did it, was quite painless
13:03sdegutisFor me to make a new account is more involved.
13:43justin_smithsdegutis: you didn't troll the clojure jira did you?
13:43sdegutisjustin_smith: sorry what?
13:43justin_smith"For me to make a new account is more involved."
13:53slawohey guys, does anybody have advice on how to make leiningen not download a dependecies transitive test-dependenices?
13:53slawoI don’t intend to run the test-suite of my deps, so …
13:53justin_smithslawo: define the dependency such that its test dependencies are separate from runtime
13:53slawohow do I do that?
13:54justin_smiththere's not much a user of the lib can do
13:54justin_smiththe author has to fix it
13:54justin_smith(or you could fix it for them)
13:54slawoIf I see it correctly, the scope is set to test on their pom
13:54slawoand maven did not download that stuff
13:54slawothe moment I used leiningen
13:54slawoI got half the internet and an ancient version of guava on my hands :)
13:55justin_smithoh, that might be a lein bug then...
13:56slawolet me see if I can come up with a minimal case
14:02slawourgh, nevermind, my bad
14:02slawomaven was downloading the stuff too
14:02justin_smithyeah, sounds like the lib's fault then
14:03slawoquick question: https://github.com/michaelklishin/validateur/blob/master/project.clj
14:03slawothat’s what I am looking at
14:04slawothere’s these profiles for different circumstances, and :dev seems to be the one pulling stuff in
14:05slawodo the profiles translate into something in the generated pom that I can use to get a scoped dependency?
14:05justin_smithslawo: yeah, if they are using cljx, they need to ship all those libs to compile it out if they are shipping source
14:05justin_smithhmm...
14:06slawoI do not know how to convince clojars to tell me what they have https://clojars.org/com.novemberain/validateur/versions/2.4.2
14:08justin_smithslawo: what does "convice clojars to tell me what they have" mean? if you go to the main validateur page it shows versions available if that's what you mean https://clojars.org/com.novemberain/validateur
14:08slawowhat they have in terms of xml :) https://clojars.org/repo/com/novemberain/validateur/
14:08slawofound it
14:10slawoclojurescript.test 0.2.1 so this thing is not scoped in the test group, and it downloads hairball (tm) transitively
14:10slawothanks :)
14:12sdegutisjustin_smith: I don't troll anyone anymore except on reddit where it's the only appropriate thing to do.
14:13justin_smithsdegutis: if reddit doesn't want trolled it shouldn't wear such revealing comment threads
14:20sdegutishear, hear!
14:30hlolliIs there any trick with quoted functions that has a variable that is a local variable in another function. When ever I eval the quoted function, it says it wont recognize a symbol that the function making the call should really recognize. I find it hard to describe, can somone relate?
14:31justin_smithhlolli: that's how it's supposed to work
14:31justin_smithhlolli: you can make a macro work that way if you really want to, but it tends to be a huge source of bugs
14:31justin_smithhlolli: you can't make a function do that
14:32hlolliI was thinking if gensymbol would solve anything?
14:32justin_smithno
14:32justin_smithhlolli: if your function needs something from another scope, then it should be passed in as an argument
14:32hlolliah ok, it did work like that before actually, with arguments. I was somehow sure that was unneccecary. But ok.
14:32justin_smithit's intentional that just using the name doesn't work, because free symbols like that make a mess
14:34hlolliok, thanks. I want to try if (defn blabla [arg] (atom '(fn arg))) could work, maybe you know already?
14:35hlolliwell with ~ symbol ofc..
14:35justin_smithwait, what do you expect that to do? it would put a list in the atom, the first element of that list would be the symbol fn
14:35hlolliah, nevermind, I just try :)
14:36justin_smithhlolli: what are you even trying to do here?
14:36hlolliI could use this atom for function call in another function. I was hoping for some muteable function calls.
14:36justin_smith,(def a (atom '(fn [])))
14:36clojurebot#'sandbox/a
14:36justin_smith,(type @a)
14:36clojurebotclojure.lang.PersistentList
14:36justin_smithsee, like I said, that just puts a list in an atom
14:38hlolliok, that list could be very useful for me, if I can call it somehow in another function with it's own local scope symbols.
14:38justin_smithyou can't call lists
14:38justin_smithI mean I guess you can eval it
14:38hlollino not persistent list
14:38hlolliyes, lingo differences.
14:39justin_smithhlolli: the atom has a list in it
14:39justin_smithnot a function
14:39justin_smithhlolli: I am not sure why you are doing this, but I am sure there is a simpler way to do it than putting the source list for a function in an atom
14:39hlollihmm, if you would eval a persistent list with a function call in first position, it will become funcion?
14:40justin_smith,(type (eval '(fn [])))
14:40clojurebotsandbox$eval73$fn__74
14:40justin_smithyes, you get a function
14:40justin_smithbut this is not the easy way to do anything
14:40justin_smithI promise, whatever it is you are really doing, there is an easier way than that
14:40hlolliyes, defenitely, Im really just experimenting with different possibilities. Actually Steven Yi sent me good tips recently to use performancethread. So Im trying to make all function calls in one performance thread.
14:41hlolliwhat was the code post, postbin.com ?
14:41justin_smithuse refheap.com
14:41hlolliok 1min
14:46hlollihttps://www.refheap.com/109696
14:47hlolliYou can see how I'm quoting so I can change the code "on-fly", of course I'd like to make macro for many function calls without manualy editing the event-poll macro. I would like to create seperate functions that append new calls or dicard. Maybe you would know of better way for live-coding scenero?
14:54justin_smithhlolli: why can't you have an argument to the function?
14:55justin_smithhlolli: also, I don't actually see where you are quoting to change the code on the fly
14:56hlolliYes I can, but the last question was actually about me experimenting with using atom-deref instead event-poll macro. If it could be a muteable variable, I could add as many function calls as I'd wish all with different if statements.
14:56justin_smithoh, wait, on line 62?
14:56hlolliyes
14:56hlolliif you would run this, you can change the macro on-fly and it can change p3-field and the rem value (now 24)
14:57justin_smithhlolli: you don't need to eval or quote, just put the definition before perf-loop
14:57amalloyhlolli: if you make event-poll a function instead of a macro, you can just call it
14:57amalloyand then you don't need to eval a list that uses it as a macro
14:57justin_smiththere's that too
14:58amalloyevent-poll as written doesn't need to be a macro for any reason
14:58justin_smithand if you want to redefine event-poll while developing, call #'event-poll and what it does in the perf-loop will change when you change the definition
14:58hlolliwell, if I don't use symbol-quote, then if will never re-evaluate the function after I start performance thread.
14:58hlolliit will...
14:58justin_smithhlolli: if you use the #'event-poll syntax it will see new definitions without having to restart the loop
14:59hlolliok! yes that too. Ah...
14:59justin_smithhlolli: #'f means (var f) and vars are newly derefed each time they are called, and whatever the current val of the var is used
14:59hlollithat makes sense, can't bealieve I dint knew this earlier
15:00justin_smithhlolli: it's OK, that's why I prompted you for more info, because I was sure there was a simpler way than what you were trying to do before
15:00hlolliyes, and I had the feeling you knew a better way too, hehe
15:01dxlr8rcongrats to me, posted an example. http://clojuredocs.org/clojure.core/defn#example-55fc6077e4b06a9ffaad4fc1 :)
15:04hlollicongrats!
15:04dxlr8rthx :)
15:04justin_smithhlolli: funny enough, I am doing some csound work right now myself, preparing a live instrument for a concert this weekend, it will be running on a raspberry pi so no clojure :P
15:05hlolliyes, are you performing?
15:06justin_smithyes, solo electronic set. I had high hopes to make a clojure program that would produce my optimized csound code but I won't have that working for the deadline, so I am just coding a state machine controlled by a MIDI controller directly in csound using tables and gotos
15:08hlolliok, I was actually thinking, for long term goal, make a DSL for csound in clojure, or with osc server like overtone. If that is of any interest to csound users. I feel like supercollider is really growing much faster than csound just because of this client-server setup.
15:09justin_smithit's because supercollider has a UDP based API
15:09justin_smithso it's easy to hook whatever language into that
15:09hlolliyes, so my point should not have been clojure per say, but make a osc api.
15:09justin_smithcsound doesn't have a machine friendly abstraction like that - we are stuck throwing strings together like animals or sql users
15:10justin_smiththat's a good idea yes
15:10hlolliI mean you should be able to do (sin-osc 440) with csound and it can make the macro instr 1 asig poscil 1, 440 etc...
15:11hlolliand rewriting instrument defenitions is possible already with the api.
15:11hlolliit's just a lot of string work I guess, making strings.
15:11TagoreI've always liked the perlisgram "The string is a stark data structure and everywhere it is passed there is much duplication of process. It is a perfect vehicle for hiding information."
15:11justin_smith(inc Tagore)
15:12justin_smithhlolli: it would be good to check out how that guy did his haskell DSL
15:13hlolliyes! I've been reading his source code and can't find out how he really did it. Because I NEVER see instr 1 stuff in his source code.
15:14hlolliWell, I think I'll meet him in St. Pete, Im in berlin so it was a cheap flight for me to go to the conference.
15:55neoncontrailsI didn't get a response when I asked this yesterday, but I'm still curious: when implementing message-passing in Clojure, what type do you typically dispatch on? Are there tradeoffs to using strings vs. quote literals vs. keywords, or is it all ultimately the same thing?
15:56neoncontrailsSICP dispatches on quote literals, but Scheme doesn't have robust support for strings, and keywords are a new type to me
15:57neoncontrailsSo it makes sense it would use quote literals -- there's no other choice in Scheme
15:58trissnot sure I'm 100% following but I think keywords would be the preferred thing in Clojure...
15:59gfredericksyeah symbols are not idiomatic to use for everyday things
16:01neoncontrailstriss: it's a design pattern that SICP uses a lot. A good introduction to it can be found at the bottom of this page: https://mitpress.mit.edu/sicp/full-text/sicp/book/node45.html
16:03gfredericksneoncontrails: most uses of symbols are for names that actually refer to some artifact in the code, or similar; keywords are used the rest of the time
16:05trissneoncontrails: upon first skim I think this how we handle that sort of polymorphism in Clojure: http://clojure-doc.org/articles/language/polymorphism.html
16:05trissmultimethods seem similar to me....
16:05neoncontrailsgfredericks: I think that makes sense. Is there an underlying difference between the two types, or is this strictly by convention?
16:07trissneoncontrails: this answer looks splendid: http://stackoverflow.com/questions/1527548/why-does-clojure-have-keywords-in-addition-to-symbols
16:07neoncontrailstriss: this is great! I was actually wondering if there was a better way to implement this pattern with multimethods... I actually just learned about them a few days ago through dnolen's cljs tutorial
16:08neoncontrails(inc triss)
16:08neoncontrails(inc gfredericks)
16:09trissmultimethods really are rather neat...
16:13gfredericksneoncontrails: multimethods can be even better with keywords because you can use inheritance if you need to; I don't *think* you can do that with symbols (but I might be wrong)
16:17neoncontrailsgfredericks: I would love to see an example of this if you have one :)
16:23gfredericksneoncontrails: http://clojure.org/multimethods
16:40sdegutis(inc neoncontrails)
16:47amalloygfredericks: you can't
16:48gfredericksamalloy: w00t
16:49gfredericks,(-> (make-hierarchy) (derive :foo :bar))
16:49sdegutisamalloy: why can't you? why is it limited to keywords?
16:49clojurebot{:parents {:foo #{:bar}}, :ancestors {:foo #{:bar}}, :descendants {:bar #{:foo}}}
16:49gfredericks,(-> (make-hierarchy) (derive 'foo 'bar))
16:49clojurebot{:parents {foo #{bar}}, :ancestors {foo #{bar}}, :descendants {bar #{foo}}}
16:49gfredericksamalloy: ^ um
16:49amalloyactually i guess i'm not any more sure than gfredericks probably was when he guessed that
16:49gfredericks,(-> (make-hierarchy) (derive 42 45))
16:49clojurebot#error {\n :cause "Assert failed: (or (class? tag) (instance? clojure.lang.Named tag))"\n :via\n [{:type java.lang.AssertionError\n :message "Assert failed: (or (class? tag) (instance? clojure.lang.Named tag))"\n :at [clojure.core$derive invokeStatic "core.clj" 5408]}]\n :trace\n [[clojure.core$derive invokeStatic "core.clj" 5408]\n [clojure.core$derive invoke "core.clj" -1]\n [sandbox$eval7...
16:49sdegutis,(-> (make-hierarchy) (derive "foo" "bar"))
16:49clojurebot#error {\n :cause "Assert failed: (or (class? tag) (instance? clojure.lang.Named tag))"\n :via\n [{:type java.lang.AssertionError\n :message "Assert failed: (or (class? tag) (instance? clojure.lang.Named tag))"\n :at [clojure.core$derive invokeStatic "core.clj" 5408]}]\n :trace\n [[clojure.core$derive invokeStatic "core.clj" 5408]\n [clojure.core$derive invoke "core.clj" -1]\n [sandbox$eval9...
16:49amalloyyou're not *encouraged* to, but evidently you can
16:50justin_smithfor top level heirarchies, only namespaced keywords are accepted
16:50sdegutisAlso symbols lack ::this-feature of keywords.
16:50justin_smithI wonder if namespaced symbols are?
16:50sdegutisSo that's something to consider.
16:50gfredericks,`this-feature
16:50clojurebotsandbox/this-feature
16:50justin_smith,(derive 'foo/bar 'foo/baz)
16:50clojurebotnil
16:50sdegutisYou can do it manually like 'this/feature but ::feature turns into :this/feature when you're inside 'this *ns*.
16:50justin_smith,(isa? 'foo/baz 'foo/bar)
16:50clojurebotfalse
16:50gfredericksI guess ` is slightly different
16:51justin_smith,(isa? 'foo/bar 'foo/baz)
16:51clojurebottrue
16:51gfredericks,[::first `first]
16:51clojurebot[:sandbox/first clojure.core/first]
16:51justin_smithso yeah, derive even accepts symbols at the top level, but they are clumsier to use
16:51sdegutis,`foo
16:51clojurebotsandbox/foo
16:51gfredericksamalloy: man we were so wrong
16:51amalloygfredericks: incidentally it looks like this limitation is only an assertion in derive; there's no functionality that depends on this
16:51gfredericksamalloy: yeah I figured as much
16:52sdegutis,`(foo)
16:52clojurebot(sandbox/foo)
16:52amalloyso you could reimplement derive without that assertion, and then you could inherit 44 from f1
16:52gfredericksinherit one hierarchy from another
16:52sdegutisamalloy: so it's a disciplinary limitation not a technical limitation
16:52sdegutisneat
16:53sdegutisPersonally I prefer to inherit vars from namespaces.
16:53sdegutisAnd dates.
16:54sdegutis,(-> (make-hierarchy) (derive (java.util.Date.) (java.util.Date.)))
16:54clojurebot#error {\n :cause "Assert failed: (not= tag parent)"\n :via\n [{:type java.lang.AssertionError\n :message "Assert failed: (not= tag parent)"\n :at [clojure.core$derive invokeStatic "core.clj" 5407]}]\n :trace\n [[clojure.core$derive invokeStatic "core.clj" 5407]\n [clojure.core$derive invoke "core.clj" -1]\n [sandbox$eval289 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval289 invoke "NO_SOU...
16:54gfredericks(doseq [[n1 n2] (partition 2 1 (range))] (derive n1 n2))
16:54sdegutiscomma
17:03eriktjacobsenHow to get namespace a function resides in from inside that function? *ns* refers to core at runtime
17:04eriktjacobsenstring of the namespace
17:04justin_smitheriktjacobsen: functions don't have namespaces
17:04justin_smithvars do
17:04justin_smithand vars can hold functions
17:04hiredmanfunctions don't live in namespaces, names do
17:05gfredericks(inc hiredman)
17:06eriktjacobsenOk. lets say I have a “cache” function defined somewhere, and everytime its called (from outside namespaces), I want to include a string version of the namespace that called it as a prefix.
17:06gfredericksfor what purpose?
17:06justin_smithfunctions do not get that kind of information from callers
17:06justin_smithunless they pass it in
17:08hiredmanmy guess is because his "cache" is a bit of global state and he wants to give different clients different views over it
17:08eriktjacobsengfredericks: to namespace the cache. afaik timbre does this with its log output. Ok. lets make it simplier and say I’ll pass it in. How would the var holding a function calling the cache pass its own namespace? again *ns* goes to core not the ns where the var is defined in
17:08hiredmanfunctions don't have an own namespace
17:09neoncontrailseriktjacobsen: I defer to justin_smith on how you would actually implement this, but it sounds like you're trying to write a macro.
17:09eriktjacobsenRight I said the var holding the function…
17:09hiredmaneriktjacobsen: I'd suggest not doing that
17:10eriktjacobsenI’m fine using a macro for this.. I’m just looking for absolutely any way to get a string version of the namespace from inside the function held by a var that is defined in that namespace
17:10hiredmaneriktjacobsen: have the cache be some local state that a client can ask for, and then if you want different caches for different places then have the client ask for a new cache
17:12hiredmanimplicitly namespacing your cache entries based on clojure namespaces is very fragile
17:12eriktjacobsenI’m simplifying the problem so we don’t get bogged down in details. For my actual purpose, I really need the namespace. I know this is possible, Timbre logging appends the namespace it was called from, so if you call (info blah) from anywhere inside api.foo.bar, it’ll print “api.foo.bar” in the output for that line. thats what I’m trying to replicate.
17:20neoncontrailseriktjacobsen: There should be a way to alias those namespace strings and map them to the original. Do the examples on this page help? https://clojuredocs.org/clojure.core/ns-aliases
17:23eriktjacobsenneoncontrails: thanks. In those examples, you must know the ns you are passing as argument into ns-aliases… i’m looking to find way to GET that ns. For instance… in file api.foo that has (ns api.foo) declared at top, I want (defn ns-string [] ???) to return “api.foo”. I just don’t know what would go in ???
17:33gfrederickseriktjacobsen: there's an easy way to do this with a macro, people just aren't telling you because they don't think it's a good idea
17:33gfredericks,(str *ns*)
17:33clojurebot"sandbox"
17:33gfredericks,(defmacro the-calling-namespace [] (str *ns*))
17:33clojurebot#'sandbox/the-calling-namespace
17:33gfredericks,(the-calling-namespace)
17:33clojurebot"sandbox"
17:34gfredericks,(defmacro assoc-calling-namespace [m] `(assoc ~m :ns ~(str *ns*)))
17:34clojurebot#'sandbox/assoc-calling-namespace
17:34gfredericks,(assoc-calling-namespace {:foo 431})
17:34clojurebot{:foo 431, :ns "sandbox"}
17:35gfredericksalso if you're not familiar with macros you might have a hard time making sense of how that works
17:36eraserhdI'd love advice for working with a Clojure newb who really wants to see a debugger and feels like they can't do anything without one.
17:38eraserhdThey want to be able to see "intermediate results" which, you know, clojure so ...
17:40gfredericks(doto x prn) is pretty easy to type; I also wrote github.com/gfredericks/debug-repl which is kind of haxy but seems to still be useful in real life
17:40gfredericksit's not a debugger but it covers a lot of use cases; I think there are real debuggers too, like that thing what colin wrote
17:40gfrederickscursive
17:40gfredericksno idea about the current state of debuggers in emacs
17:41eraserhddoto! Doh! I've been using (as-> x (do (prn x) x)).
17:41amalloy~doto is a solution to any problem
17:41clojurebotAck. Ack.
17:43eriktjacobsengfredericks: thank you
17:43gfrederickseriktjacobsen: np
17:48cflemingI think I'm going to use "that thing what colin wrote" as the new subtitle for the Cursive website.
17:48xemdetiahave it appear in the about box
17:48cflemingAlong with a tshirt for conferences saying "I'm the Cursive guy"
17:49xemdetia"primary schools don't need cursive anymore but I think you do"
17:49cflemingOh that's nice
17:49cflemingClearly I need to crowdsource my marketing
18:05justin_smithtrue story, I've been relearning actual cursive penmanship. I found a place where I could buy the spencer worksheets and everything
18:06cflemingjustin_smith has realised the need for Cursive
18:29eriktjacobsenjustin_smith: I setup my 3d printer to act like pen plotter and write out perfect cursive / calligraphy, way better than I could :)
18:33amalloywell presumably justin_smith wants to do it by hand for whatever reason. you don't have to stop walking just because cars are better at getting places
18:33justin_smithsounds like a fun project, but I'm relearning cursive as something to do with my hands that is radically different from typing
18:33justin_smithexactly
18:54crowgooselul
18:54eraserhdI'm pretty sure I can't print legibly anymore.
18:55eraserhdI think I'd rather tap two neurons for a serial port.
19:05gfredericks~cursive is that thing what colin wrote
19:05clojurebotIk begrijp
19:20trissok this is a long shot... is there a simple means of looking up the names of args for a function?
19:22domgettertriss: at runtime? Or do you mean just looking up docs?
19:22gfredericks,(meta #'first)
19:22clojurebot{:arglists ([coll]), :doc "Returns the first item in the collection. Calls seq on its\n argument. If coll is nil, returns nil.", :added "1.0", :static true, :line 49, ...}
19:22trissat runtime, like a proper dirt bag
19:23trissawesome thanks guys!
19:23trissI don't even feel that dirty
19:24trisswhat does #' do?
19:24trissI know ' is quote
19:25amalloy,'#'foo
19:25clojurebot(var foo)
19:27trissyup same as saying (var blah)
19:27trisssooooo...... I need to read up on var etc.
19:57mungojellyi thought about making my grids maps of maps of tiles but then i realized that's equivalent to making an index and then i realized that database writers are better at writing that algorithm than i am, so i'm not going to try to hand roll my own indexing that won't help anyone :)
20:11neoncontrailsjustin_smith: relevant to your interests, perhaps http://www.cs.toronto.edu/~graves/handwriting.cgi
20:25raryHello, guys! I've read so many nice things about your community that I decide to learn Clojure.
20:26justin_smithlol crowgoose tried to DCC "virus.exe" to me
20:26justin_smithrary: welcome!
20:27mungojellyrary: i just started learning too. the community is nice enough but lots of communities are nice but here the language also just works so amazingly well and reaches everywhere and does everything.
20:31raryI've downloaded LightTable, because Emacs make me feel bad (sorry, it is great and so on, but I am too stupid for it).
20:32mungojellylike earlier today i set myself the task of learning how to connect to firefox's databases and draw out the most recent youtube videos i've been to-- but that was too easy, it was just one simple line that was easy to figure out :o
20:34mungojellyclojure dissolves all ordinary limitations and gives you delusions of grandeur
20:34rarymungojelly: wow, it sounds cool.
20:38raryOkay, I thing it would be better for me to transit myself on #clojure-beginners.
20:38mungojellyrary: i'm on #clojure-beginners and it's been quiet, mostly there's room for simple questions here, just a few conversations here throughout a normal day
20:39egogiraffejustin_smith: heh, person tried sending that to me, too. at least they're honest, yanno.
20:40mungojellyactually #clojure-beginners hasn't had any conversation at all since i joined. maybe we should go talk about simple things there to give it some life. :)
20:40rary:D
20:42mungojellyi don't know much clojure yet in the big perspective but i know enough i could teach some basics if we had real beginners asking real beginner questions
20:44justin_smithrary: you might find intellij idea + cursive a more powerful and less buggy environment eventually, but light table can be a good start if you can handle its quirks
20:46justin_smithmungojelly: rary: beginners are free to talk here, but it's nice to have #clojure-beginners available if this channel gets all excited about advanced stuff about the compiler internals (which is known to happen)
20:46justin_smithbasically, we don't want to miss someone's basic question because there's lots of scroll about another topic
20:48raryjustin_smith: thank you for advice, I'll definitely try Cursive too.
20:57TEttingerI should pop into #clojure-beginners and ask about stuff like how to configure pmap to use more or less threads
21:01justin_smithTEttinger: hah
21:02justin_smithTEttinger: first step is to check out the clojure source, and find the code for pmap
21:02TEttingerI've built up way too much knowledge on the weird and arcane parts of clojure optimization and not enough on the practical stuff.
21:03justin_smithTEttinger: I just got clojure applied in the mail, and it has a good overview of what I would call the practical stuff
21:05TEttingerI do wish there was a better way to understand when clojure boxes things
21:05TEttinger,(class (int 21)) ; is not handy
21:05clojurebotjava.lang.Integer
21:05justin_smithTEttinger: NaN is the champ of all time, and wins all Boxing matches
21:06TEttingerit's beaten infinity twice
21:06TEttinger,(* 2.0 (/ 1.0 0.0))
21:06clojurebotInfinity
21:06TEttingerhm
21:06TEttinger,(/ (/ 1.0 0.0) 0.5)
21:06clojurebotInfinity
21:07TEttinger,(* (/ 1.0 0.0) (/ 1.0 0.0))
21:07clojurebotInfinity
21:07TEttingerhow did I get it...
21:07amalloyTEttinger: basically anytime you do something with a primitive other than (1) math or comparisons with it and another primitive; (2) call a java method taking a primitive; (3) call a clojure function hinted with the matching primitive type in its args
21:07justin_smith,(* 2.0 (/ 1.0 0.0) (/ 0.0 0.0))
21:07clojurebotNaN
21:07justin_smithit consumes all it touches
21:07TEttinger,(* (/ 1.0 0.0) (/ -1.0 0.0))
21:07clojurebot-Infinity
21:07justin_smith,(/ 0.0 0.0)
21:07TEttinger,(- (/ 1.0 0.0) (/ -1.0 0.0))
21:07clojurebotNaN
21:07clojurebotInfinity
21:08TEttinger,(- (/ 1.0 0.0) (/ 1.0 0.0))
21:08clojurebotNaN
21:08amalloyyou'll infect us all, justin_smi NaN
21:08TEttingerah
21:08TEttingerinfinity minus infinity is NaN
21:08justin_smiththat's another way to make it yeah
21:09amalloy,(* 0 (/ 1 0.0))
21:09clojurebotNaN
21:09amalloyoh that's the one justin_smith did
21:10amalloy,(/ (/ 1.0 0) (/ 1.0 0))
21:10clojurebotNaN