2014-11-05
| 00:00 | sm0ke | i am not sure if that macro can be written at all |
| 00:01 | sm0ke | as macros are compile time things, and i am trying to tie it up with runtime artifact |
| 00:01 | sm0ke | prove me wrong please |
| 00:01 | justin_smith | no, that's perfectly correct. all it gets at compile time is a, so it has to fail at compile time |
| 00:02 | sm0ke | ugh so sad, i wanted it so badly |
| 00:05 | sm0ke | i think may be a macro which writes a macro can do this? |
| 00:08 | justin_smith | would the macro writing macro know the number of args at compile time? |
| 00:09 | sm0ke | no but after its expansion it would right? |
| 00:09 | justin_smith | the expansion happens at compile time |
| 00:11 | sm0ke | see my pathetic attempt here https://www.refheap.com/92736 |
| 00:12 | sm0ke | now `bar` knows params# after its expanded right? |
| 00:13 | justin_smith | sm0ke: the part you removed wasn't the place where the error happened |
| 00:13 | sm0ke | but bar* still is seeing p as symbol :/ |
| 00:14 | sm0ke | no but now `bar` can act upon `n` at least it more than jsut a symbol |
| 00:14 | justin_smith | ~n evaluates to the symbol |
| 00:14 | clojurebot | Titim gan éirí ort. |
| 00:14 | justin_smith | ~n |
| 00:14 | clojurebot | I don't understand. |
| 00:15 | sm0ke | no it does not its unquote inside ` |
| 00:15 | sm0ke | try macroexpand-1 |
| 00:15 | justin_smith | right, and when it unquotes, it gets the argument |
| 00:15 | justin_smith | which is a |
| 00:16 | justin_smith | ,(clojure.core/let [params__5208__auto__ (clojure.core/repeatedly a clojure.core/gensym)] (user/bar* params__5208__auto__)) |
| 00:16 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 00:16 | justin_smith | like I said, bar is a |
| 00:16 | sm0ke | ugh yes |
| 00:16 | justin_smith | oops, sorry about that clojurebot |
| 00:16 | justin_smith | err I mean n is a |
| 00:17 | sm0ke | yea for macro expand but while eval its a value |
| 00:17 | justin_smith | so why does it get the same error then? |
| 00:17 | sm0ke | so instead of (bar* params#) if you put params# you can see a list of two symc |
| 00:18 | sm0ke | on evaluating (bar 2) |
| 00:19 | sm0ke | i mean (bar a) err |
| 00:36 | andyf | arrdem: Figure out why clojure.parallel is missing? |
| 00:36 | arrdem | andyf: I pinged puredanger and he didn't have a good answer. I haven't chased it. |
| 00:37 | andyf | I?d recommend sending an email to clojure-dev and/or Tom Faulhaber, who may be able to figure it out. |
| 00:37 | andyf | if he has time |
| 00:38 | andyf | I don?t know, but it reminds me of this bug, which may not be related at all: http://dev.clojure.org/jira/browse/CLJ-130 |
| 00:47 | arrdem | justin_smith: https://github.com/clojure-grimoire/lein-grim |
| 00:48 | arrdem | justin_smith: 0.2.0 is the latest, the svg is old |
| 00:48 | justin_smith | I see an svg that says 0.2.0 |
| 00:49 | arrdem | caching is bullshit man |
| 00:49 | justin_smith | "eventually consistent" |
| 00:50 | justin_smith | arrdem: woah, ,, to force indent in cond, I like it |
| 00:50 | arrdem | justin_smith: dude I love that trick |
| 00:50 | justin_smith | somehow this is the first I have seen it |
| 00:51 | justin_smith | I think I'm going to try to hack on pink tomorrow |
| 00:52 | justin_smith | after I get some day-job crap out of the way |
| 01:00 | arrdem | andyf: posted |
| 01:00 | andyf | thx |
| 01:01 | TEttinger | arrdem: are you one of them thar grad students who shows up to class if it fits his schedule? |
| 01:01 | arrdem | TEttinger: dude I'm an undergrad :P |
| 01:01 | TEttinger | nice |
| 01:01 | TEttinger | so you need to work! |
| 01:01 | arrdem | I am working. On clojure stuff! |
| 01:01 | arrdem | fuck this homework shit |
| 01:02 | TEttinger | I mean in general, there's no "grades don't matter" stuff like PhD-level classes |
| 01:18 | kenrestivo | my dumb core.async question of the day: is there a way to pull things out of a channel *only* if there's something in there? and return nil if nothing is available? |
| 01:19 | kenrestivo | rather than blocking/parking? take! does not do what i want: if there's nothing available right now the callback queues and executes later when something is stuffed in. |
| 01:19 | arrdem | well.. shit. I just broke 1.4.0 compat due to needing clojure.edn |
| 01:19 | arrdem | oh well |
| 01:20 | kenrestivo | who.... uses clojure 1.4.0 in 2014? :-) |
| 01:21 | arrdem | https://cognitect.wufoo.com/reports/state-of-clojure-2014-results/ |
| 01:21 | arrdem | ~4% of Clojure users :P |
| 01:21 | arrdem | poor sods |
| 01:21 | kenrestivo | it's like those android charts showing 10% of users are on 2.3 |
| 01:22 | arrdem | yes, yes it is |
| 01:23 | arrdem | kenrestivo: I suspect that's a core.async abstraction fault... the entire idea is that take! is blocking, right? |
| 01:23 | kenrestivo | take! is async |
| 01:23 | arrdem | yes that thing |
| 01:23 | kenrestivo | it's got a callback... and the callback queues |
| 01:23 | arrdem | "magic" |
| 01:24 | kenrestivo | what i want is "as of this moment, give me EVERYTHING in the queue, and if nothing is there, just nil" |
| 01:24 | dbasch | I know a large company that uses 1.2 in production |
| 01:25 | arrdem | kenrestivo: doesn't look like there's a way to do that actually. |
| 01:25 | justin_smith | I'm reading the code for pink - excited to start playing with it tomorrow |
| 01:25 | kenrestivo | no, no there isn't. |
| 01:25 | arrdem | kenrestivo: but this is me scanning the docs for the first time so... IANTBALDRIDGE |
| 01:26 | kenrestivo | i should ask questions during the day east coast usa time when the cognitecters are about |
| 01:26 | arrdem | ask on the ML |
| 01:26 | kenrestivo | meh, who uses email anymore? :-) |
| 01:26 | kenrestivo | 4% of users? |
| 01:26 | justin_smith | people use the mailing list via email? |
| 01:26 | justin_smith | I thought it was just a google group thing |
| 01:26 | arrdem | I do... T_T |
| 01:32 | TEttinger | arrdem: I use clojure 1.4 by necessity in lazybot, since clojail is limited to 1.4 last I checked |
| 01:32 | TEttinger | in my lazybot plugins i mean |
| 01:32 | justin_smith | TEttinger: dude, my lazybot update uses 1.7-alpha |
| 01:32 | justin_smith | I had no issues with clojail |
| 01:32 | TEttinger | :D |
| 01:33 | TEttinger | I'll spend some time tweaking to update to your version when you release |
| 01:33 | justin_smith | fingers crossed, lazybot will have my updates and the new clojure version soon |
| 01:34 | justin_smith | TEttinger: if you have any trouble just ask, the translation should be straightforward (basically all the hooks have new keywords thanks to the new irclj) |
| 01:34 | TEttinger | ok |
| 01:35 | TEttinger | thanks, justin_smith |
| 01:35 | TEttinger | (inc justin_smith) ; for good measure |
| 01:35 | lazybot | ⇒ 117 |
| 01:36 | arrdem | &::T/foo |
| 01:36 | lazybot | java.lang.RuntimeException: Invalid token: ::T/foo |
| 01:36 | arrdem | the hell... |
| 01:36 | arrdem | ambrosebs: ping |
| 01:36 | TEttinger | ,::T/foo |
| 01:36 | clojurebot | #<RuntimeException java.lang.RuntimeException: Invalid token: ::T/foo> |
| 01:36 | justin_smith | ,::a/foo |
| 01:36 | clojurebot | #<RuntimeException java.lang.RuntimeException: Invalid token: ::a/foo> |
| 01:36 | TEttinger | ,:T/foo |
| 01:36 | clojurebot | :T/foo |
| 01:36 | justin_smith | :a/foo |
| 01:37 | TEttinger | ,::T |
| 01:37 | clojurebot | :sandbox/T |
| 01:37 | justin_smith | yeah, double colon means use this ns |
| 01:37 | arrdem | right |
| 01:37 | arrdem | https://github.com/clojure/core.typed/search?utf8=%E2%9C%93&q=%3A%3AT%2Fspecial-collect |
| 01:37 | justin_smith | double you tee eff |
| 01:37 | arrdem | ikr |
| 01:37 | arrdem | tried to do a `lein grim core.typed` and that totally killed it |
| 01:38 | justin_smith | how did that even compile? |
| 01:38 | arrdem | hell if I know |
| 01:38 | arrdem | it's late, I'm turning in. |
| 01:38 | TEttinger | it requires [clojure.core.typed :as T] |
| 01:38 | justin_smith | (require '[clojure.string :as s]) |
| 01:38 | justin_smith | ,(require '[clojure.string :as s]) |
| 01:38 | clojurebot | nil |
| 01:38 | justin_smith | ,:s/foo |
| 01:39 | clojurebot | :s/foo |
| 01:39 | justin_smith | ,::s/foo |
| 01:39 | clojurebot | :clojure.string/foo |
| 01:39 | justin_smith | AHA |
| 01:39 | justin_smith | I had forgotten about that corner |
| 01:39 | justin_smith | so yeah, that's totally legit |
| 01:40 | arrdem | okay... so why is that killing lein-grim with an "invalid token exception" |
| 01:40 | arrdem | java.lang.RuntimeException: Invalid token: ::T/special-collect |
| 01:40 | justin_smith | if T is a local alias, that should work (as shown above) |
| 01:40 | arrdem | https://github.com/clojure/core.typed/blob/be6ffe4bd029afffec9256514cdf644bfdee2e71/module-check/src/main/clojure/clojure/core/typed/analyze_clj.clj#L16 |
| 01:41 | arrdem | https://github.com/clojure/core.typed/blob/be6ffe4bd029afffec9256514cdf644bfdee2e71/module-check/src/main/clojure/clojure/core/typed/analyze_clj.clj#L47 |
| 01:41 | arrdem | looks legit to me |
| 01:41 | TEttinger | is it not importing the right lib? |
| 01:42 | TEttinger | ,::s2/foo |
| 01:42 | clojurebot | #<RuntimeException java.lang.RuntimeException: Invalid token: ::s2/foo> |
| 01:42 | TEttinger | ,(require '[clojure.string :as s2]) |
| 01:42 | clojurebot | nil |
| 01:42 | TEttinger | ,::s2/foo |
| 01:42 | clojurebot | :clojure.string/foo |
| 01:42 | TEttinger | order could matter here |
| 01:43 | arrdem | damnit I know what's happening here |
| 01:43 | arrdem | fuck |
| 01:44 | arrdem | stupid friggin evaling reader |
| 01:44 | justin_smith | ,(read-string "::s2/foo") |
| 01:44 | clojurebot | :clojure.string/foo |
| 01:44 | arrdem | okay so here's what's happening |
| 01:44 | arrdem | that code loads just fine |
| 01:44 | justin_smith | but if you only read and did not eval the require |
| 01:44 | arrdem | then when I go to grab the source |
| 01:44 | arrdem | the source reader reads from a different context |
| 01:44 | arrdem | than the loader reads |
| 01:45 | arrdem | bang |
| 01:45 | justin_smith | oh, right |
| 01:45 | justin_smith | so you need in-ns |
| 01:45 | arrdem | yep |
| 01:45 | arrdem | &(bean *ns*) |
| 01:45 | lazybot | ⇒ {:name sandbox12103, :mappings {sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, unchecked-inc-int #'clojure.core/unchecked-inc-int, val #'clojure.core/val, ProcessBuilde... https://www.refheap.com/92739 |
| 01:45 | arrdem | &(.name *ns*) |
| 01:45 | lazybot | java.lang.SecurityException: You tripped the alarm! class clojure.lang.Namespace is bad! |
| 01:45 | justin_smith | wtf |
| 01:46 | justin_smith | ,(.name *ns*) |
| 01:46 | clojurebot | sandbox |
| 01:50 | justin_smith | OK, this is some seriously low-level code. Clearly it's only in Clojure so that the more abstract composition logic and the synth can be in the same language. |
| 01:52 | justin_smith | https://github.com/kunstmusik/pink/blob/master/src/pink/filters.clj#L281 I mean look at that shit |
| 01:55 | yedi | i'm using clojurescript in my webapp, but I want to be able to build individual js files for each page of the site. currently lein cljsbuild just builds the entire client side app into one js file. |
| 01:56 | yedi | is there a way to be able to like build separate js files for specific namespaces without having to create multiple cljs projects/ |
| 01:58 | fairuz | yedi: isn't one file is better than multiple? :) |
| 01:58 | fairuz | faster loading |
| 01:58 | yedi | maybe i guess with caching |
| 01:58 | yedi | but the initial page load will still suffer |
| 01:58 | TEttinger | barf, justin_smith |
| 02:00 | yedi | fairuz: actually i think om server side rendering would solve my problem |
| 02:00 | yedi | i just don't want to #breaktheweb |
| 02:02 | alandipert | yedi: you may consider loading the script up front on your splash or login page, but with the ‘defer’ attribute |
| 02:02 | yedi | what is the defer attr |
| 02:02 | yedi | googlin real quick |
| 02:02 | alandipert | yedi: http://stackoverflow.com/a/3982619 is the best descr i could find |
| 02:04 | alandipert | there are still reasons to have separate js tho, the big one for me is not leaking stuff to people who aren’t logged in |
| 02:04 | yedi | ah tho im fucked if i use client side rendering *cough* all these react frameworks |
| 02:04 | yedi | but i guess that was already a problem and server side rendering needs to be solved |
| 02:05 | arrdem | okay got it, I just needed to bind *ns* |
| 02:05 | arrdem | that's enough for now |
| 02:09 | sm0ke | so i found a way to do it, but now i am stuck in another problem |
| 02:26 | razum2um | how can I access project-structure (which is passed to lein plugins) in runtime repl? |
| 02:26 | sm0ke | why does `eval` loses context? |
| 02:28 | sm0ke | i mean ##(let [a 1] (eval (list 'print 1 'a))) |
| 02:28 | lazybot | java.lang.SecurityException: You tripped the alarm! eval is bad! |
| 02:34 | razum2um | sm0ke: see chapter 8 from joy of clojure - http://take.ms/aHmVu |
| 02:38 | sm0ke | i dont see anything regarding eval |
| 02:38 | sm0ke | razum2um: subpart? |
| 02:39 | sm0ke | oh got something |
| 02:39 | sm0ke | thanks razum2um |
| 02:39 | arrdem | &::T/foo |
| 02:39 | lazybot | java.lang.RuntimeException: Invalid token: ::T/foo |
| 02:42 | razum2um | sm0ke: but it's valid only if you know keys and values at compile time, if this is unpredictable you can use a hack - stash bindings into a dynamic and generate let-bindings to get functions which resolve vars using this dynamic - the graeat example is https://github.com/GeorgeJahad/debug-repl/blob/master/src/alex_and_georges/debug_repl.clj#L68 |
| 02:43 | sm0ke | wow |
| 02:43 | arrdem | if anyone feels motivated to write a patch on core... http://dev.clojure.org/jira/browse/CLJ-1579 |
| 02:43 | sm0ke | some ugly hack |
| 02:44 | razum2um | sm0ke: is the only way if bindings keys are known in runtime only |
| 02:44 | sm0ke | that *locals* thing has a problem of concurrency though? |
| 02:44 | sm0ke | what if multiple thread calls evals-with-locals |
| 02:45 | razum2um | sm0ke: don't feel so until you share mutable things there |
| 02:48 | razum2um | sm0ke: you can also try (ThreadLocal.) as a value for dynamic |
| 02:50 | sm0ke | weird how that contextual-eval is working! |
| 02:51 | sm0ke | i think its a con, for simple values sure it will work, but i think you put a fancy class there and you will get cant embedd object into code |
| 02:54 | razum2um | sm0ke: exactly, java obkects will complain about being inserted into code textually like in a macro |
| 02:55 | razum2um | sm0ke: but you can save a qualified symbol and then use find-var |
| 02:55 | sm0ke | then whats the whole point of the fancy macro i can always use `mylocal` instead of `'mylocal` |
| 02:58 | sm0ke | i mean he could have written it simply as (eval (list '+ a b)) |
| 02:58 | sm0ke | pointless example imo |
| 02:58 | razum2um | sm0ke: with macro you can pass bindings from same let block, these have no qualified name |
| 02:59 | razum2um | (let [x 1 y [1 2] z (contextual-eval {:x x} (some))) |
| 02:59 | sm0ke | yep ok agreed it shows eval is contextless |
| 03:00 | sm0ke | but not really helpful as a generic `contextual-eval` |
| 03:00 | razum2um | yes, joy of clojure seem to explain this, but i forgot |
| 03:00 | sm0ke | it will not work in most cases |
| 03:01 | sm0ke | which brings me back to 0 |
| 03:01 | razum2um | sm0ke: perhaps real implementation of eval with context will face same concurency problems as debug-repl hack |
| 03:01 | razum2um | sm0ke: what is the problem you're solving? |
| 03:03 | sm0ke | its actually like this, given a number you have to give back a function with same arity |
| 03:03 | sm0ke | https://www.refheap.com/92743 |
| 03:03 | sm0ke | the `bar` function works here, but its a toy case |
| 03:03 | sm0ke | so lets say i am passing a object along with `n` |
| 03:04 | sm0ke | which cannot be embedded in the eval list, it will fail |
| 03:06 | sm0ke | oh you have to change 'n to n for this to work, i was editing it |
| 03:07 | razum2um | why do you even need this arity, not just & args? |
| 03:08 | sm0ke | yes i know about & args, its just a requirement for another macro i am writing |
| 03:08 | razum2um | doh :) macro in macro in macro :) |
| 03:09 | sm0ke | hurm weird problem i know |
| 03:15 | sm0ke | razum2um: i think i have a neat solution, hold on |
| 03:18 | sm0ke | razum2um: https://www.refheap.com/92744 |
| 03:36 | hyPiRion | bbloom: I do, in a way. http://hypirion.com/musings/ – but noted, I'll get on it this evening |
| 05:43 | kungi | How can I create an internal maven repository for my company and use it together with leiningen? Are there any tutorials you would recommend? |
| 05:58 | razum2um | kungi: look at :repositories in profiles.clj and add like this ["clojars" {:url "https://clojars.org/repo/"}] |
| 06:24 | kungi | razum2um: thank you |
| 06:27 | clgv | kungi: there are several options for the server part |
| 06:28 | clgv | kungi: I use Apache Archiva. There is also Artifactory and at least another prominent one I dont recall right now |
| 06:31 | kungi | clgv: I found Nexus as well |
| 06:32 | clgv | kungi: ah right |
| 06:32 | clgv | kungi: archiva was easy to setup |
| 06:33 | kungi | clgv: Archiva looks nice! standalone distribution with jetty included => great |
| 06:33 | clgv | kungi: yes. the only thing that took time was that I was not familiar with redirection through apache to reuse its SSL setup |
| 06:34 | clgv | kungi: but that's probably not an issue if the repository is in your LAN |
| 06:34 | kungi | clgv: I solved that problem by delegating all our SSL stuff to nginx. |
| 06:35 | clgv | kungi: I already had an apache running and didn't use nginx so far... |
| 06:35 | kungi | clgv: nginx was the first web server where I was able to understand the config ... so I started using it and never stopped :-) |
| 06:36 | kungi | Actually I don't like doing "sysadmin stuff" |
| 06:36 | clgv | kungi: yeah apache config sometimes feels like voodoo |
| 06:36 | kungi | clgv: More like indian rain dancing than voodoo :-D |
| 06:36 | clgv | kungi: you are always better of when you have an existing working config snippet that you can adjust there ;) |
| 06:47 | the-kenny | The clojurescript repl situation is sooo complicated :/ It's really a pity. |
| 06:48 | CookedGryphon | the-kenny: I thought that, until I found weasel, much simpler imo |
| 06:48 | the-kenny | CookedGryphon: I use weasel exclusively, I'm talking about the stack under it |
| 06:48 | CookedGryphon | ah |
| 06:49 | the-kenny | there's weasel on top of austin on top of piggieback on top of nrepl |
| 06:49 | CookedGryphon | didn't realise weasel used austin under the hood |
| 06:50 | the-kenny | hm you may be right now that I think of it |
| 06:50 | the-kenny | Still, I'm searching for one (actually two) bugs in that stack |
| 06:50 | the-kenny | One that prevents stuff from being printed in the REPL before I send *any* nrepl message from Emacs |
| 06:50 | CookedGryphon | yeah, I'm looking at the deps and it doesn't seem to use austin or piggieback |
| 06:50 | the-kenny | it provides another transport for piggieback |
| 06:51 | the-kenny | while piggieback itself uses clojure.browser.repl |
| 06:51 | Glenjamin | if you try and run weasel without piggieback, it errors |
| 06:51 | CookedGryphon | ah, ok |
| 06:52 | the-kenny | Glenjamin, CookedGryphon: Do you have the issue of stuff not being printed in the REPL with print-fn set to :repl? |
| 06:52 | CookedGryphon | I've never made use of that feature, I've always just had the js console open and printed to that |
| 06:52 | the-kenny | hm :/ |
| 06:52 | Glenjamin | i had austin steal my console.log at onepoint |
| 06:54 | the-kenny | Right now I'm pretty lost where to report this issue. It's not weasel, as it seems to (print) the stuff it receives over the websocket just fine. So it's either piggieback or tools.nrepl that fails to deliver (or capture) the print-event before any other message arrives over the nrepl connection |
| 06:55 | the-kenny | I wish I could just throw away everything and start right at the bottom, implementing a 'lein ws-repl' that doesn't use piggieback under the hood. But that's a mammoth project after looking at the code of all those things |
| 06:56 | the-kenny | with a second nrepl-server *just* for cljs you could just have to nrepl connections from cider: one for cljs, one for clj. Although that would mean rewriting stuff there too |
| 07:01 | engblom | Please anyone take a look at this: http://pastebin.com/TfV0Xat5 |
| 07:02 | engblom | This works for some time until too many files are open. How do I get a continuous buffer instead of rereading the file each time? |
| 07:03 | engblom | This code is for reading mouse actions |
| 07:05 | raspasov | hey guys, do you know if it's possible to get information about a Clojure's data structure in terms of memory consumption, i.e. get how many Kb/Mb is a map (get-size-in-kb my-map) |
| 07:08 | clgv | raspasov: that's difficult similar to determining allocated memory of any Java object. there are (not that easy) ways to accomplish this |
| 07:10 | raspasov | yup, makes sense, ballpark estimates are OK, I'm trying to design a buffer pool allocator, so that if my cached objects start exceeding X megabytes, I would start removing them from memory |
| 07:11 | raspasov | the key would be doing this without a significant hit on performance |
| 07:19 | clgv | raspasov: oh just a limit on the number would not suffice? |
| 07:19 | engblom | I just solved my own problem so nm my question |
| 07:19 | raspasov | you mean a limit on the number of cached objects stored? |
| 07:20 | clgv | raspasov: determine allocated memory usually requires debug capabilities of the JVM, so performance is likely not that good |
| 07:20 | clgv | raspasov: yeah, if they consume similar amounts of memory that would work |
| 07:21 | raspasov | clgv: thanks for the input, I see, I'll search around some more, worst case a rough estimate of how big the objects are just setting a limit on the total count might be better/easier |
| 07:21 | raspasov | clgv: and simpler, which is always good :) |
| 07:21 | clgv | :) |
| 08:41 | csd_ | Is it possible to write some macro m such that {(m)} could be considered a valid hashmap? E.g. m expands into two forms prior to reader looking for them? |
| 08:43 | hyPiRion | csd_: you can do `{~@(m) ~@()} |
| 08:43 | csd_ | oh that's clever, i like it |
| 08:43 | hyPiRion | But it's probably better to do just (apply hashmap (m)) |
| 08:49 | engblom | What is the most simple way to send a message to 127.0.0.1 port 9000. I do not need to read the response. What library would you use? |
| 08:49 | Kneiva | engblom: what kind of message? curl |
| 08:49 | engblom | Kneiva: telnet |
| 08:50 | engblom | I want to make a program sending messages in the same way as I could do with telnet. |
| 08:53 | Kneiva | engblom: maybe http://stackoverflow.com/a/10447539/1790621 |
| 08:57 | engblom | Thanks |
| 09:25 | the_danko | morning! |
| 09:26 | fairuz | the_danko: night |
| 09:30 | daniel__ | the_danko: good afternoon |
| 09:31 | the_danko | fairuz daniel_ how are things going today? |
| 09:32 | the_danko | fariuz daniel_ i am doing a little core async learning from lispcast |
| 09:37 | samflores | what's the simplest way to verify whether a vec is "contained" or not in another vec? |
| 09:37 | samflores | (subvec? [1 2 3] [1 2]) ;; => true |
| 09:37 | samflores | (subvec? [1 2 3] [1 3]) ;; => false |
| 09:44 | clgv | samflores: there is nothing simple built-in |
| 09:45 | clgv | samflores: you can partition the bigger vector with respect to the size of the smaller one |
| 09:47 | clgv | ,(defn subvec? [a b] (some #(= % b) (partition (count b) 1 a))) |
| 09:47 | clojurebot | #'sandbox/subvec? |
| 09:47 | Bronsa | samflores: (defn subvec? [v1 v2] (some #{v2} (partition-all (count v2) 1 v1))) not terribly efficient but it's the shortest solution I could think of |
| 09:47 | Bronsa | clgv: ha! |
| 09:47 | clgv | ,(subvec? (range 5) [2 3]) |
| 09:47 | clojurebot | true |
| 09:47 | clgv | Bronsa: :P |
| 09:47 | clgv | 3secs :D |
| 09:48 | clgv | Bronsa: yeah, efficient solutions are more sophisticated |
| 09:48 | Bronsa | oh yeah, no reason to use partition-all in thi case |
| 09:49 | clgv | samflores: you have a pattern matching problem in case you want to look up efficient algortihms in the standard literature (Cormen...) |
| 09:53 | samflores | clgv :( |
| 09:57 | samflores | ,(every? identity (map = [1 2 3] [1 2])) ;; that's why I'm in love with FP |
| 09:57 | clojurebot | true |
| 09:57 | samflores | ,(every? identity (map = [1 2 3] [1 3])) |
| 09:57 | clojurebot | false |
| 09:58 | samflores | suddenly it just clicks :) |
| 09:58 | EvanR | :t identity |
| 09:59 | EvanR | ,(identity nil) |
| 09:59 | clojurebot | nil |
| 10:00 | clgv | samflores: that only works for special cases like the one you provided |
| 10:00 | clgv | samflores: the version Bronsa and I provided above work for all cases |
| 10:00 | hyPiRion | always a bit suprised that every? isn't vararg |
| 10:00 | clgv | ,(every? identity (map = [1 2 3] [2 3])) |
| 10:00 | clojurebot | false |
| 10:00 | clgv | samflores: ^^ |
| 10:01 | hyPiRion | wished I could do (every? = [1 2 3] [4 5 6]) |
| 10:01 | Bronsa | hyPiRion: yeah me too |
| 10:01 | clgv | hyPiRion: so why not just write a jira+patch for it? |
| 10:02 | EvanR | .oO( all? (zip-with =) or something |
| 10:02 | samflores | clgv I got disconnected and lost your replies, but I really need to verify the subset is at the beginning |
| 10:02 | clgv | samflores: that only works for special cases like the one you provided while the version Bronsa and I provided above work for all cases |
| 10:02 | clgv | ,(every? identity (map = [1 2 3] [2 3])) |
| 10:02 | clojurebot | false |
| 10:02 | clgv | samflores: see above a counterexample for your implementation ^^ |
| 10:06 | samflores | yeah, I know its false. but it fills my requirement of the subvec being at the beginning of the supervec (wich I didn't mention earlier) |
| 10:06 | Bronsa | samflores: so you don't need to find the subset, you just have to find if your vector starts with some elements |
| 10:06 | clojurebot | Gabh mo leithscéal? |
| 10:08 | EvanR | ,(every? true? '()) |
| 10:08 | clojurebot | true |
| 10:08 | EvanR | ,(every? false? '()) |
| 10:08 | clojurebot | true |
| 10:09 | samflores | Bronsa right. I asked for a subset because I thought there was something already in the clojure.core for it |
| 10:10 | EvanR | whats the opposite of every? |
| 10:10 | samflores | I expected to exists something like .indexOf |
| 10:10 | hyPiRion | not-any? |
| 10:10 | samflores | *exist |
| 10:11 | EvanR | do not see some, exist, any, etc |
| 10:11 | EvanR | at least some? doesnt do what im talking about |
| 10:11 | hyPiRion | some then. |
| 10:11 | EvanR | ah ok |
| 10:11 | EvanR | ,(some? true '()) |
| 10:11 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/some?> |
| 10:11 | EvanR | ,(some? true? '()) |
| 10:11 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/some?> |
| 10:11 | hyPiRion | ,(some true? ()) |
| 10:11 | clojurebot | nil |
| 10:11 | EvanR | ,(some true? '()) |
| 10:11 | clojurebot | nil |
| 10:11 | EvanR | ,(some false? '()) |
| 10:11 | clojurebot | nil |
| 10:12 | EvanR | k |
| 10:12 | clgv | that's why "some?" is such a good naming choice for that function :P |
| 10:13 | EvanR | it almost serves as the opposite of every? |
| 10:13 | EvanR | ,(some false? '(true true false)) |
| 10:13 | clojurebot | true |
| 10:13 | EvanR | confused |
| 10:14 | robholland | true |
| 10:14 | robholland | ;) |
| 10:14 | hyPiRion | What do you mean by opposite in the first place? |
| 10:14 | clgv | not really you have to distinguish on two levels. shall the predicate be true or false for success and how many elements of the list must fulfill that: at least one or all |
| 10:15 | EvanR | ,(or '(false false true true)) |
| 10:15 | clojurebot | (false false true true) |
| 10:15 | EvanR | is there a simpler function that is just the and or or of all the bools |
| 10:16 | EvanR | ,(false? false) |
| 10:16 | clojurebot | true |
| 10:16 | EvanR | ok i was thinking some returned the found value |
| 10:16 | Bronsa | ,(some identity [1 2 3]) |
| 10:16 | clojurebot | 1 |
| 10:16 | Bronsa | it does |
| 10:17 | EvanR | only if you us identity or a collection |
| 10:17 | EvanR | ,(some false? '(true false)) |
| 10:17 | clojurebot | true |
| 10:17 | Bronsa | ,(some inc [1 2 3]) |
| 10:17 | clojurebot | 2 |
| 10:17 | hyPiRion | EvanR: (every? true? x) == "(apply and x)" and (some true? x) == "(apply or x)" |
| 10:17 | EvanR | hyPiRion: ok |
| 10:17 | hyPiRion | well, if you assume every element is either true or false. |
| 10:17 | EvanR | ,(apply and '(true true true false)) |
| 10:17 | clojurebot | #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:17 | Bronsa | yeah usually some identity is more useful |
| 10:18 | clgv | haha only if `and` where a function ;) |
| 10:18 | hyPiRion | EvanR: That's why I wrote (apply and x) in quotes :) |
| 10:18 | clgv | hyPiRion: you tricked him! confess! :P |
| 10:18 | EvanR | ,(= (some true? x) "(apply or x)") |
| 10:19 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:19 | hyPiRion | I think you need to take me a bit more figuratively. |
| 10:22 | SagiCZ11 | . |
| 10:26 | EvanR | ,(= [1 2 3] [1 2 3]) |
| 10:26 | clojurebot | true |
| 10:26 | EvanR | ,(= [1 2 3] [1 2]) |
| 10:26 | clojurebot | false |
| 10:27 | EvanR | another way to do it ;) |
| 10:29 | EvanR | ,(map vector [1 2 3 4] [\a \b \c \d]) |
| 10:29 | clojurebot | ([1 \a] [2 \b] [3 \c] [4 \d]) |
| 10:29 | EvanR | ,(map vector [1 2 3 4] [\a \b \c]) |
| 10:29 | clojurebot | ([1 \a] [2 \b] [3 \c]) |
| 10:29 | EvanR | ,(map vector [1 2 3] [\a \b \c \d]) |
| 10:29 | clojurebot | ([1 \a] [2 \b] [3 \c]) |
| 10:35 | EvanR | is there a recursive let construct |
| 10:35 | justin_smith | EvanR: what does that mean? |
| 10:35 | verma | I expect this call to return me a channel which always outputs 1 no matter what the source had, doesn't seem to be working, I get the original value, what am I missing? |
| 10:35 | verma | https://www.refheap.com/92761 |
| 10:35 | justin_smith | ,(let [a 0 b (inc a) c (inc b)] c) |
| 10:35 | clojurebot | 2 |
| 10:36 | EvanR | thats the non recursive let |
| 10:36 | verma | the source chan values are what I get, I was hoping the transducer will be applied |
| 10:36 | justin_smith | OK what do you mean by recursive |
| 10:36 | EvanR | ,(let [a (inc b) b 3] a) |
| 10:36 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:36 | EvanR | the lhs variables can be referenced in any rhs |
| 10:36 | justin_smith | EvanR: flet is the closest we have but it can only define functions |
| 10:36 | justin_smith | it just doesn't exist |
| 10:37 | EvanR | only being able to define functions makes sense in a schemy-like context |
| 10:37 | EvanR | whats the word, eager |
| 10:37 | tbaldridge | verma: I'd need to see more of the source code, nothing seems to be putting data into the channel you're creating? |
| 10:38 | justin_smith | EvanR: there is nothing in clojure that can use things in definitions that are not yet defined - you need something like declare or resolve for vars, and there is simply no option in a let block |
| 10:38 | EvanR | i know about declare, but does that work locally |
| 10:38 | justin_smith | like I said |
| 10:38 | justin_smith | it's for vars, let bindings are not vars |
| 10:39 | tbaldridge | verma: yeah, that code won't work, You're creating a channel via chan, but then nothing is putting data into it. Async/pipe returns the 2nd argument (the 'to' chan) |
| 10:39 | EvanR | looks like flet is a no no in clojure this recommends letfn http://clojure.org/lisps |
| 10:39 | justin_smith | EvanR: you can sometimes pull something off with a promise / deliver |
| 10:39 | justin_smith | EvanR: sorry, I keep doing that |
| 10:39 | EvanR | justin_smith: are vars local? |
| 10:39 | justin_smith | no |
| 10:39 | justin_smith | they are globals |
| 10:39 | EvanR | ok |
| 10:39 | justin_smith | I keep calling letfn flet, my bad |
| 10:40 | justin_smith | same with calling promise delay (I caught myself this time0 |
| 10:40 | EvanR | letfn, all is right with the world |
| 10:40 | EvanR | well, except that tail calls might bust the stack? |
| 10:40 | justin_smith | ,(flet [(a [] (inc (c))) (c [] 3)] (a)) |
| 10:40 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: flet in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 10:41 | justin_smith | ,(letfn [(a [] (inc (c))) (c [] 3)] (a)) |
| 10:41 | clojurebot | 4 |
| 10:42 | justin_smith | EvanR: tail calls could bust the stack, and it's a bit silly to have to turn everything into a function |
| 10:42 | EvanR | it is |
| 10:43 | clgv | $source letfn |
| 10:43 | lazybot | letfn is http://is.gd/6UUJnn |
| 10:44 | clgv | ok that one dives pretty straightforward into the compiler ;) |
| 10:44 | EvanR | theres a recursive let strategy for eager language, i read about once |
| 10:44 | justin_smith | clgv: yeah, I think letfn* is a special form, and basically part of the compiler |
| 10:45 | EvanR | which crashes if what you wrote is nonsense, otherwise works |
| 10:45 | clgv | no question ;) |
| 10:45 | justin_smith | EvanR: in common lisp let is recursive and parallel, let* is sequential like ours |
| 10:46 | EvanR | right i think the paper i read was an improvement over some lisp where it was recursive but might lockup if you what you wrote makes no sense |
| 10:46 | EvanR | but i dont know |
| 10:46 | justin_smith | wait, not recursive - but they have letrec |
| 10:46 | justin_smith | it's been a while |
| 10:46 | justin_smith | let - parallel (no cross ref) let* - linear (only back ref) letrec (full cross ref) |
| 10:47 | EvanR | whats parallel let |
| 10:47 | EvanR | runs everything in parallel? |
| 10:47 | justin_smith | that means all values are effectively calculated in parallel |
| 10:47 | EvanR | funky |
| 10:47 | justin_smith | no reference to any other value in the binding form is allowed |
| 10:47 | verma | tbaldridge, thanks! yeah I messed up the argument order |
| 10:53 | EvanR | letfn gives you almost what you can do with local function defs in javascript |
| 10:53 | EvanR | if you move vars to an enclosing normal let in either case, then its the same |
| 10:53 | EvanR | (js vars) |
| 10:53 | EvanR | non functions |
| 10:55 | EvanR | vars that use the functions have to go below, so a little more tricky than full letrec |
| 11:24 | sdegutis | Do you find that your Compojure apps have an top-level routing namespace that has a ton of :requires in the (ns) form for all sorts of other routes? |
| 11:26 | sdegutis | Mine's like 30 lines long, and I'm wondering if that's a sign of bad design. |
| 11:26 | weavejester | I expect it depends on how complex your application is |
| 11:27 | weavejester | If you have 30 types of routes, your app is doing 30 different things, presumably. |
| 11:27 | nonuby | what abboout doing something like (:require [acme.web sales deals user-admin pwd-change]) etc.. |
| 11:28 | nonuby | not sure if it works, but was exploring same problem yesterday https://clojuredocs.org/clojure.core/require |
| 11:28 | sdegutis | My concern is more for the fact that I have to require them all. Perhaps I should be dynamically finding them instead? |
| 11:28 | justin_smith | yuck |
| 11:29 | kungi | sdegutis: Yes my compojure app has a routing namespace containing "tons" of routes. |
| 11:29 | sdegutis | justin_smith: What's bad about this idea? |
| 11:30 | justin_smith | sdegutis: I should be able to look at the namespace that creates the server and see exactly where the code defining routes can be found. |
| 11:30 | sdegutis | Why? |
| 11:30 | clojurebot | why not? |
| 11:30 | EvanR | its way easier to understand code that has references to what its using |
| 11:31 | justin_smith | sdegutis: because I read code, and fix other people's code |
| 11:31 | sdegutis | clojurebot: useless retort. |
| 11:31 | clojurebot | Excuse me? |
| 11:31 | EvanR | rather than just names |
| 11:31 | EvanR | simple scripts is different from a huge codebase |
| 11:32 | EvanR | in ruby (rails) the norm is to not have any requires anywhere for anything |
| 11:32 | sdegutis | justin_smith: But "follow the namespaces linked directly above in the (ns) declaration" is only one convention. Another could be "embed routes in any sub-namespace ending with '-routes'" instead. |
| 11:32 | EvanR | the assumption is that "everything" has been imported everything, this is somehow supposed to make things easier |
| 11:32 | EvanR | everywhere* |
| 11:32 | justin_smith | sdegutis: I don't want to waste my time learning a new set of conventions for each project I work on, and remembering which convention each one used |
| 11:33 | justin_smith | sdegutis: if I come to a new codebase, or a codebase I wrote a decent time ago in the past, I want to be able to figure out what happens where without reverse engineering some kind of magic |
| 11:33 | sdegutis | justin_smith: That's an unfounded exaggeration. These could be the two major conventions that all apps use, which would invalidate your concern. |
| 11:33 | sdegutis | justin_smith: If library "foobar" became very popular and uses the second convention, you'd know to look for either one or the other. |
| 11:33 | justin_smith | sdegutis: I'll agree when all apps use the convention, until then no |
| 11:34 | sdegutis | So far I've only seen apps that use the (ns)-based convention. |
| 11:34 | sdegutis | The only argument I understand so far is EvanR's. |
| 11:34 | justin_smith | sdegutis: a big part of why I use clojure is we have a very small number of conventions, I don't want to learn a new dsl every day |
| 11:35 | sdegutis | justin_smith: That doesn't mean we have no conventions. The convention of (defroutes) has already become standardized even though it's effectively a DSL. |
| 11:35 | EvanR | auto import of thing named foo works, until it doesnt |
| 11:35 | justin_smith | sdegutis: I don't use defroutes |
| 11:35 | EvanR | though i dont think were talking about that |
| 11:35 | nonuby | sdgeutis, how about routes.cljs builds a list of other routes from admin-routes.clj contact-routes.clj deal-routes.clj etc.. not sure if correct but something like (apply routes (concat (adminroutes/routes) (dealroutes/routes)) |
| 11:35 | sdegutis | justin_smith: Clojure community is very conservative about adopting new conventions, and that's probably good. But I don't think that has to mean we stop adopting new ones altogether. |
| 11:36 | EvanR | whats wrong with modules just importing what it uses |
| 11:38 | technomancy | EvanR: it's a bit tedious if you don't use slamhound |
| 11:38 | EvanR | dang |
| 11:39 | sed-utils | nonuby: You mean dynamically instead of in the (ns) declaration? |
| 11:39 | EvanR | technomancy: installing |
| 11:40 | justin_smith | sed-utils: one of the primary bonuses to clojure is that in a given namespace I can figure out where each value came from. Auto loading magic subverts this. |
| 11:41 | sed-utils | EvanR: I imagine Ruby's "auto require the entire universe" is probably difficult, especially with Ruby being more prone to conflicting module/submodule names. But in this very simple hypothetical route-finder example, I can't really see much that can go wrong it. |
| 11:41 | justin_smith | sed-utils: I don't think it's about conservatism - this is something that has evolved in clojure - we were once ok with :use, and we decided it was not explicit enough. Most languages have some kind of implicit / global / eager namespace alteration and I like that clojure at least avoids it. |
| 11:42 | sed-utils | justin_smith: I suppose we'll have to disagree about how valuable Clojure's explicit symbol tracing is. I find it very useful for simple functions like yaml/read-string or json/read-string, but for very redundant and highly-patternized names like route vars, it's not hard to find those in a project without the explicit require. |
| 11:43 | EvanR | sed-utils: i dont think there are many conflicting module names, in fact no body uses modules qualified because everything is dynamically infused into existing classes, which themselves are never named. this issue is not being able to understand what source code you have to go find on github to understand a given word in the app code |
| 11:43 | sed-utils | Btw I'm sdegutis; just changed nicks to make it easier to read, type, and autocomplete. |
| 11:43 | EvanR | invisible stuff is hard to reason about |
| 11:44 | sed-utils | The one argument I have against an implicit route-finder is that the precise ordering of your routes would be hard to control. |
| 11:44 | clgv | EvanR: you mean like dark matter? |
| 11:45 | EvanR | dark code is another thing entirely |
| 11:47 | sed-utils | I have seen some very confusing Rails apps in the past, and I agree that it can quickly become very difficult to find something, especially if you're not using something like Sublime Text's "find symbol in project" feature. |
| 11:47 | EvanR | rails and code of many libraries in ruby |
| 11:47 | EvanR | finding a symbol may not help because the symbol may be dynamically installed |
| 11:47 | sed-utils | But the Clojure code I've seen is a little too far on the explicit side, apparently simply for the sake of trying to avoid the problems an implicit infrastructure causes. |
| 11:48 | sed-utils | EvanR: Yes, I'm very much against the idea of dynamically generating methods and classes, and especially of using method_missing. |
| 11:49 | EvanR | before deciding that some code is not worth typing, and therefore should be omitted, consider if its important, if so, find a way to auto type it like that slamhound |
| 11:49 | EvanR | another case this reminds me of is the automatic local variable assignments in php |
| 11:49 | EvanR | i dont like assigning local variables, so i use an unpack command to assign a bunch of locals from a map, easy |
| 11:50 | EvanR | now you cant read the code, but at least i didnt have to type anything |
| 11:51 | technomancy | EvanR: I guess there's two types of boilerplate: one is bad because it's annoying to type and one is bad because it's annoying that it even exists |
| 11:57 | justin_smith | to quote a random thing I saw on twitter: "In my experience, hardest part of reading others' code isn't understanding code you're looking at, it's *finding* the right code to look at." |
| 11:58 | justin_smith | that's why I don't like :use, don't like implicit namespace alteration of any kind |
| 11:58 | technomancy | also think of reading via the web or from a diff vs reading inside your editor with cider or whatever |
| 11:58 | justin_smith | right |
| 11:59 | sed-utils | justin_smith: Right on. Especially in Ruby, where people like to literally just hide code and call it "refactoring" or "abstraction". |
| 11:59 | technomancy | it's not so bad with the latter because you can just M-., but that's not the only context in which code is read |
| 12:00 | justin_smith | technomancy: m-. also interrupts my reading flow - often I want to know "what namespace is this coming from" as a contextualizer, without visiting the namespace |
| 12:00 | justin_smith | also, my cider is borked and m-. doesn't even work right now :( |
| 12:01 | sed-utils | I liked Sublime Text's version of that feature, but Emacs's paredit.el is just much better than ST's. |
| 12:01 | sed-utils | But it looks to be improving, so maybe some day soon I can switch. |
| 12:04 | TimMc | justin_smith: Emacs needs tooltips. :-) |
| 12:04 | justin_smith | TimMc: it has them, they are tricky to use |
| 12:05 | TimMc | clojurebot: emacs is "it has them, they are tricky to use" |
| 12:05 | clojurebot | 'Sea, mhuise. |
| 12:05 | justin_smith | TimMc: emacs needs well designed elisp programs, and a better elisp that would facilitate them, so my swank / nrepl / cider isn't always broken |
| 12:05 | justin_smith | (inc TimMc) |
| 12:05 | lazybot | ⇒ 77 |
| 12:06 | technomancy | TimMc: eldoc isn't enough? |
| 12:06 | TimMc | I don't even know what that is. |
| 12:06 | justin_smith | technomancy: I think he meant tooltips over a symbol showing its provenance |
| 12:06 | TimMc | but it sounds like Spanish |
| 12:07 | csd_` | justin_smith: what about use :only? |
| 12:07 | technomancy | justin_smith: I mean using the minibuffer to display them specifically |
| 12:07 | justin_smith | TimMc: it would be nice if we did not fall into the java/ide tarpit, where things are readable and usable but only if you use some tool that fixes all the warts |
| 12:07 | justin_smith | csd_`: require :refer :) and judiciously, sure |
| 12:08 | justin_smith | TimMc: I'd like for a printout of code, or code viewed on github, to make sense |
| 12:08 | TimMc | yeah |
| 12:09 | TimMc | Provenance... "This symbol was typed into a buffer, saved to disk, copied into a git commit, pushed to a server, downloaded to your browser, and copied to a buffer." |
| 12:09 | justin_smith | I meant as in "where was it defined" |
| 12:09 | TimMc | :-) |
| 12:10 | technomancy | a printout! |
| 12:10 | technomancy | I like the idea. |
| 12:10 | justin_smith | technomancy: I love reading things on paper |
| 12:10 | technomancy | justin_smith: do you use page breaks in your code too??? |
| 12:10 | lazybot | technomancy: How could that be wrong? |
| 12:10 | EvanR | can i get a hardcopy of that? thanks |
| 12:10 | justin_smith | sometimes pencil marks on paper can do things that are very inconvenient to do with a computer |
| 12:10 | justin_smith | technomancy: sometimes :) |
| 12:10 | technomancy | let's be ctrl-l buddies |
| 12:11 | justin_smith | ok |
| 12:11 | technomancy | o |
| 12:11 | justin_smith | (inc ) |
| 12:11 | Glenjamin | paper is great for random access, but terrible for modification |
| 12:11 | lazybot | ⇒ 1 |
| 12:11 | justin_smith | Glenjamin: but very nice for annotation, which can inform design or future modification |
| 12:12 | amalloy | guys that is super-wasteful of paper. i am trying to irc, and now a bunch of near-blank pages are pouring out of my printer |
| 12:12 | justin_smith | (inc amalloy) |
| 12:12 | lazybot | ⇒ 186 |
| 12:13 | justin_smith | related http://www.twittertape.co.uk/ |
| 12:15 | EvanR | your printer works? |
| 12:15 | amalloy | justin_smith: i thought it was claiming to need no paper as well. i was quite confused |
| 12:15 | justin_smith | hah |
| 12:15 | justin_smith | probably a thermal printer? |
| 12:16 | technomancy | I almost bought one of those |
| 12:16 | technomancy | wanted to build a GPS system for my car that printed out directions as you went |
| 12:17 | technomancy | sadly while it's super easy to get coordinates, navigation is several orders of magnitude more difficult |
| 12:17 | amalloy | technomancy: like, after you drive to your mom's place, it prints out directions saying how you went, so that you can give them to the next person? |
| 12:17 | amalloy | that sounds amusing and i will be sad if you just meant it prints out directions for you |
| 12:18 | technomancy | I won't spoil your amusement then |
| 12:21 | EvanR | ,(set? #{}) |
| 12:21 | clojurebot | true |
| 12:21 | EvanR | ,(unset? #{}) |
| 12:21 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: unset? in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 12:22 | technomancy | ,(def unset? (complement set?)) |
| 12:22 | clojurebot | #'sandbox/unset? |
| 12:22 | technomancy | ,(unset? #{}) |
| 12:22 | clojurebot | false |
| 12:22 | technomancy | my work here is done |
| 12:23 | EvanR | ,((complement (constantly true)) 0) |
| 12:23 | clojurebot | false |
| 12:23 | EvanR | noice |
| 12:27 | EvanR | stupid ctrl W in xchat not backspacing |
| 12:27 | amalloy | ,((((constantly complement) true) set?) #{0}) |
| 12:27 | clojurebot | false |
| 12:28 | justin_smith | seems relevant to the state of my emacs "5) Complex systems run in degraded mode." "14) Change introduces new forms of failure." http://www.ctlab.org/documents/How%20Complex%20Systems%20Fail.pdf |
| 12:29 | EvanR | number 5 is hitting a lot of nails on the head it hurts |
| 12:30 | justin_smith | ,(((((constantly (constantly (constantly (constantly true)))))))) |
| 12:30 | clojurebot | true |
| 12:30 | gfredericks | reiddraper: the new shuffle generator seems to require a vector but doesn't say so in the docstring |
| 12:35 | EvanR | is into lazy |
| 12:35 | TimMc | justin_smith: https://mitpress.mit.edu/books/engineering-safer-world |
| 12:35 | justin_smith | no |
| 12:35 | TimMc | into is the opposite of lazy |
| 12:35 | nathan7 | into is a reduction operation, it cannot be lazy |
| 12:35 | TimMc | it is laziness's archenemy |
| 12:36 | EvanR | it is frustrating to me the map output of my into prints halfway before crashing on cannot create ISeq from Character |
| 12:36 | justin_smith | TimMc: in fact, let's rename lazy-seq to out-of |
| 12:36 | EvanR | pprint |
| 12:36 | EvanR | not sure what its complaining about, since the print does not complete |
| 12:41 | amalloy | EvanR: your situation is thus far somewhat vague, but my guess is that you have a non-lazy collection (produced by into) containing within it unrealized lazy seqs; when you try to print the whole thing, those inner ones blow up |
| 12:42 | EvanR | blah |
| 12:43 | arrdem | technomancy: ping |
| 12:43 | nestastubbs | gnus |
| 12:43 | nestastubbs | doh |
| 12:43 | nestastubbs | emacs fail |
| 12:44 | technomancy | arrdem: sup |
| 12:45 | arrdem | technomancy: leinigen plugin deps injection halp |
| 12:45 | arrdem | technomancy: https://github.com/clojure-grimoire/lein-grim/blob/master/src/leiningen/grim.clj#L8 |
| 12:45 | technomancy | rule 1: don't |
| 12:45 | technomancy | rule 2: (for experts only) do with great reluctance |
| 12:46 | sed-utils | rule 3: do only with great regret? |
| 12:46 | sed-utils | rule 4: don't? |
| 12:46 | technomancy | works for me |
| 12:46 | technomancy | arrdem: why is this a plugin? |
| 12:47 | Glenjamin | austin does that, it's really really really confusing |
| 12:47 | arrdem | technomancy: because I need to do source paths introspection in he src mode |
| 12:47 | arrdem | technomancy: other than that it could just be a script |
| 12:47 | technomancy | arrdem: why can't you just scan the classpath for entries that are directories? |
| 12:47 | arrdem | technomancy: checkouts for one |
| 12:47 | Glenjamin | i'd rather just be told to add a dep to deps, and add a plugin to plugin - than have the plugin add magic deps |
| 12:47 | technomancy | arrdem: lein with-profile production run -m grimoire.main |
| 12:48 | technomancy | arrdem: checkouts and tests are only in the default profile |
| 12:48 | technomancy | strip them out and you're good |
| 12:49 | arrdem | don't love that answer but it'd work... |
| 12:49 | technomancy | arrdem: if you have to alter the project map, doing it through profiles that ship with the plugin is the way to go |
| 12:49 | technomancy | because it means that the user can override them |
| 12:50 | technomancy | merging in a map that's hard-coded inside the plugin means you get zero transparency and you have to reinvent your own override mechanism, if you even bother with overriding |
| 12:50 | EvanR | thus |
| 12:50 | EvanR | ,(into {} "booya") |
| 12:50 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character> |
| 12:50 | EvanR | mentally noting that this error means "tried to convert a string into a map" |
| 12:51 | arrdem | technomancy: okay so I guess you'd do :aliases {"grim" ["run" "-m" "grimoire.doc" |
| 12:51 | EvanR | at least possibly |
| 12:51 | technomancy | arrdem: right, exactly; typing that whole thing out would get tedious |
| 12:51 | arrdem | technomancy: okay so I guess you'd do :aliases {"grim" ["run" "-m" "grimoire.doc" :project/group :project/name :/project/version]} |
| 12:51 | arrdem | then args get appended |
| 12:51 | arrdem | and away you go |
| 12:51 | technomancy | declarativity ftw <3 |
| 12:52 | technomancy | you could make a plugin that just assocs that alias into the project map =) |
| 12:52 | EvanR | ,(map? {}) |
| 12:52 | clojurebot | true |
| 12:52 | mgaare | EvanR: technically it means "tried to convert a string into a seq" |
| 12:52 | Glenjamin | (doc into) |
| 12:52 | clojurebot | "([to from] [to xform from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined. A transducer may be supplied." |
| 12:52 | arrdem | whelp that sure solves my inability to keep the artifact version in sync between two places in the source tree |
| 12:52 | amalloy | mgaare: no it doesn't |
| 12:52 | amalloy | tried to convert a *character* to a seq |
| 12:52 | Glenjamin | ,(seq "a") |
| 12:52 | clojurebot | (\a) |
| 12:52 | Glenjamin | ,(seq (seq "a")) |
| 12:52 | clojurebot | (\a) |
| 12:52 | EvanR | technically it means exactly what it says which is monumentally unhelpful by itself |
| 12:52 | mgaare | amalloy: ah yes, right you are. |
| 12:52 | Glenjamin | erm |
| 12:52 | Glenjamin | oh right |
| 12:52 | Glenjamin | ,(map seq (seq "a")) |
| 12:52 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character> |
| 12:53 | EvanR | especially since it tried to do this later when i printed out the nested map |
| 12:53 | Glenjamin | or i guess technically |
| 12:53 | justin_smith | EvanR: how is "a character is not a seq" unhelpful? |
| 12:53 | Glenjamin | ,(conj {} (first (seq "abc"))) |
| 12:53 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character> |
| 12:53 | technomancy | arrdem: I really need to get this better documented |
| 12:53 | Glenjamin | thats what's happening in into ^^ |
| 12:53 | technomancy | having this approach get better-documented would alleviate a lot of frustration |
| 12:54 | arrdem | technomancy: I mean... that I or whoever the hell can drop in IRC and ask is pretty good docs IMO |
| 12:54 | arrdem | technomancy: 10/10 support |
| 12:54 | technomancy | hehe |
| 12:54 | EvanR | justin_smith: because the character in question, which was in a string, since i wasnt dealing with characters at any point, was invisibly nested somewhere in my data which is itself mostly invisible, since i have not a good understanding of its form, and that the error wasnt triggered at the place where i actually tried the conversion |
| 12:54 | mgaare | justin_smith: one just has to remember that anything that seqs a string creates a seq of characters, otherwise it's confusing. "where did this character come from?" |
| 12:55 | EvanR | i have to do this in ruby, a lot of conversion error messages have a more likely explanation "tried to convert a string into a map" |
| 12:55 | Glenjamin | ,(into [] "abc") ; works |
| 12:55 | clojurebot | [\a \b \c] |
| 12:55 | Glenjamin | ,(into {} "abc") ; expects the argument to be a seq of pairs, so fails |
| 12:55 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character> |
| 12:55 | EvanR | yeah so wtf |
| 12:56 | EvanR | oh it tries to do seq twice |
| 12:56 | Glenjamin | ,(into {} [1 2 3]) ; it's like trying to do |
| 12:56 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 12:56 | Glenjamin | ,(into {} [[:a 1] [:b 2] [:c 3]]) ; instead of |
| 12:56 | clojurebot | {:a 1, :b 2, :c 3} |
| 12:56 | Glenjamin | and yes, the error message sucks |
| 12:56 | justin_smith | ,(into {} '((a 0) (b 1))) ; another fun variation |
| 12:56 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.util.Map$Entry> |
| 12:57 | Glenjamin | does the stack trace show that it's conj that's complaining? |
| 12:57 | Glenjamin | not sure if that'd help |
| 12:57 | EvanR | Glenjamin: at the very end of this trace its clojure.lang.RT.seqFrom |
| 12:57 | Glenjamin | (source into) |
| 12:57 | Glenjamin | $source into |
| 12:57 | lazybot | into is http://is.gd/jIBW7I |
| 12:57 | EvanR | i didnt see any of my actual code in the trace which is frustrating |
| 12:58 | mgaare | EvanR: yeah, it calls seq twice - once to turn the argument into seq, and then again on each element to try to turn it into something that can be a MapEntry |
| 12:58 | EvanR | so i need to dynamically determine if the thing can be converted into a map with into {} |
| 12:59 | EvanR | "if the first element can be converted into a map entry" -_- |
| 12:59 | mgaare | EvanR: you need to know the "shape" of your data regardless |
| 13:00 | justin_smith | EvanR: in practice, I only use into {} when the thing came out of a hash-map |
| 13:00 | mgaare | ,(apply hash-map "abcd") |
| 13:00 | clojurebot | {\a \b, \c \d} |
| 13:00 | justin_smith | EvanR: like if you map on a hash map, and return each entry, into {} is great there |
| 13:00 | sed-utils | But I heard it's inefficient. |
| 13:00 | mgaare | that works for "flat" things. (into {}) is for seqs of 2-tuples |
| 13:00 | EvanR | this is a datomic entity map, and it needs to be a normal map to work with other maps in a diff |
| 13:01 | justin_smith | ,(into {} (map (fn [[k v]] [k (inc v)]) {:a 0 :b 1 :c 2})) |
| 13:01 | clojurebot | {:c 3, :b 2, :a 1} |
| 13:01 | amalloy | justin_smith: really? i use into/{} all the time on stuff that didn't come from a map |
| 13:01 | amalloy | it's like the best way to make maps |
| 13:01 | mgaare | EvanR: have you looked at the new datomic pull api? it's helpful for that |
| 13:01 | justin_smith | amalloy: after generating each entry in some other way? OK |
| 13:02 | EvanR | mgaare: yeah this looks about right |
| 13:05 | EvanR | mgaare: looks rather new |
| 13:05 | mgaare | EvanR: just released 10-28 |
| 13:06 | EvanR | i have an older version of datomic installed because the latest one was crashing or something... |
| 13:06 | EvanR | blah |
| 13:07 | sed-utils | EvanR: I've used (into {} datomic-map) many times. |
| 13:07 | sed-utils | EvanR: And I cringe each time. |
| 13:08 | sed-utils | EvanR: What version of Datomic are you using, and what for? |
| 13:08 | mdrogalis | sed-utils: The new pull API should help that, at least some. |
| 13:08 | amalloy | justin_smith: i just did a little searching, and it turns out i don't actually do it *that* often in real code, but i see some stuff like (into {} (for [x xs] [x (f x)])) |
| 13:08 | EvanR | sed-utils: 0.9.4894 |
| 13:08 | sed-utils | mdrogalis: I'm sorry, which library is this API part of? |
| 13:08 | sed-utils | EvanR: Oh, okay. I'm using 0.8.4218 |
| 13:09 | EvanR | heh |
| 13:09 | justin_smith | amalloy: like a more flexible zip-map |
| 13:09 | sed-utils | Honestly I just want to use Postgres. |
| 13:09 | mdrogalis | sed-utils: Latest release of Datomic. |
| 13:09 | amalloy | justin_smith: i don't like that comparison: i hate building maps like that with zipmap |
| 13:09 | amalloy | (zipmap xs (map f xs)) is gross to me |
| 13:09 | sed-utils | But the Board of Directors really wants us using Datomic, so we'll probably never use Postgres :( |
| 13:10 | mdrogalis | Things I don't usually hear, heh. ^ |
| 13:10 | EvanR | ah yes board of directors making decisions about database implementations |
| 13:10 | justin_smith | amalloy: s/more flexible/less gross/ maybe? |
| 13:10 | amalloy | i found another one: (into {} (for [[k v] m :when (f k v)] [k something-else])) |
| 13:10 | justin_smith | agreed that zipmap coming from two maps on the same data is gross btw |
| 13:11 | sed-utils | mdrogalis: Neat. I wonder about the Pull API's efficiency. |
| 13:11 | amalloy | justin_smith: i just don't see the point of comparing it to zipmap. it's a way of accomplishing a task that zipmap isn't good for |
| 13:11 | justin_smith | OK |
| 13:11 | amalloy | why not call it a more specialized reduce? |
| 13:11 | sed-utils | EvanR: Our Board of Directors is two very-senior and still-active coders. |
| 13:11 | justin_smith | amalloy: that's the *typical* use of zipmap that I have seen |
| 13:11 | EvanR | that explains a bit more |
| 13:11 | sed-utils | And very respected in the programming community. |
| 13:11 | justin_smith | and yes, it is gross |
| 13:12 | amalloy | i choose to remove such uses of zipmap from my memory, and so the only ones i have seen are in like csv parsers: (map #(zipmap headers %) data-rows) |
| 13:12 | EvanR | sed-utils: im new to datomic, some of the blurbs make sense, some of these tools surrounding it dont make sense, and in the end who knows if its really web scale |
| 13:12 | justin_smith | amalloy: also, that other one is exactly the case I was talking about (into {} is natural if you just iterated across a map and made new entries) |
| 13:12 | sed-utils | EvanR: The only difficulty I have had with Datomic Free is that it kills the GC super badly. |
| 13:13 | sed-utils | I had to do some ugly hacks to make the site stop completely dying day after day. |
| 13:13 | amalloy | justin_smith: i guess so. "came from a map" was unclear to me, because the data i'm putting into the map actually is not map entries from some other map |
| 13:13 | EvanR | sed-utils: thats absurd |
| 13:13 | sed-utils | That said, I'm not a devops person, and while I can write some slick Clojure, I have no idea how to configure a JVM. |
| 13:13 | amalloy | but now that you say it, the way i intrerpreted your statement doesn't make any sense |
| 13:13 | technomancy | arrdem: let me know if the alias approach works well for grimoire. I have tried to think through the use cases but haven't put it through the paces with some of the latest changes yet myself. |
| 13:14 | arrdem | technomancy: lol kk I'll do a test 0.3.0 of lein-grim later today and let you know how it shakes out |
| 13:16 | EvanR | well after lein depsing the latest version of datomic, vim hangs when trying to reload |
| 13:17 | mdrogalis | "depsing". Mmmmm. |
| 13:18 | EvanR | requiring my namespace from the lein repl hangs |
| 13:18 | EvanR | going back to the old version and using into |
| 13:18 | csd_ | Is it possible to expand a macro within the binding section of let |
| 13:19 | Glenjamin | i'd like to turn {:a true :b false :c true} into [:a :c] - currently conj-ing a vector in reduce-kv - anyone got a better idea? |
| 13:19 | csd_ | (defmacro foo [] '`a) (let [(foo) :bar] a) |
| 13:19 | TimMc | csd_: Yes... if you wrap the let in another macro. :-P |
| 13:19 | csd_ | how do you mean |
| 13:20 | TimMc | Somethign that preprocesses the let form. |
| 13:20 | EvanR | Glenjamin: off the top of my head id do a filter keys followed by keys |
| 13:20 | TimMc | I bet amalloy_ could do some magic with symbol-macrolet. |
| 13:20 | csd_ | TimMc: sounds like a headache |
| 13:20 | TimMc | yep |
| 13:21 | csd_ | it seems to me that if there were a way to give macros execution priority that you could solve it too |
| 13:21 | Glenjamin | EvanR: you mean like (->> {} (filter second) (map first)) ? |
| 13:22 | EvanR | im not sure exactly what ->> {} does |
| 13:22 | technomancy | when in doubt, macroexpand |
| 13:23 | Glenjamin | is that an answer to ->> or the let question? |
| 13:23 | mi6x3m | hey clojure, is it customary to define dummy vars in test namespaces in order to test something made to run on vars? |
| 13:23 | mi6x3m | like a dummy function |
| 13:23 | sed-utils | Umm.. |
| 13:23 | perplexa | somehow i always read Ganjaman ;p |
| 13:24 | Glenjamin | It's like Benjamin, but with Glen :p |
| 13:24 | TimMc | It's the answer to "What is Glen short for?" |
| 13:24 | perplexa | glen's jammin! |
| 13:24 | sed-utils | Just like Annie is short for Annielia. |
| 13:25 | perplexa | ;p |
| 13:25 | schmee | Glenjamin: (for [[k v] m :when v] k) |
| 13:25 | Glenjamin | oh right, for |
| 13:25 | Glenjamin | i always forget about for |
| 13:25 | TimMc | M-x for |
| 13:25 | TimMc | s/for/butterfly/ |
| 13:27 | Glenjamin | (inc schmee) |
| 13:27 | lazybot | ⇒ 1 |
| 13:27 | schmee | woohoo! |
| 13:27 | schmee | I lost my virginity |
| 13:27 | Glenjamin | ,(defn class-set [m] (string/join " " (for [[k v] m :when v] k))) |
| 13:27 | schmee | or something |
| 13:27 | clojurebot | #<CompilerException java.lang.RuntimeException: No such namespace: string, compiling:(NO_SOURCE_PATH:0:0)> |
| 13:27 | Glenjamin | meh, whatever |
| 13:27 | Glenjamin | it works \o/ |
| 13:29 | EvanR | i am so not used to vim hanging |
| 13:30 | Glenjamin | ,(str :thingy) |
| 13:30 | clojurebot | ":thingy" |
| 13:30 | Glenjamin | always catches me out :( |
| 13:32 | schmee | ,(name :thingy) |
| 13:32 | clojurebot | "thingy" |
| 13:32 | schmee | Glenjamin: ^ |
| 13:32 | Glenjamin | yeah, i just always forget :) |
| 13:33 | sed-utils | $karma sdegutis |
| 13:33 | lazybot | sdegutis has karma 6. |
| 13:33 | sed-utils | $karma sed-utils |
| 13:33 | lazybot | sed-utils has karma 0. |
| 13:34 | sed-utils | Oh nice. |
| 13:36 | EvanR | hallelujah lord jesus it works now |
| 13:36 | EvanR | pull api and all |
| 13:40 | EvanR | mgaare: gah it returns collections as a vector rather than a set... |
| 13:52 | sdegutis | EvanR: Why is that bad? |
| 13:52 | EvanR | because im trying to do a diff |
| 13:52 | sdegutis | EvanR: You get ordering that way. |
| 13:52 | EvanR | you get some ordering but not necessarily a desired or consistent ordering |
| 13:52 | EvanR | the data for a many attribute is naturally in a set state |
| 13:53 | justin_smith | EvanR: you can make a set reliable from a vector, the reverse is not the case |
| 13:53 | EvanR | yes, i am doing that |
| 13:53 | EvanR | but this vector is itself from a set |
| 13:53 | EvanR | the default api gives you a set |
| 13:54 | justin_smith | OK |
| 13:57 | EvanR | ,(clojure.data/diff [1 2 3] [1 3 2]) |
| 13:57 | clojurebot | #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.data> |
| 13:57 | EvanR | [[nil 2 3] [nil 3 2] [1]] |
| 13:58 | martinklepsch | is there a function to get a file path for a namespace? i.e. (x 'project.server.api) => "project/server/api.clj" ? |
| 14:01 | hyPiRion | #(str (munge %) ".clj") ? |
| 14:02 | hyPiRion | well, that ignores the . to / conversion, so nevermind that. |
| 14:06 | martinklepsch | so there's nothing built-in I guess |
| 14:07 | amalloy | TimMc: there's not much you can do with symbol-macrolet, when the thing you want to "expand" isn't in an evaluation position |
| 14:11 | amalloy | csd_: "execution priority" for macros is...i mean, i don't think it's strictly impossible, but it isn't really in line with how macros work |
| 14:11 | CookedGryphon | Is it possible to add an annotation to a reified thing? |
| 14:13 | amalloy | to implement it you'd need to impose a total ordering on all macros in existence, and change the compiler dramatically |
| 14:13 | amalloy | and it leads to weird questions like, what if the order is A first, then B, then C, and in code like (C (B x)) C expands to A? |
| 14:17 | maarek | I'm trying to convert this java class to clojure http://pastebin.com/kBUUkV3y. Can someone check my clojure. I seem to have a lot of issues with it from IllegalArgumentException Parameter declaration Fields. should be a vector to and CompilerException java.lang.RuntimeException: Unable to resolve symbol: deserializeString in this context. |
| 14:19 | justin_smith | maarek: you need to put the definitions in a different order |
| 14:19 | justin_smith | maarek: the clojure compiler does no lookahead for definitions |
| 14:19 | justin_smith | at the time that -deserialize is defined, deserializeString does not exist yet |
| 14:19 | dbasch | the defn in line 19 is wrong |
| 14:20 | justin_smith | oh yeah, the defns are wrong, you need an args list on each |
| 14:20 | justin_smith | *that defn |
| 14:21 | justin_smith | also, for any function that acts as a method, the first argument is always "this" |
| 14:21 | justin_smith | so you want another arg I think |
| 14:21 | maarek | Hmm |
| 14:21 | justin_smith | maarek: that is, when deserializeString is called with no args, "string" will be "this", when it is called with one arg, you will get an exception for the wrong argument count |
| 14:22 | justin_smith | because the object is always the first argument to the method |
| 14:24 | maarek | justin_smith: I've reordered so that deserializeString is first and added [] to getOutputFields. I'll see what happens. |
| 14:24 | justin_smith | maarek: add a "this" arg, unless they are static methods |
| 14:25 | maarek | deserializeString is static and the other two are not. |
| 14:25 | justin_smith | OK - in your declaration deserializeJson (which does not exist) is the static one |
| 14:27 | maarek | justin_smith: Opp I changed that to deserializeString after the pastebin :) |
| 14:28 | justin_smith | Ok, just remember that a regular method always gets its object as the first arg |
| 14:28 | maarek | justin_smith: Will do, thanks. |
| 14:29 | hiredman | amalloy: change macros to expand on the way down and on the way up |
| 14:30 | justin_smith | hiredman: hah, macro middleware |
| 14:31 | sir_pinecone | hey all, is it possible to use an if statement in thread-last? I want to leave the value as is if the if evals to true. something like (->> items (if foo identity reverse) (partition-all 3) ...) |
| 14:32 | maarek | justin_smith: Do I have the class definition correct? Would I import this as (:import [storm.kafka StringScheme]) |
| 14:33 | justin_smith | maarek: it looks right at a first glance at least |
| 14:33 | dbasch | sir_pinecone: no, you have to make it a function that takes one argument |
| 14:33 | justin_smith | maarek: one more thing: #^{:static true} could just be ^:static |
| 14:34 | sir_pinecone | dbasch: OK, thanks |
| 14:34 | maarek | justin_smith: okay thanks. |
| 14:35 | justin_smith | maarek: I remember someone saying (maybe it was amalloy?) that (:import (some.package Class)) was better, but I forget why |
| 14:36 | amalloy | justin_smith: technomancy probably says it too |
| 14:37 | technomancy | clojurebot: import indent? |
| 14:37 | clojurebot | import indent is brackets imply all entries are peers, while parens imply that the first entry is different from the rest: http://p.hagelb.org/import-indent.html |
| 14:37 | technomancy | ~botsnack |
| 14:37 | clojurebot | Thanks! Can I have chocolate next time |
| 14:37 | justin_smith | aha! now I know the reason, thanks |
| 14:38 | samflores | is there a way to use something like a "subtopic" with core.async? |
| 14:38 | samflores | ^ using pub/sub |
| 14:38 | amalloy | technomancy: i can never remember how you square that (har har) with the use of square brackets for require |
| 14:39 | technomancy | amalloy: how so? |
| 14:39 | dbasch | it’s really splitting hairs, I wouldn’t say it’s “better” |
| 14:40 | amalloy | technomancy: (:require [foo.bar.core :as bar \n :refer [whatever]]) |
| 14:40 | amalloy | :refer is clearly a peer of :as, not of foo.bar.core |
| 14:40 | amalloy | and yet we have to use square brackets anyway, because in *this* case the clojure compiler treats them differently |
| 14:41 | technomancy | amalloy: hmm... I guess I never put newlines in requires |
| 14:41 | amalloy | i lied earlier: i remember that being your answer, in fact |
| 14:41 | technomancy | because class names are redonkulously long, but usually clojure peeps have the good sense not to go nuts about it |
| 14:41 | amalloy | which is totally a cop-out, philosophically |
| 14:41 | technomancy | yep |
| 14:42 | amalloy | i've needed newlines in requires once or twice, for like long :refer lists followed by a :rename or something |
| 14:42 | technomancy | I don't think I've ever used :rename |
| 14:43 | amalloy | amazingly, i actually used it once a few months ago, although i'd forgotten about it |
| 14:43 | amalloy | (:require [hiccup.util :refer [escape-html] :rename {escape-html escape}]) |
| 14:43 | technomancy | hm |
| 14:43 | amalloy | because what kind of lame name is escape-html |
| 14:44 | technomancy | I do have a pet peeve when you have stuff like (for instance) hiccup.html/escape-html |
| 14:44 | amalloy | exactly |
| 14:44 | technomancy | when the var name includes the last segment of the ns name |
| 14:44 | technomancy | it just looks silly |
| 14:44 | amalloy | (or the first segment) |
| 14:44 | justin_smith | I like the name for that: smurf naming |
| 14:44 | technomancy | hehe |
| 14:45 | technomancy | I think that was more common when :use was prevalent |
| 14:45 | amalloy | i am unsurprised to hear you've never used :rename, though, since you were one of the earliest detractors of prefix lists in require, making it hard to grep for stuff |
| 14:45 | justin_smith | require hiccup.smurf/smurf-html |
| 14:45 | amalloy | and rename presents similar problems |
| 14:45 | technomancy | amalloy: hm; actually the grep thing is more about namespaces than individual vars |
| 14:46 | technomancy | grepping a var name is never going to work well due to false positives |
| 14:47 | TimMc | justin_smith: :-D |
| 14:47 | amalloy | i had forgotten about the term "smurf naming" |
| 14:48 | amalloy | (inc justin_smith) ; for the reminder |
| 14:48 | lazybot | ⇒ 118 |
| 14:49 | TimMc | (inc justin_smith-human) |
| 14:49 | lazybot | ⇒ 1 |
| 14:49 | justin_smith | thanks for keeping track of that stuff for us, lazybot-bot |
| 14:50 | samflores | that's what I'm trying to accomplish: https://gist.github.com/samflores/62cacdf10b6f1a4d1ca9 |
| 14:52 | justin_smith | samflores: could this be done be a broadcast channel that repeats another broadcast channel? |
| 14:53 | jonathanj | is there a pattern (or recommendation) for pluggable code in clojure? |
| 14:54 | justin_smith | jonathanj: pluggable in what sense? |
| 14:54 | technomancy | how is "pluggable code" distinct from "first-class functions"? |
| 14:54 | samflores | justin_smith, I'm not sure I got what your idea |
| 14:54 | jonathanj | well, i mean supplied by someone other than the software author |
| 14:55 | samflores | s/what// |
| 14:55 | justin_smith | jonathanj: multimethods and protocols are both useful for that |
| 14:55 | justin_smith | jonathanj: as are pure functions that take functions as arguments |
| 14:55 | amalloy | jonathanj: a library that accepts functions as arguments to its functions? or are you hoping end-users can write code at runtime? |
| 14:56 | jonathanj | amalloy: runtime would be nice but even if you could drop some code into some "plugins" directory and discover it at runtime would be sufficient |
| 14:56 | justin_smith | samflores: https://clojure.github.io/core.async/#clojure.core.async.lab/broadcast so you could use this, or multiplex, which is right next to it - depending which side you want to do the merging on |
| 14:57 | technomancy | jonathanj: leiningen looks for tasks under the leiningen.$TASK/$TASK var and that has worked out very well |
| 14:57 | technomancy | you can put metadata on the var to signal options, like docstrings or requirements |
| 14:58 | jonathanj | can leiningen discover tasks or do you have to invoke the specific task? |
| 14:58 | technomancy | jonathanj: I don't understand how those two are distinct |
| 14:59 | amalloy | technomancy: he's asking if `lein help` can enumerate all extant tasks |
| 14:59 | amalloy | (yes, it can) |
| 14:59 | jonathanj | how does that work? |
| 14:59 | justin_smith | technomancy: I think he wants a system where putting an artifact in a magic plays makes it get run, magically |
| 14:59 | samflores | justin_smith: I'll need some time to understand/try it :) thanks |
| 14:59 | justin_smith | s/plays/place |
| 14:59 | technomancy | jonathanj: it scans the classpath using the bultitude lib |
| 15:00 | amalloy | outside of lein, that sort of magical discovery of stuff isn't very popular in clojure; it's more popular to be explicit, by providing an interface that takes in some functions, and wiring them together to the structure your program wants to have |
| 15:00 | technomancy | https://github.com/Raynes/bultitude |
| 15:00 | justin_smith | (inc amalloy) |
| 15:00 | lazybot | ⇒ 187 |
| 15:00 | samflores | (inc justin_smith) |
| 15:00 | lazybot | ⇒ 119 |
| 15:00 | technomancy | right, the whole point of leiningen is to bridge the CLI->clojure functions |
| 15:01 | technomancy | so the convention of CLI args -> tasks is always at the forefront |
| 15:01 | wsmoak | any hints on grammars for TextMate? It doesn’t know .clj yet… |
| 15:01 | technomancy | if this isn't true in your situation, some configuration might help make things clearer |
| 15:01 | jonathanj | hrm, so something like a config file mapping command names to functions |
| 15:02 | justin_smith | wsmoak: I don't know texmate, but I know that dnolen_ knows his shit, so this is probably legit https://github.com/swannodette/textmate-clojure |
| 15:02 | justin_smith | it's old though |
| 15:02 | wsmoak | justin_smith: thanks. had found https://github.com/mmcgrana/textmate-clojure (of which that’s a fork) but it’s years old so I wasn’t sure |
| 15:03 | justin_smith | yeah, both their projects tend to be pretty good, but I can't speak to that particular thing at all |
| 15:03 | jonathanj | can one have cyclic dependencies in clojure? |
| 15:03 | justin_smith | no |
| 15:04 | jonathanj | (i think i mean requirements, not dependencies) |
| 15:04 | justin_smith | jonathanj: cyclical require is detected as a compiler error when loading a namespace |
| 15:05 | justin_smith | jonathanj: you can fake it with resolve, but it's better to refactor to eliminate the cycle |
| 15:05 | jonathanj | okay |
| 15:07 | justin_smith | jonathanj: two things to consider regarding cycles is that it is common in clojure to address a broader range of functionality in one namespace than would in a single java class - so merging may be in order |
| 15:08 | justin_smith | the other thing is that I forget what the other thing I was thinking |
| 15:09 | jonathanj | justin_smith: i come from a Python background, so the broader range thing is already a part of my daily life; the cycles thing was just something that suddenly occurred to me, i haven't actually run into it yet |
| 15:10 | m1dnight1 | guys, sorry to ask for help about namespaces *again*, but i cant seem to get my code to run, once more.. |
| 15:10 | justin_smith | jonathanj: cool. I think the other thing was "why not put a multimethod or protocol in a third namespace that the other two namespaces use" |
| 15:11 | m1dnight1 | the project worked fine last week, now it can't find classes anymore |
| 15:13 | m1dnight1 | "could not locate meta_clojure/actors/actors__init.class or meta_clojure/actors/actors.clj on classpath |
| 15:13 | m1dnight1 | however, they are in my classpath. My project.clj has the entry ":source-paths["src"]" (which has been like that since the begining |
| 15:14 | justin_smith | so, is there some error in meta_clojure/actors/actors.clj that would prevent the ns being loaded? |
| 15:14 | m1dnight1 | let me try and compile that one |
| 15:14 | m1dnight1 | brb |
| 15:14 | m1dnight1 | also a clasnotfound exception for a java file |
| 15:14 | jonathanj | is there some kind of static analysis tool for clojure that i can use in my editor (emacs)? |
| 15:14 | m1dnight1 | but, to fix that, previously I added this to my core.clj: |
| 15:14 | m1dnight1 | :java-source-paths ["interop"] |
| 15:14 | jonathanj | Exception in thread "main" java.lang.RuntimeException: EOF while reading, starting at line 79, compiling:(clj_acheron/core.clj:214:1) |
| 15:14 | justin_smith | jonathanj: I use lein check in the repl |
| 15:15 | jonathanj | is particularly annoying to debug |
| 15:15 | jonathanj | justin_smith: what do you mean in the repl? |
| 15:15 | justin_smith | sorry, I mean in the terminal |
| 15:15 | justin_smith | d'oh |
| 15:15 | m1dnight1 | and to verify, there is indeed a file in interop/actors/BlockingStore.java |
| 15:15 | m1dnight1 | I also tried "lein compile" in the terminal first |
| 15:16 | justin_smith | jonathanj: that error means that in the file clj_acheron/core.clj, starting on line 79, there is a paren, bracket, or string literal that is never closed |
| 15:16 | m1dnight1 | oh, it seems that restarting emacs did the trick, odd |
| 15:16 | m1dnight1 | so probably the lein compile? |
| 15:17 | justin_smith | m1dnight1: it could have been there was a stale class file that was loaded and out of sync with everything else |
| 15:17 | justin_smith | and the lein compile would overwrite it |
| 15:17 | m1dnight1 | Yeah that probably was it |
| 15:17 | m1dnight1 | i'll have to keep it in mind then :) |
| 15:17 | m1dnight1 | I wa sure of it that everything worked :p |
| 15:17 | m1dnight1 | thanks for listening though guys |
| 15:18 | justin_smith | m1dnight1: "lein do clean, x" is an option |
| 15:19 | jonathanj | justin_smith: yes, it's the "starting on" part that's annoying |
| 15:19 | justin_smith | why? doesn't it help to know where the unclosed context opened? it's not like the compiler can know where it should have closed |
| 15:20 | EvanR | but it could give you some good alternatives to pick from ;) |
| 15:20 | jonathanj | well if you have something like (defn foo [] ((let [a 1]) a) |
| 15:20 | jonathanj | then "starting from" points at the defn line |
| 15:21 | justin_smith | yes, that's the first of the two non-closed parens |
| 15:21 | EvanR | "perhaps you meant to close the defn right before line foo, the start of the next defn |
| 15:21 | EvanR | " |
| 15:22 | justin_smith | EvanR: yeah, clojure's compiler does not attempt to be smart or helpful like that at all |
| 15:23 | justin_smith | I mean, defn inside another defn is allowed after all. It's just not usually what you want |
| 15:23 | justin_smith | ah, right! |
| 15:23 | justin_smith | jonathanj: perhaps you want a linter type tool, there are a few |
| 15:23 | jonathanj | unfortunately i don't have a real example, i just tried to recreate one that i spent about 5 minutes trying to debug only to find out i was barking up the wrong tree |
| 15:23 | justin_smith | and they catch things that are not errors per se, but are often errors |
| 15:23 | EvanR | its allowed, i wouldnt be surprised, but i would appreciate it if a tool assumed i didnt want to do that |
| 15:23 | justin_smith | jonathanj: eastwood is a popular one |
| 15:23 | justin_smith | kibit is decent |
| 15:24 | EvanR | whats the effect of a defn in side a defn, to replace the top level function? |
| 15:24 | justin_smith | EvanR: replace? you can create a top level function inside a function. It just isn't a good idea, usually |
| 15:25 | justin_smith | and yes, on a second run it would replace it |
| 15:25 | EvanR | or a first, if it was already defned somewhere else |
| 15:25 | justin_smith | jonathanj: https://github.com/jonase/eastwood |
| 15:25 | EvanR | im going to say its not a good idea at all |
| 15:25 | justin_smith | EvanR: sure, but that's true for a normal defn too |
| 15:25 | justin_smith | EvanR: it is a TERRIBLE idea |
| 15:25 | justin_smith | but it is allowed |
| 15:26 | EvanR | my life is a struggle to treat dynamic-as-fuck systems as if they were static ;) |
| 15:26 | justin_smith | heh |
| 15:27 | justin_smith | EvanR: but consider that we allow arbitrary redefinition, because repl based development would be a pain in the ass otherwise |
| 15:27 | justin_smith | where in a static system a double definition should be an error |
| 15:27 | EvanR | ruby for example if you ignore instance_eval, normal eval, method missing etc, could be sanely type inferred |
| 15:28 | EvanR | arbitrary redefinition makes sense in the context of an implicit nested let |
| 15:28 | EvanR | let [a 1 a 2 a 3 etc |
| 15:29 | justin_smith | EvanR: that's not redefinition |
| 15:29 | EvanR | shadowing |
| 15:29 | justin_smith | that's shadowing |
| 15:29 | wsmoak | dnolen_: around? I can’t get the bundle to work under ~/Library/… at all. works under /Applications though. :::shrug::: just wondered if you’re using TextMate 2 and where you put yours. |
| 15:29 | justin_smith | EvanR: (def a 2) (def a 4) is not shadowing, it is redefinition |
| 15:29 | EvanR | it has the same effect if you are always evaluating some let |
| 15:29 | justin_smith | EvanR: in that it effects any definitions in between that relied on a |
| 15:29 | EvanR | yes i get it |
| 15:30 | dnolen_ | wsmoak: I haven't touched the textmate support in years - it's abandonware at this point |
| 15:30 | EvanR | it would work if you reloaded the other definitions after |
| 15:30 | EvanR | if they is what you want, though |
| 15:30 | EvanR | that* |
| 15:30 | EvanR | just talking about possible repl methodology |
| 15:30 | justin_smith | ,(let [a 0 f (fn [] a) a 1] (f)) |
| 15:30 | clojurebot | 0 |
| 15:30 | justin_smith | ,(def a 0) |
| 15:30 | clojurebot | #'sandbox/a |
| 15:30 | justin_smith | ,(defn f [] a) |
| 15:30 | clojurebot | #'sandbox/f |
| 15:31 | justin_smith | ,(def a 1) |
| 15:31 | clojurebot | #'sandbox/a |
| 15:31 | justin_smith | ,(f) |
| 15:31 | clojurebot | 1 |
| 15:31 | justin_smith | EvanR: that's how it's different |
| 15:31 | EvanR | yes, depends on what youd rather happen |
| 15:31 | justin_smith | well, one mutates other things you defined, the other does not |
| 15:32 | wsmoak | dnolen_: yeah I saw the dates. wasn’t sure if the syntax was just that stable, or… ;) thanks. |
| 15:32 | EvanR | it doesnt mutate the things but the context that they are going to execute in |
| 15:32 | EvanR | and context doesnt have to be mutable to work like that |
| 15:36 | visof | i guys |
| 15:36 | visof | hi |
| 15:36 | visof | what is the fastest way to remove all words in a list from a string ? |
| 15:36 | justin_smith | ,(remove (set [ |
| 15:36 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 15:37 | justin_smith | ,(remove (set ["a" "b" "c"]) ["a" "b" "d" "c" "a" "f" "b" "g"]) |
| 15:37 | clojurebot | ("d" "f" "g") |
| 15:37 | justin_smith | you can use set to turn a list / vector / lazy-seq into a predicate |
| 15:37 | visof | great |
| 15:38 | justin_smith | that tests if the argument is in it |
| 15:38 | visof | justin_smith: thanks man |
| 15:38 | justin_smith | np |
| 15:38 | justin_smith | not strictly a predicate - but good enough for one :) |
| 15:38 | visof | so it's working fast if you have 10^6 word? |
| 15:38 | justin_smith | visof: caveat - if nil or false are in your list of things to remove this would fail |
| 15:38 | dbasch | justin_smith: he said a string, not a list of strings |
| 15:38 | justin_smith | dbasch: oh, oops |
| 15:39 | justin_smith | I misread |
| 15:39 | dbasch | visof: do you have a string or a list? |
| 15:39 | visof | dbasch: it's okay |
| 15:39 | visof | dbasch: i should split the string by spaces to words |
| 15:39 | dbasch | yeah, it’s an extra step of split / str |
| 15:39 | visof | but if there is a faster way this would be fine wihout converting |
| 15:39 | dbasch | or join |
| 15:39 | justin_smith | visof: if you reuse the same set of matched strings, a set should be pretty fast |
| 15:39 | justin_smith | visof: there may be something faster but harder to implement though |
| 15:40 | visof | justin_smith: so what is the method? |
| 15:40 | dbasch | strings are immutable, so you’d need a stringbuilder and a linear scan |
| 15:40 | justin_smith | visof: harder to implement, as in I haven't implemented it |
| 15:41 | sdegutis | Clojure and Ruby have one thing in common: x = x |
| 15:41 | sdegutis | kirloo: go away bot |
| 15:41 | sdegutis | (def x x) |
| 15:41 | sdegutis | Both work even when x is not yet defined. |
| 15:41 | sdegutis | ,x |
| 15:41 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:41 | sdegutis | ,(def x x) |
| 15:41 | clojurebot | #'sandbox/x |
| 15:41 | sdegutis | ,x |
| 15:41 | clojurebot | #<Unbound Unbound: #'sandbox/x> |
| 15:42 | EvanR | if false; x = x; end, also works, causing x to be defined ;) |
| 15:43 | justin_smith | sdegutis: the first arg in a def form is added as a var in the namespace before the value is evaluated. It just isn't bound to any value yet. So (def x x) binds x to a var that has not yet been assigned a value. |
| 15:43 | justin_smith | sdegutis: that's why, but not neccissarily an excuse or argument that it should make sense |
| 15:44 | sdegutis | EvanR: x = x unless x |
| 15:44 | EvanR | i never reassign to the same variable in ruby |
| 15:44 | justin_smith | sdegutis: so is this because the language writers were huge fans of Aristotle, or of Ayn Rand? |
| 15:45 | amalloy | little-known fact: aristotle was a huge fan of ayn rand |
| 15:45 | EvanR | ya lyin |
| 15:49 | dbasch | justin_smith: you’re saying it’s an objectivism-oriented language? |
| 15:50 | justin_smith | ,(def a a) |
| 15:50 | clojurebot | #'sandbox/a |
| 15:51 | sdegutis | ,x |
| 15:51 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:52 | sdegutis | Such a short memory. |
| 15:52 | dbasch | clojurebot has this condition |
| 15:53 | EvanR | ,(let [a a] a) |
| 15:53 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:53 | EvanR | ,(letfn [a (fn [] (a)] (a)) |
| 15:53 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]> |
| 15:53 | EvanR | ,(letfn [a (fn [] (a))] (a)) |
| 15:53 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol, compiling:(NO_SOURCE_FILE:0:0)> |
| 15:54 | amalloy | are you looking for (letfn [(a [] (a))] (a))? |
| 15:54 | EvanR | ,(letfn [(a [] (a))] (a)) |
| 15:54 | clojurebot | #<StackOverflowError java.lang.StackOverflowError> |
| 15:55 | amalloy | equivalently, ((fn a [] (a))) |
| 15:55 | EvanR | jenga! |
| 15:57 | m1dnight1 | is there a way to make a hard copy of a value in clojure? |
| 15:57 | m1dnight1 | to pass it to another thread |
| 15:58 | amalloy | m1dnight1: if it's immutable, all copies are "hard", in that they never change. just send a reference |
| 15:58 | amalloy | if it's not immutable, Here There Be Dragons |
| 15:58 | bbloom | ... and normal java rules about defensive deep clones apply |
| 15:58 | bbloom | *cringe* |
| 15:58 | EvanR | defensive deep clones |
| 15:58 | m1dnight1 | well you actually have a valid point amalloy |
| 15:58 | EvanR | deploy |
| 15:58 | dbasch | lock ; clone ; unlock ; sigh |
| 15:58 | m1dnight1 | it would be enough for my usecase |
| 15:59 | bbloom | m1dnight1: it's enough for all but the highest performance use cases, and even then it's often enough |
| 15:59 | EvanR | whats an example of a mutable "value" ? |
| 15:59 | dbasch | well, in hickeyspeak “values” don’t mutate |
| 16:00 | dbasch | the vessels containing said values mutate |
| 16:00 | bbloom | EvanR: laziness? like the hash field in clojure's structures. but i'd argue that lazy "values" are not "values", sshhh don't tell the haskellers (unless they've moved on to idris and learned to prefer strictness) |
| 16:00 | EvanR | still, that does not compute |
| 16:01 | EvanR | i mean dbasch makes sense, i dont see how laziness has anything to do with it |
| 16:01 | EvanR | so if two threads are attempting to use the same lazy seq, they might mess each other up? |
| 16:03 | bbloom | EvanR: not if the lazy thunk is deterministic, no. the advancing of seqs are synchorinized in clojure |
| 16:05 | EvanR | uh huh |
| 16:05 | EvanR | a lazy sequences head, then, does not count as a mutable object, from the programmers perspective |
| 16:06 | EvanR | im just trying to understand a case where m1dnight_ needs to worry about what he is passing to another thread |
| 16:13 | sdegutis | I'm reducing a small Ruby file that uses Sprockets, and I'm appreciating Clojure a lot right now. |
| 16:20 | EvanR | what is the trick to put a print in the middle of the thread first macro |
| 16:21 | dbasch | EvanR: you want a function that prints the argument and evaluates to the argument |
| 16:21 | EvanR | yeah |
| 16:23 | EvanR | ,(-> {:a 1 :b 2} (dissoc :a)) |
| 16:23 | clojurebot | {:b 2} |
| 16:23 | EvanR | ,(-> {:a 1 :b 2} (dissoc :a) (update-in [:b] inc) |
| 16:23 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 16:23 | EvanR | ,(-> {:a 1 :b 2} (dissoc :a) (update-in [:b] inc)) |
| 16:23 | clojurebot | {:b 3} |
| 16:32 | martinklepsch | in ns-tracker, if a namespace A changes does this flag namespace B that requires A ? |
| 16:34 | verma | after I add a dep to project.clj, do I have to sort of restart my repl, and cljsbuilds? |
| 16:38 | AeroNotix | is there a better client for cassandra than the clojurewerkz one? |
| 16:40 | ystael_ | AeroNotix: i can name at least one _not_ better one, but i don't know of a better one :) |
| 16:40 | AeroNotix | blegh |
| 16:52 | sveri | Hi, how can I use fixtures with test.check? |
| 16:58 | {blake} | I just realized that I've been doing block commenting with double quotes. That seems potentially problematic. |
| 16:58 | {blake} | sveri, Did you see this: https://clojuredocs.org/clojure.test/use-fixtures ? |
| 16:59 | sveri | {blake}: yea, but its not working with test.checks defspec |
| 17:01 | {blake} | sveri, Huh. |
| 17:02 | {blake} | sveri, I'm just now doing a serious test suite for Clojure so I'm not too familiar with either. |
| 17:02 | sveri | {blake}: yea, np |
| 17:22 | justin_smith | EvanR: were you thinking of (doto println) ? |
| 17:22 | EvanR | i dont know |
| 17:22 | justin_smith | ,,(-> {:a 1 :b 2} (dissoc :a) (doto println) (update-in [:b] inc)) |
| 17:22 | clojurebot | {:b 2}\n{:b 3} |
| 17:22 | EvanR | good |
| 17:23 | EvanR | though i figured out my problem just by staring at the code |
| 17:24 | technomancy | fenyman method woo |
| 17:24 | technomancy | *feynman |
| 17:25 | ag0rex | can private instance fields be accessed with java interop? |
| 17:25 | justin_smith | ag0rex: with reflection, same as you would do it in java |
| 17:26 | EvanR | i thought feynmans method was to have your buddies hold you upside down while you pee on the problem |
| 17:26 | EvanR | because that would have been more satisfying |
| 17:26 | dbasch | EvanR: that works really well if the problem is you |
| 17:26 | EvanR | lol |
| 17:26 | ag0rex | justin_smith: is there a clojure wrapper around java reflection api? |
| 17:27 | justin_smith | ag0rex: clojure.reflect |
| 17:27 | mdrogalis | EvanR: I *really* enjoyed his book. |
| 17:28 | justin_smith | EvanR: is there some in joke about Feynman in that that I am missing? |
| 17:28 | TimMc | It's a reference to one of his stories. |
| 17:29 | TimMc | Some buddies of his apparently thought that peeing worked by gravity. (Or they only said so to see what he's do?) |
| 17:29 | EvanR | is there something like whatever || fallback |
| 17:29 | EvanR | where if whatever if nil, you get fallback |
| 17:29 | ag0rex | justin_smith: thank you! |
| 17:29 | technomancy | justin_smith: feynman problem-solving method: 0) write down the problem, 1) think very hard, 2) write down the solution |
| 17:30 | EvanR | step 0 is often skipped |
| 17:30 | EvanR | often a disaster |
| 17:30 | mdrogalis | EvanR: (or x y) |
| 17:30 | mdrogalis | ,(doc fnil) ; Also very useful. |
| 17:30 | clojurebot | "([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched." |
| 17:31 | justin_smith | technomancy: I know that one :) not the one about having buddies hold you upside down while you pee on the problem. |
| 17:31 | technomancy | right right |
| 17:31 | technomancy | (inc fnil) |
| 17:31 | lazybot | ⇒ 2 |
| 17:32 | mdrogalis | *Facepalm* |
| 17:32 | justin_smith | 0) write down the problem (skipped) 1) think very hard 2) go make a pizza because I was thinking about pizza and I |
| 17:32 | justin_smith | 'm hungry now. |
| 17:32 | guest59 | In Om, how can I pass a key when using a for loop? |
| 17:32 | justin_smith | wait what? |
| 17:36 | dbasch | guest59: what do you mean by a for loop? do you have some code you can paste somewhere? |
| 17:37 | EvanR | what is the operation for append two vectors |
| 17:37 | EvanR | ,(+ [1] [2]) |
| 17:37 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number> |
| 17:37 | EvanR | good |
| 17:37 | eric_normand | EvanR: into |
| 17:37 | eric_normand | ,(into [1 2 3] [4 5 6]) |
| 17:37 | EvanR | sup eric |
| 17:37 | clojurebot | [1 2 3 4 5 ...] |
| 17:38 | EvanR | im working on the third floor |
| 17:38 | eric_normand | EvanR: I'm on the second floor |
| 17:38 | eric_normand | EvanR: same building? |
| 17:38 | EvanR | actually i dont know |
| 17:39 | eric_normand | EvanR: you're in IP Building? |
| 17:39 | guest59 | dbasch: In Om, how can I use a loop with a key without using om/build? I keep getting a react warning "Each child in array should have a unique 'key' prop ..." |
| 17:39 | m1dnight_ | quick question about clojure and emacs. Sometimes I have threads that keep on running. How do I kill all of them? atm I'm using cider-restart but it annoys me a bit that when I do that all my windows are rearranged :p |
| 17:39 | EvanR | yeah, the intellectual property building |
| 17:39 | eric_normand | EvanR: I'm in Beta |
| 17:39 | m1dnight_ | ctrl+c in the repl doesn't kill them. They still spew messages in the messagebuffer (println that is) |
| 17:39 | eric_normand | EvanR: Tyler told me you were using Clojure now |
| 17:39 | eric_normand | EvanR: how do you like it? |
| 17:41 | j0ni | m1dnight_: you can interrupt a running repl invocation with C-c C-b i think |
| 17:41 | justin_smith | m1dnight_: the Thread API has ways to list threads, and you can set their interrupted property, but unless they are checking that property, via ##(.isInterrupted (Thread/currentThread)) there is no reliable way to shut down another thread in the jvm |
| 17:41 | lazybot | ⇒ false |
| 17:41 | j0ni | yeah "Interrupt any pending evaluations" from the cider README |
| 17:41 | justin_smith | you can write threads that check that .isInterrupted flag and shut down if it is set, of course |
| 17:42 | EvanR | eric_normand: real fun |
| 17:42 | justin_smith | j0ni: that's for the top level repl thread, not for any threads it spawned |
| 17:42 | justin_smith | j0ni: bound to C-c C-c |
| 17:42 | eric_normand | EvanR: rocking the dynlang? |
| 17:42 | j0ni | ah, sorry I guess I didn't read back far enough |
| 17:42 | dbasch | guest59: what does your array look like? it it an array of #js objects each one of which contains a key property? |
| 17:43 | EvanR | eric_normand: probably going to go insane at some point but hey |
| 17:43 | guest59 | Array of clojure maps, each one has title key. |
| 17:44 | dbasch | guest59: each one should have a “key” key |
| 17:46 | EvanR | eric_normand: i get the best of both worlds, null pointer exceptions and uncaught type mismatch |
| 17:46 | technomancy | ,((apply juxt (map #(fn [c] (c %)) (range 5))) [:a :b :c :d :e]) |
| 17:46 | clojurebot | [:a :b :c :d :e] |
| 17:49 | EvanR | ,(nil) |
| 17:49 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0:0)> |
| 17:49 | eric_normand | EvanR: well, it looks like you're exploring the contours of the language |
| 17:49 | EvanR | (nil) gives null pointer exception for me |
| 17:50 | EvanR | cant call nil makes more sense |
| 17:50 | justin_smith | ,(let [a nil] (a)) |
| 17:50 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 17:50 | justin_smith | it's a special case that doesn't always work |
| 17:50 | EvanR | jaaa |
| 17:51 | technomancy | amazing https://github.com/garybernhardt/base |
| 17:51 | dbasch | EvanR: whats’’s your clojure version? |
| 17:51 | dbasch | what’s |
| 17:51 | EvanR | 0.old |
| 17:51 | EvanR | 1.5.1 |
| 17:52 | guest59 | dbasch: I added a :key and "key", but it didn't kill the warning. I deal with it for right now ... thanks for your help |
| 17:56 | EvanR | ,(not-empty []) |
| 17:56 | clojurebot | nil |
| 17:56 | EvanR | ,(not-empty [1]) |
| 17:56 | clojurebot | [1] |
| 18:10 | EvanR | the channel closes at 5pm or is it just me ;) |
| 18:10 | justin_smith | it's 15:00 here! |
| 18:10 | EvanR | socal people get off at 3 i thought |
| 18:11 | dbasch | it’s always 5 o’clock somewhere, so it that were the case it would always be closed |
| 18:11 | TimMc | technomancy: Next seajure project: A namespace that automatically exports the contents of every other namespace. |
| 18:12 | justin_smith | EvanR: in socal you can get off whenever, and wherever, you want |
| 18:12 | technomancy | TimMc: potemkin-plus |
| 18:13 | EvanR | hawt |
| 18:13 | technomancy | potemkin-professional-edition, rather |
| 18:16 | TimMc | potemkin-enterprise-edition exposes an XML configuration system where you can encode how to handle name conflicts |
| 18:16 | TimMc | It is Turing-complete. |
| 18:17 | technomancy | I'm on a chaise-lounge in the back yard FWIW |
| 18:18 | visof | hi |
| 18:18 | visof | how can i convert arraylist to clojure native ds ? |
| 18:18 | visof | #<ArrayList [Hello-1, ,-2, world-3]> |
| 18:18 | justin_smith | visof: into works nicely for that |
| 18:18 | visof | thanks |
| 18:19 | justin_smith | ,(into [] (java.util.ArrayList. [1 2 3 4])) |
| 18:19 | clojurebot | [1 2 3 4] |
| 18:19 | justin_smith | as you see, it is asly to make an ArrayList out of a vector |
| 18:19 | justin_smith | alsy = also easy, btw |
| 18:20 | EvanR | but what is a clojure native ds |
| 18:20 | justin_smith | EvanR: one which has a readable printed form |
| 18:20 | EvanR | ok data structure |
| 18:20 | justin_smith | EvanR: or numbers |
| 18:21 | justin_smith | or booleans |
| 18:21 | justin_smith | or nil |
| 18:21 | EvanR | data type |
| 18:21 | justin_smith | I think by ds he meant data structure, yes |
| 18:21 | EvanR | can you convert an array list into a map |
| 18:21 | justin_smith | EvanR: or my answer is way off base because he was talking about a portable nintendo gaming unit |
| 18:22 | justin_smith | EvanR: one is key/value the other is sequential |
| 18:22 | EvanR | ok |
| 18:22 | EvanR | ,(into {} [[1 2] [3 4]]) |
| 18:22 | clojurebot | {1 2, 3 4} |
| 18:23 | EvanR | i guess it would work if it was an array list of pairs |
| 18:23 | justin_smith | yeah |
| 19:03 | womble | How do I install a third-party clojure library in my riemann installation? I'm using the Debian packages from riemann.io if that makes any difference. |
| 19:03 | justin_smith | womble: most of us use lein for dep management |
| 19:04 | sritchie | womble: you have to create a new lein project that includes both riemann and something else |
| 19:04 | sritchie | alternatively, when you run riemann, you have include your project’s jar on the classpath |
| 19:05 | sritchie | (creating a new lein project and making an uberjar is just an easy way to do that) |
| 19:05 | sritchie | womble: so, to “install” just modify the launcher script |
| 19:05 | sritchie | then you can access more stuff from your riemann config |
| 19:06 | womble | OK. Assume I'm *not* already a smug clojure weenie, and therefore have no idea whatsoever what any of that actually meant. |
| 19:06 | justin_smith | womble: lein is leiningen, a dependency management tool |
| 19:06 | technomancy | womble: I don't think anyone here knows how debian packages riemann |
| 19:07 | womble | technomancy: Good thing I'm not using Debian's packages, then. |
| 19:08 | TimMc | Ah, just .debs then. |
| 19:10 | justin_smith | womble: I don't see anything smug or weenie like about what's been said here. lein is used to manage deps. Clojure "builds" everything each time you run it. |
| 19:10 | TimMc | womble: Where is riemann's doc for third-party libs? |
| 19:10 | TimMc | (I am not yet a smug riemann weenie.) |
| 19:10 | womble | TimMc: I have no idea. I can't find any. |
| 19:10 | technomancy | you probably don't have to, but having no idea what the debian packaging is like, that's the only way anyone is going to be able to help you. |
| 19:11 | TimMc | womble: Ah, it sounded like you had identified a certain integration path and were unsure how to proceed on it. |
| 19:12 | TimMc | It sounds like Riemann does everything via clients, not libraries. |
| 19:12 | womble | TimMc: I'm trying to write a client, but in order to avoid having to write my own $EVERYTHING, I'm using an external library to do the heavy lifting. |
| 19:12 | womble | I've actually got code that might work, if I could work out how to download the bloody package off clojars and put it $SOMEWHERE |
| 19:13 | justin_smith | womble: that's what lein used |
| 19:13 | justin_smith | *what lein does |
| 19:13 | justin_smith | 99% of use use lein. It builds a dependency tree, downloads the things you need, and launches the app. |
| 19:14 | TimMc | womble: So it sounds like you should make a leiningen project that pulls in riemann-clojure-client as a dependency. |
| 19:14 | womble | Great. How do I do that? |
| 19:14 | justin_smith | $google leiningen |
| 19:14 | lazybot | [Leiningen] http://leiningen.org/ |
| 19:14 | justin_smith | it's one shell script, you can put it in ~/bin |
| 19:14 | TimMc | lein has good docs |
| 19:18 | womble | Sigh, I've just realised I'm in #clojure, not #riemann. Don't know how my fingers ended up here. |
| 19:19 | justin_smith | womble: hah, maybe they will be more helpful :) |
| 19:19 | womble | That's what I'm hoping. |
| 19:20 | justin_smith | now if you were writing your client lib in clojure, I am sure we could help with that |
| 19:24 | womble | justin_smith: Thankfully, I don't need to write a lib, just a thin wrapper. |
| 19:24 | justin_smith | cool |
| 19:45 | bitfl1pper | hello all, has anyone here tried implementing the CSRF protection as described in the luminus documentation? http://www.luminusweb.net/docs/routes.md, I'm having a rough time getting it to compile, I feel like it may be predicated on a deprecated function, or maybe I'm missing something really obvious. I'm relatively noob at clojure btw |
| 19:46 | justin_smith | bitfl1pper: what is the error message you are getting? |
| 19:46 | justin_smith | no, I haven't used the CSRF stuff, but can probably help you figure out your compilation errors anyway |
| 19:48 | bitfl1pper | ~ Caused by: java.lang.RuntimeException: Unable to resolve symbol: add-tag! in this context, i've been digging around the predicate library ring-anti-forgery middleware and I can't find the function anywhere, I'm thinking that I may not understand middleware enough? because I tried wrapping the handler as described in the newer ring-af repo |
| 19:48 | clojurebot | Titim gan éirí ort. |
| 19:50 | bitfl1pper | thanks by the way, if this doesn't work out, I'm going to try to start a little smaller and learn Ring from the ground up, because i've been struggling getting luminus to stick together, I don't think i understand the lower level stuff well enough |
| 19:51 | justin_smith | add-tag! seems to be in luminus |
| 19:52 | erikcw | Does anyone know how to generate a react component using Reagent that will cause React.isValidClass(component) to return true? |
| 19:53 | justin_smith | bitfl1pper: it's defined in selmer.parser https://github.com/yogthos/Selmer/blob/7adffc8afe23731d8629ea1bf4a003cbfdc75f90/src/selmer/parser.clj#L79 |
| 19:53 | justin_smith | bitfl1pper: I think the rest of luminus should be pulling in the dep, you just need to use a require to make sure it is available in your namespace |
| 19:53 | talios | seancorfield - how are you finding Frege? |
| 19:54 | justin_smith | bitfl1pper: also, I would call putting a funciton in your docs that is from another lib, and not describing where it came from, a documentation error |
| 19:54 | bitfl1pper | yep, thanks, it looks like the NS declaration :requires selmer.parser :as parser, but the documentation doesn't parser/add-tag! ? is that correct? |
| 19:54 | justin_smith | yeah, sounds about right |
| 19:54 | justin_smith | anyway, try parser/add-tag! |
| 19:55 | justin_smith | I like how excited that name makes me sound |
| 19:55 | justin_smith | (inc !) |
| 19:55 | lazybot | ⇒ 1 |
| 19:55 | nestastubbs | woot |
| 19:55 | bitfl1pper | justin_smith: thanks a lot, trying now |
| 19:56 | nestastubbs | A clojure lib providing a distributed rate limiting service on top of redis: https://github.com/craigbro/turnstile |
| 19:56 | nestastubbs | only took two beers! |
| 19:57 | justin_smith | cool |
| 19:57 | justin_smith | clojure can be way cool like that |
| 19:57 | nestastubbs | rate limiting was the last bit of state stopping us from running N instanced of our API service |
| 19:58 | nestastubbs | the carmine dep is out of date, but... |
| 19:59 | seancorfield | talios: early days yet - but I like Haskell so I'm liking Frege |
| 19:59 | seancorfield | once I have the lein plugin built for compiling Frege I'll be able to experiment a bit more with using it for stuff inside Clojure projects |
| 19:59 | talios | seancorfield - nice. I'm liking it as well, tho I need to find time to revisit it. And find something "real" to try and do with it. |
| 20:00 | seancorfield | currently I'm working through "Real World Haskell" again but using Frege for all the examples and exercises |
| 20:00 | bitfl1pper | justin_smith: well the add-tag error seems to be gone, but now I have a new one which I suspect is also caused by not declaring in ns, thanks for your help |
| 20:00 | seancorfield | there's a repo with all of the examples converted to Frege (but not the exercises!) |
| 20:00 | justin_smith | bitfl1pper: np, good luck sorting out the rest |
| 20:00 | talios | seancorfield - yep, must revisit that repo/book as well. |
| 20:01 | talios | seancorfield - will be interested to hear how you go with mixing clojure/frege - and how/why it worked better for your usecase |
| 20:02 | seancorfield | Yeah, I've no idea how that will pan out... but being able to mix languages will make it more likely I'll actually use Frege for something real :) |
| 20:09 | bitfl1pper | justin_smith: I've got it compiling now-- probably newbie mistakes on my part -- needed to change add-tag! -> parser/add-tag! ; also, needed to add [ring.util.anti-forgery :refer [anti-forgery-field] to ns dec. |
| 20:09 | justin_smith | bitfl1pper: cool |
| 20:18 | nestastubbs | hiccup users: is there a hiccup replacement that escapes content by default? |
| 20:21 | amalloy | you can't really do that, nestastubbs, because then (html x) becomes different from (html (html x)) |
| 20:22 | amalloy | and how can it even tell what pieces you want unescaped? [(keyword user-input) "s"] is just as unsafe as [:tr user-input] |
| 20:24 | nestastubbs | amalloy: sure you can, other languages do it all the time, and there is nothing inc lojure that stops it |
| 20:24 | nestastubbs | it means you have to mark strings as safe |
| 20:25 | nestastubbs | be default, assume a string is not safe, you escape it and make it safe. Once marked safe, it won't be double escaped |
| 20:26 | nestastubbs | there are some edges, like, how to treat concat of safe and unsafe string... |
| 20:30 | justin_smith | nestastubbs: sounds like something you could do with a deftype and a protocol actually |
| 20:30 | justin_smith | or a defmethod |
| 20:32 | nestastubbs | might be more complicated than that, but tractable |
| 20:32 | nestastubbs | would want concatenation to make the end result unsafe, or escape the unsafe elements.. |
| 20:33 | nestastubbs | but that is not essential |
| 20:39 | nathan7 | bbloom: I think MonadPlus might be a semigroup |
| 20:42 | nathan7 | bbloom: hmm, no, nevermind |
| 20:50 | amalloy | wow, are we back on MonadPlus again? |
| 20:50 | nathan7 | I was trying to figure out what mathematical structure it describes |
| 20:50 | nathan7 | and these things stick around in one's subconscious |
| 20:52 | amalloy | i mean, the haskell Monad typeclass is, as i understand it, pretty far from the mathematical idea of monads, even though that's what it was originally inspired by. it's not always the case that you can find a useful correspondence |
| 20:57 | bbloom | ,(clojure.lang.Compiler/demunge 'WOW_CONFUSING) |
| 20:57 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String> |
| 20:57 | bbloom | ,(clojure.lang.Compiler/demunge "WOW_CONFUSING") |
| 20:57 | clojurebot | "WOW-CONFUSING" |
| 20:58 | TEttinger | ,(clojure.lang.Compiler/demunge "_-_-_-_") |
| 20:58 | clojurebot | "-------" |
| 20:58 | bbloom | i often name something LIKE_THIS as a temporary name while i tried to come up with something better |
| 20:59 | bbloom | couldn't find it w/ grep when i got an ArityException b/c it was LIKE-THIS |
| 21:01 | TEttinger | ,(clojure.lang.Compiler/demunge "_-_-_-_") |
| 21:01 | clojurebot | "-------" |
| 21:02 | nonuby | using tools.cli how do I specify a required option, removing :default seems to just omit that key from :options rather than populating :errors |
| 21:02 | TEttinger | ,(= (clojure.lang.Compiler/demunge "_-_-_-_") "-------") |
| 21:02 | clojurebot | false |
| 21:02 | nonuby | then again I guess options should be just that.. hmm |
| 21:02 | nonuby | i.e. optional |
| 21:10 | nonuby | is something better than tools.cli that also merge environment variables (ala 12 factor) before apply cli options, and produces a similar map |
| 21:22 | arrdem | &(demunge "_-_") |
| 21:22 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: demunge in this context |
| 21:22 | arrdem | interesting |
| 21:26 | justin_smith | amalloy: redid that pr, sorry that was such a mess, it was the last thing I did that night and I did not even think to check if it applied cleanly |
| 21:27 | justin_smith | the funniest was one of the plugins where head had nothing and master had like 8 newlines, and that was the entirety of the merge conflict |
| 21:29 | verma | does anyone know how :foreign-libs works when building cljs projects? it seems I can supply a URL, but that always fails for me with a Not a file error. |
| 21:32 | TEttinger | ,(= "_-_-_-_" "_-_-_-_") |
| 21:32 | clojurebot | false |
| 21:32 | TEttinger | this is a fun trick |
| 21:33 | TEttinger | ,(map count ["_-_-_-_" "_-_-_-_"]) |
| 21:33 | clojurebot | (8 7) |
| 21:34 | justin_smith | ,(map #(map int %) ["_-_-_-_" "_-_-_-_"]) |
| 21:34 | clojurebot | ((95 45 95 45 65279 ...) (95 45 95 45 95 ...)) |
| 21:34 | justin_smith | 🎵one of these things is not like the others🎵🎵 |
| 21:35 | TEttinger | ,"(clojure.lang.Compiler/demunge \"_-_-\ufeff_-_\")" |
| 21:35 | clojurebot | "(clojure.lang.Compiler/demunge \"_-_-_-_\")" |
| 22:03 | jeffterrell | TEttinger: What is that? A nonprinting character? |
| 22:03 | TEttinger | yes |
| 22:03 | TEttinger | it's also a legitimate character in clojure identifiers |
| 22:06 | jeffterrell | Crazy. TIL… |
| 22:12 | justin_smith | ,(def 22) |
| 22:12 | clojurebot | #'sandbox/ |
| 22:12 | justin_smith | , |
| 22:12 | clojurebot | 22 |
| 22:12 | justin_smith | that is pretty evil |
| 22:41 | ghadishayban | transducers on Java Iterators https://gist.github.com/ghadishayban/ed64040c9c7de4b4663c |
| 22:42 | ghadishayban | why not right? |
| 22:43 | TEttinger | awesome ghadishayban |
| 22:46 | ghadishayban | the horrors! |
| 22:47 | nonuby | given a fn: (defn x [& {:keys [a b c] }] {:a2 a :b2 b :c2 c}) and given (def v1 {:a 1 :b 2 :c 3}) how can I call x with v1 without extracting each parameter? |
| 22:47 | justin_smith | ,(+ ) |
| 22:47 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 22:47 | justin_smith | ,(def 22) |
| 22:47 | clojurebot | #'sandbox/ |
| 22:47 | justin_smith | ,(+ ) |
| 22:47 | clojurebot | 44 |
| 22:48 | justin_smith | ,(apply (fn x [& {:keys [a b c] }] {:a2 a :b2 b :c2 c}) (apply concat {:a 1 :b 2 :c 3})); nonuby |
| 22:48 | clojurebot | {:a2 1, :b2 2, :c2 3} |
| 22:48 | justin_smith | and yeah, that is clumsy and & {} is bad |
| 22:50 | nonuby | thanks justin_smith, that makes sense, I can see how it works now, yeah I agree it smells but a lot of libraries use it |
| 22:50 | justin_smith | right |
| 22:59 | bbloom | is it just me, or does anyone else find infix notation less and less familiar as time goes on? |
| 23:00 | ghadishayban | not just you |
| 23:00 | justin_smith | I get messed up when people use parens / braces weird - like on the line closes in an algol, or on their own line in a lisp |
| 23:01 | justin_smith | otherwise I can mostly handle the switch |
| 23:01 | bbloom | do you guys also experience constant operator precedence anxiety? |
| 23:01 | jeffterrell | bbloom: In general yes, but I still have to stop and think about how prefix - and / work, e.g. (/ 8 4 2). |
| 23:01 | bbloom | i start to twitch and feel like i need a lot more parens |
| 23:01 | justin_smith | like somehow the gestalt of trailing } tells my reptile brain "infix" |
| 23:02 | bbloom | ,(-) |
| 23:02 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/-> |
| 23:02 | bbloom | ,(- 1) |
| 23:02 | clojurebot | -1 |
| 23:02 | bbloom | ,(- 1 2) |
| 23:02 | clojurebot | -1 |
| 23:02 | bbloom | ,(- 1 5) |
| 23:02 | clojurebot | -4 |
| 23:02 | justin_smith | ,(-) |
| 23:02 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: - in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 23:02 | justin_smith | ,(- ) |
| 23:02 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: - in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 23:03 | justin_smith | ,(- ) |
| 23:03 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: - in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 23:03 | ghadishayban | is it unicode day in here? |
| 23:03 | justin_smith | ,(- ) |
| 23:03 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 23:03 | justin_smith | finally |
| 23:03 | justin_smith | ghadishayban: TEttinger was showing that off, and I found it amusing |
| 23:03 | justin_smith | ,(def 22) |
| 23:03 | clojurebot | #'sandbox/ |
| 23:03 | justin_smith | ,(- ) |
| 23:03 | clojurebot | -22 |
| 23:03 | bbloom | ,(- 3 7 9) |
| 23:03 | clojurebot | -13 |
| 23:04 | bbloom | does feel a tad strange |
| 23:04 | bbloom | ,(/) |
| 23:04 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core//> |
| 23:04 | bbloom | ,(/ 5) |
| 23:04 | clojurebot | 1/5 |
| 23:04 | bbloom | ,(/ 5 10) |
| 23:04 | clojurebot | 1/2 |
| 23:04 | bbloom | ,(/ 5 10 15) |
| 23:04 | clojurebot | 1/30 |
| 23:04 | jeffterrell | Whoa, didn't know about single-arity / |
| 23:04 | bbloom | yeah, reciprocal |
| 23:05 | jeffterrell | Except now I no longer trust what I see, thanks a lot justin_smith and TEttinger. |
| 23:05 | ghadishayban | all i want for christmas is a bunch of reducible collection sources... |
| 23:05 | ghadishayban | ... that all respect reduced properly |
| 23:06 | bbloom | really - and / are very strange symbols for prefix |
| 23:06 | bbloom | b/c `x - y` is really `x + -y` |
| 23:06 | bbloom | similarly `x / y` is really `x * y^-1` |
| 23:07 | jeffterrell | bbloom: Yeah, haven't thought deeply about why, but there's definitely some impedance mismatch going on there, at least in my brain. |
| 23:08 | bbloom | jeffterrell: yeah, it's b/c subtraction and division are derived concepts built on top of negation, addition, multiplication, and exponentiation |
| 23:09 | jeffterrell | I never thought about subtraction and division as derived that way, but I think that would explain why they feel weird with infix. Neat. |
| 23:11 | bbloom | it's weird, b/c some times i feel the need for infix, but it's never for like + or * |
| 23:11 | maarek | This is pretty basic I think but what is the "-" before a function? Sometimes it's there and sometimes not and it's not easy to search for. |
| 23:11 | bbloom | it's when i actually care about spatial relationships |
| 23:11 | bbloom | maarek: - is a valid symbol, so you can type: |
| 23:11 | bbloom | (doc -) |
| 23:11 | clojurebot | "([x] [x y] [x y & more]); If no ys are supplied, returns the negation of x, else subtracts the ys from x and returns the result. Does not auto-promote longs, will throw on overflow. See also: -'" |
| 23:12 | maarek | bbloom: Okay I'll check it. Thanks. |
| 23:15 | maarek | bbloom: Hmm but on a function definition (defn -someMethod [] somethingElse)… how does negation work there? |
| 23:16 | bbloom | maarek: lisp's tokenization rules are much simpler than most languages. that's one symbol: "-someMethod", not two symbols "-" and "someMethod" |
| 23:16 | bbloom | watch: |
| 23:16 | bbloom | ,(count '[ -someMethod ]) |
| 23:16 | clojurebot | 1 |
| 23:16 | bbloom | ,(count '[ - someMethod ]) |
| 23:16 | clojurebot | 2 |
| 23:17 | bbloom | ,(map class '[ - someMethod ]) |
| 23:17 | clojurebot | (clojure.lang.Symbol clojure.lang.Symbol) |
| 23:17 | justin_smith | even more commonly seen as ##(count '[some-method]) |
| 23:17 | lazybot | ⇒ 1 |
| 23:18 | amalloy | maarek: -foo is sometimes used to mean "an implementation detail of how foo is built" or "a protocol function underlying the public function foo". as justin_smith and bbloom say, there's nothing inherently special about - in a name, but -foo is a convention |
| 23:19 | maarek | amalloy: I have been seeing it on an implementation of java interfaces. |
| 23:20 | TEttinger | ,(def1) |
| 23:20 | clojurebot | #'sandbox/ |
| 23:20 | TEttinger | justin_smith: ^ |
| 23:20 | maarek | Thanks guys |
| 23:20 | justin_smith | maarek: yeah, that is a default translation when you use :gen-class |
| 23:21 | TEttinger | ,(- ) |
| 23:21 | justin_smith | so -main because the method main, etc. |
| 23:21 | clojurebot | -1 |
| 23:21 | justin_smith | *becomes |
| 23:22 | justin_smith | I keep doing semi-phonetic typos today |
| 23:22 | maarek | :prefix "-" is default in gen-class then? |
| 23:23 | maarek | It all makes sense then. Whew, nothing magical. |
| 23:23 | justin_smith | maarek: yeah, if you look at (doc gen-class) it is in there |
| 23:23 | justin_smith | maarek: we work pretty hard to avoid magic |
| 23:24 | maarek | justin_smith: Yeah I just pulled it up. Thanks |
| 23:24 | TEttinger | yay, now we can imitate APL |
| 23:24 | TEttinger | ,(#(`[~@%](`[~@%&](+)))[:?:|:>:<](+(*)(*))) |
| 23:24 | clojurebot | :> |
| 23:25 | TEttinger | justin_smith: speak for yourself, swearjure is magic |