2013-04-08
| 00:10 | murtaza52 | I have a sorted map that I am sending to the client. The client is in cljs, the hash-map that appears on the client is not sorted, any ideas? |
| 00:11 | nightfly | I don't think javascript has a native notion of a sorted map |
| 00:14 | murtaza52 | so the sort order wont me maintained, I mean I am not manipulating the collection on the client |
| 00:14 | murtaza52 | I am displaying it as is |
| 00:14 | pbostrom | murtaza52: you are sending as edn? |
| 00:14 | murtaza52 | nope |
| 00:14 | murtaza52 | I am using shoreleave which uses fetch |
| 00:15 | pbostrom | in any case, you'll probably have to explicitly call sorted-map |
| 00:16 | murtaza52 | call sorted-map on the client ? |
| 00:17 | pbostrom | yeah |
| 00:17 | murtaza52 | the problem is that sorting is being done based on the date, which is using clj-time, which uses java's joda time. So I wont have this dependency avalaible in cljs |
| 00:19 | pbostrom | hmm, maybe convert the map to a vector of map entries instead |
| 00:19 | murtaza52 | any way around it? |
| 00:19 | pbostrom | before sending to the client |
| 00:19 | pbostrom | that will stay in order at least |
| 00:21 | murtaza52 | thanks pbostrom, let me try that. The reason it will maintain the order, is because arrays are ordered by index ? |
| 00:26 | pbostrom | yes, your sorted map is probably getting converted to a normal map for serializing over the wire via fetch, it seems like there would be a way to maintain the sorted map using the edn reader, but I don't know enough about it |
| 00:27 | andyfingerhut | I'm pretty sure edn has no notion of order for sets or maps. |
| 00:27 | andyfingerhut | vectors or lists would be the way to go if you want to preserve order. |
| 00:29 | andyfingerhut | Here's an excerpt from the edn spec regarding sets: "No semantics should be associated with the order in which the elements appear." It says the same for maps. |
| 00:30 | andyfingerhut | Hmmm. I think I'll suggest to Bronsa that he mention this somewhere in the tools.reader docs for that edn reader. |
| 00:30 | pbostrom | there you go |
| 01:44 | ebaxt | Are there any good reasons for not having a regex? predicate in Clojure? |
| 01:51 | andyfingerhut | One could potentially argue that there are plenty of similar things that could be added. Where would you draw the line? |
| 01:51 | andyfingerhut | e.g. array? uuid? file? |
| 01:51 | andyfingerhut | (instance java.util.regex.Pattern x) should do what you need, yes? |
| 01:52 | andyfingerhut | er, that should have been instance? with a ? |
| 01:53 | ebaxt | andyfingerhut: fair point |
| 05:10 | NobitaZ | hii |
| 17:35 | zaphyr | oh. i see. so i have to :require-macros or such in every cljs ns i want to use them in, there's no way to make them export? |
| 17:36 | gfredericks | that's how clojure generally works; explicitely requiring things |
| 17:37 | zaphyr | yes, but in clojure I can import macros along with other definitions in the same :require, whereas in clojurescript macros are imported with a different :require-form, you can't just (:require foo :as bar), but you also have to (:require-macros foo :as bar) |
| 17:38 | gfredericks | yep |
| 17:38 | zaphyr | ouch |
| 17:38 | gfredericks | the compiler has to know whether something is a macro or not |
| 17:38 | gfredericks | it's definitely not ideal |
| 17:38 | zaphyr | sure, but clojurescript is entirely AOT isn't it? so in *theory* you could do that |
| 17:38 | zaphyr | okay it would break brepl |
| 17:39 | dnolen | zaphyr: macros are written in Clojure, require is for runtime dependencies. I don't see how it could be made to work. |
| 17:39 | dnolen | or I could imagine it, and it sounds yucky. |
| 17:40 | zaphyr | hey, it's not r6rs staged macro horror :) |
| 17:41 | zaphyr | but- can't you track imports, at least via ns, at compile time, then fully macro-expand the source then? (in theory) |
| 17:41 | Okasu | Guys, what do you usually use when it comes to realtional db and clojure? Clojure jdbc lack of abstraction disturbing(yeah, i can abstract things away by myself but is there something already done in this field?). |
| 17:42 | dnolen | zaphyr: CLJS compilation unit is a function, just like Clojure. |
| 17:43 | zaphyr | dnolen: ah. |
| 17:44 | dnolen | zaphyr: I take it you do a bit of Scheme? :) |
| 17:45 | zaphyr | a bit of all sorts of lisps. but implementing scheme macros is... oh.. dear lord. |
| 07:48 | ggbothso | Hi all, is there a way to automatically run the tests every time a filesystem change is detected? |
| 07:49 | ggbothso | in scala, using sbt, I can do it with: "~ test" |
| 07:50 | babilen | ggbothso: midje supports that (autotest), no idea if there is anything like that for clojure.test |
| 07:51 | babilen | ggbothso: there was lein-autotest, but that hasn't been maintained (along with lazytest) in quite a while |
| 07:54 | babilen | ggbothso: midje /can/ run clojure.test tests as well (cf. https://github.com/marick/Midje/wiki/A-tutorial-introduction-for-Clojure.test-users) but you might want to take a look at the Testing section on https://github.com/technomancy/leiningen/wiki/Plugins |
| 11:39 | mpenet | unless you are thinking about something I am missing |
| 11:44 | mpenet | the problem with clojure.core promise is that they are way too simple, it's sometimes good, but often it's not enough. The callback issue is one but exception handling is another important issue (deref can't throw), well the fact that there is only 1 type of result really. |
| 11:47 | CookedGryphon | hugod: I've tried disabling eldoc and autocomplete-mode in my nrepl buffer, but I'm still having issues with the repl hanging after I clear an exception window. Any ideas? |
| 11:48 | CookedGryphon | I am at least past the point where emacs would just completely freeze |
| 11:49 | CookedGryphon | also, all the locals in one of the exceptions I caught appear to be nil, is that something other people have come across? |
| 11:54 | alexnixon | Coo--- File clojure/2013-04-10.log |
| 17:08 | tbaldrid_ | these are reader issues, legal symbols can be anything. |
| 20:10 | neilmarcus | hello? |
| 20:10 | clojurebot | BUENOS DING DONG DIDDLY DIOS, fRaUline neilmarcus |
| 20:25 | ravster | whats the max that java.lang.Integer can go to? I'm trying to use the java.awt.Polygon class to find if a given latitude and longitude is part of a polygon, and I'm not sure by how many decimal places I can move a value (Egs: latitude 44.35745968346 -> 4435745968346 ) |
| 20:26 | hiredman | ,Interger/MAX_VALUE |
| 20:26 | clojurebot | #<CompilerException java.lang.RuntimeException: No such namespace: Interger, compiling:(NO_SOURCE_PATH:0:0)> |
| 20:26 | hiredman | ,Integer/MAX_VALUE |
| 20:26 | clojurebot | 2147483647 |
| 20:26 | hiredman | ,Integer/MIN_VALUE |
| 20:26 | clojurebot | -2147483648 |
| 20:26 | hiredman | ,Long/MAX_VALUE |
| 20:26 | clojurebot | 9223372036854775807 |
| 20:26 | hiredman | ,Long/MIN_VALUE |
| 20:26 | clojurebot | -9223372036854775808 |
| 20:27 | ravster | hiredman: oh, I wish I could use longs. But the Polygon class doesn't seem able to consume them. |
| 20:27 | ravster | hiredman: and thanks for the answer. :) |
| 20:38 | noprompt | when using require is it possible to both refer and rename? |
| 20:40 | noprompt | or is it ok to use use in that case? |
| 20:42 | noprompt | oh, there it is. |
| 20:46 | bttf | brand new to clj ... just wrote some code in my core.clj, trying to run it in my 'lein repl' ... i do (in-ns 'testing-clj.core) to get into the namespace but it seems not able to see my symbols |
| 20:49 | bttf | https://gist.github.com/bttf/776f7389cd96b4743dd7 |
| 20:51 | bttf | it seems that i'm entering that namespace but completely separate from what i have defined in src/testing_clj/core.clj |
| 20:53 | ivan | does it work without (:gen-class)? are you sure you're doing (in-ns 'testing-clj.core) and not (in-ns 'testing_clj.core)? |
| 20:54 | ivan | `hello` shouldn't even compile because `hi` is defined after it, though I don't know how AOT works with that |
| 20:54 | bttf | ivan: thanks for replying, i have since removed (:gen-class) since i am not using it ... when I do lein compile i get no output whatsoever .. i don't even know if lein see's the file |
| 20:55 | bttf | i mean, i just generated a new project ,wrote the code and did a 'lein compile' |
| 20:55 | ivan | you don't need to lein compile before lein repl |
| 20:56 | bttf | ok |
| 20:57 | bttf | and yes i'm sure i am doing (in-ns 'testing-clj.core) |
| 20:58 | bttf | i've rearranged the functions, same issue |
| 21:00 | ivan | bttf: I'm probably missing something obvious, it's not working here either |
| 21:01 | bttf | ok ... does somehing need to be specified in the project.clj ? id assume that it should be set to go |
| 21:03 | ivan | bttf: maybe it's because your directory starts with "test" |
| 21:04 | ivan | lein might be ignoring those by default |
| 21:04 | bttf | weird, let me try |
| 21:04 | ivan | make sure you change the (ns too |
| 21:06 | ivan | bttf: heh, actually you need to (require 'testing-clj.core) first |
| 21:06 | ivan | (in-ns) does not seem to load things |
| 21:06 | dakrone | amalloy_: cool, will look when I can |
| 21:07 | bttf | ivan: ahh that works, thank you |
| 21:09 | mdeboard | brehaut: re: named groups https://gist.github.com/mattdeboard/5359853 |
| 21:10 | mdeboard | I find it hard to believe this doesn't exist already |
| 21:11 | ivan | bttf: you can put :main testing-clj.core in project.clj to load and enter that namespace |
| 21:13 | bttf | ah cool thanks |
| 21:14 | jhawk28 | can anyone give be some suggestions on creating a DSL? |
| 21:14 | jhawk28 | I want to create a subset of the language that is mainly arithmetic/boolean with some specific functions |
| 21:15 | jhawk28 | but I need to to be limited since the code is "dynamic" and can potentially be unsafe |
| 21:16 | jhawk28 | is there a way to remove all functions from the dsl's namespace and only add in the specific ones I want? |
| 21:16 | jhawk28 | or do I need to just read in the data as ebn and then execute it myself |
| 21:17 | ivan | I think I would use edn and a whitelist |
| 21:17 | mthvedt | jhawk28: you want to read in untrusted data that's a subset of clojure? |
| 21:17 | nightfly | clojail might be useful |
| 21:17 | jhawk28 | yes, a subset |
| 21:18 | bttf | ivan: what about reloading a file in the repl? i'm trying (load-file) but its not cooperatng |
| 21:19 | mthvedt | you could walk the tree and throw out anything not on the whitelist |
| 21:19 | ivan | bttf: probably (require 'testing-clj.core :reload) |
| 21:19 | mthvedt | after reading it in as edn |
| 21:19 | ivan | there's also a :reload-all |
| 21:20 | ivan | also nrepl.el has many conveniences for sending new forms to the repl |
| 21:20 | bttf | nice, it works |
| 21:21 | bttf | ill check out nrepl.el |
| 21:22 | bttf | there isn't a vim equivalent is there? ;) |
| 21:22 | brehaut | mdeboard: cool; pity you have to double handle the group names :/ |
| 21:22 | mdeboard | Yeah. Either that or uh |
| 21:22 | mdeboard | parse the patterns :P |
| 21:22 | mdeboard | nothx |
| 21:22 | jhawk28 | thanks, I think the edn or the clojail may work |
| 21:22 | brehaut | (╯°□°)╯︵ ┻━┻ |
| 21:22 | mdeboard | brehaut: I'm sure there's a much better way of handling that |
| 21:22 | mdeboard | ┬──┬◡ノ(° -°ノ) chill out bro |
| 21:22 | mdeboard | dat emacs macro |
| 21:23 | ivan | bttf: I hear people use https://github.com/tpope/vim-fireplace |
| 21:23 | mdeboard | never got to use it in the wild before |
| 21:23 | brehaut | ha |
| 21:23 | bttf | brehaut: are you flipping tables |
| 21:23 | brehaut | yes |
| 21:23 | bttf | awesome |
| 21:23 | brehaut | regexps bring out the worst in me |
| 21:29 | brehaut | ,(re-pattern (str #"\w" #"\d")) ; mdeboard |
| 21:29 | clojurebot | #"\w\d" |
| 21:29 | brehaut | mdeboard: that'll save you having to escape all your slashes in your regexps |
| 21:36 | mdeboard | brehaut: Oh, didn't think that works, using the regex reader |
| 21:37 | mdeboard | as args to str |
| 21:37 | brehaut | mdeboard: str takes anything that has a toString method (ie, everything) |
| 21:38 | brehaut | regex patterns happen to have a very useful toString |
| 21:38 | brehaut | its perhaps not immediately obvious though; i learnt the trick from weavejester |
| 21:42 | mdeboard | brehaut: Cool, thanks for the pointer |
| 21:56 | mikepence | reading the joy of closure |
| 21:56 | mikepence | <3 new stuff |
| 22:05 | bttf | anyone good with vim-fireplace in here ? |
| 22:07 | TimMc | Almost certainly. If you have a question, ask and find out! |
| 22:10 | joegallo | that was the question, he was just checkin' ;) |
| 22:11 | bttf | well, i'm moving my cursor to a namespace and trying 'gf' .. it's complaining about several things, the first one is that its unable to resolve a symbol that i've not implemented yet (this is the test) |
| 22:11 | bttf | and when i try :Eval ( ... ), whatever i try it gives me the same complaint of unable to resolve symbol |
| 22:12 | tpope | is your file requirable? |
| 22:15 | bttf | tpope: my apologies, the hopping stops here |
| 22:16 | bttf | in the repl i can require the file no problem |
| 22:16 | bttf | is there a fireplace command for require |
| 22:17 | tpope | there is, :Require |
| 22:17 | tpope | it also implicitly requires the current namespace if it's your first time evaluating code in it |
| 22:18 | tpope | which I assumed was what was failing, albeit with a pecular sounding error |
| 22:18 | tpope | can you refheap the error? |
| 22:18 | tpope | use :messages to see it again |
| 22:19 | bttf | i don't see the 'unable to resolve symbol' errors in messages |
| 22:19 | bttf | but i do see the others, dealing with 'Error detected while processing function <SNR>36_GF..fireplace#findfile..<SNR>36_eval' |
| 22:20 | tpope | what are you pressing gf on? |
| 22:20 | bttf | https://gist.github.com/bttf/808d402bea36784c1eb4 |
| 22:21 | bttf | https://gist.github.com/bttf/4db2ea0d2bf7d3a31dbc line 3 is what i'm gf-ing |
| 22:23 | tpope | https://github.com/tpope/vim-fireplace/issues/44#issuecomment-16054922 |
| 22:23 | tpope | is that your alterego? same error right down to the example |
| 22:24 | tpope | oh, because it's from the tutorial, herp derp |
| 22:24 | bttf | nope and yes, the tut |
| 22:25 | tpope | bttf: to be clear, you can require the *test* file, correct? |
| 22:26 | bttf | (clojure.core/require 'command-line-args.core-test :reload) |
| 22:26 | bttf | CompilerException java.lang.RuntimeException: Unable to resolve symbol: parse-args in this context, compiling:(command_line_args/c |
| 22:26 | bttf | nope |
| 22:26 | tpope | well, that's the root of the problem |
| 22:26 | tpope | the error is messier than it should be |
| 22:27 | bttf | messier or misleading? |
| 22:27 | tpope | it says couldn't require command-line-args.core-test plain is day |
| 22:28 | tpope | it's just surrounded by 5 lines of vim garbage |
| 22:28 | bttf | oh i see |
| 22:29 | bttf | but when I require the test, i only get the error i pasted just above |
| 22:29 | bttf | unless the other erros are hidden away somewhere |
| 22:29 | tpope | well it's one level of abstraction up. requiring the file tells you what went wrong. doing something that implicitly requires the file tells you the file couldn't be required |
| 22:30 | tpope | I just reproduced it. there's another error that happens at the top that tells you exactly what you're looking for |
| 22:30 | mthvedt | is there a macro that's like memoize, but for an inline chunk of code |
| 22:31 | mthvedt | to execute it exactly once |
| 22:34 | amalloy | mthvedt: delay |
| 22:35 | tpope | bttf: I just cleaned up the error on gf and ]d. let me know if you find others |
| 22:35 | bttf | alright, ill give it a try |
| 22:36 | mthvedt | amalloy: delay returns an object that can be derefed, i want to skip that intermediate step |
| 22:36 | amalloy | mthvedt: in that case, all code always, is executed exactly once :P |
| 22:37 | mthvedt | it would have made this one thing i'm writing more readable… but never mind |
| 22:41 | bttf | tpope: looks good so far |
| 22:42 | bttf | but cpR isn't doing anything for me. |
| 22:42 | bttf | and i've deleted my function definition from the code and the test isn't giving me the unresolved symbol error that it should, i believe |
| 22:43 | tpope | well it only requires once |
| 22:43 | tpope | after that it's up to you to reload |
| 22:44 | bttf | and cpr reloads, no ? |
| 22:46 | bttf | cpR should reload-all, but i don't see it happening. if i do cpr on each file, i dont see any errors |
| 22:46 | tpope | cemerick made me take away cpR :( |
| 22:47 | bttf | ooh |
| 22:47 | tpope | you can :Require! to reload-all |
| 22:47 | bttf | ok |
| 22:47 | bttf | still no dice |
| 22:49 | tpope | well try :Eval (require ... :reload-all) |
| 22:49 | tpope | that's all :Require! is doing |
| 22:50 | bttf | i did :Eval (require 'command-line-args.core) :reload-all |
| 22:50 | bttf | then I did, :Eval (clojure.test/run-tests) |
| 22:51 | bttf | and im seeing errors from when my function existed |
| 22:51 | tpope | re-requiring a file doesn't delete the old namespace first |
| 22:52 | tpope | you can ns-unmap, or just restart your repl |
| 22:52 | bttf | interesting |
| 22:52 | bttf | but if i make changes to my source, shouldnt it automatically update namespace? |
| 22:53 | bttf | maybe im missing something here |
| 22:53 | tpope | ignoring your use of "automatically", it doesn't remove anything |
| 22:54 | tpope | if you defined a function, it's not automagically undefined just because you deleted it from the file |
| 22:56 | bttf | heh |
| 22:56 | bttf | i guess if the behavior of the function is changed that will be reflected when reloaded |
| 22:57 | bttf | but if its flat-out deleted? shouldn't that somehow be reflected the same way? |
| 22:57 | bttf | i guess the repl isn't made to work like that |
| 23:08 | bttf | thx for the help tpope |
| 23:09 | tpope | ta |
| 23:44 | dr_choc | Anyone here mess around with clojurescript? Specifically the browser repl? |
| 23:46 | brehaut | ~anyone |
| 23:46 | clojurebot | Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..." |
| 23:46 | brehaut | (inc amalloy) |
| 23:46 | lazybot | ⇒ 49 |
| 23:52 | dr_choc | Has anyone found the cljs browser repl to be finicky? I'm using the lein-cljsbuild plugin and running lein trampoline cljsbuild repl-listen to get a repl, but sometimes it works and sometimes it just hangs as if the browser never connected, but I can see in the network tab (chrome) that it does connect. Any ideas? |