#clojure logs

2015-07-11

00:10TEttinger$seen ohpauleez
00:10lazybotohpauleez was last seen quittingQuit: ohpauleez 31 weeks and 2 days ago.
00:10TEttingerdamn
00:11TEttingerPaul deGrandis was working on a nice-looking clojure-on-lua thing, https://github.com/ohpauleez/cljs-terra
00:28mercwithamouthso would you say cursive works as well as emacs right now?
00:29mercwithamouthi'm comfortable with emacs but trying to decide if i should give an IDE a chance with clojure
00:30amalloycursive has very good clojure integration, if you don't mind the editor
00:32mercwithamouthhmm...i'll take a look
00:32mercwithamouthi really love emacs but....if it's worth getting comfortable with intellij again......
00:57mercwithamouthamalloy: have you happened to run across this error when starting a repl? 'Disconnected from the target VM, address: '127.0.0.1:63825', transport: 'socket'
01:16mercwithamouthgot it
01:44seangrov`Anyone implemented read handlers for transit (ideally with immutant)? Trying to get uri's to read in as java.net.URI, not the transit URI type
01:45justin_smithI've done writers, but not readers
01:47seangrov`justin_smith: close, close
01:48justin_smithseangrov`: relevant code that will eventually end up in an open sourced lib https://www.refheap.com/105970
01:50seangrov`Oh, looks interesting
01:52seangrov`Cool that you could extend it with the notion of e.g. bson
01:54justin_smithseangrov`: really it's a hack to send data straight from mongo to cljs over a websocket with minimal processing
01:54justin_smiththe implementation being to simply turn all those types into strings by calling str before encoding them
03:51mmeixIs there a naming convention for functions which assoc a new key/val into a coll of maps, for example: (func [{:step 2} {:step 3}]) ==> [{:step 2, :x 8.3} {:step 3, :x 2.5}]
03:51mmeixassoc-x, add-x ... ?
04:01PupenoOh my, hiccup doesn't escape strings by default. Does it have a mode where it escapes them by default that I can enable?
04:29elvis4526How do i use clojure.inspector/inspect ?
04:29elvis4526I know nothing about swing
05:10ak5hey guys, I am trying to make an extremely high performance web application to match inbound traffic with other information and then render the correct page for that traffic (think ads). Is clojure a good match for something like this? I don't really understand the JVM and warmup and I am concerned about these things. If not, I was also looking at nginx-lua (totally different, and it seems like its missing a
05:10ak5lot of libs that exist in clojure). Can someone give me pointers on this?
05:23mmeixIn Clojure/ClojureScript: something like Om or Reagent - lots of examples on the web
05:23mmeixbut other users with more experience have to chime in re perfromance
05:31mmeix"traffic and other information": core.async
07:19PupenoWhat’s the appropriate way to get a full URL when calling redirect in a luminus/compojure app?
07:51crocketHow do I express (mapcat (fn [a b] [(inc a) (inc b)]) [1 2 3] [4 5 6]) more concisely?
07:51crocket(fn [a b] [(inc a) (inc b)]) is verbose.
07:52crocket(mapcat #(identity [(inc %1) (inc %2)]) [1 2 3] [4 5 6])
07:53crocketI want to remove identity
07:55Bronsayou can do (mapcat #(list (inc %1) (inc %2)) [1 2 3] [4 5 6]
07:55Bronsa)
07:55crocketAnything more concise such as juxt?
07:56Bronsanot really
07:56Bronsa,(mapcat #(map inc %&) [1 2 3] [4 5 6])
07:56clojurebot(2 5 3 6 4 ...)
07:57crocketBronsa, I like it the most.
08:42crocketI like the fact that macros enforce compile-time invariants.
08:43crocketInterpreted languages can never have it.
08:53namradoes anyone now what the minimum jvm memory requirements are to just run clojure?
09:04crocketnamra, I guess it's 128MB for one JVM running clojure.
09:04namracrocket: thanks
09:15crocketA clojure book says a macro in http://dpaste.com/35TP7VK generates a warning.
09:15crocketBut, it doesn't.
09:15crocketI see no reflection warning in my REPL.
09:15crocketWhere is the warning?
09:17crocketDoes defmacro preserve user-supplied metadata?
10:31justin_smith, (defmacro ^{:foo :bar} ? [] :hmm)
10:31clojurebot#'sandbox/?
10:32justin_smith,(meta (var ?))
10:32clojurebot{:foo :bar, :arglists ([]), :line 0, :column 0, :file "NO_SOURCE_PATH", ...}
10:32justin_smith,(?)
10:32clojurebot:hmm
10:34crocket,(binding [*print-meta* true] (prn (macroexpand '^String (or a b))))
10:34clojurebot(let* [or__4236__auto__ a] (if or__4236__auto__ or__4236__auto__ (clojure.core/or b)))\n
10:34crocketAs you can see, there is no metadata.
10:34crocketor is a macro
10:38justin_smithmacroexpand does not get ^String as an argument
10:38crocketjustin_smith, or macro expands to a let special form, and special forms don't take type hints.
10:38justin_smithand ^String is not being applied to or, it's being applied to the return value of (or a b)
10:39justin_smithalso, '^String is just ^String, they are identical
10:40crockethttp://dpaste.com/1H3B8VS preserves metadata of any code returned by macro expansion..
10:40crocketUse it in a macro.
10:53zophy_hi
10:54Wild_Catare there any good libs that could be use to model and/or generate C++ code from Clojure?
10:54Wild_Catand if not, could you point me at any resources/best practices to get started with that?
10:55amalloyjustin_smith: am i missing some context? '^String x is the symbol x with the metadata {:tag 'String}, and ^String x evaluates x
10:55Wild_CatI'm currently thinking of modeling an AST using a lot of {:tag [data]}-style variants, but I'm a bit in the dark as to whether that's the best approach
10:55justin_smithamalloy: oh, right
10:56justin_smithamalloy: crocket: to be honest I hate, fear, and distrust metadata, and my knowledge of it consists mostly in finding ways to avoid ever dealing with it, sorry
10:56amalloyhaha. sounds like my relationship with AOT
10:56justin_smithI shouldn't have tried to pretend I could address a question about metadata
10:56zophy_is there a clojure idiom for creating classes with members and methods or should i use java for that ?
10:57justin_smithzophy_: defrecord
10:57zophy_ah, i was wondering..
10:57justin_smithzophy_: with the restriction that all methods must be defined beforehand in some interface or protocol
10:57zophy_ok
10:57justin_smithalso deftype (less features, more flexible, harder to use)
13:52chelseaclintonheya, I want to get started with clojure on ubuntu, got the clojure 1.7 jar but I can't do nothing in intellij, I'm using La Clojure
13:57scottjchelseaclinton: I think most prefer cursive to la clojure.
14:00cflemingscottj chelseaclinton: La Clojure is now officially deprecated in favour of Cursive. It's not going to be updated for IntelliJ 15.
14:01chelseaclintonso how do I get cursive on my intelli
14:01cflemingchelseaclinton: Instructions are here: https://cursiveclojure.com/userguide/
14:03cflemingchelseaclinton: Make sure you uninstall La Clojure first or things won't work.
14:04chelseaclintonsorry for not googling
14:04chelseaclintoni feel like an asshat
14:04cflemingchelseaclinton: No worries, as long as you don't mind an RTFM in response :-)
14:05chelseaclintoni am always prepared forr a rtfm
14:06cflemingchelseaclinton: I haven't written a getting started guide yet and the doc is a little out of date, but hopefully you can figure it out. Let me know if you have issues, I'll be on and off here.
14:08chelseaclintonI have been successful
14:08chelseaclintonthanks :)
14:08chelseaclintonfirst line of clojure as well
14:08cflemingNice!
14:29jack0Hi, are there any Clojure conferences coming up? And is there any way I can register and get funded for it? I know it's too much to ask, but it would be nice to know!
14:30arrubinjack0: Clojure/West was earlier in the year and Clojure/conj is later in the year.
14:31arrubinhttp://lanyrd.com/topics/clojure/
14:31jack0Hi arrubin, is it possible to get funded to attend Clojure/conj?
14:31arrubinjack0: I do not know.
14:31jack0Thanks arrubin
14:43chelseaclintonis clojure a widely used language
14:43chelseaclintonbecause today is the first day I've ever heard of it
14:44atomiyeah
14:49chelseaclintonany big projects i can look into
14:49chelseaclintoni really dont know what i should build first :D
14:54atomiyeah clojure is great at introducing the theoretical potential of programming
15:12chelseaclinton(def addtwo (fn [x] (inc (inc x)))) am I headed in the right direction? is fn like lambda in scheme?
15:27zophy_chelseaclinton, yes, that particular code in my mind gives a name (identity) to an anonymous function
15:27amalloyyes, that is valid and does what you think it does
15:27amalloy(defn add-two [x] ...) would be more usual, stylistically
15:29chelseaclintonthanks for your feedback!
16:29vas_anybody use Postal for sending mail? I'm trying to send verification mails via a gmail account but it is not playing very nicely...
16:29TimMcchelseaclinton: If you're used to scheme, pay close attention to the definition of let -- and let* is not generally something you want to use. (They don't mean quite the same thing as in scheme.)
17:49justin_smithzophy_: sorry to nitpick, but you can name anonymous functions with an optional arg (fn f [x]) is named f, what he did was bind an anonymous function to a var
17:49justin_smithnaming and binding are distinct
19:18elvis4526Is there a way to "clean" a REPL ? Let's say I change the dispatch function of a multimethod, if I just re-eval the definition it doesn't get updated
19:19elvis4526So I have to close the REPL, open it and this takes forever.
19:31justin_smithelvis4526: defmulti is defonce - you can restart your repl, or you can define it to nil before redefining, or delete the namespace binding before redefining
19:32justin_smitheg if you did (defmulti mymulti ...) you can do (def mymulti nil) followed by (defmulti mymulti ...) again
19:59elvis4526justin_smith: haaa right. Thanks
20:18crazydiamondHi. Can I create macro/some other thing, that maps a list turns '[foo bar buz] into construct like (def foo 1)(def bar 1)(def buz 1)
20:18tmtwdwhat is that tool for clojure that allows you to push code to server without restarting the server?
20:18crazydiamonds/maps a list//
20:22crazydiamondtmtwd, what kind of server do you have?
20:22tmtwdcompojure
20:23crazydiamondtmtwd, are you talking about hot code-push?
20:23tmtwdyes
20:24crazydiamondthere's something http://webcache.googleusercontent.com/search?q=cache:PQKoffDQ3UcJ:samrat.me/blog/2013/07/clojure-websockets-with-http-kit/+&cd=2&hl=ru&ct=clnk&gl=ru
20:24crazydiamondI'm not sure but they say: ring-devel is required for hot code reloading
20:25crazydiamondmany google result are more about clojurescript
20:26crazydiamondI can only add that on my local I'm using Boot, that allows to create a loop of reloads when some file is modified
20:53freeman42beginner question, how do you perform an action in a loop n times without needing any binding value? eg, this without n: (dotimes [n 2] (.attack this "Rig"))
20:53freeman42like (dotimes 2 (.attack this "Rig")) or something
20:55freeman42preferably without creating a function myself, just looking for something standard, cause it has to exist
20:56metaphorhello hivemind, I am now using Korma as my db tool, but my db naming is a_b_c, I have to issue query like (where {:a_b_c 1}), but I want something like (where {:a-b-c 1}), which still generate sql like 'WHERE a_b_c = 1', any thought?
20:57andyffreeman42: I don't think it does exist. There is repeat, but it is lazy, so not what you want unless you force the return value to be evaluated with something like dorun or doall
20:57freeman42andyf, perhaps https://clojuredocs.org/clojure.core/repeatedly
20:58andyfAh, yes, repeatedly, not repeat.
20:58andyfBut again, note the return is lazy, so unless you force it to be evaluated, you won't get the side effects that your example implies you want.
20:59freeman42might need some import though, I tried to use it in Codecombat but it says it is not a function, so not imported probably http://i.imgur.com/UhPgk3f.png
20:59andyfIs there a reason you need to avoid having a binding value?
20:59tomjackI'd just write (dotimes [_ 2] ...)
20:59freeman42andyf, the reason to avoid having a binding value is that it is simply not needed and code should be as simple as possible
20:59andyfIf it is in clojure.core, then it should be in every Clojure namespace unless you do something to avoid it being there.
21:00freeman42I'd prefer just write a function instead though :)
21:05freeman42tomjack, that _ thing is cool though, thanks :) similar to how it works in scala/haskell
21:08vas_freeman42: all the examples I can find of dotimes require [n some-number] ... which makes sense, n is bound every loop iteration..
21:09vas_freeman42: however, you should check out recur. http://clojuredocs.org/clojure.core/recur
21:09freeman42vas_, not sure what you are saying. n is definitely not needed in lots of cases
21:11freeman42vas_, tried to write a function to do that using dotimes http://i.imgur.com/ZB4AIcB.png not there yet, getting some syntax/meaning wrong
21:11vas_freeman42: you mean there's no need to have a named binding in many cases? regardless, somewhere there will be a value, whether or not it is used or apparent to the coder is another story
21:12andyffreeman42: I don't think you can write a function to do this, at least not without being like repeatedly and passing in a function. Your (.attackThis ...) expression, when passed to a function, is invoked once before calling the function only.
21:12freeman42vas_, if it is not needed then it should not be there, avoiding unneeded complexity
21:12andyfYou can write a macro to do what you want.
21:12freeman42aw :(
21:13freeman42I thought it would be easy to write that function using the existing one
21:13freeman42have to read on macros now
21:13andyfIf you pass in a function, e.g. (fn [] (.attackThis ...)), then your function can do (f) in its do times body.
21:16freeman42andyf, is the dotimes a macro? cause it seems to be able to use the (.attackThis ...) even though it is not wrapped in a function
21:16freeman42or is it cause of lazyness?
21:16lodin_freeman42: dotimes is a macro, yes.
21:17freeman42ah, so if I look at the dotimes implementation it should be easy to figure out how to write a version that only takes the number of times to repeat
21:17freeman42without having to actually learn about macros :)
21:18lodin_freeman42: Or you could just put the function in (fn [] ...) or even #(...) if that works.
21:18vas_https://github.com/clojure/clojure/blob/f6a90ff2931cec35cca0ca7cf7afe90ab99e3161/src/clj/clojure/core.clj#L2581
21:18vas_(defmacro dotimes ...
21:18freeman42lodin_, tried http://i.imgur.com/adUldeX.png it doesn't attack
21:19lodin_freeman42: You need to invoke f in times.
21:19freeman42vas_, thanks, had a look at it already
21:19lodin_freeman42: So (f).
21:20freeman42lodin_, with this, it still does not attack: http://i.imgur.com/AGqJAGI.png
21:21lodin_freeman42: Then you have a problem in .attack.
21:22freeman42lodin_, but this: (dotimes [n 2] (.attack this "Rig")) <- works
21:23lodin_freeman42: I don't believe you. :-) Either both work, or neither.
21:23andyffreeman42: If you try in a local Clojure REPL, you should find that your function times prints twice when you call (times 2 (fn [] (println "hi")))
21:23freeman42lodin_, maybe I'm doing something weird then
21:23andyfI don't know enough about the Codecombat web site to know what limitations or bugs it may have.
21:24freeman42lodin_, ah, you are right, I thought it attacks but it does not
21:24freeman42(dotimes [n 2] (.attack this "Rig")) does not work either
21:25lodin_I'd still just use (dotimes [_ 2] ...) though.
21:26freeman42lodin_, no, wait... actually it works but the animation is weird, I know it works cause Rig dies... :)
21:26lodin__ is understood to not be used, so it's not adding actual complexity.
21:26freeman42lodin_, well, it is for learning and less clutter, using dotimes feels like pulling 90 KO of jquery just to use a few functions
21:27lodin_Like having commas here and there does not add complexity.
21:27freeman42lodin_, it is more than it is actually needed, so it does add complexity, things should be minimal
21:27freeman42(times n someFunction) is ideal
21:28lodin_freeman42: If I had a function called (dotimesbracketunderscore n f), would that be OK?
21:28freeman42why there is no such implementation, really really weird
21:28freeman42lodin_, yeah
21:29lodin_And (dotimes [_ 2] ...) is that, just with a different spelling, if you accept that everyone understand that _ is not a value that is ever used.
21:29freeman42yes, I perfectly understand that, do you understand that it is not minimal?
21:29freeman42and that there should be a (times n someFunction) in the base libraries?
21:30lodin_freeman42: It is technically not minimal, but it is for all intents and purposes as minimal as the dotimesbracketunderscore function.
21:30freeman42as I said, I perfectly understand that... but it is not minimal, hence not good enough
21:32lodin_So you would rather use a function called dotimesbracketunderscore than write "dotimes [_ "?
21:32freeman42if we go by functionally equivalent, why not write in ASM then? or machine code? same problem, unneded complexity/verbosity
21:32freeman42lodin_, of course
21:32freeman42why write something more verbose when something simpler conveys perfectly the intended purpose?
21:33vas_ (times n f) is perfectly great for all the times you never need to reference n... but that one time you do, dotimes looks a lot more appealing.
21:33lodin_freeman42: My point is that it is even syntactically equivalent.
21:33freeman42vas_, ofc, I never said not to have the one with the bindings, just saying there should be one just with the count of times to repeat
21:34vas_freeman42: but then you wouldn't be having this excellent learning opportunity :D
21:34freeman42lodin_, not sure what you mean by 'syntactically equivalent', does that mean more verbose and containing unneded cruft?
21:35freeman42vas_, yes, I mean it is not bad :) but why it is not in the base libs... really really weird
21:35vas_we could go one step further and add to the base libs "do-once" "do-twice" ...
21:35vas_is that more or less complex :D
21:36lodin_freeman42: It's not weird because everyone knows that "dotimes [_ n]" == "dotimesbracketunderscore n".
21:36freeman42vas_, that would be just silly and completely unrelated to the direction I was talking about :p
21:36freeman42but you can do in that direction if you want
21:36lodin_freeman42: And I put the quotes there, because you could do a search and replace and it would work.
21:38freeman42lodin_, not sure where the discussion is going. are you saying it is a good idea NOT to have the function requiring only n in the base libs?
21:39lodin_freeman42: Not really. But you said it's really weird it is not included, and I don't think it is weird. Because everyone knows that the hypothetical dotimesunderbracketscore function is spelled "dotimes [_ n]".
21:39freeman42vas_, refactoring dotimes to take only n would make it more generic, doing that do-once, do-twice etc. would just make everything extremely ungeneric and crazy
21:40lodin_freeman42: How is dotimesbracketunderscore more generic?
21:41vas_freeman42: some might argue that it makes it far less generic, because if you use (times 5 f) and want to do something special on the third loopover, someone unfamiliar with dotimes would bind a new variable... making things (in the end) more cumbersome...
21:42freeman42lodin_, it is not constrained to use the binding
21:42lodin_freeman42: Constrained?
21:42freeman42the syntax is less generic
21:42lodin_I don't follow.
21:42freeman42you have to write [_ n] instead of n
21:42lodin_Is that about being generic?
21:43freeman42lodin_, from the point of view of the syntax
21:43lodin_You have to write "bracketunderscore" in the function.
21:43freeman42dotimes has 2 moving parts, times has 1 moving part, more moving parts -> less generic
21:43freeman42I might be using the wrong word though :p
21:44lodin_I have an argument for why dotimesbracketunderscore might be cool, but I'm holding on to it for a bit more. ;-)
21:44freeman42lodin_, lol :D
21:45vas_dotimes and times have the same number of moving parts.
21:45vas_it is just a matter of visibility
21:46freeman42vas_, nope, times has only 1 argument, n, much less way of making mistakes when using it, dotimes has 2, let's say twice the number of ways of making mistakes when using it
21:46lodin_freeman42: I really don't buy your arguments, but the reason a macro that takes the number first could be useful would be that you could combine it with the -> macro (but since it returns nil it would have to be at the end).
21:47freeman42lodin_, is there anything which was false about my arguments or... ?
21:47vas_Yeah... take a look at another 50 clojure functions and tell me if you feel the same way after learning about -> and ->> (=
21:47freeman42as I said, "do not write more code than needed" dotimes is verbose/non minimal
21:48vas_i'd rather write more code and be able to come back to it in 6 months than write absolutely bare minimal code and not understand it in 6 months..
21:48freeman42vas_, what are -> and ->> ? :)
21:48lodin_freeman42: My point is that dotimes with and underscore is just syntactically more verbose, and you agreed that the much longer names was ok, so it's obviously not about syntax either.
21:49freeman42vas_, you'd have problems understanding what a function called times with 1 argument does but not have problems with dotimes which has TWO? ehm, wat? :)
21:49vas_i was just speaking in general, not everything revolves around dotimes xD
21:49freeman42they are functionally equivalent, only 1 is more verbose and requires stuff which is not always needed
21:49vas_-> and ->> are really cool!
21:49freeman42vas_, well, ok then :p but generally minimal -> easy to understand, with exceptions ofc
21:50vas_they are very lispy operators. let me make sure i understand them before i try and teach you about em
21:50vas_minimal != easy-to-grok
21:50freeman42lodin_, "and you agreed that the much longer names was ok" not sure what you mean by this
21:51lodin_freeman42: But that's like saying that you should always choose the shortest possible name, because the rest of the name is verbose and not needed.
21:51lodin_freeman42: You said you prefer "dotimesbracketunderscore n" over "dotimes [_ n]".
21:51vas_Lol I saw an article "26 variable names for programmers in a hurry.. a b c d e f g .. etc) xD XD
21:52freeman42lodin_, not sure what you are talking about, you probably assumed that I was talking about name length when that long name was given, I did not care about that, I was talking about complexity of passed variable states
21:52lodin_freeman42: Do you accept that underscore means "I'm not here, I'm just line noise, ignore me."?
21:53freeman42lodin_, I said I prefer that as in, taking only n, not having a huge name you just gave lol
21:53freeman42just a misunderstanding
21:53vas_http://clojuredocs.org/clojure.core/-%3E (thread-first)
21:53freeman42lodin_, "But that's like saying that you should always choose the shortest possible name, because the rest of the name is verbose and not needed." to say something like that would just be silly :)
21:54vas_so say you have a constant constantfive that's 5...
21:54tomjackin ruby, IIRC, there is 3.times{ puts "hello" } and 3.times{ |n| puts "hello" }
21:54freeman42lodin_, https://en.wikipedia.org/wiki/Principle_of_charity
21:54lodin_freeman42: Would you prefer if dotimes was defined to look like "(dotimes n 3 ...)" instead?
21:54tomjackin clojure that seems complicated though
21:54freeman42lodin_, I would like to have both ways
21:55freeman42lodin_, with and witout binding
21:55lodin_freeman42: It's not necessary to write dotimes so that it takes a vector.
21:55lodin_freeman42: You can write a (dotimes' n 3 ...) that still binds to n.
21:55freeman42lodin_, yeah, but, it would have been nice if there was already one defined in the base libs
21:56lodin_freeman42: I don't think you follow what I mean.
21:56freeman42lodin_, I'm a beginner, and to do this basic thing... I have to write it :)
21:56lodin_Let's pretend that dotimes does not exist.
21:56freeman42ok
21:56lodin_And you want to write one.
21:56lodin_That indeed bind the count to a name.
21:57lodin_Would you create it so that the syntax is (dotimes v n ...) or (dotimes [v n] ...)?
21:57freeman42lodin_, as I said above, it would be best to have BOTH
21:57freeman42both are very useful and will be used a lot
21:58lodin_freeman42: They do *exactly* the same thing.
21:58lodin_I'm just talking syntax.
21:58freeman42ah sorry
21:58freeman42I thought you said (dotimes n ...) vs (dotimes [v n] ...)
21:59freeman42for that question, just do what you know it is best, now knowing enough closure to know what is generally better in that case
21:59vas_man I guess my thread-first -> and thread-thru ->> excitement will just have to wait... haha
21:59freeman42or even if there is such a 'better'
21:59tomjackI didn't even consider the possibility of a single dotimes which checks whether the second arg is a vector
21:59TEttinger,(defmacro times [n# body#] `(dotimes [_# ~n#] ~body#))
21:59clojurebot#'sandbox/times
21:59freeman42vas_, yes, sorry :p will read up
21:59TEttinger,(times 5 (print 1))
21:59clojurebot11111
21:59lodin_freeman42: I thought you would say that the one without the vector is better, since it does not require a vector it it's syntax.
21:59vas_clojurebot, will you dance with me?
21:59clojurebotIt's greek to me.
22:00kristofToo soon
22:00freeman42lodin_, that is a good point, somehow I find putting those in the vector less disturbing that having unneeded actual arguments
22:01vas_TEttinger: thank you, I learned about macros just now!
22:02TEttingerheh, it might be more complex than it needs to be
22:02lodin_freeman42: My point is that you should consider _ to be just "syntax noise" like the vector is.
22:03freeman42lodin_, well, the vector is not sytanx noise if you use it
22:03lodin_freeman42: Right. If you use it.
22:03freeman42lodin_, and if you do not use the binding the vector AND the biding ARE syntax noise...
22:04freeman42really, overcomplicating things, this discussion is not leading anywhere :)
22:04freeman42just add it to base libs and I will shut up, go go go :D
22:04freeman42repeating some action n times is like... and inherent need of the universe, why is it not there yet in a minimal to use manner?
22:06lodin_freeman42: Because everyone can read "dotimes [_" and understand that it's a synonym for your times macro.
22:06vas_yeah man it's already there you just need these awesome lenses for your glasses :D
22:07freeman42sorry, I give up, you are making my brain hurt, I told you many times that I understand perfectly that they are FUNCTIONALLY equivalent, and so is MACHINE CODE and the high level code we write
22:07freeman42would you write verbose machine code instead? NO!
22:08lodin_freeman42: Unfortunately my point is not just about functional equivalent, but synonyms. :-)
22:08vas_i think the deeper issue is that the bracket keys are too far away for you comfortably on your qwerty layout
22:09vas_now if you'll excuse me i must get into my invisible dvorak jetplane...
22:09vas_is there a place where I can exchange smugness for bitcoins?
22:14lodin_freeman42: _ is also commonly used when you don't care about the return value of something in a let, so you can write (let [a ... _ ... b ...] ...) instead of (let [a ...] ... (let [b ...] ...)).
22:15lodin_freeman42: An honest question, which do you prefer?
22:16lodin_I'm actually just curious.
22:17freeman42lodin_, they have same number of moving parts, so it is different than times vs dotimes which differ on number of usable arguments
22:17lodin_freeman42: Wait what?
22:18freeman42lodin_, your last example has same number of inputs
22:18freeman42it is not the same as the difference between times and dotimes which have different number of inputs
22:18lodin_Not counting _ then, I guess.
22:19freeman42lodin_, I don't actually get what that code is doing, I'm a beginner, does it not have same number of inputs?
22:20freeman42a _ is an input also
22:20vas_(let [ bindings ] ... ) is awesome
22:20lodin_(let [... ... ... ... ... ...] ...) has 7 "inputs", while (let [... ...] ... (let [... ...] ...))" has 6.
22:20vas_instead of being like 'var a = 2 , var b = 7' in clojure you use (let [ a 2, b 7] ... )
22:22freeman42lodin_, then they are not functionally equivalent I assume, same problem?
22:22freeman42one being a generalisation of the other?
22:22freeman42what does the extra input do?
22:22lodin_freeman42: Example (let [enemy (get-enemy self) _ (attack-enemy this enemy) health (get-health this)] ...)
22:23lodin_Or maybe even (let [old (get-health self) _ (attack-enemy this) new (get-health this)] (- old new))
22:23lodin_versus (let [enemy (get-enemy self)] (attack-enemy this enemy) (let [health (get-health this)] ...))
22:24freeman42was this not supposed to work? or did I misscopy TEttinger's code? http://i.imgur.com/S7HCWJ2.png
22:24lodin_If you reformat that in an editor, you'll see the difference. (They do the same work.)
22:24freeman42lodin_, so what does the extra input do then?
22:25lodin_err, I'm tired. My versus was all wrong.
22:25vas_freeman42: their interface might not let you use defmacro... what do you think?
22:26lodin_Versus (let [old (get-health self)] (attack-enemy this) (let [new (get-health this)] (- old new)))
22:26freeman42vas_, was thinking that might be the case, very very sad :(
22:26vas_heartbreaking xD
22:26freeman42vas_, without macros it is not possible to write that wrapper function in some other way?
22:27lodin_freeman42: You had is already when you wrapped the code in a function.
22:27freeman42lodin_, ?
22:27lodin_freeman42: (defn times [n f] (dotimes [_ n] (f)))
22:28TEttingerlodin_: that won't work with a body of code, it will with a function of no args
22:28lodin_TEttinger: That's the point. :_)
22:29TEttingerfreeman42, hm, that looks like they might be expecting some piece of code to fill in a blank? not familiar with that site
22:29TEttingeroh!
22:29TEttingeryou did dotimes instead of times below, freeman42
22:30TEttingerodd error for that though
22:30freeman42hmmmm http://i.imgur.com/rEJRBov.png
22:31TEttinger(.attack this "Rig") is not a function
22:31TEttingeryou could do
22:31TEttinger#(.attack this "Rig")
22:31lodin_freeman42: Put a # before the expression.
22:31lodin_Like TEttinger.
22:31TEttingerwhich is an anonymous fn
22:31freeman42TEttinger, tried with times now, same error though http://i.imgur.com/QaGe5Fi.png
22:32freeman42TEttinger, same #(.attack this "Rig")
22:32freeman42http://i.imgur.com/OKyqV3U.png
22:33freeman42aw, I'm drunk xD
22:33freeman42I assume this is what you meant: http://i.imgur.com/8mpLKSU.png
22:34TEttingerno, not quite
22:34TEttingerI meant... hang on
22:34freeman42I should just get an actual IDE and test this code :)
22:34TEttinger(defn times [n f] (dotimes [_ n] (f)))
22:34vas_The REPL is your friend, freeman42
22:35TEttinger(times 2 #(.attack this "Rig"))
22:35freeman42TEttinger, this runs but it does not attack http://i.imgur.com/17KNsdw.png
22:36lodin_freeman42: Guess you won't defeat the ogres then. ;-)
22:36vas_Amusing image. Hero DEAD, but on the bright side your code checks out. =D
22:36freeman42haha :D guess I will go with dotimes :p until they add an overload taking only n or a times function :)
22:37vas_Are you sure your .attack thing is in order?
22:37freeman42vas_, I will check again
22:37vas_if you do just (do (.attack this "Rig") (.attack this "Rig")) does it defeat Rig?
22:37lodin_freeman42: Just for kicks, try putting a (do ...) around the code. Both the defn and the times call.
22:38lodin_vas_: :-)
22:38freeman42vas_, dead Rig: http://i.imgur.com/KK7rxGE.png
22:40freeman42lodin_, nope :( http://i.imgur.com/KMJW7jS.png
22:41vas_well (defn) is a definition of a fxn. if you were to put (do) anywhere it would wrap (times)
22:41vas_like (do (times 2 (.attack this "Rig")))
22:42lodin_vas_: The point was to include the def in the do, in case the reader only read one form.
22:43freeman42aight, time to go pragmatic and stop wasting time, I am paid to kill monsters after all, not kill them using minimal functions :) so, dotimes ftw
22:44vas_freeman42: that's an interesting game, what's it called?
22:44freeman42vas_, https://codecombat.com
22:46freeman42vas_, it is a fun way to do Clojure for me, otherwise I would not have any reason to study it even though it is very interesting syntax wise,... or rather, for the lack of syntax :)
22:46vas_I suppose to an englishman Japanese would clearly "lack syntax" as well xD
22:47vas_Yeah that is pretty cool. Learn to code via games. I like that a lot. Like guitar hero is to music as codecombat is to coding
22:47freeman42vas_, I mean it in the way that, there are minimal magical keywords, if's are functions :)
22:47vas_maybe not a perfect analogy, but kinda true. sorry your toolkit seems to be a bit crippled in there
22:48freeman42that makes it VERY interesting as a language
22:48vas_oh yeah, have you seen any of rich hickey's talks? it's really cool the way he breaks down the philosophy behind it
22:49freeman42vas_, no, haven't seen any yet, too busy with other languages, trying to focus on Haskell / F# and a little dabbling in Rust
22:51freeman42I'd comment this as 'ugly hack' http://i.imgur.com/PJiMpjb.png
22:52freeman42still not satisfied, knowing how to wrap a simple function should be something very easy to do
22:52tomjackwow https://github.com/vickychijwani/closer.js
22:54tomjackfreeman42: your problem is apparently that you're not using clojure :)
22:54freeman42tomjack, what do you mean? :p
22:54tomjackthey tried to reimplement clojure in js, but it's broken
22:55freeman42tomjack, the reason that I'm not investing a lot in Clojure is that even though it has an awesome lack of syntax it is mainly dynamically typed, typed clojure lacks IDE support and it is mostly a hack
22:55tomjackor it just works differently than clojure, I dunno
22:55tomjackno, I mean when you evaluate so-called clojure code in codecombat, it's not clojure. it's closer
22:56freeman42tomjack, so, this runs without error, but it does not attack... http://i.imgur.com/8MoL3DD.png
22:56tomjackand closer is apparently buggy
22:56freeman42tomjack, would it work if it were clojure code?
22:56tomjackyes
22:56freeman42wow, really really weird...
22:56tomjackexcept that there is no weird `this` in clojure
22:56justin_smithyeah, I tried a few things, the game rejects valid clojure code
22:56freeman42aw man :(
22:57justin_smithtomjack: well, you could totally have "this" to invoke methods on, but that's a weird coding style
22:57clojurebotExcuse me?
22:57tomjackperhaps just now it could be possible for them to do their game in cljs?
22:58vas_freeman42: your code looks very beautiful and easy to understand. good work.
22:58tomjackI'm not aware yet of the details on the bootstrapping project, just heard that something was happening. exciting :)
22:59freeman42vas_, humorous really :D
23:00lodin_freeman42: How much experience do you have with F# and Haskell?
23:01freeman42lodin_, F# dabbled, Haskell over 1 year of reading, books doing MOOCs and doing different exercises online on CodeWars etc. but zero work experience or on actual projects
23:02freeman42lodin_, let's just say that monads and buritos have not clicked in yet
23:02lodin_freeman42: :D
23:03freeman42any idea how to do a print in that closer.js site? I wanna test that code that wraps dotimes
23:04lodin_freeman42: If you had to choose a language for a real project that you'd start today, which would it be?
23:05freeman42lodin_, depends on what it would do, but I'd probably try to use F# for the logic
23:05freeman42I don't feel adventurous enough to use Haskell cause of the lack of good enough tooling and libraries
23:05freeman42F# can use the entire .NET ecosystem, like Scala can use the Java, etc. libs
23:06lodin_freeman42: You mean like *Clojure* can use the Java etc. libs. ;-)
23:06freeman42lodin_, Clojure can also use them, but I like my errors caught at compile time, not run time ;-) so Clojure is a no-go
23:07justin_smithI'd pick java over scala
23:07freeman42justin_smith, Java 8?
23:08justin_smithany java
23:08turbofailscala's interop with java is a bit iffy at times, especially when the java side needs to reach into scala-land
23:08justin_smithluckily nobody is making me make that choice
23:08freeman42justin_smith, I'd say hell no to that :) if it is not at least Java 8
23:09freeman42Scala is very complicated/powerful compared to Java, and the complicated part can get annoying and the compile tiems :D but tooling is awesome
23:11freeman42TEttinger, ah, regarding closure "defmacro is not supported at the moment, as I haven't quite figured it out yet. Ideas and pull requests on how to go about it are always welcome!"
23:18vas_my limited understanding of defmacro and macros in general is that they are a compile-time transformation of stuff.
23:18freeman42ouch, I though that defmacro is the way to define macros, now I find out there are TWO things to learn O.O
23:20turbofailit is the way to define macros
23:20turbofailthere's no other way to do it
23:28freeman42oh, ok, cool then
23:38justin_smithturbofail: not quite true
23:41justin_smith,(defn ^:macro x [_ _ foo] (list foo 1)) ; turbofail
23:42clojurebot#'sandbox/x
23:42justin_smith,(x dec)
23:42clojurebot0
23:42justin_smith,(x inc)
23:42clojurebot2
23:42justin_smithturbofail: but defmacro is the only *sane* way to make a macro
23:42turbofailsure
23:45freeman42so, it does not work cause... the macro is used inside I assume http://i.imgur.com/HhFObE6.png
23:46justin_smithlooks like they have a weak / buggy compiler
23:46freeman42yeah https://github.com/vickychijwani/closer.js/issues/6
23:46justin_smith,(defn times [n f] (dotimes [_ n] (f))
23:46clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
23:46justin_smith,(defn times [n f] (dotimes [_ n] (f)))
23:46clojurebot#'sandbox/times
23:46justin_smith,(times 2 #(print "attack Rig "))
23:46clojurebotattack Rig attack Rig
23:47justin_smithfreeman42: that example wouldn't work, you need the second arg to times to be a lambda
23:47justin_smithfreeman42: there is no defmacro in that code
23:47justin_smithso that's not the issue
23:47turbofaillooks like a combination of not supporting macros, and not implementing all macros that normally come in the standard lib as special forms
23:48freeman42justin_smith, yeah, I don't mean defmacro is in the code, I mean that a macro is used and that is probably the problem
23:48freeman42when I use thar macro outside of any function it works correctly
23:48turbofailoh, looks like in this particular case it's probably not the macro
23:49turbofailno, it's as justin_smith says, you need to pass in a function
23:49freeman42justin_smith, so, calling this works: (dotimes [_ 2] (.attack this "Rig")) outside of any function
23:49justin_smithturbofail: I think there are multiple problems, and that is one of them, but fixing it won't be enough to make the thing work
23:50turbofailfreeman42: (.attack this "Rig") is most likely not an expression that yields a function
23:50justin_smithfreeman42: OK, so they implemented dotimes as a top level form, but their implementation of defn is broken?
23:50tomjack(defn invoke [f] (f)) (invoke #(.attack this "Rig"))
23:51freeman42turbofail, all I can say is that (dotimes [_ 2] (.attack this "Rig")) works :)
23:51tomjack(defn doit [] (.attack this "Rig")) (doit) (doit)
23:51turbofailfreeman42: it would most likely work if you used (times 2 #(.attack this "Rig"))
23:51tomjackreally baffling
23:51turbofailfreeman42: or equivalently (times 2 (fn [] (.attack this "Rig")))
23:52freeman42I'll give it a try
23:52turbofailassuming that's a runtime error and not a compile error
23:52tomjackneither of my examples works
23:52turbofailif it's a compile error then who knows
23:52tomjacker, uhm. the first doesn't work and the second does
23:55freeman42tomjack, this works: http://i.imgur.com/HkUmFyk.png
23:56freeman42turbofail, this does not work, I do not think that closure.js knows what #(...) does http://i.imgur.com/2HJGlqb.png
23:56tomjack#() can work
23:57tomjacke.g. (def doit #(.attack this "Rig"))
23:57tomjackhence "baffling"...
23:57turbofailhuh
23:57turbofailwhat about (fn [] (.attack this "Rig"))?
23:57freeman42turbofail, this does not work either http://i.imgur.com/6szEMuF.png
23:57freeman42maybe closure does not support anonymous functions/lambdas at all
23:57turbofailalright i guess the compiler really is just buggy
23:58turbofailthat's some weird shit
23:59justin_smithyeah, that's probably the worst possible way to learn clojure, a compiler that doesn't even work
23:59freeman42haha :D
23:59tomjackthey thought it would be easier to reimplement clojure in js than to deploy and safely eval in a jvm, I guess?