2014-07-17
| 01:31 | tuft | do you guys use :pre and :post? |
| 01:31 | arrdem | all the time |
| 01:32 | tuft | ok thanks =) |
| 01:33 | arrdem | If you have environmental conditions, like dynamic variables that need to be bound, atoms that need to have values and arguments with explicit types :pre is awesome. I don't tend to use :post as much because typically I'd just be typechecking a return value, which is trivial. |
| 01:34 | arrdem | https://github.com/clojure/tools.emitter.jvm/commit/32b1d01abd259fe4053389e98915aac0a763bb07 |
| 01:34 | tuft | this particular use case is just testing two numeric parameters |
| 03:03 | kenrestivo | is there some way using the chronicle (flatland) library to get it to use the local time zone? |
| 03:03 | kenrestivo | it uses joda time. it doesn't seem to take parameters to tell it what time zone to use.... could it require poking at some global singleton in the underlying java library? |
| 03:05 | kenrestivo | ah never mind found it. yes it does, apparently http://joda-time.sourceforge.net/apidocs/org/joda/time/DateTimeZone.html#setDefault%28org.joda.time.DateTimeZone%29 |
| 03:23 | _eric | if I have a (loop) that doesn't have a (recur) in one branch, will it continue to loop or will it drop out? |
| 03:23 | amalloy | try it and see, _eric |
| 03:34 | luxbock | does there exist an API documentation for all the functions of cljs.core that are not part of clojure.core? |
| 03:34 | luxbock | I'm trying to find if there's a predicate function for telling js-objects apart from Clojure maps |
| 03:37 | Glenjamin | i'm fairly sure objects don't pass map? |
| 03:38 | luxbock | is there a way to test for something being a js-object specifically though? |
| 03:39 | Glenjamin | everything is a js object |
| 03:39 | Bronsa` | luxbock: there's a object? predicate |
| 03:40 | Glenjamin | orly |
| 03:40 | Glenjamin | i wish one of the bots had a cljs repl handy |
| 03:41 | luxbock | Bronsa: ah yeah perfect |
| 03:42 | augustl | https://github.com/krukow/clj-ds - 0.0.4, still at Clojure 1.5.1 - is anyone actively maintaining a stand-alone version of Clojure's data structures? :) |
| 03:44 | Glenjamin | Bronsa: is that fairly new? both himera and cljsfiddle are erroring saying there's no object? |
| 03:47 | Bronsa | Glenjamin: no idea. |
| 03:49 | Bronsa | Glenjamin: https://github.com/clojure/clojurescript/commit/a8797e4c6b9395c061170aa75da41414290fedf9 |
| 03:51 | Glenjamin | cheers |
| 03:51 | Glenjamin | i guess thats a reasonable implementation |
| 03:52 | chamomile | hi - new to clojure and trying to make a simple static site generator, i don't know the specifics for serving valid http, what clojure libs can i learn from? |
| 03:53 | Glenjamin | https://github.com/mmcgrana/ring/blob/master/SPEC might be worth a look |
| 03:59 | chamomile | thanks Glenjamin, |
| 03:59 | augustl | chamomile: you could look at a static stite generator :) https://github.com/magnars/stasis |
| 04:02 | Glenjamin | (object? #js {}) ;=> #<false> |
| 04:02 | chamomile | augustl: thanks, i find clojure confusing sometimes when i'm trying to do something i've never done before |
| 04:02 | chamomile | this will help |
| 04:07 | Bronsa | Glenjamin: that returns true on my repl |
| 04:14 | Glenjamin | I think I need a better repl |
| 04:14 | augustl | repl-ace it with a better one |
| 04:15 | Glenjamin | Is there a good "run this and get a cli repl" for cljs? |
| 04:26 | razum2um | how can I iterate over java object which implements Iterable ? |
| 04:28 | Bronsa | Glenjamin: I use script/repljs from the cljs repo |
| 04:28 | razum2um | oh. found it - iterator-seq, sorry |
| 04:37 | hhenkel | Hi all, I'm wondering if there is a better / more elegant way to achieve this: https://www.refheap.com/88274 |
| 04:38 | hhenkel | The idea is to merge data depending on if it is allready within a datastructure or not. |
| 04:39 | TEttinger | hhenkel, this came up not long ago |
| 04:40 | hhenkel | TEttinger: okay, any reference where I could find something about it? |
| 04:40 | TEttinger | well your problem uh... doesn't seem like it makes sense yet to me |
| 04:40 | TEttinger | not sure if it's the same |
| 04:41 | TEttinger | I wrote a snippet to handle extracting stuff out of nested maps |
| 04:42 | hhenkel | TEttinger: The idea / problem I'm trying to solve is that I got some configuration from config files and other parts that get evaluated dynamicaly. |
| 04:42 | hhenkel | TEttinger: The configuration parts are from the same "type", therefore I want them to merge them in a datastructure to process them. |
| 04:43 | TEttinger | hm, http://clojure-log.n01se.net/ is out of date |
| 04:43 | TEttinger | ok, but there are some problems with your pseudocode |
| 04:44 | hhenkel | I updated it, as I saw the list definition was wrong |
| 04:44 | TEttinger | well => (merge a {:bla (merge (:bla a) {:1 (concat ((:bla a) :1) (:1 b))})}) |
| 04:44 | TEttinger | (:bla a) -- what is a? |
| 04:45 | TEttinger | it's in the lists |
| 04:45 | hhenkel | Ah, okay sorry it is not clearly named. |
| 04:45 | hhenkel | a is in this case the def a. |
| 04:45 | hhenkel | I'll update the names, one sec |
| 04:47 | hhenkel | TEttinger: Okay, things should be clearer now |
| 05:19 | hhenkel | TEttinger: So any idea? |
| 05:19 | TEttinger | sorry haven't checked yet, was debugging my own stuff |
| 05:21 | hhenkel | okay |
| 05:21 | TEttinger | this seems like it would be very hard to do in a general way |
| 05:21 | TEttinger | the :1 being under :bla and not under :bla could be problematic |
| 05:22 | hhenkel | TEttinger: That is not much of an issue. I'll check if the key is allready available in an if and depending on the outcome I execute one or the other. |
| 05:23 | hhenkel | I'm more interested to find out if there is a better / smarter way to do the merging. |
| 05:23 | TEttinger | I'm going to fall asleep soon, so smarter is not in my domain right now :) |
| 05:25 | hhenkel | TEttinger: okay, no problem. |
| 05:25 | hyPiRion | hhenkel: let me have a look |
| 05:25 | hhenkel | hyPiRion: https://www.refheap.com/88274 |
| 05:26 | hyPiRion | thanks |
| 05:31 | hyPiRion | hhenkel: I suppose you want the option to have the config maps add in new keys over time? |
| 05:31 | hyPiRion | Eh, that was poorly worded. If you add in new keys for new functionality, you shouldn't have to manually handle merging of those, I meant. |
| 05:32 | hhenkel | hyPiRion: Yes exactely. Current situation is that I got static config via files. I now implemented something to do automatic lookup resulting in more config items (as they are of the same type as the static ones). |
| 05:36 | hhenkel | hyPiRion: I'm afk for the next 30 min, lunch... |
| 05:36 | hyPiRion | hhenkel: alright |
| 05:38 | hyPiRion | hhenkel: well, here's what I came up with just now. https://www.refheap.com/88275 -- it's sort of a stripped down version of how Lein does the profile merging |
| 06:23 | hhenkel | hyPiRion: Oh, that looks promising. I'll try out that. |
| 06:36 | hhenkel | hyPiRion: That works like a charm! Are you involved in lein or why did you get the idea to be inspired by it? |
| 07:01 | luxbock | is importing types supported in ClojureSciprt? I'd like to use them for Schema-validation |
| 07:02 | luxbock | but I'm getting warnings when I try to do it like how I'd do it in regular Clojure |
| 07:03 | luxbock | ah, found it: "ClojureScript types and records should be brought in with :use or :require :refer, not :imported" |
| 07:04 | hyPiRion | hhenkel: sorry, went out for lunch as well. Yeah, I'm one of the "regulars" on Lein |
| 07:05 | noidi | I wonder if there's anyone who prefers that `some` returns the value of the predicate and not the item matching the predicate |
| 07:06 | noidi | I keep reaching for `some` only to realize that I need `(first (filter ...))` to do what I want |
| 07:10 | razum2um | I have a strange cast issue with calling a method accepting a generic: https://gist.github.com/razum2um/432181a0689e5c447b09 any ideas how it happens? |
| 07:10 | hyPiRion | noidi: yeah, I think it has actually been discussed whether or not to include a ffilter function in core, but don't quote me on that |
| 07:15 | Glenjamin | so, what's the deal with clojure-in-clojure for cljs - is there somewhere i can help contribute? |
| 07:50 | rurumate | &(clojure.set/union #{1} [2]) |
| 07:50 | lazybot | ⇒ #{1 2} |
| 07:50 | rurumate | &(clojure.set/union #{1} [2 3]) |
| 07:50 | lazybot | ⇒ [2 3 1] |
| 07:51 | nobodyzzz | but why? =( |
| 07:54 | nobodyzzz | oh it does (reduce conj longer_seq shorter_seq) |
| 08:02 | instilled | hi! how can i represent an empty character in clojure? something like \empty |
| 08:02 | instilled | ? |
| 08:03 | rurumate | do you mean \space? |
| 08:03 | rurumate | you can represent any char by its unicode sequence ofc |
| 08:03 | instilled | nope. i would like to replace \space with \empty (\u0000). |
| 08:04 | rurumate | you want to remove spaces? |
| 08:04 | instilled | exactly. |
| 08:04 | rurumate | so "this has spaces" would become "thishasspaces"? |
| 08:04 | instilled | yup! |
| 08:04 | rurumate | ok, that's different. how would you do it in java? |
| 08:05 | instilled | ' ' -> '' |
| 08:05 | rurumate | doesn't look java to me |
| 08:06 | noidi | ,(clojure.string/replace "foo bar baz" \space \u0000) |
| 08:06 | clojurebot | "foo |
| 08:06 | instilled | well, then i go with regexps… i thought there was maybe a way to do it without regexp (or filter). |
| 08:06 | rurumate | you can use a stringbuilder ofc |
| 08:06 | rurumate | regexp are extremely slow, avoid them in perf critical code |
| 08:06 | rurumate | &(.indexOf "myString" (int \space)) |
| 08:06 | lazybot | ⇒ -1 |
| 08:07 | rurumate | you can check if it has the character first. .indexOf is very fast |
| 08:07 | instilled | rurumate: i'll do that then. cheers a lot! |
| 08:08 | nobodyzzz | (clojure.string/string "foo bar baz") |
| 08:08 | nobodyzzz | ,(clojure.string/trim "foo bar baz") |
| 08:08 | clojurebot | "foo bar baz" |
| 08:08 | instilled | `(.replace "ab c" " " "") |
| 08:08 | instilled | ,(.replace "ab c" " " "") |
| 08:08 | clojurebot | "abc" |
| 08:08 | nobodyzzz | ,(clojure.string/trim "foo bar baz" " " "") |
| 08:08 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: string/trim> |
| 08:09 | nobodyzzz | ,(clojure.string/replace "foo bar baz" " " "") |
| 08:09 | clojurebot | "foobarbaz" |
| 08:10 | rurumate | wait, I think I got something for you |
| 08:11 | rurumate | instilled: https://www.refheap.com/88278 |
| 08:12 | rurumate | you can call (space-first) in a loop and build the string in a stringbuilder |
| 08:14 | instilled | rurumate: that looks nice :) I'll keep it simple for now with (.replace "some string" " " ""). that does work well. |
| 08:14 | rurumate | something like this (untested): (loop [sb (StringBuilder) s "this has spaces"] (if-let [token (space-first s) (do (.append sb token) (recur (space-rest s)) (.toString db)) |
| 08:15 | rurumate | or move the sb to a surrounding let |
| 08:15 | rurumate | one moment.. |
| 08:19 | rurumate | instilled: https://www.refheap.com/88279 |
| 08:20 | rurumate | try (remove-spaces "this has spaces") -> "thishasspaces" |
| 08:20 | ElroyJetson | I've got CIDER and leiningen installed. I would appreciate some help on getting my feet wet from here as I have described here - http://www.reddit.com/r/emacs/comments/2ay4z0/clojure_baby_steps/ |
| 08:21 | instilled | rurumate: cheers! |
| 08:23 | pyrtsa | rurumate: FYI, your code runs 2x slower than (clojure.core/replace lorem " " "") on a "Lorem ipsum ..." string of 446 characters (68 spaces). |
| 08:24 | rurumate | really? how did you test it? |
| 08:25 | rurumate | oh it's clojure.core replace w/o rexexp. I didn't know that existed. |
| 08:25 | rurumate | in that case instilled you should probable use clojure.core/replace |
| 08:25 | hyPiRion | uh, replace takes a map and a collection |
| 08:26 | hyPiRion | ,(replace {\a \b \c \d} "acca") |
| 08:26 | clojurebot | (\b \d \d \b) |
| 08:26 | hyPiRion | not entirely what you want |
| 08:26 | rurumate | &(clojure.core/replace "a b c" " " "") |
| 08:26 | lazybot | clojure.lang.ArityException: Wrong number of args (3) passed to: core$replace |
| 08:26 | rurumate | umm |
| 08:26 | instilled | rurumate: yeah. i'll go with that! |
| 08:27 | hyPiRion | maybe you just meant .replace |
| 08:27 | instilled | ,(replace "abc def" " " "") |
| 08:27 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core/replace> |
| 08:27 | instilled | ,(.replace "abc def" " " "") |
| 08:27 | clojurebot | "abcdef" |
| 08:27 | rurumate | so java.lang.String.replace is the way to go apparently |
| 08:27 | instilled | does exactly that. |
| 08:36 | pyrtsa | rurumate: I tested it by wrapping inside (time (dotimes [_ 100000] ...)), resulting in ~2300 ms (yours) vs. ~1100 ms (clojure.string). |
| 08:37 | rurumate | ok, thanks for testing. I hope it's still faster than a regexp. |
| 08:38 | pyrtsa | (time (dotimes [_ 100000] (str/replace lorem " " ""))) ;;=> "Elapsed time: 1032.865 msecs" |
| 08:38 | pyrtsa | (time (dotimes [_ 100000] (str/replace lorem #" " ""))) ;;=> "Elapsed time: 1187.55 msecs" |
| 08:38 | pyrtsa | (time (dotimes [_ 100000] (str/replace lorem #" +" ""))) ;;=> "Elapsed time: 1585.51 msecs" |
| 08:38 | pyrtsa | Certainly depends on the regular expression, but still no. |
| 08:39 | mpenet | well regex is faster for me too |
| 08:39 | mpenet | (clojure.string/replace "foo bar baz" #"\s+" "") vs " " |
| 08:40 | mpenet | in that case at least (microbenchmarks ftw) |
| 08:40 | pyrtsa | Microbenchmarks indeed. :) |
| 08:41 | mpenet | without the + in the regex it is a bit faster too |
| 09:11 | boxed | ,(= (eval 'str) str) |
| 09:11 | clojurebot | true |
| 09:11 | boxed | ,(= (type (eval 'str)) (type str)) |
| 09:11 | clojurebot | true |
| 09:11 | boxed | ,(var str) |
| 09:11 | clojurebot | #'clojure.core/str |
| 09:11 | boxed | ,(var (eval 'str)) |
| 09:11 | clojurebot | #<CompilerException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:0:0)> |
| 09:12 | boxed | wtf? can someone explain that to me? |
| 09:12 | pyrtsa | var is a special form. |
| 09:13 | stuartsierra1 | ,(eval 'str) |
| 09:13 | clojurebot | #<core$str clojure.core$str@1be9101> |
| 09:14 | stuartsierra1 | ,(var str) |
| 09:14 | clojurebot | #'clojure.core/str |
| 09:14 | stuartsierra1 | ,(resolve 'str) |
| 09:14 | clojurebot | #'clojure.core/str |
| 09:14 | pyrtsa | The var special form treats its argument like a macro does. That's why "(eval 'str)" looks like a PersistentList to it, a list containing the symbol "eval" and the quoted str. |
| 09:15 | pyrtsa | And the argument must be a Symbol, so thus the error. |
| 09:25 | hhenkel | I'm trying to cast a LazySeq into an array but I keep getting an error: java.lang.IllegalArgumentException: array element type mismatch |
| 09:26 | hhenkel | I got "(into-array String attributes)" with attributes as LazySeq. |
| 09:26 | hhenkel | How must I cast this? |
| 09:28 | zoldar | hhenkel: are you sure that all elements in your lazyseq are strings? |
| 09:30 | hhenkel | zoldar: I would say so: https://www.refheap.com/88280 |
| 09:36 | hhenkel | Is there a way to debug on which element the code is failing? |
| 09:36 | hhenkel | zoldar: ^^ |
| 09:37 | hhenkel | I tried to use only one attribute and the code is allready failing. |
| 09:38 | mpenet | try to trace the `type` of your attribute |
| 09:39 | hhenkel | mpenet: I just did that, it gives me "TRACE attributes: java.lang.String" with (trace "attributes" (type (first (:attributes request)))) |
| 09:40 | mpenet | hhenkel: maybe gist your code |
| 09:40 | mpenet | ,(into-array String (map identity ["a"])) |
| 09:40 | clojurebot | #<String[] [Ljava.lang.String;@a5d82a> |
| 09:40 | mpenet | should work |
| 09:40 | mpenet | (type (map identity ["a"])) |
| 09:40 | mpenet | ,(type (map identity ["a"])) |
| 09:40 | clojurebot | clojure.lang.LazySeq |
| 09:49 | hhenkel | mpenet: For what is identity in your example? |
| 09:49 | hhenkel | It does not work for me |
| 09:50 | hhenkel | mpenet: I'm checking if I could provide some small example. |
| 09:53 | hhenkel | mpenet: https://www.refheap.com/88283 |
| 09:56 | hhenkel | mpenet: Okay, I gues I found the error. I moved the trace to the function that recieves the values and there I see that only the first value is handed over, not the complete seq. |
| 09:57 | mpenet | hhenkel: identity is just one way to make a lazyseq out of ["a"] |
| 10:06 | stevenfx | Hey |
| 10:07 | stevenfx | Is anyone having any problems with deps problem with clojure 1.6 not being avaliable |
| 10:07 | stevenfx | ? |
| 10:10 | stevenfx | I keep getting https://www.refheap.com/88284 |
| 10:11 | stevenfx | might just be my network |
| 10:24 | stevenfx | ok I must be living under a rock because today is the first day I see the new clojars.org design :) |
| 10:24 | stevenfx | looks amazing |
| 12:06 | ptcek | Is it right that prismatic fnk / defnk does not support input schemas? |
| 12:34 | andyf_ | hiredman: Ping |
| 12:38 | hiredman | andyf_: hello |
| 12:38 | hiredman | I mean |
| 12:38 | hiredman | andyf_: pong |
| 12:39 | andyf_ | In the github issue for Eastwood about selective disabling of warnings, you mention marker macros, "but those have issues" |
| 12:40 | andyf_ | I wanted to find out what issues you meant, since I was considering using a marker macro for this purpose |
| 12:41 | hiredman | you couldn't only have a dev dependency on eastwood then |
| 12:42 | andyf_ | Meaning you need to require the namespace defining the macro, yes? |
| 12:42 | hiredman | right |
| 12:42 | hiredman | which could be a distinct "slim" depdency or something |
| 12:43 | andyf_ | What if that were in a tiny project doing almost nothing but defining that macro? |
| 12:44 | technomancy | this sounds like a textbook example for why metadata is useful? |
| 12:44 | andyf_ | technomancy: I'm considering that, but you cannot put it on everything |
| 12:45 | ambroseb_ | andyf_: org.clojure/core.typed.rt is basically that for core.typed |
| 12:45 | andyf_ | A macro can wrap any expression |
| 12:45 | MrJones98 | mikerod: thanks for the help yesterday - turned out to be a bunch of issues jumbled together. the primary problem was interaction in the repl and reloading namespaces |
| 12:45 | technomancy | andyf_: what's an example of a valid source form that would generate a warning but not be IObj or IMeta? |
| 12:45 | Bronsa | a macro can be a no-op only for functions tohough, if you have (macro1 (macro2 ..)) macro2 will not be invisible to macro1 |
| 12:45 | xk05 | civilian airliner shot down over eastern ukraine |
| 12:46 | Bronsa | technomancy: a keyword |
| 12:46 | Bronsa | technomancy: eastwood has a misspelled-keyword linter |
| 12:46 | technomancy | huh |
| 12:46 | technomancy | ^:eastwood/ignore (identity :not-a-typo) =) |
| 12:46 | mikerod | MrJones98: no problem. I'm glad you got it sorted out. I know there can certainly be issues when matching on types, when those types are being dynamically reloaded into the runtime. |
| 12:47 | technomancy | Bronsa: can't you just move the metadata up to the form containing the keyword though? |
| 12:47 | Bronsa | technomancy: that might work, yes |
| 12:47 | andyf_ | technomancy: A marker macro can leave compiled byte code unmodified, I believe |
| 12:47 | Bronsa | technomancy: actually no |
| 12:47 | Bronsa | technomancy: it has the same issues as using a macro |
| 12:48 | Bronsa | technomancy: e.g. if your keyword is an argument to a macro that expects a keyword literal |
| 12:48 | technomancy | I see |
| 12:48 | MrJones98 | mikerod: yeah - you provided the sanity check that it wasn’t a misuse of the library but something possibly more insidious |
| 12:48 | technomancy | Bronsa: actually no, I don't |
| 12:48 | technomancy | just attach the metadata to the macro call |
| 12:48 | technomancy | and the linter shouldn't descend into it, right? |
| 12:48 | andyf_ | Bronsa: I'm not expecting people will want to disable keyword warnings that way, necessarily, but I wouldn't want to disallow it |
| 12:48 | technomancy | (forget the identity bit) |
| 12:49 | Bronsa | andyf_: I think at this point having evaluated all the possibile solutions metadata seems like the best one. we can use a gloabal table of keywords to ignore |
| 12:49 | Bronsa | technomancy: ^{:eastwood/ignore-keywords #{:foo}} (macro ... :foo ..) ? |
| 12:50 | technomancy | right |
| 12:50 | technomancy | or just ^:eastwood/ignore-keywords if you are lazy and sacrifice granularity |
| 12:50 | andyf_ | Bronsa: Do you have any concerns about a marker macro other than the need to require its definition? |
| 12:50 | Bronsa | andyf_: yes. it wont work in some cases |
| 12:50 | Bronsa | 18:43:34 <Bronsa> a macro can be a no-op only for functions tohough, if you have (macro1 (macro2 ..)) macro2 will not be invisible to macro1 |
| 12:50 | Bronsa | |
| 12:50 | Bronsa | andyf_: ^ |
| 12:51 | Bronsa | andyf_: silly example, (for [x (range) (eastwood-ignore :when) (even? x)] x) |
| 12:51 | Bronsa | that won't work |
| 12:52 | andyf_ | Sorry if I am being dense here, but if macro2 is defined to expand only to its 1 arg , what can go wrong there? |
| 12:53 | technomancy | andyf_: just saw the eastwood ticket about re-using JVMs; are you aware of :eval-in :nrepl? |
| 12:53 | andyf_ | Ok, but that example doesn't work equally for metadata, either |
| 12:53 | Bronsa | andyf_: (defmacro x [y] (if (= :y y) 1 2)) (x :y) (x (do :y)) will produce different results |
| 12:55 | Bronsa | andyf_: correct, there's no way to wrap a form in an "invisible" way, if the form is used inside a macro call it will always be problematic |
| 12:55 | Bronsa | andyf_: what technomancy suggested might be the best solution -- attaching the :ignore metadata on a previous form |
| 12:56 | andyf_ | Back in a few mins |
| 12:57 | ben-o | hi. any advice on how to print lazy seqs? I have a clojure.lang.LazySeq and i'm trying to force eval and print to file. but the file only prints the lazy seq object id. |
| 12:58 | ben-o | i've tried doall, map prn |
| 13:07 | nkoza | ben-o: (prn my-lazy-seq) should work |
| 13:09 | ben-o | nkoza: thanks but that doesn't seem to work |
| 13:09 | nkoza | ben-o: can you create a gist with your code? |
| 13:11 | johnwalker | when you use xml->, is there any way to assert that all predicates are true? |
| 13:12 | johnwalker | i'd like to get an error if an element isn't found |
| 13:15 | ben-o | nkoza: https://gist.github.com/BenjyO238/6aae961f81bf565cbc8a |
| 13:15 | ben-o | thanks |
| 13:18 | GoodBobK | Hi, possibly stupid question. I'm looking at https://github.com/swannodette/om/blob/master/src/om/core.cljs, line 566-568: |
| 13:18 | GoodBobK | (cond |
| 13:18 | GoodBobK | (nil? m) |
| 13:18 | GoodBobK | (let [shared (or (:shared m) (get-shared *parent*)) |
| 13:18 | GoodBobK | What's the point of (:shared m) when in this branch m is nil? |
| 13:21 | nkoza | ben-o: you need to use pr-str instead of prn |
| 13:22 | nkoza | ben-o: prn prints the lazy-seq to standard ouput and returns nil, then spit is taking that nil value |
| 13:22 | nkoza | ben-o: pr-str prints the lazy-seq to an string and returns that string, use it. |
| 13:23 | andyf_ | Sorry to drop out on folks when you were helping me out there. Work intrudes. Will read the discussion and bring it up again later if I have more questions. Thanks! |
| 13:24 | ben-o | nkoza: thanks! works now. appreciate your help. |
| 13:25 | mi6x3m | hey guys, what is the most convenient way to get a list of all symbols used by a function? |
| 13:25 | mi6x3m | right now I use (filter symbol? (flatten (read (source-fn |
| 13:25 | nkoza | GoodBobK: seems there is no point, you should blame on that line to notify dnolen about it |
| 13:26 | mi6x3m | also, is there an elegant way to strip the namespace in a qualified symbol? |
| 13:26 | GoodBobK | nkoza: thanks |
| 13:27 | nkoza | mi6x3m: I only found (-> 'ns/sym name symbol) |
| 13:27 | tvanhens | In datalog, if I have a set of names-to-check, and a set of names-in-db, how would I query for all names-to-check which are not already contained in names-in-db? |
| 13:28 | mi6x3m | nkoza: ah! it seems name ignores the ns qualifier |
| 13:28 | mi6x3m | thanks |
| 14:03 | rurumate | can anyone give an example of what reduced and reduced? are doing? |
| 14:03 | rurumate | &(reduced 1) |
| 14:03 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: reduced in this context |
| 14:03 | rurumate | ok that's fail |
| 14:04 | ambrosebs | ,reduced |
| 14:04 | clojurebot | #<core$reduced clojure.core$reduced@3002b9> |
| 14:04 | ambrosebs | a Reduced is a special wrapper value that terminates a reduce early |
| 14:05 | boxed | how do I make clojure drop into a repl when the process throws an uncaught exception? |
| 14:05 | razum2um | does anybody knows why it happens: https://gist.github.com/razum2um/432181a0689e5c447b09 ? |
| 14:05 | rurumate | but why can lazybot not resolve it? |
| 14:05 | technomancy | boxed: I think ritz does that |
| 14:05 | rurumate | and what is it good for? example? |
| 14:07 | ambrosebs | &*clojure-version* |
| 14:07 | lazybot | ⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil} |
| 14:07 | technomancy | huh, is reduced a special form? |
| 14:07 | ambrosebs | ,*clojure-version* |
| 14:07 | clojurebot | {:major 1, :minor 6, :incremental 0, :qualifier nil} |
| 14:07 | ambrosebs | I mean it's treated specially in reduce |
| 14:07 | boxed | technomancy: hmm.. the docs on that seems… lacking. Referring to a presentation from a conj the first thing makes the baby jesus cry |
| 14:08 | ambrosebs | oh and it was introduced in 1.5.1 |
| 14:08 | technomancy | boxed: yeah, it's unfortunate |
| 14:08 | ambrosebs | or 1.5.0 |
| 14:13 | Bronsa | technomancy: reduces is just a regular function |
| 14:15 | Bronsa | technomancy: it wraps the value in a clojure.lang.Reduced, when reduce is handled a c.l.Reduced as its accum it short circuits |
| 14:15 | technomancy | yeah, I didn't expect lazybot to have such an old version |
| 14:18 | mikerod | I didn't realize that binding conveyance worked for lazyseq's produced in the scope of dynamically bound vars. |
| 14:18 | mikerod | has this been the case for long in clj? |
| 14:18 | mikerod | I also, don't think I fully understand how this works. I wasn't wanting to dig around to understand it. I have observed that something like `with-redefs-fn` doesn't play nice with laziness. |
| 14:19 | tbaldridge | laziness and dynamic bindings of any kind is just wrong |
| 14:20 | mikerod | tbaldridge: hmm |
| 14:20 | mikerod | tbaldridge: it apparently works to some degree |
| 14:20 | mikerod | I think the problem with statements like that is that things sometimes end up being lazy when you dont' expect, just due to the "lazy when it can be" behavior in clj. |
| 14:21 | tbaldridge | dynamic bindings say "do this within this timeframe", laziness says "do this later". Hilarity ensues |
| 14:21 | tbaldridge | right so the default should be, avoid binding an with-redefs |
| 14:21 | tbaldridge | *and |
| 14:21 | mikerod | In reality, the issue is that dynamic bindings are just nasty. If you write a fn and it has lazy behavior, but uses some fn deeper down the stack that references a dynamic var, you'd have to just know about that and be defensive/force eagerness. |
| 14:22 | trptcolin | or use bound-fn* |
| 14:22 | mikerod | tbaldridge: yes, avoidance... |
| 14:22 | mikerod | trptcolin: I was unaware of bound-fn, pretty cool |
| 14:23 | mikerod | my main point is, it looks like dynamic bindings were working with a lazy seq |
| 14:23 | mikerod | I didn't think it did. Now I'm curious how/why/and is it reliable. |
| 14:23 | mikerod | Not that I really intend to utilize it. |
| 14:23 | tbaldridge | they do, sometimes... |
| 14:24 | mikerod | tbaldridge: so this is one of those things that are hit-or-miss and hard to identify the scenarios where it fails? |
| 14:24 | tbaldridge | no, it makes perfect sense if you know about things like chunked-seqs |
| 14:24 | mikerod | I have observed that with-redefs just fails on some pretty simple cases. I'm thinking it doesn't work at all, but perhaps that is also a flawed assumption. Then again with-redefs is not really a "main" code sort of construct to use. |
| 14:25 | mikerod | tbaldridge: I know about them to some degree. |
| 14:25 | mikerod | I guess not enough though, since I don't see the lines clearly drawn at the moment. :) |
| 14:25 | tbaldridge | I personally think that if you're using dynamic vars, or with-redefs, you should really try to restructure your code, there's just no reason to use those. |
| 14:26 | mikerod | tbaldridge: with-redefs - I agree should be reserved for trying to mock in tests and only if that's the "best you can do". |
| 14:26 | mikerod | dynamic vars, are more often used. |
| 14:26 | tbaldridge | don't even use it for mocks, use protocols are pass your components into your functions |
| 14:26 | mikerod | I'm not a big fan. I see why people start using them to avoid the "pass this argument to everyone" issue. |
| 14:27 | mikerod | tbaldridge: Well, unfortunately we cannot always be in control of every fn we interact with to fix them all. :P |
| 14:27 | mikerod | I agree with the design principle of not using them though. |
| 14:27 | tbaldridge | At this point I've been using clojure professionally for about 2 years, and have never used with-redefs and have only used dynamic vars once or twice in production code. |
| 14:29 | augustl | is there a set operation for "replace existing" instead of "don't add if exists"? |
| 14:29 | mikerod | I've been using it professionally for about 2 now too. I have had to deal with essentially 1 dynamic var, that is prevalent though. I've used with-redefs to mock away some nasty Java interop stuff and to mock something involved with the dynamic var. |
| 14:29 | augustl | set as in sets, not "set/update" :) |
| 14:31 | augustl | seems disjoin does just that |
| 14:32 | augustl | eh no, disjoin just removes it |
| 14:32 | amalloy | augustl: what would it mean to replace an item in a set with another object just like it? |
| 14:33 | augustl | yeah I suppose my set usage is a bit weird.. The hash code for the items i add to the set isn't for the complete value, so the idea is to replace the old value with the updated value, and find it in the set based on the hash code.. |
| 14:33 | augustl | suppose I shouldn't use sets |
| 14:33 | clojurebot | Excuse me? |
| 14:34 | augustl | a PersistentTreeMap probably makes more sense (I need sorting), that I can just assoc into |
| 14:35 | amalloy | yeah, that's a map |
| 14:35 | amalloy | not a set |
| 14:37 | augustl | in hindsight that makes so much sense that I'm embarrassed :) Implementing an object with hashCode instead of just using a map with keys instead of hashCode.. :) |
| 14:41 | kenrestivo | i'm using https://github.com/flatland/chronicle , and having fits trying to figure out how to make it be time zone aware, i.e. for hours |
| 14:41 | Fare | hi |
| 14:42 | Fare | how do I access a data file in a clojure jar and/or make sure it's included in the jar? |
| 14:42 | kenrestivo | it produces times that are in UTC. so if you tell it {:hour [0]}, it produces 7am (here, PST8PDT) |
| 14:42 | Fare | at compile and/or at runtime |
| 14:43 | trptcolin | time zone awareness is a myth. like dry land. |
| 14:43 | mi6x3m | Fare: I doubt at run time you know that you are running from a jar :) |
| 14:43 | technomancy | Fare: check out the resources/ dir and clojure.java.io/resource |
| 14:43 | kenrestivo | amalloy: and i suspect you might know a little something about this |
| 14:44 | amalloy | just give it a different start time than t/now, and it adds in increments. for example, iirc t/local-now is a thing |
| 14:44 | kenrestivo | amalloy: perfect, thanks |
| 14:46 | amalloy | kenrestivo: if that works, please put it in the readme for me |
| 14:47 | Fare | technomancy, wonderful! |
| 14:47 | Fare | (inc technomancy) |
| 14:47 | lazybot | ⇒ 121 |
| 14:47 | kenrestivo | amalloy: will do. it does using l/local-now. now i have to patch moments to make it use l/local-now instead of t/now |
| 14:49 | kenrestivo | Raynes: if you're interested in such a patch, that is |
| 14:51 | amalloy | local-now is probably a better default, but it would be better to take that kind of thing as a config option. (let [scheduler (moments/scheduler t/local-now)] (schedule-every scheduler executor 1000 #(println 'hi))) would be a nice thing to be able to write |
| 14:52 | amalloy | or perhaps that scheduler contains an executor as well, whatever |
| 14:57 | kenrestivo | it contains a ScheduledThreadPoolExecutor, which is even more special |
| 14:59 | amalloy_ | kenrestivo: well, i was suggesting you define a new "scheduler" thing, which contains t/now or t/local-now. then you can fold the executor into that as well, so you don't even have to pass any more arguments |
| 15:00 | celwell | I have a map with an arbitrary number of levels of nesting, and I'm trying to get all of the submaps that contain a specific value for a specific key ":xtype". Been trying to use postwalk, but the furthest I can get is to println each of the desired submaps. I just need to get them into a list at this point, but I'm stuck. Any thoughts? |
| 15:05 | justin_smith | celwell: perhaps tree-seq |
| 15:05 | justin_smith | otherwise, you could conj onto an atom with a vector or hash-map in it, but tree-seq is likely simpler |
| 15:06 | justin_smith | postwalk is helpful to make a variation on a tree, but to extract subtrees, tree-seq is likely the right thing |
| 15:07 | celwell | justin_smith: if i conj onto an atom, isn't that considered a less 'clojure' way of doing it? |
| 15:07 | celwell | justin_smith: I'll check out tree-seq though |
| 15:07 | PigDude | how do i test if a value implements some protocol? |
| 15:09 | trptcolin | satisfies? |
| 15:11 | justin_smith | celwell: indeed, but sometimes doing an algorithm in terms of a well scoped mutation (won't leak out and change behaviour outside that let block or in other threads) is much simpler than forcing it to be immutable |
| 15:19 | augustl | anyone happen to know why Clojure's data structures aren't in a separate lib, cljs style (mori)? |
| 15:19 | stuartsierra | mori came *after* ClojureScript. |
| 15:20 | bbloom | i think he's asking about the jvm structures |
| 15:20 | bbloom | augustl: you don't need them packaged up nicely on the jvm |
| 15:20 | stuartsierra | I know people use them from Jav. |
| 15:20 | stuartsierra | *Java |
| 15:20 | augustl | bbloom: true, but the current version of PersistentHashMap requires the runtime to be initialized |
| 15:20 | augustl | and who knows what might happen in the future, etc |
| 15:21 | stuartsierra | Someone's probably ported them already. |
| 15:21 | augustl | there's https://github.com/krukow/clj-ds but it doesn't seem to be actively maintained |
| 15:22 | bbloom | augustl: do you need them to be CLOJURE'S or just you want persistent array mapped tries? |
| 15:22 | bbloom | http://pcollections.org/ maybe? |
| 15:23 | bbloom | see also: http://stackoverflow.com/questions/20834721/what-libraries-provide-persistent-data-structures/20834722 |
| 15:23 | augustl | well I want something that's actively maintained and tuned and awesome :) And the ones in Clojure are actively maintained. Seems like clj-dns and pcollections doesn't have all that many users |
| 15:24 | augustl | I've chosen clj-ds, that works for me. Mostly just curious why JVM Clojure hasn't split it like cljs has :) |
| 15:24 | bbloom | augustl: how actively do they really need to be maintained? i mean, the only major change to the clojure ones were hashing fixes |
| 15:24 | augustl | and perhaps that's just a couple of patches/contributions away |
| 15:25 | bbloom | but i mean, they are "done" in many senses |
| 15:25 | augustl | does pcollections have transients? |
| 15:25 | augustl | it's not mentioned anywhere as far as I can tell |
| 15:25 | bbloom | no idea, found that at random |
| 15:25 | bbloom | *shrug* |
| 15:26 | augustl | the real question is why aren't all JVM devs using a persistent data structure lib ;) |
| 15:27 | stuartsierra | I think Guava has some. |
| 15:27 | bbloom | last i checked, guava only had "unmodifiable" not persistent |
| 15:27 | augustl | ah, I thought guava only had COW and unmodifiable |
| 15:27 | stuartsierra | ah, ok |
| 15:28 | bbloom | apparently persistent collections are in the "idea graveyard" http://code.google.com/p/guava-libraries/wiki/IdeaGraveyard#Persistent_mutable_collections/mutation_methods_on_immutable_col |
| 15:29 | bbloom | *shrug* |
| 15:29 | augustl | I suppose it's pretty common for people that like persistent data structures to just use Clojure |
| 15:29 | bbloom | i don't even remember what like was like before persistent data structures |
| 15:29 | bbloom | s/like/life/ |
| 15:29 | augustl | bbloom: copy all the things, or get ConcurrentModificationException |
| 15:30 | bbloom | or just solve smaller problems :-P |
| 15:31 | augustl | haha |
| 15:35 | Desheng | does Kmett have a site where he gives possible use cases for category-extras or a blog about his arrival at each one, or anything like that? |
| 15:44 | TimMc | Desheng: You might have better results asking in #haskell... |
| 15:44 | Desheng | oh dang sorry |
| 15:44 | TimMc | :-P |
| 15:44 | Desheng | the tabs are right next to each other in my client lol |
| 15:45 | TimMc | Are you in the Boston area? |
| 15:45 | TimMc | I just happened to hear the name "Kmett" from a coworker who was at the local Haskell meetup last night, otherwise I wouldn't've had a clue. |
| 15:46 | Desheng | if you loosely enough define Boston area maybe |
| 15:46 | Desheng | I'm in Maine |
| 15:49 | mikerod | Oh no! haskell talk can't be allowed here :P |
| 15:49 | mikerod | Oh, I had no idea that cljs broke out the persistent data structures into a standalone |
| 15:51 | bbloom | mikerod: it doesn't really. dnolen_ just packaged up a nice js api called mori by wrapping core |
| 15:54 | mikerod | bbloom: oh, tricky |
| 16:09 | sritchie | dnolen_: hey david, QQ about om component state organization - |
| 16:10 | dnolen_ | sritchie: hopefully I can answer it :) |
| 16:10 | sritchie | :) dnolen_: I’ve got a component that needs state from two separate locations in my cursor - |
| 16:10 | sritchie | I can paste the state schema in a sec |
| 16:11 | sritchie | so instead of (om/build-all event-row (-> state :static :events)) |
| 16:11 | sritchie | that component also needs (-> state :static :pricing) |
| 16:11 | dnolen_ | sritchie: so just compose those two things into a map |
| 16:12 | dnolen_ | (om/build event-row {:events ... :pricing}) |
| 16:12 | sritchie | so (om/build-all event-row (map (fn [event] {:pricing (-> state :static :pricing), :event event}) (-> state :static :events)) |
| 16:13 | sritchie | dnolen_: oh, just use “build” and give it a single map |
| 16:13 | dnolen_ | sritchie: either should work |
| 16:13 | dnolen_ | I would probably do it w/ a map though |
| 16:13 | sritchie | then have that component internally use “build-all” for its event rows, now that it has the “static” pricing alongside |
| 16:13 | sritchie | ? |
| 16:14 | dnolen_ | oh sorry I didn't see you were doing a build all |
| 16:14 | dnolen_ | yes that work |
| 16:14 | dnolen_ | s |
| 16:15 | sritchie | okay, trying that out |
| 16:15 | sritchie | thanks! |
| 16:15 | sritchie | well, actually… this is still a little confusing |
| 16:15 | sritchie | let me type up a gist example, one sec |
| 16:16 | sritchie | I’m rendering a row for each event that a race organizer is offering, and each event has its own list of genders, age groups and boat types; so that fits the build-all model well |
| 16:16 | sritchie | but every one of those rows has to have access to a single instance of pricing |
| 16:17 | sritchie | dnolen_: I find myself worrying in advance about mapping across cursors and screwing with Om’s ability to do diffs |
| 16:17 | dnolen_ | sritchie: you shouldn't run into problems |
| 16:17 | dnolen_ | Om just used = now |
| 16:17 | dnolen_ | uses |
| 16:18 | sritchie | okay |
| 16:18 | dnolen_ | sritchie: if you have something that's slow let me know but I doubt it :) |
| 16:18 | sritchie | okay, I’ll go for it and see what happens |
| 16:18 | sritchie | yeah, this view in particular is just never going to suffer |
| 16:18 | sritchie | :) |
| 16:18 | sritchie | once I go back and redo that timing app example with its millisecond-level updates, maybe I’ll hit something, but not now |
| 16:42 | sandbags | anyone used and recommend any of the twitter streaming libs? |
| 16:43 | sandbags | twitter-streaming-client looks the most maintained but i'm not sure i like its interface very much |
| 16:44 | sandbags | i wish clojars could sort libs by, e.g., last release date |
| 16:49 | bbloom | ,let [t (transient [:x :y :z])] (persistent! t) (persistent! t)) ; huh? why? is there any harm in calling persistent on a transient that is already in use persistently? |
| 16:50 | clojurebot | #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/let, compiling:(NO_SOURCE_PATH:0:0)> |
| 16:50 | bbloom | ,(let [t (transient [:x :y :z])] (persistent! t) (persistent! t)) ; huh? why? is there any harm in calling persistent on a transient that is already in use persistently? |
| 16:50 | clojurebot | #<IllegalAccessError java.lang.IllegalAccessError: Transient used after persistent! call> |
| 16:50 | amalloy | bbloom: yes |
| 16:50 | bbloom | amalloy: what's the problem? |
| 16:51 | bbloom | seems like the arrays are never modified once the edit root is null |
| 16:51 | amalloy | well. i guess maybe not? i suppose it might be fine to call persistent! twice; it's other calls that'd be no good |
| 16:51 | bbloom | all further modifications to the collections do an array clone first |
| 16:51 | bbloom | well of course actual modifications can't be done after persistent! |
| 16:52 | amalloy | bbloom: it might be the case that if there are two different persistent pointers to the same transient collection, you lose the amortized performance guarantees because they repeat the same work |
| 16:53 | bbloom | amalloy: i'm not sure i follow |
| 16:53 | amalloy | well like, when you take a transient and make it persistent, there's some cleanup work left to be done, right? |
| 16:54 | amalloy | and it's amortized o(1) because it gets done on-demand as you traverse and/or "modify" the persistent collection |
| 16:54 | bbloom | amalloy: a tad. persistent vector trims the tail array w/ a copy |
| 16:55 | amalloy | so i was imagining that if there are two persistent pointers owning that same underlying transient, you might wind up repeating that cleanup work; persistent! might refuse to let that happen in order to preserve its performanec guarantees |
| 16:57 | bbloom | i'm not so sure about the perf issue, but i could see how it would be seen as a bug to call persistent! twice... in my case, i actually have two different transient objects that share an edit root |
| 16:57 | bbloom | (i'm doing something crazy) |
| 16:58 | bbloom | so my problem is that i want to atomically clear the edit root, but still call persistent! on each of the independent transient objects to create the persistent wrappers |
| 16:58 | bteuber | (no need for that remark, you're in #clojure so noone would expect anything but :D ) |
| 16:59 | amalloy | bbloom: you have two transients sharing an edit root? i don't know enough about transients to know what that means, let alone how you make it happen |
| 16:59 | bbloom | ensureEditable checks that edit thread == current thread, but i think for persistent, the check really should be edit thread == current thread OR edit thread == null |
| 16:59 | bbloom | amalloy: internally, persistent vector's nodes all have a single atomic reference containing the thread that may edit them |
| 17:00 | bbloom | amalloy: i'm doing a custom structure that has something similar, but it just so happens that the internal nodes are themselves useable as transients standalone |
| 17:04 | bbloom | ok, that's what i'm doing... normal check is (not= owner (Thread/currentThread) but for persistent! i'm checking (and owner (not= owner (Thread/currentThread))) |
| 17:10 | gfredericks | so leiningen profiles support using a vector of maps & keywords instead of a simple map |
| 17:10 | gfredericks | where the keywords are names of other profiles |
| 17:10 | gfredericks | which is cool and useful |
| 17:11 | gfredericks | ... but |
| 17:12 | gfredericks | :profiles {:a [{...} :b] :b {...}} |
| 17:12 | gfredericks | ^ this warns about :b being not found |
| 17:12 | gfredericks | while :profiles {:b {...} :a [{...} :b]} |
| 17:12 | gfredericks | is okay |
| 17:12 | gfredericks | i.e., the map ordering seems to be sensitive |
| 17:12 | technomancy | gfredericks: https://github.com/technomancy/leiningen/issues/1424 |
| 17:12 | gfredericks | hey hey hey |
| 17:13 | technomancy | we should add a warning though |
| 17:13 | technomancy | even if we can't drop support yet |
| 17:13 | gfredericks | oh I see so I'm Doing It Wrong |
| 17:13 | technomancy | yeah, but it's not obvious or documented |
| 17:13 | gfredericks | so I should do :profiles {:a' {...} :b {...} :a [:a' :b]} |
| 17:14 | technomancy | yeah |
| 17:15 | technomancy | except use a proper unicode prime mark; geez |
| 17:15 | technomancy | ya slacker |
| 17:15 | gfredericks | O_O |
| 17:15 | Frozenlo` | Are browsers preloading urls? I've got a route in my ring app printing to console when its visited and it prints BEFORE I press enter in my browser. :-/ |
| 17:15 | amalloy | Frozenlo`: chrome often does |
| 17:16 | Frozenlo` | amalloy: So I'm not mad then. Thanks. |
| 17:17 | justin_smith | Frozenlo`: what is the path? is it a wildcard? with wildcards I found myself serving favicon.ico requests as if they were dynamically generated pages (until I made a middleware to steal all */favicon.ico) |
| 17:17 | Frozenlock | Not, it's a normal path... "/some-path" |
| 17:18 | justin_smith | like I would have a article/:id0/comments/:id1 which would get requests with :id1 being favicon.ico |
| 17:18 | justin_smith | Oh, OK |
| 17:18 | amalloy | justin_smith: that seems weird. isn't favicon.ico only requested at /? |
| 17:19 | arrdem | amalloy: you can "suggest" an alternate favicon location. Grimoire and my blog do this. |
| 17:19 | arrdem | but by default yeah it's /favicon.ico |
| 17:21 | gfredericks | technomancy: hey hey hey thanks man |
| 17:21 | gfredericks | (inc technomancy) |
| 17:21 | lazybot | ⇒ 122 |
| 17:22 | technomancy | no problem |
| 17:25 | sdegutis | What's Clojure's biggest strength that sets it apart from other languages? |
| 17:26 | mthvedt | parens |
| 17:26 | sdegutis | I'm trying to figure out if the only reason I used Clojure to write this web app was because of the honeymoon effect from when I first learned it, coinciding with my realization that Rails causes pain. |
| 17:26 | jonathanj | dynamic typing, every compile is a type-lotto |
| 17:26 | justin_smith | amalloy: yeah it is weird, but we definitely got it at arbitrary paths |
| 17:27 | TEttinger | sdegutis, probably the seq abstraction and how easy concurrency is |
| 17:27 | sdegutis | TEttinger: the seq abstraction in what sense? |
| 17:27 | TEttinger | being able to deal with complex nested data easily is really handy |
| 17:27 | sdegutis | Oh, so the core functions that operate on lazy sequences. |
| 17:27 | TEttinger | at least for the stuff I use clojure for |
| 17:27 | TEttinger | sorta |
| 17:28 | sdegutis | Yeah I wrote briefly about something like that here: http://sdegutis.github.io/2013/10/22/clojure-for-web-apps-p1/ |
| 17:28 | TEttinger | any coll in clojure can be treated as a seq, so it makes it really nice to convert around |
| 17:28 | justin_smith | amalloy: ahh, looks like it was an old chrome bug http://stackoverflow.com/questions/1003350/why-is-chrome-searching-for-my-favicon-ico-when-i-serve-up-a-file-from-asp-net-m |
| 17:31 | verma | ,(for [x (range 4) y (range 3)] [x y]) |
| 17:31 | clojurebot | ([0 0] [0 1] [0 2] [1 0] [1 1] ...) |
| 17:32 | sdegutis | I used to like the whole DSL abstraction that macros allow, but I often find myself looking up the source for something like "defroutes" or "defstylesheet" to see what it's actually doing. |
| 17:36 | numberten | what does the period mean in https://github.com/jonase/kibit/blob/master/src/kibit/rules/arithmetic.clj ? |
| 17:37 | cbp | numberten: that depends on what defrules does |
| 17:37 | numberten | ah it's a macro, reading now |
| 17:37 | numberten | thanks |
| 17:37 | amalloy | numberten: it's the old dotted-pair notation for sequences |
| 17:38 | jdkealy | if i had an entity which had an attribute of type string with cardinality many, how do i delete one of the items in the list? updating the entity with a new list does not retract the old ones, and there's no ID associated with the string to retract |
| 17:38 | amalloy | (a b c . d) is a sequence of at least three args, the first three of which are named a/c/b, and the remaining args are named d |
| 17:38 | numberten | amalloy: ah thanks |
| 17:38 | numberten | can d be '()? |
| 17:38 | amalloy | like ##(let [[a b c & d] (range 10)] [a b c d]) |
| 17:38 | lazybot | ⇒ [0 1 2 (3 4 5 6 7 8 9)] |
| 17:39 | amalloy | probably |
| 17:39 | bbloom | amalloy: heh, maybe dnolen_ should deprecate that in favor of & |
| 17:39 | numberten | alright thanks |
| 17:39 | cbp | well TIL |
| 17:39 | amalloy | bbloom: this is kibit, not core.match |
| 17:39 | bbloom | amalloy: https://github.com/jonase/kibit/blob/master/src/kibit/rules/util.clj |
| 17:39 | amalloy | oh, but it's using core.logic |
| 17:39 | bbloom | compile.rule delegates entirely to core.logic |
| 17:42 | augustl | any libs around to turn an xml file into a persistent data structure, ideally without having to read the whole file into memory first (streaming, om nom) |
| 17:43 | augustl | ? |
| 17:43 | bbloom | augustl: what would it mean for persistent data structure to be streaming? |
| 17:44 | augustl | not the data structure, just the actual parsing of the xml file |
| 17:44 | augustl | under the hood |
| 17:44 | bbloom | presumably data.xml does that |
| 17:44 | augustl | not super important I guess, all I really want is to have the xml as a persistent data structure in-memory |
| 17:44 | bbloom | https://github.com/clojure/data.xml |
| 17:45 | augustl | nice, tnx |
| 17:45 | arohner | augustl: and yes, you can make data.xml stream lazily |
| 17:46 | arohner | obviously only useful if you have an array-like structure |
| 17:46 | justin_smith | augustl: maybe xml-seq? |
| 17:47 | augustl | justin_smith: looking that up, tnx |
| 18:00 | sritchie | dnolen_: BOOM, google places autocomplete component working :) |
| 18:03 | sritchie | dnolen_: the beginning of a bootstrap forms component: https://gist.github.com/sritchie/9014c14c15d72c8b6458 |
| 18:03 | sritchie | works great over here. next is a table, and then the scrolling component we talked about months ago |
| 18:08 | bbloom | what do i do if i have a deftype with an :unsynchronized-mutable and want to create a private helper function that operates on it? |
| 18:08 | bbloom | mutables are private |
| 18:09 | bbloom | so i can't just make a free function w/ a type hint... |
| 18:09 | dnolen_ | sritchie: nice! |
| 18:10 | bbloom | i know that cljs core has a few "private" methods, by just defining them against Object & relying on the lack of validation |
| 18:11 | bbloom | example: https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L5045 |
| 18:12 | bbloom | seems like on the JVM my best option is just a private protocol |
| 18:14 | dnolen_ | bbloom: or a implement a definterface + helper function that calls it, I think. |
| 18:15 | bbloom | dnolen_: bummer. i'm doing (defprotocol Private ...) right before the deftype & repeating myself like a god damn C programmer |
| 18:16 | dnolen_ | bbloom: well you're doing something low level, not supposed to be fun. |
| 18:17 | bbloom | dnolen_: yeah, but it's also kinda weird b/c if somebody were to use this class from java, they'd have public methods thanks to the interface |
| 18:17 | bbloom | seems like for interop sake, it would be nice to actually define a private method |
| 18:19 | seangrove | "not supposed to be fun" - interesting thought |
| 18:22 | bbloom | seems like nothing i do is ever supposed to be fun :-p |
| 18:22 | bbloom | "you're programming, it's supposed to be pain and suffering without explaination" |
| 18:24 | amalloy | would an explanation really make it better? "this is no fun because your program is objectively bad" |
| 18:24 | amalloy | i wouldn't want to hear that |
| 18:33 | ephemeron | I am writing a wrapper around a rather OOP-ish library which makes extensive use of mutable fields, with much of its API focussed on getting/setting those fields. |
| 18:34 | ephemeron | Is it generally considered idiomatic to wrap these methods with functions that return the affected object, e.g. for ease of chaining, |
| 18:35 | ephemeron | or is it better to let the wrapper functions return nil, be side-effecting only, and let the wrapper user do the chaining if he needs, e.g. with doto? |
| 18:37 | ephemeron | (Wrapper/library are actually cljs/js, but I venture that the question is general enough not to be off-topic.) |
| 18:38 | dnolen_ | ephemeron: probably would bother wrapping overly side-effecting libs, but guess it just depends on what you are trying to accomplish |
| 18:38 | dnolen_ | s/would/wouldn't |
| 18:42 | ephemeron | dnolen_: Thanks for answering. For now, the wrapper is rather thin, which validates your preference; it is mostly a way to avoid littering namespaces with verbose interop. |
| 18:45 | arrdem | ephemeron: one thing you could do is basically create a do monad wrapper, so your "API" really just accumulates instructions, and then you have some force! or execute! instruction which actually interprets the command sequence against mutable objects you never expose to users. You could also achieve the same thing with chained partial applications. Another alternative is to just create object clones and side-effect the clones for global side-effects or what |
| 18:54 | ephemeron | arrdem: I suspect that, in my case, object clones would either be contrived or simply unviable, but your first suggestion is interesting; I will likely consider it in the longer run. Danke schön. |
| 19:38 | Jaood | ,(every? symbol? ()) |
| 19:38 | clojurebot | true |
| 19:39 | Jaood | ,(symbol? ()) |
| 19:39 | clojurebot | false |
| 19:39 | Glenjamin | ,(every? false? []) |
| 19:39 | clojurebot | true |
| 19:39 | Glenjamin | ,(every? false? [1]) |
| 19:39 | clojurebot | false |
| 19:40 | Glenjamin | every appears to return true with an empty collection, i guess that makes sense |
| 19:40 | arrdem | clearly we need a logical indeterminate value... |
| 19:40 | Glenjamin | ,(doc every?) |
| 19:40 | clojurebot | "([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false." |
| 19:42 | Jaood | Glenjamin: I guess an empty list is still an empty list of symbols |
| 19:48 | celwell | I'm having trouble finding sufficient docs for clojure.java.jdbc. I'm trying to create a table with an :id column that is primary key and auto increment. I have this, but how can I extend it to make the id column be AUTO_INCREMENT? [:id "varchar(255)" "primary key"]. (to clarify, I'm using the "create-table" function.) |
| 19:49 | amalloy | celwell: c.j.jdbc does not contain a lot of schema modification features. i'd just create the tables in a psql shell or something |
| 19:50 | celwell | amalloy: I have to create the tables programatically so I was hoping there was an option for auto increment as there is for primary key. Mayb I should peruse so java jdbc docs. ill see... |
| 19:51 | amalloy | just jdbc/execute! for anything more complicated than a SELECT |
| 19:51 | amalloy | the fancy features for trying to work with anything more clojurey than a giant string sql statement are pretty limited |
| 19:53 | celwell | amalloy: ok good point, i guess ill have just create the sql string myself, sigh |
| 19:53 | elben | I have an infinite lazyseq (it consumes from a kafka queue). I can iterate using (doseq [msg stream] …), but what’s the best way of “breaking out” after some condition is met (e.g. have consumed N messages)? |
| 19:54 | elben | however, I don’t want to realized N messages right away using (take n stream) |
| 19:55 | hiredman | take is lazy |
| 19:56 | hiredman | but anway, I think seqs for modeling consumtion from queues is tempting, but ultimately not good |
| 19:57 | hiredman | most queues provide some way to ack/nack messages which seqs don't provide, you may want to timeout pulling a message, seqs don't provide a way to do it |
| 19:57 | hiredman | etc |
| 19:58 | elben | understandable. i’m using the kafka scala consumer, which is an Iterator interface, hence why I’m using a seq. |
| 19:59 | elben | i suppose it throws an exception on timeouts etc |
| 20:32 | gfredericks | haha wow okay woohoo so |
| 20:32 | gfredericks | two projects on the same machine use the same library; when I `lein repl` in either one the pom.properties for the library shows identical versions |
| 20:33 | gfredericks | yet one has a function missing (a function new in this particular version) |
| 20:33 | gfredericks | can't wait to find out what on earth |
| 20:34 | amalloy | gfredericks: how is lein repl related to pom.propertise? actually i don't even know what pom.properties is |
| 20:34 | hiredman | check lein classpath |
| 20:34 | hiredman | also stop aot compiling |
| 20:34 | hiredman | etc |
| 20:34 | amalloy | technomancy: getting those same spam PMs from kitimini |
| 20:34 | gfredericks | amalloy: it gets packaged with the jar, good for sanity checking what version of a lib you're actually using |
| 20:35 | gfredericks | I should mention that results from CI are consistent |
| 20:36 | gfredericks | which rules out pretty much every possible explanation I think |
| 20:36 | gfredericks | except goblins |
| 20:36 | hiredman | check lein classpath |
| 20:36 | gfredericks | on it |
| 20:37 | hiredman | Ooooh |
| 20:37 | gfredericks | yep lein classpath did it |
| 20:37 | hiredman | or you could be depending on some other library that transitively aot compiles that was built against an old version, but built after the new version of the library was released |
| 20:37 | gfredericks | it's lamer than that |
| 20:37 | gfredericks | I had forked it |
| 20:37 | hiredman | (true story, I've seen it happen) |
| 20:38 | gfredericks | so one of my projects had two versions of it |
| 20:38 | gfredericks | due to different group names |
| 20:38 | hiredman | and becuase the timestamps on the aot classfiles are newer the "old" code is prefered |
| 20:38 | amalloy | hiredman: that sounds like an artists rendition of hell |
| 20:39 | hiredman | there was a lot of thrashing around before we figured that out |
| 20:45 | technomancy | I've debugged that in a support ticket |
| 20:45 | technomancy | it ain't pretty |
| 20:47 | arrdem | so what on earth does Clojure do AOT for a variadic -main.. |
| 20:48 | gfredericks | arrdem: I think there's a shim method |
| 20:48 | gfredericks | since .main needs to take an array anyhow |
| 20:49 | arrdem | gfredericks: yeah that's what I'm thinking. you eat an array and then apply the var that's named -main |
| 20:49 | gfredericks | public static void main(String[] args){ // as you all have dutifully memorized |
| 20:49 | gfredericks | arrdem: I've seen it in the stacktrace |
| 20:49 | gfredericks | there's a .main and a ._main |
| 20:49 | gfredericks | I guess it's a gen-class feature? |
| 20:50 | arrdem | probably. |
| 20:50 | gfredericks | the ._main is just a regular var class |
| 20:50 | gfredericks | er...function class |
| 20:52 | arrdem | okay so the "-main" var has to "exist", because you could potentially recur through it.. so yeah you emit the main var as a "var" (which is a lie for me but whatever) and then you emit the-ns.class with a -main that shims into the "var"... okay doable. |
| 20:53 | amalloy | arrdem: because you could recur through it? how is that relevant. it exists because you're allowed to call it |
| 20:53 | arrdem | amalloy: that's what I meant, recur as a call rather than clojure's loop jump. |
| 20:54 | amalloy | but that doesn't have to be recursive. i can just call (-main) anytime, anywhere |
| 20:55 | gfredericks | when pizza's on a bagel you can call (-main) anytime |
| 20:58 | hellofunk | I'm trying to find docs about the max size available for a core.async channel buffer. Doesn't appear to be mentioned anywhere. |
| 20:59 | gfredericks | why would there be a max size? |
| 20:59 | hellofunk | i don't know, just figured there would be; you suggest there isn't? |
| 21:00 | gfredericks | I can't think of a reason for one |
| 21:00 | hiredman | hellofunk: do you want a max size buffer for some reason? |
| 21:01 | hellofunk | hiredman not for a specific reason, I just didn't know if something like 10,000 is a reasonable number or not. I'm having a problem in cljs where my reads aren't happening as fast as my puts, leading to the error about exceeding 1024 pending puts. So I'm thinking a bufferred channel may be necessary to provide some slack. |
| 21:01 | hiredman | because I think doing that will mean fighting core.async since it explcitly requires a max size so channels can back pressure |
| 21:02 | arrdem | gfredericks: yep. https://www.refheap.com/88314 |
| 21:03 | arrdem | can I do this without RT.seq.. |
| 21:04 | amalloy | why would you want to, arrdem? |
| 21:06 | arrdem | amalloy: I'm trying to compile a standalone hello world as a test program. If I can escape RT altogether (and I almost have) I would prefer to, both for complexity's sake and to escape the startup time of loading Clojure "proper". |
| 21:06 | amalloy | but you'll just be calling into a var that needs clojure proper anyway, right? |
| 21:07 | arrdem | no... |
| 21:07 | arrdem | the whole point of my project is to throw out everything I can, especially vars. |
| 21:08 | arrdem | this test program compiles to zero vars. Note that Oxcart does not claim to be able to interop with Clojure. |
| 21:08 | amalloy | okay cool, well i guess i have no idea what you're up to. good luck |
| 21:08 | arrdem | :P thanks |
| 21:09 | arrdem | urgh. AFn uses RT. this can't be done. |
| 23:42 | hellofunk | Does anyone know if the limit of 1024 pending puts applies to all types of channels, therefore if you have a buffered channel with say 1000 size, then you could put 2400 on that channel before exceeding this limit? |
| 23:42 | hellofunk | sorry I meant 2024 |