2015-07-11
| 00:10 | TEttinger | $seen ohpauleez |
| 00:10 | lazybot | ohpauleez was last seen quittingQuit: ohpauleez 31 weeks and 2 days ago. |
| 00:10 | TEttinger | damn |
| 00:11 | TEttinger | Paul deGrandis was working on a nice-looking clojure-on-lua thing, https://github.com/ohpauleez/cljs-terra |
| 00:28 | mercwithamouth | so would you say cursive works as well as emacs right now? |
| 00:29 | mercwithamouth | i'm comfortable with emacs but trying to decide if i should give an IDE a chance with clojure |
| 00:30 | amalloy | cursive has very good clojure integration, if you don't mind the editor |
| 00:32 | mercwithamouth | hmm...i'll take a look |
| 00:32 | mercwithamouth | i really love emacs but....if it's worth getting comfortable with intellij again...... |
| 00:57 | mercwithamouth | amalloy: 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:16 | mercwithamouth | got it |
| 01:44 | seangrov` | 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:45 | justin_smith | I've done writers, but not readers |
| 01:47 | seangrov` | justin_smith: close, close |
| 01:48 | justin_smith | seangrov`: relevant code that will eventually end up in an open sourced lib https://www.refheap.com/105970 |
| 01:50 | seangrov` | Oh, looks interesting |
| 01:52 | seangrov` | Cool that you could extend it with the notion of e.g. bson |
| 01:54 | justin_smith | seangrov`: really it's a hack to send data straight from mongo to cljs over a websocket with minimal processing |
| 01:54 | justin_smith | the implementation being to simply turn all those types into strings by calling str before encoding them |
| 03:51 | mmeix | Is 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:51 | mmeix | assoc-x, add-x ... ? |
| 04:01 | Pupeno | Oh my, hiccup doesn't escape strings by default. Does it have a mode where it escapes them by default that I can enable? |
| 04:29 | elvis4526 | How do i use clojure.inspector/inspect ? |
| 04:29 | elvis4526 | I know nothing about swing |
| 05:10 | ak5 | hey 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:10 | ak5 | lot of libs that exist in clojure). Can someone give me pointers on this? |
| 05:23 | mmeix | In Clojure/ClojureScript: something like Om or Reagent - lots of examples on the web |
| 05:23 | mmeix | but other users with more experience have to chime in re perfromance |
| 05:31 | mmeix | "traffic and other information": core.async |
| 07:19 | Pupeno | What’s the appropriate way to get a full URL when calling redirect in a luminus/compojure app? |
| 07:51 | crocket | How do I express (mapcat (fn [a b] [(inc a) (inc b)]) [1 2 3] [4 5 6]) more concisely? |
| 07:51 | crocket | (fn [a b] [(inc a) (inc b)]) is verbose. |
| 07:52 | crocket | (mapcat #(identity [(inc %1) (inc %2)]) [1 2 3] [4 5 6]) |
| 07:53 | crocket | I want to remove identity |
| 07:55 | Bronsa | you can do (mapcat #(list (inc %1) (inc %2)) [1 2 3] [4 5 6] |
| 07:55 | Bronsa | ) |
| 07:55 | crocket | Anything more concise such as juxt? |
| 07:56 | Bronsa | not really |
| 07:56 | Bronsa | ,(mapcat #(map inc %&) [1 2 3] [4 5 6]) |
| 07:56 | clojurebot | (2 5 3 6 4 ...) |
| 07:57 | crocket | Bronsa, I like it the most. |
| 08:42 | crocket | I like the fact that macros enforce compile-time invariants. |
| 08:43 | crocket | Interpreted languages can never have it. |
| 08:53 | namra | does anyone now what the minimum jvm memory requirements are to just run clojure? |
| 09:04 | crocket | namra, I guess it's 128MB for one JVM running clojure. |
| 09:04 | namra | crocket: thanks |
| 09:15 | crocket | A clojure book says a macro in http://dpaste.com/35TP7VK generates a warning. |
| 09:15 | crocket | But, it doesn't. |
| 09:15 | crocket | I see no reflection warning in my REPL. |
| 09:15 | crocket | Where is the warning? |
| 09:17 | crocket | Does defmacro preserve user-supplied metadata? |
| 10:31 | justin_smith | , (defmacro ^{:foo :bar} ? [] :hmm) |
| 10:31 | clojurebot | #'sandbox/? |
| 10:32 | justin_smith | ,(meta (var ?)) |
| 10:32 | clojurebot | {:foo :bar, :arglists ([]), :line 0, :column 0, :file "NO_SOURCE_PATH", ...} |
| 10:32 | justin_smith | ,(?) |
| 10:32 | clojurebot | :hmm |
| 10:34 | crocket | ,(binding [*print-meta* true] (prn (macroexpand '^String (or a b)))) |
| 10:34 | clojurebot | (let* [or__4236__auto__ a] (if or__4236__auto__ or__4236__auto__ (clojure.core/or b)))\n |
| 10:34 | crocket | As you can see, there is no metadata. |
| 10:34 | crocket | or is a macro |
| 10:38 | justin_smith | macroexpand does not get ^String as an argument |
| 10:38 | crocket | justin_smith, or macro expands to a let special form, and special forms don't take type hints. |
| 10:38 | justin_smith | and ^String is not being applied to or, it's being applied to the return value of (or a b) |
| 10:39 | justin_smith | also, '^String is just ^String, they are identical |
| 10:40 | crocket | http://dpaste.com/1H3B8VS preserves metadata of any code returned by macro expansion.. |
| 10:40 | crocket | Use it in a macro. |
| 10:53 | zophy_ | hi |
| 10:54 | Wild_Cat | are there any good libs that could be use to model and/or generate C++ code from Clojure? |
| 10:54 | Wild_Cat | and if not, could you point me at any resources/best practices to get started with that? |
| 10:55 | amalloy | justin_smith: am i missing some context? '^String x is the symbol x with the metadata {:tag 'String}, and ^String x evaluates x |
| 10:55 | Wild_Cat | I'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:55 | justin_smith | amalloy: oh, right |
| 10:56 | justin_smith | amalloy: 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:56 | amalloy | haha. sounds like my relationship with AOT |
| 10:56 | justin_smith | I shouldn't have tried to pretend I could address a question about metadata |
| 10:56 | zophy_ | is there a clojure idiom for creating classes with members and methods or should i use java for that ? |
| 10:57 | justin_smith | zophy_: defrecord |
| 10:57 | zophy_ | ah, i was wondering.. |
| 10:57 | justin_smith | zophy_: with the restriction that all methods must be defined beforehand in some interface or protocol |
| 10:57 | zophy_ | ok |
| 10:57 | justin_smith | also deftype (less features, more flexible, harder to use) |
| 13:52 | chelseaclinton | heya, 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:57 | scottj | chelseaclinton: I think most prefer cursive to la clojure. |
| 14:00 | cfleming | scottj chelseaclinton: La Clojure is now officially deprecated in favour of Cursive. It's not going to be updated for IntelliJ 15. |
| 14:01 | chelseaclinton | so how do I get cursive on my intelli |
| 14:01 | cfleming | chelseaclinton: Instructions are here: https://cursiveclojure.com/userguide/ |
| 14:03 | cfleming | chelseaclinton: Make sure you uninstall La Clojure first or things won't work. |
| 14:04 | chelseaclinton | sorry for not googling |
| 14:04 | chelseaclinton | i feel like an asshat |
| 14:04 | cfleming | chelseaclinton: No worries, as long as you don't mind an RTFM in response :-) |
| 14:05 | chelseaclinton | i am always prepared forr a rtfm |
| 14:06 | cfleming | chelseaclinton: 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:08 | chelseaclinton | I have been successful |
| 14:08 | chelseaclinton | thanks :) |
| 14:08 | chelseaclinton | first line of clojure as well |
| 14:08 | cfleming | Nice! |
| 14:29 | jack0 | Hi, 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:30 | arrubin | jack0: Clojure/West was earlier in the year and Clojure/conj is later in the year. |
| 14:31 | arrubin | http://lanyrd.com/topics/clojure/ |
| 14:31 | jack0 | Hi arrubin, is it possible to get funded to attend Clojure/conj? |
| 14:31 | arrubin | jack0: I do not know. |
| 14:31 | jack0 | Thanks arrubin |
| 14:43 | chelseaclinton | is clojure a widely used language |
| 14:43 | chelseaclinton | because today is the first day I've ever heard of it |
| 14:44 | atomi | yeah |
| 14:49 | chelseaclinton | any big projects i can look into |
| 14:49 | chelseaclinton | i really dont know what i should build first :D |
| 14:54 | atomi | yeah clojure is great at introducing the theoretical potential of programming |
| 15:12 | chelseaclinton | (def addtwo (fn [x] (inc (inc x)))) am I headed in the right direction? is fn like lambda in scheme? |
| 15:27 | zophy_ | chelseaclinton, yes, that particular code in my mind gives a name (identity) to an anonymous function |
| 15:27 | amalloy | yes, that is valid and does what you think it does |
| 15:27 | amalloy | (defn add-two [x] ...) would be more usual, stylistically |
| 15:29 | chelseaclinton | thanks for your feedback! |
| 16:29 | vas_ | 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:29 | TimMc | chelseaclinton: 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:49 | justin_smith | zophy_: 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:49 | justin_smith | naming and binding are distinct |
| 19:18 | elvis4526 | Is 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:19 | elvis4526 | So I have to close the REPL, open it and this takes forever. |
| 19:31 | justin_smith | elvis4526: 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:32 | justin_smith | eg if you did (defmulti mymulti ...) you can do (def mymulti nil) followed by (defmulti mymulti ...) again |
| 19:59 | elvis4526 | justin_smith: haaa right. Thanks |
| 20:18 | crazydiamond | Hi. 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:18 | tmtwd | what is that tool for clojure that allows you to push code to server without restarting the server? |
| 20:18 | crazydiamond | s/maps a list// |
| 20:22 | crazydiamond | tmtwd, what kind of server do you have? |
| 20:22 | tmtwd | compojure |
| 20:23 | crazydiamond | tmtwd, are you talking about hot code-push? |
| 20:23 | tmtwd | yes |
| 20:24 | crazydiamond | there'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:24 | crazydiamond | I'm not sure but they say: ring-devel is required for hot code reloading |
| 20:25 | crazydiamond | many google result are more about clojurescript |
| 20:26 | crazydiamond | I 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:53 | freeman42 | beginner 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:53 | freeman42 | like (dotimes 2 (.attack this "Rig")) or something |
| 20:55 | freeman42 | preferably without creating a function myself, just looking for something standard, cause it has to exist |
| 20:56 | metaphor | hello 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:57 | andyf | freeman42: 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:57 | freeman42 | andyf, perhaps https://clojuredocs.org/clojure.core/repeatedly |
| 20:58 | andyf | Ah, yes, repeatedly, not repeat. |
| 20:58 | andyf | But 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:59 | freeman42 | might 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:59 | andyf | Is there a reason you need to avoid having a binding value? |
| 20:59 | tomjack | I'd just write (dotimes [_ 2] ...) |
| 20:59 | freeman42 | andyf, the reason to avoid having a binding value is that it is simply not needed and code should be as simple as possible |
| 20:59 | andyf | If it is in clojure.core, then it should be in every Clojure namespace unless you do something to avoid it being there. |
| 21:00 | freeman42 | I'd prefer just write a function instead though :) |
| 21:05 | freeman42 | tomjack, that _ thing is cool though, thanks :) similar to how it works in scala/haskell |
| 21:08 | vas_ | freeman42: all the examples I can find of dotimes require [n some-number] ... which makes sense, n is bound every loop iteration.. |
| 21:09 | vas_ | freeman42: however, you should check out recur. http://clojuredocs.org/clojure.core/recur |
| 21:09 | freeman42 | vas_, not sure what you are saying. n is definitely not needed in lots of cases |
| 21:11 | freeman42 | vas_, 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:11 | vas_ | 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:12 | andyf | freeman42: 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:12 | freeman42 | vas_, if it is not needed then it should not be there, avoiding unneeded complexity |
| 21:12 | andyf | You can write a macro to do what you want. |
| 21:12 | freeman42 | aw :( |
| 21:13 | freeman42 | I thought it would be easy to write that function using the existing one |
| 21:13 | freeman42 | have to read on macros now |
| 21:13 | andyf | If you pass in a function, e.g. (fn [] (.attackThis ...)), then your function can do (f) in its do times body. |
| 21:16 | freeman42 | andyf, 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:16 | freeman42 | or is it cause of lazyness? |
| 21:16 | lodin_ | freeman42: dotimes is a macro, yes. |
| 21:17 | freeman42 | ah, 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:17 | freeman42 | without having to actually learn about macros :) |
| 21:18 | lodin_ | freeman42: Or you could just put the function in (fn [] ...) or even #(...) if that works. |
| 21:18 | vas_ | https://github.com/clojure/clojure/blob/f6a90ff2931cec35cca0ca7cf7afe90ab99e3161/src/clj/clojure/core.clj#L2581 |
| 21:18 | vas_ | (defmacro dotimes ... |
| 21:18 | freeman42 | lodin_, tried http://i.imgur.com/adUldeX.png it doesn't attack |
| 21:19 | lodin_ | freeman42: You need to invoke f in times. |
| 21:19 | freeman42 | vas_, thanks, had a look at it already |
| 21:19 | lodin_ | freeman42: So (f). |
| 21:20 | freeman42 | lodin_, with this, it still does not attack: http://i.imgur.com/AGqJAGI.png |
| 21:21 | lodin_ | freeman42: Then you have a problem in .attack. |
| 21:22 | freeman42 | lodin_, but this: (dotimes [n 2] (.attack this "Rig")) <- works |
| 21:23 | lodin_ | freeman42: I don't believe you. :-) Either both work, or neither. |
| 21:23 | andyf | freeman42: 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:23 | freeman42 | lodin_, maybe I'm doing something weird then |
| 21:23 | andyf | I don't know enough about the Codecombat web site to know what limitations or bugs it may have. |
| 21:24 | freeman42 | lodin_, ah, you are right, I thought it attacks but it does not |
| 21:24 | freeman42 | (dotimes [n 2] (.attack this "Rig")) does not work either |
| 21:25 | lodin_ | I'd still just use (dotimes [_ 2] ...) though. |
| 21:26 | freeman42 | lodin_, no, wait... actually it works but the animation is weird, I know it works cause Rig dies... :) |
| 21:26 | lodin_ | _ is understood to not be used, so it's not adding actual complexity. |
| 21:26 | freeman42 | lodin_, well, it is for learning and less clutter, using dotimes feels like pulling 90 KO of jquery just to use a few functions |
| 21:27 | lodin_ | Like having commas here and there does not add complexity. |
| 21:27 | freeman42 | lodin_, it is more than it is actually needed, so it does add complexity, things should be minimal |
| 21:27 | freeman42 | (times n someFunction) is ideal |
| 21:28 | lodin_ | freeman42: If I had a function called (dotimesbracketunderscore n f), would that be OK? |
| 21:28 | freeman42 | why there is no such implementation, really really weird |
| 21:28 | freeman42 | lodin_, yeah |
| 21:29 | lodin_ | 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:29 | freeman42 | yes, I perfectly understand that, do you understand that it is not minimal? |
| 21:29 | freeman42 | and that there should be a (times n someFunction) in the base libraries? |
| 21:30 | lodin_ | freeman42: It is technically not minimal, but it is for all intents and purposes as minimal as the dotimesbracketunderscore function. |
| 21:30 | freeman42 | as I said, I perfectly understand that... but it is not minimal, hence not good enough |
| 21:32 | lodin_ | So you would rather use a function called dotimesbracketunderscore than write "dotimes [_ "? |
| 21:32 | freeman42 | if we go by functionally equivalent, why not write in ASM then? or machine code? same problem, unneded complexity/verbosity |
| 21:32 | freeman42 | lodin_, of course |
| 21:32 | freeman42 | why write something more verbose when something simpler conveys perfectly the intended purpose? |
| 21:33 | vas_ | (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:33 | lodin_ | freeman42: My point is that it is even syntactically equivalent. |
| 21:33 | freeman42 | vas_, 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:34 | vas_ | freeman42: but then you wouldn't be having this excellent learning opportunity :D |
| 21:34 | freeman42 | lodin_, not sure what you mean by 'syntactically equivalent', does that mean more verbose and containing unneded cruft? |
| 21:35 | freeman42 | vas_, yes, I mean it is not bad :) but why it is not in the base libs... really really weird |
| 21:35 | vas_ | we could go one step further and add to the base libs "do-once" "do-twice" ... |
| 21:35 | vas_ | is that more or less complex :D |
| 21:36 | lodin_ | freeman42: It's not weird because everyone knows that "dotimes [_ n]" == "dotimesbracketunderscore n". |
| 21:36 | freeman42 | vas_, that would be just silly and completely unrelated to the direction I was talking about :p |
| 21:36 | freeman42 | but you can do in that direction if you want |
| 21:36 | lodin_ | freeman42: And I put the quotes there, because you could do a search and replace and it would work. |
| 21:38 | freeman42 | lodin_, 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:39 | lodin_ | 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:39 | freeman42 | vas_, 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:40 | lodin_ | freeman42: How is dotimesbracketunderscore more generic? |
| 21:41 | vas_ | 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:42 | freeman42 | lodin_, it is not constrained to use the binding |
| 21:42 | lodin_ | freeman42: Constrained? |
| 21:42 | freeman42 | the syntax is less generic |
| 21:42 | lodin_ | I don't follow. |
| 21:42 | freeman42 | you have to write [_ n] instead of n |
| 21:42 | lodin_ | Is that about being generic? |
| 21:43 | freeman42 | lodin_, from the point of view of the syntax |
| 21:43 | lodin_ | You have to write "bracketunderscore" in the function. |
| 21:43 | freeman42 | dotimes has 2 moving parts, times has 1 moving part, more moving parts -> less generic |
| 21:43 | freeman42 | I might be using the wrong word though :p |
| 21:44 | lodin_ | I have an argument for why dotimesbracketunderscore might be cool, but I'm holding on to it for a bit more. ;-) |
| 21:44 | freeman42 | lodin_, lol :D |
| 21:45 | vas_ | dotimes and times have the same number of moving parts. |
| 21:45 | vas_ | it is just a matter of visibility |
| 21:46 | freeman42 | vas_, 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:46 | lodin_ | 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:47 | freeman42 | lodin_, is there anything which was false about my arguments or... ? |
| 21:47 | vas_ | Yeah... take a look at another 50 clojure functions and tell me if you feel the same way after learning about -> and ->> (= |
| 21:47 | freeman42 | as I said, "do not write more code than needed" dotimes is verbose/non minimal |
| 21:48 | vas_ | 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:48 | freeman42 | vas_, what are -> and ->> ? :) |
| 21:48 | lodin_ | 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:49 | freeman42 | vas_, 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:49 | vas_ | i was just speaking in general, not everything revolves around dotimes xD |
| 21:49 | freeman42 | they are functionally equivalent, only 1 is more verbose and requires stuff which is not always needed |
| 21:49 | vas_ | -> and ->> are really cool! |
| 21:49 | freeman42 | vas_, well, ok then :p but generally minimal -> easy to understand, with exceptions ofc |
| 21:50 | vas_ | they are very lispy operators. let me make sure i understand them before i try and teach you about em |
| 21:50 | vas_ | minimal != easy-to-grok |
| 21:50 | freeman42 | lodin_, "and you agreed that the much longer names was ok" not sure what you mean by this |
| 21:51 | lodin_ | 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:51 | lodin_ | freeman42: You said you prefer "dotimesbracketunderscore n" over "dotimes [_ n]". |
| 21:51 | vas_ | Lol I saw an article "26 variable names for programmers in a hurry.. a b c d e f g .. etc) xD XD |
| 21:52 | freeman42 | lodin_, 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:52 | lodin_ | freeman42: Do you accept that underscore means "I'm not here, I'm just line noise, ignore me."? |
| 21:53 | freeman42 | lodin_, I said I prefer that as in, taking only n, not having a huge name you just gave lol |
| 21:53 | freeman42 | just a misunderstanding |
| 21:53 | vas_ | http://clojuredocs.org/clojure.core/-%3E (thread-first) |
| 21:53 | freeman42 | lodin_, "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:54 | vas_ | so say you have a constant constantfive that's 5... |
| 21:54 | tomjack | in ruby, IIRC, there is 3.times{ puts "hello" } and 3.times{ |n| puts "hello" } |
| 21:54 | freeman42 | lodin_, https://en.wikipedia.org/wiki/Principle_of_charity |
| 21:54 | lodin_ | freeman42: Would you prefer if dotimes was defined to look like "(dotimes n 3 ...)" instead? |
| 21:54 | tomjack | in clojure that seems complicated though |
| 21:54 | freeman42 | lodin_, I would like to have both ways |
| 21:55 | freeman42 | lodin_, with and witout binding |
| 21:55 | lodin_ | freeman42: It's not necessary to write dotimes so that it takes a vector. |
| 21:55 | lodin_ | freeman42: You can write a (dotimes' n 3 ...) that still binds to n. |
| 21:55 | freeman42 | lodin_, yeah, but, it would have been nice if there was already one defined in the base libs |
| 21:56 | lodin_ | freeman42: I don't think you follow what I mean. |
| 21:56 | freeman42 | lodin_, I'm a beginner, and to do this basic thing... I have to write it :) |
| 21:56 | lodin_ | Let's pretend that dotimes does not exist. |
| 21:56 | freeman42 | ok |
| 21:56 | lodin_ | And you want to write one. |
| 21:56 | lodin_ | That indeed bind the count to a name. |
| 21:57 | lodin_ | Would you create it so that the syntax is (dotimes v n ...) or (dotimes [v n] ...)? |
| 21:57 | freeman42 | lodin_, as I said above, it would be best to have BOTH |
| 21:57 | freeman42 | both are very useful and will be used a lot |
| 21:58 | lodin_ | freeman42: They do *exactly* the same thing. |
| 21:58 | lodin_ | I'm just talking syntax. |
| 21:58 | freeman42 | ah sorry |
| 21:58 | freeman42 | I thought you said (dotimes n ...) vs (dotimes [v n] ...) |
| 21:59 | freeman42 | for that question, just do what you know it is best, now knowing enough closure to know what is generally better in that case |
| 21:59 | vas_ | man I guess my thread-first -> and thread-thru ->> excitement will just have to wait... haha |
| 21:59 | freeman42 | or even if there is such a 'better' |
| 21:59 | tomjack | I didn't even consider the possibility of a single dotimes which checks whether the second arg is a vector |
| 21:59 | TEttinger | ,(defmacro times [n# body#] `(dotimes [_# ~n#] ~body#)) |
| 21:59 | clojurebot | #'sandbox/times |
| 21:59 | freeman42 | vas_, yes, sorry :p will read up |
| 21:59 | TEttinger | ,(times 5 (print 1)) |
| 21:59 | clojurebot | 11111 |
| 21:59 | lodin_ | 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:59 | vas_ | clojurebot, will you dance with me? |
| 21:59 | clojurebot | It's greek to me. |
| 22:00 | kristof | Too soon |
| 22:00 | freeman42 | lodin_, that is a good point, somehow I find putting those in the vector less disturbing that having unneeded actual arguments |
| 22:01 | vas_ | TEttinger: thank you, I learned about macros just now! |
| 22:02 | TEttinger | heh, it might be more complex than it needs to be |
| 22:02 | lodin_ | freeman42: My point is that you should consider _ to be just "syntax noise" like the vector is. |
| 22:03 | freeman42 | lodin_, well, the vector is not sytanx noise if you use it |
| 22:03 | lodin_ | freeman42: Right. If you use it. |
| 22:03 | freeman42 | lodin_, and if you do not use the binding the vector AND the biding ARE syntax noise... |
| 22:04 | freeman42 | really, overcomplicating things, this discussion is not leading anywhere :) |
| 22:04 | freeman42 | just add it to base libs and I will shut up, go go go :D |
| 22:04 | freeman42 | repeating 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:06 | lodin_ | freeman42: Because everyone can read "dotimes [_" and understand that it's a synonym for your times macro. |
| 22:06 | vas_ | yeah man it's already there you just need these awesome lenses for your glasses :D |
| 22:07 | freeman42 | sorry, 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:07 | freeman42 | would you write verbose machine code instead? NO! |
| 22:08 | lodin_ | freeman42: Unfortunately my point is not just about functional equivalent, but synonyms. :-) |
| 22:08 | vas_ | i think the deeper issue is that the bracket keys are too far away for you comfortably on your qwerty layout |
| 22:09 | vas_ | now if you'll excuse me i must get into my invisible dvorak jetplane... |
| 22:09 | vas_ | is there a place where I can exchange smugness for bitcoins? |
| 22:14 | lodin_ | 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:15 | lodin_ | freeman42: An honest question, which do you prefer? |
| 22:16 | lodin_ | I'm actually just curious. |
| 22:17 | freeman42 | lodin_, they have same number of moving parts, so it is different than times vs dotimes which differ on number of usable arguments |
| 22:17 | lodin_ | freeman42: Wait what? |
| 22:18 | freeman42 | lodin_, your last example has same number of inputs |
| 22:18 | freeman42 | it is not the same as the difference between times and dotimes which have different number of inputs |
| 22:18 | lodin_ | Not counting _ then, I guess. |
| 22:19 | freeman42 | lodin_, I don't actually get what that code is doing, I'm a beginner, does it not have same number of inputs? |
| 22:20 | freeman42 | a _ is an input also |
| 22:20 | vas_ | (let [ bindings ] ... ) is awesome |
| 22:20 | lodin_ | (let [... ... ... ... ... ...] ...) has 7 "inputs", while (let [... ...] ... (let [... ...] ...))" has 6. |
| 22:20 | vas_ | instead of being like 'var a = 2 , var b = 7' in clojure you use (let [ a 2, b 7] ... ) |
| 22:22 | freeman42 | lodin_, then they are not functionally equivalent I assume, same problem? |
| 22:22 | freeman42 | one being a generalisation of the other? |
| 22:22 | freeman42 | what does the extra input do? |
| 22:22 | lodin_ | freeman42: Example (let [enemy (get-enemy self) _ (attack-enemy this enemy) health (get-health this)] ...) |
| 22:23 | lodin_ | Or maybe even (let [old (get-health self) _ (attack-enemy this) new (get-health this)] (- old new)) |
| 22:23 | lodin_ | versus (let [enemy (get-enemy self)] (attack-enemy this enemy) (let [health (get-health this)] ...)) |
| 22:24 | freeman42 | was this not supposed to work? or did I misscopy TEttinger's code? http://i.imgur.com/S7HCWJ2.png |
| 22:24 | lodin_ | If you reformat that in an editor, you'll see the difference. (They do the same work.) |
| 22:24 | freeman42 | lodin_, so what does the extra input do then? |
| 22:25 | lodin_ | err, I'm tired. My versus was all wrong. |
| 22:25 | vas_ | freeman42: their interface might not let you use defmacro... what do you think? |
| 22:26 | lodin_ | Versus (let [old (get-health self)] (attack-enemy this) (let [new (get-health this)] (- old new))) |
| 22:26 | freeman42 | vas_, was thinking that might be the case, very very sad :( |
| 22:26 | vas_ | heartbreaking xD |
| 22:26 | freeman42 | vas_, without macros it is not possible to write that wrapper function in some other way? |
| 22:27 | lodin_ | freeman42: You had is already when you wrapped the code in a function. |
| 22:27 | freeman42 | lodin_, ? |
| 22:27 | lodin_ | freeman42: (defn times [n f] (dotimes [_ n] (f))) |
| 22:28 | TEttinger | lodin_: that won't work with a body of code, it will with a function of no args |
| 22:28 | lodin_ | TEttinger: That's the point. :_) |
| 22:29 | TEttinger | freeman42, hm, that looks like they might be expecting some piece of code to fill in a blank? not familiar with that site |
| 22:29 | TEttinger | oh! |
| 22:29 | TEttinger | you did dotimes instead of times below, freeman42 |
| 22:30 | TEttinger | odd error for that though |
| 22:30 | freeman42 | hmmmm http://i.imgur.com/rEJRBov.png |
| 22:31 | TEttinger | (.attack this "Rig") is not a function |
| 22:31 | TEttinger | you could do |
| 22:31 | TEttinger | #(.attack this "Rig") |
| 22:31 | lodin_ | freeman42: Put a # before the expression. |
| 22:31 | lodin_ | Like TEttinger. |
| 22:31 | TEttinger | which is an anonymous fn |
| 22:31 | freeman42 | TEttinger, tried with times now, same error though http://i.imgur.com/QaGe5Fi.png |
| 22:32 | freeman42 | TEttinger, same #(.attack this "Rig") |
| 22:32 | freeman42 | http://i.imgur.com/OKyqV3U.png |
| 22:33 | freeman42 | aw, I'm drunk xD |
| 22:33 | freeman42 | I assume this is what you meant: http://i.imgur.com/8mpLKSU.png |
| 22:34 | TEttinger | no, not quite |
| 22:34 | TEttinger | I meant... hang on |
| 22:34 | freeman42 | I should just get an actual IDE and test this code :) |
| 22:34 | TEttinger | (defn times [n f] (dotimes [_ n] (f))) |
| 22:34 | vas_ | The REPL is your friend, freeman42 |
| 22:35 | TEttinger | (times 2 #(.attack this "Rig")) |
| 22:35 | freeman42 | TEttinger, this runs but it does not attack http://i.imgur.com/17KNsdw.png |
| 22:36 | lodin_ | freeman42: Guess you won't defeat the ogres then. ;-) |
| 22:36 | vas_ | Amusing image. Hero DEAD, but on the bright side your code checks out. =D |
| 22:36 | freeman42 | haha :D guess I will go with dotimes :p until they add an overload taking only n or a times function :) |
| 22:37 | vas_ | Are you sure your .attack thing is in order? |
| 22:37 | freeman42 | vas_, I will check again |
| 22:37 | vas_ | if you do just (do (.attack this "Rig") (.attack this "Rig")) does it defeat Rig? |
| 22:37 | lodin_ | freeman42: Just for kicks, try putting a (do ...) around the code. Both the defn and the times call. |
| 22:38 | lodin_ | vas_: :-) |
| 22:38 | freeman42 | vas_, dead Rig: http://i.imgur.com/KK7rxGE.png |
| 22:40 | freeman42 | lodin_, nope :( http://i.imgur.com/KMJW7jS.png |
| 22:41 | vas_ | well (defn) is a definition of a fxn. if you were to put (do) anywhere it would wrap (times) |
| 22:41 | vas_ | like (do (times 2 (.attack this "Rig"))) |
| 22:42 | lodin_ | vas_: The point was to include the def in the do, in case the reader only read one form. |
| 22:43 | freeman42 | aight, 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:44 | vas_ | freeman42: that's an interesting game, what's it called? |
| 22:44 | freeman42 | vas_, https://codecombat.com |
| 22:46 | freeman42 | vas_, 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:46 | vas_ | I suppose to an englishman Japanese would clearly "lack syntax" as well xD |
| 22:47 | vas_ | 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:47 | freeman42 | vas_, I mean it in the way that, there are minimal magical keywords, if's are functions :) |
| 22:47 | vas_ | maybe not a perfect analogy, but kinda true. sorry your toolkit seems to be a bit crippled in there |
| 22:48 | freeman42 | that makes it VERY interesting as a language |
| 22:48 | vas_ | 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:49 | freeman42 | vas_, no, haven't seen any yet, too busy with other languages, trying to focus on Haskell / F# and a little dabbling in Rust |
| 22:51 | freeman42 | I'd comment this as 'ugly hack' http://i.imgur.com/PJiMpjb.png |
| 22:52 | freeman42 | still not satisfied, knowing how to wrap a simple function should be something very easy to do |
| 22:52 | tomjack | wow https://github.com/vickychijwani/closer.js |
| 22:54 | tomjack | freeman42: your problem is apparently that you're not using clojure :) |
| 22:54 | freeman42 | tomjack, what do you mean? :p |
| 22:54 | tomjack | they tried to reimplement clojure in js, but it's broken |
| 22:55 | freeman42 | tomjack, 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:55 | tomjack | or it just works differently than clojure, I dunno |
| 22:55 | tomjack | no, I mean when you evaluate so-called clojure code in codecombat, it's not clojure. it's closer |
| 22:56 | freeman42 | tomjack, so, this runs without error, but it does not attack... http://i.imgur.com/8MoL3DD.png |
| 22:56 | tomjack | and closer is apparently buggy |
| 22:56 | freeman42 | tomjack, would it work if it were clojure code? |
| 22:56 | tomjack | yes |
| 22:56 | freeman42 | wow, really really weird... |
| 22:56 | tomjack | except that there is no weird `this` in clojure |
| 22:56 | justin_smith | yeah, I tried a few things, the game rejects valid clojure code |
| 22:56 | freeman42 | aw man :( |
| 22:57 | justin_smith | tomjack: well, you could totally have "this" to invoke methods on, but that's a weird coding style |
| 22:57 | clojurebot | Excuse me? |
| 22:57 | tomjack | perhaps just now it could be possible for them to do their game in cljs? |
| 22:58 | vas_ | freeman42: your code looks very beautiful and easy to understand. good work. |
| 22:58 | tomjack | I'm not aware yet of the details on the bootstrapping project, just heard that something was happening. exciting :) |
| 22:59 | freeman42 | vas_, humorous really :D |
| 23:00 | lodin_ | freeman42: How much experience do you have with F# and Haskell? |
| 23:01 | freeman42 | lodin_, 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:02 | freeman42 | lodin_, let's just say that monads and buritos have not clicked in yet |
| 23:02 | lodin_ | freeman42: :D |
| 23:03 | freeman42 | any idea how to do a print in that closer.js site? I wanna test that code that wraps dotimes |
| 23:04 | lodin_ | freeman42: If you had to choose a language for a real project that you'd start today, which would it be? |
| 23:05 | freeman42 | lodin_, depends on what it would do, but I'd probably try to use F# for the logic |
| 23:05 | freeman42 | I don't feel adventurous enough to use Haskell cause of the lack of good enough tooling and libraries |
| 23:05 | freeman42 | F# can use the entire .NET ecosystem, like Scala can use the Java, etc. libs |
| 23:06 | lodin_ | freeman42: You mean like *Clojure* can use the Java etc. libs. ;-) |
| 23:06 | freeman42 | lodin_, Clojure can also use them, but I like my errors caught at compile time, not run time ;-) so Clojure is a no-go |
| 23:07 | justin_smith | I'd pick java over scala |
| 23:07 | freeman42 | justin_smith, Java 8? |
| 23:08 | justin_smith | any java |
| 23:08 | turbofail | scala's interop with java is a bit iffy at times, especially when the java side needs to reach into scala-land |
| 23:08 | justin_smith | luckily nobody is making me make that choice |
| 23:08 | freeman42 | justin_smith, I'd say hell no to that :) if it is not at least Java 8 |
| 23:09 | freeman42 | Scala is very complicated/powerful compared to Java, and the complicated part can get annoying and the compile tiems :D but tooling is awesome |
| 23:11 | freeman42 | TEttinger, 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:18 | vas_ | my limited understanding of defmacro and macros in general is that they are a compile-time transformation of stuff. |
| 23:18 | freeman42 | ouch, I though that defmacro is the way to define macros, now I find out there are TWO things to learn O.O |
| 23:20 | turbofail | it is the way to define macros |
| 23:20 | turbofail | there's no other way to do it |
| 23:28 | freeman42 | oh, ok, cool then |
| 23:38 | justin_smith | turbofail: not quite true |
| 23:41 | justin_smith | ,(defn ^:macro x [_ _ foo] (list foo 1)) ; turbofail |
| 23:42 | clojurebot | #'sandbox/x |
| 23:42 | justin_smith | ,(x dec) |
| 23:42 | clojurebot | 0 |
| 23:42 | justin_smith | ,(x inc) |
| 23:42 | clojurebot | 2 |
| 23:42 | justin_smith | turbofail: but defmacro is the only *sane* way to make a macro |
| 23:42 | turbofail | sure |
| 23:45 | freeman42 | so, it does not work cause... the macro is used inside I assume http://i.imgur.com/HhFObE6.png |
| 23:46 | justin_smith | looks like they have a weak / buggy compiler |
| 23:46 | freeman42 | yeah https://github.com/vickychijwani/closer.js/issues/6 |
| 23:46 | justin_smith | ,(defn times [n f] (dotimes [_ n] (f)) |
| 23:46 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 23:46 | justin_smith | ,(defn times [n f] (dotimes [_ n] (f))) |
| 23:46 | clojurebot | #'sandbox/times |
| 23:46 | justin_smith | ,(times 2 #(print "attack Rig ")) |
| 23:46 | clojurebot | attack Rig attack Rig |
| 23:47 | justin_smith | freeman42: that example wouldn't work, you need the second arg to times to be a lambda |
| 23:47 | justin_smith | freeman42: there is no defmacro in that code |
| 23:47 | justin_smith | so that's not the issue |
| 23:47 | turbofail | looks like a combination of not supporting macros, and not implementing all macros that normally come in the standard lib as special forms |
| 23:48 | freeman42 | justin_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:48 | freeman42 | when I use thar macro outside of any function it works correctly |
| 23:48 | turbofail | oh, looks like in this particular case it's probably not the macro |
| 23:49 | turbofail | no, it's as justin_smith says, you need to pass in a function |
| 23:49 | freeman42 | justin_smith, so, calling this works: (dotimes [_ 2] (.attack this "Rig")) outside of any function |
| 23:49 | justin_smith | turbofail: 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:50 | turbofail | freeman42: (.attack this "Rig") is most likely not an expression that yields a function |
| 23:50 | justin_smith | freeman42: OK, so they implemented dotimes as a top level form, but their implementation of defn is broken? |
| 23:50 | tomjack | (defn invoke [f] (f)) (invoke #(.attack this "Rig")) |
| 23:51 | freeman42 | turbofail, all I can say is that (dotimes [_ 2] (.attack this "Rig")) works :) |
| 23:51 | tomjack | (defn doit [] (.attack this "Rig")) (doit) (doit) |
| 23:51 | turbofail | freeman42: it would most likely work if you used (times 2 #(.attack this "Rig")) |
| 23:51 | tomjack | really baffling |
| 23:51 | turbofail | freeman42: or equivalently (times 2 (fn [] (.attack this "Rig"))) |
| 23:52 | freeman42 | I'll give it a try |
| 23:52 | turbofail | assuming that's a runtime error and not a compile error |
| 23:52 | tomjack | neither of my examples works |
| 23:52 | turbofail | if it's a compile error then who knows |
| 23:52 | tomjack | er, uhm. the first doesn't work and the second does |
| 23:55 | freeman42 | tomjack, this works: http://i.imgur.com/HkUmFyk.png |
| 23:56 | freeman42 | turbofail, this does not work, I do not think that closure.js knows what #(...) does http://i.imgur.com/2HJGlqb.png |
| 23:56 | tomjack | #() can work |
| 23:57 | tomjack | e.g. (def doit #(.attack this "Rig")) |
| 23:57 | tomjack | hence "baffling"... |
| 23:57 | turbofail | huh |
| 23:57 | turbofail | what about (fn [] (.attack this "Rig"))? |
| 23:57 | freeman42 | turbofail, this does not work either http://i.imgur.com/6szEMuF.png |
| 23:57 | freeman42 | maybe closure does not support anonymous functions/lambdas at all |
| 23:57 | turbofail | alright i guess the compiler really is just buggy |
| 23:58 | turbofail | that's some weird shit |
| 23:59 | justin_smith | yeah, that's probably the worst possible way to learn clojure, a compiler that doesn't even work |
| 23:59 | freeman42 | haha :D |
| 23:59 | tomjack | they thought it would be easier to reimplement clojure in js than to deploy and safely eval in a jvm, I guess? |