2013-02-13
| 00:06 | Frozenlock | I have a limited understanding of java, but I think this is where everything begins https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L229 Two little missing .setDynamic. |
| 00:11 | abp | amalloy: quite comprehensive.. https://www.refheap.com/paste/11239 any more to shave off? |
| 00:23 | abp | Is there a function that turns a val or a seq into a seq? |
| 00:37 | jibble | How can I append to a vector that's a couple of levels deep in a map? |
| 00:37 | jibble | I want the whole map, plus a new thing added to a vector that's nested within |
| 00:38 | jeremyheiler | jibble, use update-in |
| 00:38 | jibble | jeremyheiler: thx, will look at it |
| 00:38 | abp | ,(update-in {:a {:b {:c [1 2]}}} [:a :b :c] conj 3) |
| 00:38 | clojurebot | {:a {:b {:c [1 2 3]}}} |
| 00:39 | abp | ^ jibble |
| 00:40 | xeqi | Raynes: https://www.refheap.com/paste/11240 ; should that work? |
| 00:40 | jibble | abp: thanks, that's it |
| 00:41 | Raynes | xeqi: Nope, fragment-to-html. |
| 00:41 | Raynes | xeqi: Or you can map to-html, I think. If you just wanted the individual strings. |
| 00:47 | xeqi | Raynes: ah. I'm really trying to do something like https://www.refheap.com/paste/11242 |
| 00:48 | Raynes | xeqi: Use html-content instead of content and I think it'll work. |
| 00:50 | xeqi | html-content + fragment-to-html works, thanks |
| 00:50 | xeqi | is there an equivalent for replace? |
| 00:52 | Raynes | xeqi: I think replace replaces the :content vector in place. If you pass it a seq, it should just put it there, so it should Just Work. |
| 00:53 | Raynes | Like, IIRC ((laser/replace (laser/parse-fragment "<a></a") {:content []}) should = {:content [{node for a}]} |
| 00:54 | yedi | is there a function for getting a submap of a map containing only the specific key-value pairs that you want |
| 00:54 | xeqi | &(doc select-keys) |
| 00:54 | lazybot | ⇒ ------------------------- clojure.core/select-keys ([map keyseq]) Returns a map containing only those entries in map whose key is in keys nil |
| 00:54 | Raynes | xeqi: Also, you can probably use the 'nodes' function instead of parse-fragment. It delegates to it when given a string. |
| 00:55 | Raynes | &(select-keys {:a 1 :b 2 :c 3} [:a :b]) |
| 00:55 | lazybot | ⇒ {:b 2, :a 1} |
| 00:55 | yedi | cool, thanks |
| 00:55 | Raynes | xeqi: You don't *have* to, but it is shorter than 'parse-fragment' so I thought I'd mention it. :) |
| 00:57 | xeqi | Raynes: https://www.refheap.com/paste/11243 ; nodes work where parse-fragment doesn't, thanks! |
| 00:58 | Raynes | That's weird. |
| 00:58 | Raynes | I guess I've forgotten how it works already. |
| 00:58 | Raynes | Oh. |
| 00:58 | xeqi | heh |
| 00:59 | Raynes | xeqi: Okay, so the problem is that parse-fragment turns the parsed nodes into a zipper. |
| 00:59 | Raynes | Usually you just want to pass the nodes themselves. |
| 00:59 | Raynes | So there is parse-fragment* for that. |
| 00:59 | Raynes | And that's what nodes delegates to. |
| 00:59 | Raynes | So yeah, just use that. |
| 01:01 | Raynes | xeqi: And in case you're curious as to why nodes exists, it's because it is the 'normalizing' function of sorts. If you pass it a string, it calls parse-fragment* on it to give you a collection of nodes; if you call it with something sequential, it assumes it is already a seq of nodes and is identity; and if you pass it something that is not a string or sequential, it assumes it is a single node (a map) and wraps it in a vector and returns it. Yay, no |
| 01:01 | Raynes | rmalization! |
| 01:02 | abp | Coding is done, now comes the hard-part: Naming. Those functions, maps and immediate values are all the same. :( |
| 01:12 | clifton | hehe, hello world clojurescript file 750kb |
| 01:20 | abp | Is it normal not to put /bin into .gitignore? |
| 01:40 | xeqi | Raynes: I got everything working, thanks |
| 01:40 | Raynes | xeqi: Coolio. Happy to hear it. |
| 01:42 | michaelr525 | good morning |
| 01:58 | sturner | Anyone have much experience embedding nRepl in java applications or using closure as a plugin/scripting language within java? I'm attempting to extend and enhance a java applications plugin architecture with clojure. So far, I've successfully passed context/state via intern to the repl and I am now exploring how to use gen-class to fully implement the plugin api in clojure. |
| 02:20 | Phonatacid | oh hey, I've almost finished a project of mine (my first in clojure) and I released it via uberjar. Since it includes sing-based UIs usng seesaw (and some other libraries) the uberjar I get from it weighs 12mo. To really have an idea of how heavy is seesaw i built a dummy project that just displays a jdialog (using seesaw's dialog function). And it turns out it weighs 8mo. How can I minimize it and trash all the unused |
| 02:20 | Phonatacid | classes (it appears this jar also embeds swing examples!) |
| 02:25 | noidi | Phonatacid, I haven't tried it, but maybe ProGuard could help? http://proguard.sourceforge.net/ |
| 02:25 | noidi | "It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions." |
| 02:26 | Phonatacid | yes I'm currently trying to achieve "something" with it. Quite an heavy piece of software. I think a proguard leiningen plugin would be welcome. |
| 02:28 | Frozenlock | Phonatacid: do it now! :) |
| 02:29 | Phonatacid | I was considering it actually ! But i'm still a baby when it comes to clojure ! |
| 07:03 | borkdude | Which Python version does clojure-py assume |
| 07:05 | Foxboron | borkdude: looking at the source, i see "print x, y" so i assume 2.7.3 |
| 07:05 | borkdude | Foxboron yes, hm |
| 07:05 | Foxboron | borkdude: it uses optparser, but it still got new objects. So its 2.7 :P |
| 07:06 | Foxboron | new style classes* |
| 07:07 | borkdude | I wonder why this isn't made explicit |
| 07:10 | Foxboron | borkdude: dunno tbh :/ |
| 07:10 | lucian | borkdude: it's the default anyway |
| 07:10 | lucian | it's what people mean when they say "python" |
| 07:10 | Foxboron | lucian: naaahhhh |
| 07:10 | Foxboron | It would be true a few months ago. But lately Python3 is on the march. |
| 07:11 | lucian | it's still not practically usable |
| 07:11 | lucian | it will be in a few years, but 2.7 is what we all use |
| 07:11 | Foxboron | lucian: no, but it's getting more and more common. |
| 07:11 | lucian | i'd say very slightly more common that it has been. there are still many useful libraries missing, and more importantly PyPy |
| 07:12 | lucian | portability between CPython 2.7 and PyPy is more useful |
| 07:12 | lucian | and is likely to require similar effort |
| 07:13 | Foxboron | i totally agree. |
| 07:13 | Foxboron | But again. saying python nowdays dosnt explicitly mean python2.7. |
| 07:17 | borkdude | Python 3 was my first real introduction to Python ;) |
| 07:17 | borkdude | so it's my default anyway |
| 07:17 | Foxboron | borkdude: virtualenv is awsome if you encounter some problems with 2 and 3 :P |
| 07:18 | borkdude | Foxboron yup, I have one env for 3.0 and one for 2.7 :) |
| 07:18 | borkdude | Foxboron also I like Pycharm, which supports virtualenv |
| 07:25 | cemerick | does anyone else get compilation warnings w/ defprotocol in a cljs repl? No warnings are emitted when compiling outside of a REPL... |
| 07:28 | ChongLi | hmm |
| 07:29 | ChongLi | can't even bring up the repl right now |
| 07:29 | ChongLi | caching jvm class names forever |
| 07:29 | cemerick | hah |
| 07:29 | cemerick | actually, I only get warnings if I've moved the repl outside of cljs.user |
| 07:29 | ChongLi | I don't rely on the cljs repl too much |
| 07:30 | cemerick | yikes |
| 07:30 | Bronsa | cemerick: Use of undeclared Var? |
| 07:30 | cemerick | Bronsa: yeah, for each of the fn/method names of the protocol |
| 07:30 | Bronsa | yep |
| 07:30 | Bronsa | me too |
| 07:30 | cemerick | is that expected? |
| 07:30 | Bronsa | I have no idea |
| 07:30 | ChongLi | it's been difficult to deal with |
| 07:30 | cemerick | lol |
| 07:30 | Bronsa | I wouldn't think so |
| 07:31 | ChongLi | I'm not sure how to get it to bring new macros in after they've been added |
| 07:31 | ChongLi | I mostly use cljsbuild auto and reloading the browser :( |
| 07:32 | ChongLi | and I can't figure out how to get a browser-connected repl working since my application depends on XHR |
| 07:32 | ChongLi | and that requires a server |
| 07:32 | ChongLi | obviously |
| 07:32 | cemerick | you end up needing using two http servers |
| 07:33 | cemerick | your one for ring, and then another that the browser repl starts |
| 07:33 | ChongLi | can the browser one make XHRs to the ring server? |
| 07:33 | cemerick | ChongLi: as a result of a REPL evaluation? sure. |
| 07:34 | ChongLi | hmmm |
| 07:34 | ChongLi | I'll take another look |
| 07:34 | cemerick | I've been picking away at "fixing" all of these things, but every one I knock down, a new one pops up. |
| 07:34 | ChongLi | for some reason I had it stuck in my mind that the cross origin policy required the same server, but that doesn't make sense |
| 07:35 | ChongLi | a lot of sites use multiple servers; scaling wouldn't be possible otherwise |
| 07:35 | ChongLi | alright, time to take another crack at piggieback |
| 07:36 | ChongLi | hmm, emacs is locked up hard on caching jvm class names |
| 09:42 | SurlyFrog1 | Okay, I think I've made progress on my understanding of laziness. I would really appreciate it if someone could take a brief look at this code: http://pastebin.com/ub5p2aTq It is an iteration on the code I wrote yesterday (http://pastebin.com/BQLSEvBs) which amalloy and gfredericks properly pointed out looks like a straight port from Common Lisp and was not actually lazy. |
| 09:49 | clgv | SurlyFrog1: is this a training exercise? otherwise you should use `concat` |
| 09:50 | alexnixon | SurlyFrog1: looks good, minor points: in the "one seq has data" case you can just return that seq, there's no need to recurse; I believe it's more conventional to use :else rather than :done |
| 09:50 | clgv | alexnixon: yes thats righ |
| 09:50 | SurlyFrog1 | alexnixon: thanks, I was wondering about that. |
| 09:51 | clgv | and you could end the `cond` with :else (seq b) |
| 09:51 | SurlyFrog1 | clgv: not sure `concat` does what I need it to. I want to merge two already sorted seqs (as in a merge-sort) |
| 09:52 | SurlyFrog1 | clgv: sure, that's shorter |
| 09:52 | clgv | SurlyFrog1: oh, I did not read your predicate in the if statement |
| 09:53 | clgv | well then I would end the statement with: (cond ... (seq a) a :else (seq b)) |
| 09:54 | SurlyFrog1 | clgv: yep, that makes sense |
| 10:12 | amphtrox | I need some help :( http://pastebin.com/xMXQ2bzs |
| 10:15 | Chousuke | amphtrox: bindings gets bound to the list you pass it as parameter there |
| 10:22 | jeremyheiler | amphtrox, Are you trying to re-create with-open? |
| 10:23 | amphtrox | kind of |
| 10:24 | amphtrox | but this is a simpler, flawed version |
| 10:25 | jeremyheiler | One problem, as Chousuke said, when you cons onto a vector it becomes a seq, and let only allows a vector for the bindings. |
| 10:38 | amphtrox | jeremyheiler ok thank you, do you have any idea of an alternative solution? |
| 10:38 | amphtrox | im getting nowhere with this :( |
| 10:39 | jeremyheiler | What's your reasoning for not using with-open? |
| 10:45 | amphtrox | i got this as an assignment is class, to make this macro |
| 10:46 | TimMc | amphtrox: Best to note that up-front when asking for help. |
| 10:47 | amphtrox | they expect us to write this macro after one lecture in clojure? is that reasonable? |
| 10:47 | Chousuke | amphtrox: make sure you understand what each parameter is getting bound to for each call you make to the macro. |
| 10:47 | amphtrox | never touched functional languages before |
| 10:47 | Chousuke | basically all you're doing is data structure transformation |
| 10:48 | Chousuke | you get the macro parameters, and produce a data structure that corresponds to whatever you want. |
| 10:48 | Chousuke | a good way to get started is to just write down a few invocations of the macro |
| 10:48 | Chousuke | and then the code that the invocations should expand to |
| 10:50 | SurlyFrog1 | Is there a clean way to interrupt a computation in an nrepl buffer inside emacs? I've told my REPL to do something amazingly dumb that will take forever…. o_O |
| 10:51 | lucian | amphtrox: there are lectures in clojure? cool |
| 10:51 | jeremyheiler | SurlyFrog1, C-c C-b |
| 10:52 | SurlyFrog1 | jeremyheiler: thanks |
| 10:53 | amphtrox | Chousuke ok thank you, ill try that |
| 10:53 | amphtrox | lucian its a part in a course where we try different programming paradigms |
| 10:54 | lucian | amphtrox: i see. interesting |
| 11:00 | Frozenlock | technomancy: I can't reproduce your serializable example... I obtain (serializable.fn/fn [x] (+ 1 2)) instead of (fn [x] (+ 1 2)). How do you get rid of the namespace prefix? |
| 11:01 | Frozenlock | I did (use '[serializable.fn :only (fn)]) beforehand to bring it in the current namespace. |
| 11:09 | technomancy | Frozenlock: I actually haven't used serializable-fn since I wrote it at a seajure meeting, sorry. |
| 11:14 | luxbock | how does one use clojure.java.shell/with-sh-dir? |
| 11:14 | luxbock | I can't find any examples of how to use it and nothing I try seems to work |
| 11:16 | jeremyheiler | luxbock, Looking at the source, it appears the variables you can bind are *sh-dir* and *sh-env* ... is that what is troubling you? |
| 11:17 | jeremyheiler | err... I suppose you just need to pass a string or File as the binding for with-sh-dir, so nevermind. |
| 11:17 | jeremyheiler | What is your problem? |
| 11:18 | luxbock | say I have a file called file.exe in C:\Stuff and I want to access its output from Clojure |
| 11:18 | luxbock | how do I do that? |
| 11:22 | jeremyheiler | I assume it woud be like this: (with-sh-dir "C:\\Stuff" (sh "file.exe")) |
| 11:22 | jeremyheiler | The output would be a map with the :out key |
| 11:24 | luxbock | yeah that's what I tried but it doesn't appear to work |
| 11:24 | jeremyheiler | That doesn't help me help you. What is your problem? |
| 11:25 | luxbock | ahhhh, it was working, I just misinterpreted the message I was getting |
| 11:25 | luxbock | thanks |
| 11:27 | jeremyheiler | luxbock, no problem. |
| 11:34 | Frozenlock | (def my-fn clojure.core/fn) ---> CompilerException java.lang.RuntimeException: Can't take value of a macro |
| 11:34 | Frozenlock | o_O |
| 11:36 | TimMc | ,@#'fn |
| 11:36 | clojurebot | #<core$fn clojure.core$fn@69e9764a> |
| 11:36 | TimMc | ...but you'd still need to copy over the var's metadata. |
| 11:37 | Frozenlock | Well at this point it's not a big deal. What is '@' for? |
| 11:37 | magopian | hello there |
| 11:37 | TimMc | ,'@#'fn |
| 11:37 | clojurebot | (clojure.core/deref (var fn)) |
| 11:37 | Frozenlock | I usually just use it with atoms, or in macro ~@ |
| 11:37 | TimMc | @ and ~@ are unrelated |
| 11:38 | Frozenlock | Ok so it's really just the @ as with atoms |
| 11:39 | TimMc | Yeah. |
| 11:40 | Frozenlock | Well now it works, thanks a lot :) |
| 11:45 | TimMc | Frozenlock: There may be some more complexity, such as .setMacro on the var. I think flatland/useful might have a var aliasing utility. |
| 12:00 | olenhad | Hey folks, whats the best way to deal with audio buffers in clojure? I'm writing a thin layer over java's AudioSystem for basic sound IO, and was thinking of what the clojurian way would be to copy buffers? |
| 12:12 | dnolen | olenhad: not really a best way, it's common to write a thin layer around Java interop to make it more fun to use. Some people get ambitious and write DSLs. |
| 12:24 | jonasen | dnolen: what's your take on http://dev.clojure.org/jira/browse/CLJS-470?focusedCommentId=30583&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-30583 ? |
| 12:25 | jonasen | Looking at what defprotocol expands to: Is the else-part only evaluated if (defprotocol...) is entered via the repl? I guess the "then" part is the fast-path of protocol dispatch? |
| 12:25 | olenhad | @dnolen: Yeah I was thinking of the former. My concern though is that Java uses subclasses(AudioInput/OutputStream) of Input/OutputStreams in idiomatic AudioSystem code. I could do a literal translation of the code, which in most cases is copying from AudioInputStream to a byte array using a while loop. But that seems unclojurey. |
| 12:26 | olenhad | Like here's a sample of what I mean:https://gist.github.com/olenhad/4309581 |
| 12:26 | oriig | * TODO Fix MLA alert map duplication. |
| 12:26 | oriig | * TODO Convert the old configuration file of the alert hints* TODO Fix MLA alert map duplication. |
| 12:27 | olenhad | Which I think you might agree is pretty ugly code :( |
| 12:27 | Chousuke | considering it's just java calls, I don't think you can get it much neater. |
| 12:28 | dnolen | olenhad: well if you're doing audio stuff, you probably care about perf so that code seems conceptually fine to me. |
| 12:29 | oriig | ops |
| 12:29 | oriig | sorry about that |
| 12:29 | dnolen | jonasen: fqn is nothing special, that was what the original code did I believe and I simply moved it to a function to avoid code duplication |
| 12:31 | dnolen | jonasen: in fact the top case in your comment is definitely wrong - you access properties on the fn, not the protocol |
| 12:32 | jonasen | dnolen: ok |
| 12:32 | olenhad | Ah. thanks then. |
| 12:39 | cemerick | given a fully-qualified symbol, is there a standard cljs function that will "resolve" that to the corresponding fn? |
| 12:39 | gfredericks | is it weird to want ring middleware that opens a db connection and then closes it only once the response has fully finished sending? |
| 12:40 | Bronsa | dnolen: ping |
| 12:40 | dnolen | Bronsa: pong |
| 12:40 | technomancy | cemerick: wouldn't that break with munging and dead code removal? |
| 12:40 | Bronsa | re: cljd-470 |
| 12:40 | Bronsa | are you asking for this? http://sprunge.us/iaHP?diff |
| 12:40 | dnolen | Bronsa: yes |
| 12:40 | weavejester | gfredericks: Is that because you want a streaming response? |
| 12:40 | Bronsa | cljs* |
| 12:40 | gfredericks | weavejester: exactly |
| 12:40 | dnolen | cemerick: no and it's not really possible under advanced compilation |
| 12:41 | jonasen | dnolen: The warning is "WARNING: Use of undeclared Var foo/f at line 2". The protocol name is Foo (with capital F), maybe we should expand to something like foo/Foo$f and not foo/f? |
| 12:41 | gfredericks | weavejester: it seems to be an awkward thing to implement |
| 12:41 | cemerick | technomancy: ignoring tree-shaking for now; such a thing would have to account for the munging, yeah |
| 12:41 | gfredericks | weavejester: though I guess you could have a lazy seq of DB results that closes the connection itself once it's been realized |
| 12:41 | cemerick | dnolen: right, there's *that* munging, too. :-/ |
| 12:42 | weavejester | gfredericks: Yes, or create an InputStream wrapper around it. |
| 12:42 | weavejester | I wonder if there should be a dedicated protocol for Ring bodies |
| 12:42 | Bronsa | dnolen: updated the patch |
| 12:42 | gfredericks | weavejester: that might be pretty cool |
| 12:43 | weavejester | Although that might be re-inventing the wheel, considering libraries like lamina |
| 12:43 | cemerick | bugger |
| 12:44 | weavejester | Lamina might be a bit heavy though |
| 12:44 | dnolen | jonasen: I still don't really understand why this only happens at REPL |
| 12:44 | dnolen | Bronsa: on the ticket? |
| 12:44 | Bronsa | dnolen: yes |
| 12:45 | gfredericks | weavejester: so in what way would it differ from the InputStream interface? e.g., what would the protocol methods be? |
| 12:45 | dnolen | Bronsa: I don't see anything changed? |
| 12:46 | Bronsa | wait, I didn't read about adding a comment |
| 12:47 | dnolen | Bronsa: and you can just explain it to me now :) |
| 12:47 | jonasen | dnolen: Is '(. x -foo$Foo$f$arity$1)' null (or undefined) in a repl and not when compiling from file? |
| 12:47 | Bronsa | dnolen: regarding the whitespace change, I changed the indentation level, did you notice I changed the "assoc-in .. (merge" to update-in .. merge |
| 12:48 | ravster1 | say, is everything in clojure lazy-evaluated by default? |
| 12:48 | dnolen | Bronsa: yes, but I still don't see why. |
| 12:48 | weavejester | gfredericks: I'm not certain. next/close would be the obvious ones, but next what? Perhaps just a seq extended with a close method? |
| 12:49 | Bronsa | well. before (get-in @namespaces [ns-name :defs sym]) would return nil and taht's why you'd need assoc-in |
| 12:49 | gfredericks | I guess responses can be closed prematurely, so that prevents assuming you can just implicitely close when the whole thing has been read? |
| 12:49 | Bronsa | now, at that point, (get-in @namespaces [ns-name :defs sym]) returns {:name name} |
| 12:50 | weavejester | gfredericks: Yes, if you have some open resource to clean up, lazy seqs don't have a way of handling that. |
| 12:51 | Bronsa | I moved that before "(analyze (assoc env :context :expr) (:init args) sym))" because that analyze call would try to analyze namespace.proto-fn before that is added in the namespace |
| 12:51 | Bronsa | you can see it as a (declare proto-fn) |
| 12:51 | dnolen | jonasen: I don't see why that matters, that's property access. |
| 12:52 | gfredericks | lazy seq extensions are interesting. I was thinking core.logic could use a lazy seq with a "step" extension |
| 12:53 | Frozenlock | Grrr... I had a redifining function that made the serialization working for both fn and defn, but the '#()' reader macro doesn't listen. |
| 12:53 | gfredericks | Frozenlock: they can't can they? clojure.core gets loaded by a reader that already has them? |
| 12:53 | Frozenlock | redefining even. |
| 12:54 | TimMc | ,'#() |
| 12:54 | clojurebot | (fn* [] ()) |
| 12:54 | TimMc | Frozenlock: #() expands to fn*, not fn. |
| 12:54 | dnolen | Bronsa: still not following - why does this affect proto fns and not other fns. |
| 12:54 | Frozenlock | Ah... that would have been too easy -_- |
| 12:55 | TimMc | And I guess that's a compiler literal. |
| 12:55 | Frozenlock | So no redefining of fn*? |
| 12:56 | TimMc | ,(let [fn* list] (fn* [] 5)) |
| 12:56 | clojurebot | #<sandbox$eval53$fn__54 sandbox$eval53$fn__54@6b281ec1> |
| 12:56 | TimMc | ,(let [fn list] (fn [] 5)) |
| 12:56 | clojurebot | ([] 5) |
| 12:56 | Bronsa | dnolen: this is not specific to protocol fns, this makes so that "(def foo (fn [] (aget *ns*.foo bar)))" doesn't throw |
| 12:57 | Bronsa | defprotocol expands to something like that, that's why it was printing a warning |
| 12:57 | Bronsa | as to why it only happens using the repl, i have no idea :) |
| 12:59 | Bronsa | s/throw/print a warning/ that is |
| 13:01 | dnolen | Bronsa: ok I see now. thanks. |
| 13:09 | jonasen | dnolen: There is a warning only for single segment namespaces: (ns foo.bar) (defprotocol Foo (f [x])) does not generate a warning |
| 13:11 | atyz | hey guys, i'm trying to deploy a composure/ring app with immutant |
| 13:11 | atyz | i get the error No :main namespace specified in project.clj. however i'm not entirely sure what the main method needs |
| 13:12 | tcrawley | atyz: come see us in #immutant and we'll see if we can get you sorted out |
| 13:13 | atyz | tcrawley: i will do! thanks |
| 13:15 | dnolen | jonasen: Bronsa: hmm, I'm going to have to think about this some more - it's not clear to me that foo.bar.-baz should trigger a resolution warning, anything in that form is about interop/implementation details. |
| 13:16 | dnolen | it's a bit strange that we get foo/-bar warnings when we emit foo.-bar |
| 13:18 | Frozenlock | http://blog.n01se.net/blog-n01se-net-p-41.html what happened to clojure-in-clojure? |
| 13:20 | dnolen | jonasen: Bronsa: yes, in the RELP, (ns foo) (fn [] foo.-bar) triggers the same warning |
| 13:20 | dnolen | er REPL |
| 13:21 | Bronsa | right |
| 13:22 | dnolen | I think line 132 in analyzer.clj should never warn - if there's not a namespace and the symbol contains a '.', we have some kind of interop thing happening. |
| 13:22 | Bronsa | so probably where to look for a fix is the (.contains s ".") branch of the analyzer |
| 13:22 | dnolen | yeah |
| 13:22 | Bronsa | s/analyzer/resolve-var |
| 13:27 | dnolen | ok that fixes it for me, and all test pass. Any objects jonasen Bronsa? |
| 13:27 | dnolen | objections |
| 13:27 | Bronsa | sounds right to me |
| 13:31 | ieure | cemerick, I'm having a super weird issue with friend. |
| 13:31 | ieure | cemerick, I'm using the http-basic workflow, but when auth fails I get a 302 to /login instead of a 401. |
| 13:32 | cemerick | ieure: sounds like a recently-fixed bug....one sec |
| 13:32 | cemerick | ieure: what version are you using? |
| 13:32 | Frozenlock | weavejester: I see that hiccup-bootstrap has bootrap.min.js included, but doesn't use it. Is there a reason? |
| 13:32 | ieure | cemerick, 0.1.3. |
| 13:33 | ieure | cemerick, So the weird part is that I wrote a unit test. It works correctly in the test, but not when I run the service. |
| 13:33 | ieure | Soooooo |
| 13:34 | weavejester | Frozenlock: hiccup-bootstrap is pretty incomplete at the moment |
| 13:34 | ieure | cemerick, Yeah, so; If I pass in credentials, right or wrong, I get the correct response (200 from my route or 401 for wrong creds). |
| 13:34 | magopian | guy, i'm very new with clojure (even though i have done 100-or-so problems on 4clojure), very noob, and am looking for where to go from there, to code/read some actual real code |
| 13:34 | ieure | cemerick, No creds at all gives me 302. |
| 13:34 | magopian | thinking about github, open source projects i could read (and even maybe cntribute to), any advices? |
| 13:35 | cemerick | ieure: see https://github.com/cemerick/friend/issues/38 and the link to :unauthenticated-handler usage in the mock app |
| 13:35 | magopian | (on project names) |
| 13:35 | weavejester | Frozenlock: I haven't had a lot of time to work on it lately |
| 13:35 | ieure | Okay cemerick. |
| 13:35 | cemerick | ieure: no creds at all should get an auth challenge |
| 13:36 | cemerick | That's what the :unauthenticated-handler allows you to force |
| 13:36 | ieure | cemerick, Right; but a 401 _is_ a HTTP Basic auth challenge. |
| 13:36 | dnolen | http://github.com/clojure/clojurescript/commit/e33a6ba9c4b6e8d744e1ac2f3e784822459a5530 |
| 13:36 | weavejester | magopian: What are your interests, in terms of programming? e.g. web design, networking, distributed computing, graphics, etc. |
| 13:37 | Frozenlock | weavejester: What?! You mean that with the SMALL libraries like ring and compojure, you don't have the time to make another one! Sheeesh! |
| 13:37 | weavejester | magopian: A project in an area you're interested in might grab your attention more than a random one |
| 13:37 | magopian | weavejester: i'm a web (django) developper at the moment, and have been for several years |
| 13:37 | cemerick | ieure: but unless you force it, the http-basic workflow doesn't know that it's the only one in play, so it's not going to send back a 401 in case the request can be auth'ed by another workflow later on |
| 13:37 | weavejester | Frozenlock: I'm such a slacker :) |
| 13:37 | Frozenlock | :P |
| 13:37 | magopian | weavejester: sure, i had a look (very quickly) at compojure, ring, lib-noir |
| 13:38 | magopian | i'm also looking for recommendation on "clean" (and if possible "simple") code to read |
| 13:38 | Frozenlock | I guess I'll have to learn bootstrap then. :/ |
| 13:38 | magopian | for example in the python world, it's well known that code from KEnneth Reitz or Armin Ronacher are awesome, perfect to read/learn |
| 13:38 | weavejester | Frozenlock: It's basically just a bunch of CSS classes for making pages look pretty. |
| 13:38 | magopian | wondering if there's something like those advices for clojure ) |
| 13:39 | magopian | i was two videos from james reeves and got mind blown |
| 13:39 | ieure | cemerick, Yeah, I get it. But in practice, do people really have >1 workflow for the same endpoint? |
| 13:39 | magopian | that's what led me to compojure/ring, not sure if it's a good start though for a beginner |
| 13:40 | weavejester | magopian: I'm glad you enjoyed the videos. I'm not sure what would be a good project to look at for a beginner, as I think I'd find it hard to judge what would be easy code to follow from a beginners point of view. |
| 13:41 | ieure | cemerick, How do you feel about having authenticate* count the workflows and use the unauth'd response if (= (count workflows) 1)? |
| 13:41 | weavejester | magopian: I like to think Ring is fairly easy to follow, and people have mentioned that in the past, but I have something of a bias when it comes to Ring/Compojure :) |
| 13:41 | magopian | hahaha, totally didn't get that you were james reeves, sorry ;) (btw sent you a "thank you" email this afternoon ;) |
| 13:42 | weavejester | magopian: Ah, that was you? I was going to send a response later. |
| 13:42 | magopian | weavejester: yup ;) |
| 13:42 | magopian | as i said, it blew my mind |
| 13:42 | n_b | magopian: Look at raynes' library tentacles |
| 13:42 | magopian | coming from OOP and MVC and all that stuff... |
| 13:42 | cemerick | ieure: sure; an API endpoint that is also used by a web frontend needs to support e.g. HTTP basic + a user-interactive login |
| 13:42 | n_b | It's quite easy to understand and is well documented |
| 13:43 | magopian | n_b: https://github.com/Raynes/tentacles#readme ? awesome, i'll look at that too then ;) |
| 13:43 | magopian | thanks, that's two good starting points, thanks people |
| 13:43 | ieure | cemerick, Honestly I don't think I've ever seen that in practice either. But, whatever, would you be okay with the change I suggested? |
| 13:43 | weavejester | magopian: You might want to try writing some code, and then asking on #clojure what you could do to improve it (if anything) |
| 13:43 | weavejester | Or the clojure google group, perhaps |
| 13:43 | n_b | The pastebin he works on is quite nice too, but the name is escaping me atm |
| 13:44 | ieure | cemerick, Alternately the first/last of the workflow unauth responses could be used as the default if no specific handler is specified. |
| 13:44 | cemerick | ieure: if a workflow returns a ring response, authenticate* always sends that through |
| 13:44 | maio | is there some way to make clojure startup faster? it takes 15 seconds to "lein run" empty ring app |
| 13:44 | ieure | cemerick, I really don't see how this design works in practice, though. If you have multiple auth methods but only one unauth handler, won't N of them always get an inappropriate response? |
| 13:45 | ieure | cemerick, So if you use OAuth / interactive-form, your OAuth consumer would get the wrong flow, or your interactive would. |
| 13:45 | n_b | magopian: Refheap! Is the one. That's a good ring sample IMO. |
| 13:45 | weavejester | maio: There's drip, but I didn't have much luck with that. |
| 13:46 | cemerick | ieure: only if you try to put them both on the same URI or something |
| 13:46 | magopian | n_b: perfect, i'll add that to the list ;) |
| 13:46 | magopian | weavejester: will do that ;) is https://github.com/ring-clojure/ring the "official" repository for ring? |
| 13:46 | weavejester | magopian: Yep |
| 13:47 | ieure | cemerick, Isn't that the exact usecase you were just suggesting? |
| 13:48 | magopian | awesome, thanks again ;) |
| 13:49 | cemerick | ieure: No, because interactive-form sits on one URI, whereas http-basic can sprawl across any (and trying to http-basic auth against e.g. /login would be dumb and pointless from the client's perspective) |
| 13:49 | ieure | cemerick, Right, but wouldn't it make more sense to use different routes with one workflow per in that case? |
| 13:49 | weavejester | cemerick: In bandalore, is there a way of making a polling-receieve poll indefinitely? |
| 13:50 | ieure | You can put the same endpoints in multiple routes if you need to reuse that code. |
| 13:51 | cemerick | ieure: Perhaps, but your app routing isn't friend's concern. |
| 13:51 | cemerick | Maybe it should be, and maybe it will be for some friend-friendly add-on (esp. for establishing route-level access policies, for example), but that's not here now. |
| 13:52 | cemerick | weavejester: I barely remember that I wrote something called 'bandalore' at this point. ;-| |
| 13:52 | weavejester | cemerick: Haha :) |
| 13:52 | cemerick | weavejester: is that the fn that returns a lazy seq of messages? |
| 13:52 | weavejester | I might be submitting some pull requests for it, although it's pretty complete |
| 13:52 | cemerick | should carry on indefinitely, if memory serves |
| 13:53 | cemerick | weavejester: it's actually not; there's a bunch of SQS features that were released some time after my attention drifted |
| 13:53 | weavejester | cemerick: Yeah. There's an example where a :max-wait is set to Integer/MAX_VALUE, but as far as I can tell, it's in milliseconds, so that's a maximum of 24.85 days. |
| 13:54 | weavejester | cemerick: So for queues that aren't used much, the process might randomly end :) |
| 13:54 | cemerick | weavejester: that's got to be the strangest humblebrag of all time ;-) |
| 13:55 | weavejester | cemerick: humblebrag? |
| 13:56 | cemerick | don't worry about it, I barely know what it means :-P |
| 13:56 | weavejester | Ah, okay |
| 13:56 | cemerick | weavejester: :max-wait is millis, but doesn't correspond with any AWS api -- that's just limiting the cumulative Thread/sleep'ing that'll be done between receiving messages. |
| 13:56 | cemerick | Toss Long/MAX_VALUE at it, and you'll be good for a while |
| 13:57 | weavejester | cemerick: Ah, so it doesn't have to be an int |
| 13:57 | cemerick | weavejester: nope; not sure why I used an int... |
| 13:57 | weavejester | cemerick: That'll probably solve it. I only noticed it because a worker watching a test queue died. |
| 13:58 | weavejester | It hadn't received any data in a while. |
| 14:02 | Frozenlock | amalloy: Last week you gave me link to a middleware in ring to get the current URI. I... lost it... Could you, in your infinite generosity, give it again? |
| 14:03 | amalloy | Frozenlock: i could, but instead i'll just give you a hint to encourage future foraging: most of the interesting middlewares i use or wrote are in 4clojure |
| 14:03 | Frozenlock | Good enough, thanks! |
| 14:03 | Raynes | amalloy: And most of them get moved to lib-noir. |
| 14:04 | amalloy | good point. i wonder if you stole that one |
| 14:04 | cemerick | weavejester: I made the slightest possible change to the bandalore readme :-P |
| 14:04 | amalloy | nope |
| 14:05 | Frozenlock | Raynes: Really? I just checked lib-noir and assumed the requested part had been removed: http://www.luminusweb.net/noir-api/noir.request.html |
| 14:06 | weavejester | cemerick: Thanks :) |
| 14:07 | Raynes | Frozenlock: https://github.com/noir-clojure/lib-noir/blob/master/src/noir/util/middleware.clj is our collection of middleware. |
| 14:07 | Raynes | Relatively small middleware, anyways. |
| 14:16 | nishant | Hi! Does anyone know which namespaces are loaded in the 4clojure REPL? |
| 14:56 | muhoo | has someone already written a macro to deal with java patterns like (let [foo (Constructor.)] (.init foo) foo) ? or is it in clojure core already? |
| 14:56 | amalloy | &(doc doto) |
| 14:56 | lazybot | ⇒ ------------------------- clojure.core/doto ([x & forms]) Macro Evaluates x then calls all of the methods and functions with the value of x supplied at the front of the given arguments. The forms are evaluated in order. Returns x. (doto (new java.uti... https://www.refheap.com/paste/11259 |
| 14:56 | muhoo | doh |
| 14:56 | muhoo | thanks |
| 14:57 | amalloy | nishant: you should behave as though all you have is clojure.core, clojure.string, and clojure.set, since those are the namespaces that the repl auto-loads for you. in practice, you might accidentally have access to some others |
| 14:58 | muhoo | hmm, hot to chain them will be interesting, when i get crap like this: https://www.refheap.com/paste/11258 |
| 15:03 | amalloy | muhoo: -> and doto go together like two things that go really well together |
| 15:03 | muhoo | this is what i got so far, doesn't compile, i'll figure it out https://www.refheap.com/paste/11260 |
| 15:05 | Raynes | That doesn't do at all what you think it does, muhoo. |
| 15:05 | amalloy | i don't recommend actually doing it this way, but https://www.refheap.com/paste/11262 should be equivalent |
| 15:05 | muhoo | Raynes: yeah, it throws an exception, is what it does :-) |
| 15:06 | amalloy | oh, i don't need the -> there at all |
| 15:06 | muhoo | amalloy: wow, if you can do in 15 seconds what takes me 2 hours to do, how will i learn to do it in less than 2 hours? :-) |
| 15:07 | muhoo | amalloy: thanks though |
| 15:12 | Raynes | muhoo: The secret is that you don't need to learn to, since you can just ask amalloy. That's what I do. I actually know nothing at all, I just top off when I need it. |
| 15:13 | muhoo | i used to work at a place where the answer to almost every question was "ask jerry" |
| 15:14 | Raynes | lol |
| 15:14 | magopian | Raynes: do you need some kind of token to "ask amalloy" ? or is it free for all? :) |
| 15:14 | Raynes | muhoo: I work with Alan in person. In fact, he is right across the room from me. I'm blessed, sir. |
| 15:14 | Raynes | It's like having an encyclopedia I don't have to actually look things up in. |
| 15:14 | muhoo | oh, you're in la now? awesome! |
| 15:15 | Raynes | indeed |
| 15:15 | magopian | hey Raynes btw i read your post on "moving away from noir" this afternoon, very clear ;) |
| 15:16 | Raynes | Excellent. |
| 15:16 | Raynes | Glad to hear it. |
| 15:16 | muhoo | heh, the source of doto is exactly what i typed. |
| 15:17 | magopian | and you've been advised (with refheap) as the "code you should read because it's clear and clean" to me (as a newbie) |
| 15:18 | Raynes | Oh stop, you're making me blush. |
| 15:18 | magopian | that wasn't my aim, but eh, let it be ;) |
| 15:19 | magopian | it's so easy to see/read/give negative comments on the internet (especially in the OSS world?) |
| 15:19 | magopian | i believe it's as (much more?) important to give good feedback and thanks |
| 15:20 | Raynes | Well, it is certainly appreciated. |
| 15:20 | muhoo | it seems it's changed oer the years. i find people a lot nicer these days than a decade or two ago |
| 15:20 | magopian | muhoo: is that true? |
| 15:20 | magopian | i keep seeing a**holes spitting out venom at everything |
| 15:21 | muhoo | magopian: for a very limited value of "true", my personal experience |
| 15:21 | muhoo | well, don't hang out in #anonymous then :-) |
| 15:21 | magopian | and in general, educated and clever people dissing each other |
| 15:21 | magopian | haha :) |
| 15:21 | magopian | i believe i'm part of a pretty "cool" community (django and python devs) |
| 15:22 | muhoo | the era of the brilliant a-hole working alone i[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[Cs pretty much over. the world is big and complex, and people need to work together. that's what i've seen. |
| 15:22 | magopian | so there isn't too much meanies, but still, you more often hear advice _against_ than _for_ libraries, for example |
| 15:22 | magopian | s/too much/too many/ |
| 15:26 | muhoo | magopian: anyway, i've found the clojure world very supportive. nice people. enjoy. |
| 15:26 | magopian | muhoo: thanks ;) |
| 15:27 | magopian | let's see how it goes, i had a short stay here a few months ago when i first started learning clojure (by solving problems on 4clojure <3) |
| 15:27 | magopian | but my day job (and young daughter ;) ate away my free time |
| 15:28 | magopian | we'll see how it goes this time around |
| 16:16 | canweriotnow | Any advice for testing fns with verbose text output? |
| 16:16 | canweriotnow | like, say one that uses hiccup to generate an html table? |
| 16:26 | ivan | round-trip it back to hiccup |
| 16:29 | Seba51 | Having a function with a rest param &foo, How can I pass it a list or vector? |
| 16:30 | ivan | apply, if I assume correctly |
| 16:30 | canweriotnow | ivan can you elaborate? |
| 16:31 | ivan | canweriotnow: presumably the main annoyance is having all that ugly HTML in your test files, and perhaps this can be avoided by turning the HTML back into hiccup structures |
| 16:31 | ivan | e.g. http://stackoverflow.com/questions/11094837/is-there-a-parser-for-html-to-hiccup-structures |
| 16:31 | canweriotnow | sweet, thanks! |
| 16:31 | Seba51 | Thanks, you assumed correctly. |
| 16:33 | ivan | so does anyone have a fork of hiccup that doesn't require (h ) to avoid XSS? |
| 16:34 | ivan | presumably by keeping the entire structure until it's time to output HTML |
| 16:34 | TimMc | ivan: clojars |
| 16:34 | TimMc | Their fork screws around with protocols a bit. |
| 16:36 | ivan | their project.clj points to [hiccup "1.0.1"] |
| 16:41 | xeqi | ivan: https://github.com/ato/clojars-web/blob/master/src/clojars/web/safe_hiccup.clj |
| 16:41 | ivan | awesome, thanks |
| 16:41 | xeqi | I haven't pulled it out into its own fork yet |
| 16:42 | gfredericks | is the inverse of interleave in clojure.core? |
| 16:43 | TimMc | gfredericks: partition |
| 16:43 | TimMc | sort of |
| 16:43 | gfredericks | partition is the inverse of concat |
| 16:43 | amalloy | $google 4clojure reverse interleave |
| 16:43 | lazybot | [public jamiltron / 4clojure-solutions - GitHub] https://github.com/jamiltron/4clojure-solutions/blob/master/solutions.clj |
| 16:44 | gfredericks | that solution has quote in it O_O |
| 16:45 | ivaraasen | dnolen: ping |
| 16:45 | dnolen | ivaraasen: pong |
| 16:48 | ivaraasen | dnolen: looking at paraconsistent logic formalisms. I wonder if it would be possible to do something similar in core.logic. would be nice for inconsistent data sets |
| 16:49 | ivaraasen | dnolen: there appears to have been a Prolog dialect for this (Paralog e) |
| 16:51 | TimMc | gfredericks: Yeah, I have some concerns about that solution. |
| 16:52 | dnolen | ivaraasen: I've never looked at paraconsistent logic, but Google seems to show that some people seem interested in the topic in relation to Prolog |
| 16:54 | dnolen | ivaraasen: you could probably put create a core.logic extension to support paraKanren or some such - but I can't give any guidance on that |
| 16:56 | ivaraasen | dnolen: I'll give it a shot this weekend |
| 16:58 | dnolen | ivaraasen: might be worth prototyping against miniKanren first |
| 17:15 | siscia | hey guys, I need a little hit |
| 17:15 | siscia | it is something pretty stupid I guess... |
| 17:15 | siscia | I have a function defined like so: |
| 17:16 | siscia | (defn a [f a & more] (map f a more)) |
| 17:16 | siscia | but I have problem with the more... |
| 17:17 | Iceland_jack | siscia: Do you intend on using the identifier `a' twice? |
| 17:17 | siscia | nope, sorry |
| 17:17 | siscia | (defn function [f a & more] (map f a more)) |
| 17:19 | siscia | (defn function [f a & more] (map f a more)) |
| 17:19 | siscia | #'parallel-colt-matrix.core/function |
| 17:19 | siscia | parallel-colt-matrix.core> (function + [1 2] [3 4]) |
| 17:19 | siscia | ClassCastException clojure.lang.PersistentVector cannot be cast to java.lang.Number clojure.lang.Numbers.add (Numbers.java:126) |
| 17:19 | siscia | im pretty sure the problem is the rest argument (& more) |
| 17:19 | siscia | but i don't know how to solve it... |
| 17:19 | siscia | any ideas ? |
| 17:21 | rck | what is the eta for 1.5? |
| 17:22 | hugod | is map destructuring on protocol function arguments removed in 1.5? |
| 17:25 | dnolen | hugod: works for me |
| 17:26 | hugod | 1.5 RC15 refuses to compile such a protocol for me |
| 17:29 | amalloy | hugod: paste? i don't think anything like that has changed recently |
| 17:30 | hugod | https://www.refheap.com/paste/11264 |
| 17:31 | hugod | passes in 1.4, but not in 1.5 RC15 |
| 17:31 | hugod | code added in CLJ-1024 to reject this case |
| 17:36 | dnolen | hugod: oh, I don't think putting destructuring in the protocol def was ever really supported |
| 17:36 | dnolen | only in implementations |
| 17:37 | hugod | seems to work fine in 1.4 |
| 17:38 | dnolen | hugod: which doesn't mean it was supported |
| 17:39 | hugod | I never saw anything saying don't use it |
| 17:40 | dnolen | hugod: I think Clojure has enough cases like that where if there's isn't explicit documentation saying it's supported, it's probably not |
| 17:41 | hugod | what's the best way of getting clarification? |
| 17:42 | amalloy | i don't think this was a good patch to accept. throwing an exception for & makes sense, because otherwise you get subtly confusing behavior; but destructuring the argument name causes no problems, and can be useful as documentation |
| 17:43 | hiredman | http://books.google.com/books?id=I8KdEKceCHAC&pg=PA265&lpg=PA265&dq=protocol+destructuring+clojure&source=bl&ots=wNkKSbT7f4&sig=F_PiZFJbFfPbuRxSbJr97-vVpQ4&hl=en&sa=X&ei=2RYcUfOoFca6iwLz7IBw&ved=0CE4Q6AEwAzgK#v=onepage&q=protocol%20destructuring%20clojure&f=false not that I accept this as authority, but it is in ink |
| 17:43 | gfredericks | amalloy: could it be confusing? |
| 17:43 | gfredericks | i.e., give the impression that it's more than documentation? |
| 17:43 | dnolen | hugod: when in doubt, ask on the dev list - submit a docstring enhancement. In CLJS we like and accept warning patches to the analyzer. |
| 17:45 | dnolen | I think malformed defprotocol/type/record should be errors. |
| 17:49 | hugod | I agree the malformed protocols should error - I don't see this is as malformed though. It's specifying an arglist which is valid. |
| 17:51 | SurlyFrog | I have a list of files to operate on. I can (map io/reader (map io/resource ["file1" "file2" …])) to get them all open, however, I'd like to use that list inside a `with-open` form. Any ideas on how that could be done? |
| 17:52 | SurlyFrog | Meaning, I'd like to programmatically construct `(with-open [x (io/reader x) y (io/reader y) …]…)` without having prior knowledge about how many files might be in that list. |
| 17:54 | dnolen | hugod: I don't really have a strong opinion about it. I don't really think of destructuring as being part of the fn signature (unlike rest args), but I might be in the minority here. |
| 17:58 | borkdude | when did the original clojure.core/read(-string) evaluate code? |
| 17:59 | technomancy | borkdude: whenever *read-eval* wasn't rebound to false |
| 17:59 | borkdude | technomancy so, (clojure.core/read-string "(System/exit 0)") should exit my program? |
| 18:00 | technomancy | oh, no that'd be (read-string "#=(System/exit 0)") |
| 18:00 | technomancy | still does that, fwiw |
| 18:01 | borkdude | technomancy I see. |
| 18:03 | borkdude | technomancy so the problem would arise in for example a web application if someone entered #=(System/exit 0) in a text field where you expected some other string |
| 18:03 | technomancy | sure, if you're lucky |
| 18:04 | borkdude | (clojure.core/read-string "#=(System/exit 0)") ;;=> ClassNotFoundException System java.net.URLClassLoader$1.run (URLClassLoader.java:202) |
| 18:04 | technomancy | oh, that'd be java.lang.System |
| 18:04 | arrdem | clojurebot anyone? |
| 18:04 | borkdude | ah yes |
| 18:04 | technomancy | if you're not lucky they make off with sensitive user data; wipe your DB and backups, and send rude letters to upper management |
| 18:06 | borkdude | (clojure.edn/read-string "#=(java.lang.System/exit 0)") ;;=> RuntimeException No dispatch macro for: = clojure.lang.Util.runtimeException (Util.java:219) |
| 18:07 | amalloy | technomancy: as rhickey pointed out, read-string runs [some] code regardless of the read-eval settings, eg via the #my.record[1 2 3] syntax |
| 18:07 | technomancy | amalloy: yeah, borkdude was specifically asking about the "original" read-string |
| 18:07 | technomancy | that stuff was a later addition |
| 18:08 | amalloy | well, 1.3 |
| 18:08 | technomancy | back when the reader was cool, and before all this new nonsense =\ |
| 18:08 | pjstadig | technomancy: you're such a reader hipster |
| 18:08 | arrdem | technomancy: our reader is still pretty dang cool... no reader macros and "fun stuff" |
| 18:09 | technomancy | pjstadig: it used to be you could trust the reader! |
| 18:09 | dnolen | borkdude: even w/ *read-eval* set to false too many loop holes in read - the subtleties of http://tenderlovemaking.com/2013/02/06/yaml-f7u12.html is a good analogy |
| 18:10 | technomancy | trying to come up with a metafictional/fourth-wall joke here but I'm having a hard time, sorry |
| 18:10 | SegFaultAX | technomancy: Are you not a fan of ednor reader literals? |
| 18:10 | SegFaultAX | edn or* |
| 18:11 | borkdude | amalloy do you mean "read macros" still form a security issue in the edn/read-string? |
| 18:11 | technomancy | SegFaultAX: I'm fairly horrified by the fact that the reader can return mutable objects; the fact that they can be java.util.Date (the worst class in the entire JDK) is salt on the wound. the uuid literals aren't horrible so much as silly. |
| 18:12 | borkdude | amalloy readER macros |
| 18:12 | technomancy | SegFaultAX: edn strikes me as just an attempt to get back what we had before reader literals complicated things. |
| 18:13 | technomancy | well, that's the charitable explanation that doesn't ascribe it to an attempt to drum up support for community-created datomic drivers in other languages anyway |
| 18:13 | borkdude | does anyone really use custom reader literals? |
| 18:13 | dnolen | borkdude: yes |
| 18:14 | SegFaultAX | Why is the reader returning mutable objects a bad thing necessarily? |
| 18:15 | technomancy | it used to be you could make assumptions about the stability of what the reader returned; now you can't |
| 18:15 | hiredman | technomancy uses a monkey patched version of jdbc that doesn't return java.sql.Date or java.sql.Timestamp |
| 18:15 | technomancy | assuming you're dealing primarily with values is one of the major draws of Clojure |
| 18:16 | technomancy | hiredman: well, nobody claims jdbc is particularly good |
| 18:17 | technomancy | if a database is involved, you necessarily already have to start paying more attention because things are going to be messy |
| 18:18 | borkdude | it is one giant mutable thing, scary |
| 18:18 | technomancy | mutability on its own is a problem, but j.u.Date is an incredible case of bad API design on multiple fronts |
| 18:19 | hiredman | we use dates (java.util and java.sql) all over at work, in large part because they come from jdbc, guess how many bugs we've have due to java.util.Date being mutable? |
| 18:19 | borkdude | technomancy I agree. I didn't work in Java for a long time, but was used to Dates in C#. When I returned to Java, this was the first thing that put me off. |
| 18:19 | technomancy | zero means 1900 now, didn't you get the memo? ugh. |
| 18:19 | hiredman | (ask about simpledateparser bugs and it is another story) |
| 18:20 | amalloy | ugh, dateformat. why would you not make that class thread-safe? |
| 18:20 | hiredman | cause you hate freedom |
| 18:22 | SurlyFrog | Can you not have a `doseq` in a `finally` block? Something about being able to recur from a catch/finally |
| 18:22 | SurlyFrog | 'Cannot recur from catch/finally' |
| 18:23 | borkdude | thanks for the info and good night |
| 18:23 | gfredericks | SurlyFrog: sounds right |
| 18:23 | SurlyFrog | that's a bummer... |
| 18:24 | Frozenlock | technomancy: ping when you'll come up with your reader implementation, I'd like to not be afraid to use a read function |
| 18:24 | technomancy | SurlyFrog: I think you can use dorun+for. bit ugly but it works |
| 18:24 | technomancy | Frozenlock: heh, well it sounds like they're spinning off a safe tools.reader contrib |
| 18:24 | SurlyFrog | technomancy: thanks, I'll try it. |
| 18:25 | hiredman | tools.reader is based on blind, and turning it to a contrib was started some time ago |
| 18:25 | hiredman | https://github.com/Bronsa/blind |
| 18:26 | technomancy | I was thinking the edn bits might come from clojure, but actually I have no idea |
| 18:27 | hiredman | https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader/edn.clj#L101 :( |
| 18:28 | hiredman | lets around top level forms make me sad |
| 18:28 | Bronsa | me too. but hardcoding constants that are not self-explanatory makes me more sad than that |
| 18:28 | SurlyFrog | technomancy: nope, same compiler issue using `dorun` and `for` |
| 18:29 | hiredman | they should be defs obviously |
| 18:30 | SurlyFrog | I'm trying to write my own `with-open` that will take a seq of files. So I thought I'd wrap it in a `try/finally` block. Using the finally to run down the seq and call close on each file. |
| 18:30 | SurlyFrog | but it doesn't appear possible |
| 18:31 | technomancy | mapv maybe? |
| 18:31 | SurlyFrog | hmmm…let me look |
| 18:31 | Bronsa | hiredman: meh. I kinda prefer it that way honestly. |
| 18:32 | technomancy | Bronsa: jump-to-definition doesn't work on locals =\ |
| 18:32 | technomancy | neither does eval-at-point |
| 18:32 | Bronsa | :( |
| 18:32 | enquora | http://clojurescriptone.com/getting-started.html purports to provide a guide to getting started with clojurescript but the first lein command, 'lein bootstrap' is unknown/invalid. Is this for real? can anyone explain? |
| 18:32 | SurlyFrog | technomany: Thanks! That works! |
| 18:33 | technomancy | SurlyFrog: cool |
| 18:33 | technomancy | enquora: clojurescriptone isn't actively maintained from what I can tell. they assume you use a very old version of leiningen. |
| 18:33 | Bronsa | technomancy: you just reminded me how an emacs noob I am. thanks. |
| 18:33 | technomancy | heh |
| 18:33 | enquora | thks. not for real, then |
| 18:33 | SurlyFrog | So, it looks like this: http://pastebin.com/Z28ktkfz |
| 18:34 | SurlyFrog | That's a testing stub, but hopefully the right idea |
| 18:34 | hiredman | def is always prefered, "encapsulation" and "information hiding" is how you build non-reusable components |
| 18:34 | technomancy | SurlyFrog: maybe a comment saying "I know, I know; mapv isn't right for this, but the compiler disallows doseq" |
| 18:34 | SurlyFrog | technomancy: oh yeah, this one is going to have an essay above it :-) |
| 18:34 | technomancy | heh |
| 18:35 | Bronsa | hiredman: right, but that's only ever used in read-char* and only to avoid hardwriting a constant, but meh. I can change that to a def. |
| 18:36 | hiredman | Bronsa: code doesn't exist in vacuum, jsut because you only use magic constants in one place doesn't mean other people won't want access to them |
| 18:37 | hiredman | in a, just, etc |
| 18:38 | enquora | am looking for examples of a distributed client/server app using both clojurescript and clojure. Clojurescript examples seem thin on the ground in any form - anything out there? |
| 18:40 | xeqi | cemerick: did you use any clojure libraries for the stripe integration on clojureatlas? |
| 18:48 | Frozenlock | ... ok this one surely is obvious... what is the function like `for', but which isn't lazy? |
| 18:48 | Frozenlock | I'm always doing (into [] (for... and I'm pretty sure there must be another solution. |
| 18:56 | pbostrom | Frozenlock: doseq |
| 18:57 | Frozenlock | but doseq returns nil |
| 18:57 | jao | doall |
| 18:57 | Frozenlock | as in (doall (for... ? |
| 18:57 | jao | yes |
| 18:58 | Frozenlock | Well... yes I gain 1 character over into [] |
| 18:58 | Frozenlock | :P |
| 18:58 | jao | (defmacro for* [& body] `(doall (for ~@body))) |
| 18:58 | jao | :) |
| 19:29 | finnj | why does the filter function require key in a map to be integer? |
| 19:30 | amalloy | &(get [] :a) |
| 19:30 | lazybot | ⇒ nil |
| 19:30 | amalloy | &([] :a) |
| 19:30 | lazybot | java.lang.IllegalArgumentException: Key must be integer |
| 19:30 | finnj | Yes, thats the one |
| 19:32 | cemerick | xeqi: just clj-http; the stripe API is basically too simple to bother writing a Library™ |
| 19:33 | TimMc | amalloy: I don't understand how you got from the stated problem to the actual problem like that. |
| 19:33 | Frozenlock | xeqi: https://github.com/abengoa/clj-stripe |
| 19:33 | amalloy | TimMc: practice |
| 19:33 | hiredman | it obviously isn't a map, becuase maps don't require integer keys |
| 19:34 | amalloy | a thorough memory of the error messages clojure produces, i suppose |
| 19:34 | TimMc | I fixated on "filter". |
| 19:35 | finnj | hiredman: ok, could you just look at this gist? https://gist.github.com/finnjohnsen/4949716 |
| 19:35 | finnj | swore I made a map, but I may very well be getting it wrong :) |
| 19:36 | hiredman | finnj: I think you should put (prn person) in the body of strong, and the result will surprise you |
| 19:36 | hiredman | (until you realize what you are doing) |
| 19:41 | finnj | hiredman: ah yes |
| 19:41 | finnj | thanks mate |
| 19:42 | finnj | map of maps made me confused :D |
| 20:04 | xeqi | Frozenlock: thanks, I saw that but it was a bit too wrapped for me, was hoping for something more map based |
| 20:05 | xeqi | cemerick: k, was what I was leaning to as well, though I played with the java api a bit |
| 20:07 | Raynes | ibdknox: pppppppppiiiiiiiiiiiiiiiiiiinnnnnnnnnnnnnngggggggggggggg |
| 20:07 | ibdknox | Raynes: pong |
| 20:07 | Raynes | ibdknox: https://github.com/noir-clojure/noir/commit/570029409f54f4ecc45b8295a6260b4b28d58346 why did you add (remove :_flash) here? yogthos and I are too astupid to figure it out. |
| 20:08 | Raynes | We're trying to figure out why wrap-noir-flash has to come before wrap-noir-session in a handler. |
| 20:09 | yogthos | yeah kind of stumped on that one :) |
| 20:10 | ibdknox | Raynes: yogthos: I think that's an artifact of trying to use ring's flash stuff. I don't think it actually matters in this implementation. |
| 20:10 | yogthos | ibdknox: that was my suspicion, I tried it without it and seemed ok, ring uses it to check the :flash from the request part I think |
| 20:11 | ibdknox | yeah |
| 20:11 | ibdknox | and that was causing issues when I tried using it |
| 20:11 | ibdknox | but I just went around it since it didn't have the same semantics as what we were shooting for |
| 20:12 | yogthos | yeah that makes sense |
| 20:12 | yogthos | so is it something in initializing the ring session wrapper that messes up the noir flash |
| 20:12 | yogthos | that's the only thing I can see wrap-noir-session doing that could cause it |
| 20:13 | yogthos | they look pretty independent otherwise |
| 20:14 | ibdknox | wait, what's the problem you're running into? |
| 20:14 | ibdknox | oh I remember now |
| 20:15 | ibdknox | so rings flash stuff uses the session with that key, which isn't part of your actual session information so I removed it. The flash stuff reads and writes to the :flash key in the request and then sticks it into the session |
| 20:15 | ibdknox | so the session has to be there |
| 20:15 | yogthos | ahhh |
| 20:17 | yogthos | it's all coming together now :) |
| 20:18 | rboyd | is there destructuring syntax to bind to the last n elements of a seq? or should I just reverse |
| 20:19 | jeremyheiler | rboyd, No. That wouldn't be good for lazy seqs. |
| 20:20 | jeremyheiler | Well, infinite lazy seqs to be more precise. |
| 20:21 | rboyd | ah |
| 20:47 | Frozenlock | Sweet... wasted 2 hours trying to debug why my computer was behaving strangely when entering http://my-site.com instead of http://www.my-site.com. Turns out I had a configuration for it in my host file. |
| 20:47 | Frozenlock | (dec Frozenlock) |
| 20:47 | lazybot | You can't adjust your own karma. |
| 20:48 | Frozenlock | Oh... lazybot evolved? |
| 20:51 | gozaboru | is there an idiomatic way to represent subsequent pairs of a seq? (e.g. [1 2 3 4] to ['(1 2) '(2 3) '(3 4)]) |
| 20:51 | amalloy | ~partition |
| 20:51 | clojurebot | partition is probably not what you want; see partition-all. |
| 20:51 | amalloy | hmph |
| 20:51 | amalloy | (partition 2 1 [1 2 3 4]) |
| 20:52 | gozaboru | oh cool, I read the step as step after the last value, not the first |
| 20:52 | gozaboru | thanks! |
| 21:00 | dxeh | what is the closest thing to structs from C in clojure? |
| 21:00 | amalloy | maps |
| 21:01 | dxeh | amalloy: wat |
| 21:01 | dxeh | you know what i mean by struct right? and if so then ok ill go look up maps |
| 21:01 | amalloy | of course |
| 21:01 | amalloy | hash maps are what we use for structs |
| 21:02 | dxeh | amalloy: alright, because im looking to rewrite this in clojure https://github.com/dxeh/svm/blob/master/src/clsfile.h |
| 21:03 | dxeh | maps still the best way? |
| 21:04 | ieure | dxeh: You might want to use a structmap if you're going to be creating a lot of those: http://clojure.org/data_structures#toc19 |
| 21:05 | ieure | dxeh: But, yeah, Clojure has a much more dynamic type system, so you basically just use hash-maps for this kind of thing. |
| 21:06 | dxeh | alright ieure :P i know many languages but none like clojure so i was like "map...? " lol |
| 21:06 | amalloy | structmaps have been dead for longer than michael jackson |
| 21:06 | dxeh | mj hasnt been dead THAT long |
| 21:06 | dxeh | well |
| 21:06 | dxeh | i guess he has |
| 21:06 | dxeh | but not in the literal term |
| 21:07 | ieure | dxeh: Python and Ruby are similar in terms of data structures. |
| 21:07 | TimMc | ieure: Records are the new structmap. |
| 21:08 | ieure | TimMc, amalloy, Sure, okay. |
| 21:09 | dxeh | ieure: oh, well i actually only know C,java,javascript,C++,C#,groovy and html lol i dont exactly know either of those languages (although i've heard of them obviously and seen snippets) |
| 21:09 | TimMc | dxeh: Well, what would you do in JS for a struct? |
| 21:10 | amalloy | it turns out i was actually wrong about MJ. struct-maps survived him by almost a year |
| 21:10 | TimMc | Let that be a lesson. |
| 21:11 | amalloy | i guess "random guessing" isn't always the best approach to historical allusions |
| 21:11 | TimMc | (And if you figure out what the lesson is, I'm very curious to know what you come up with.) |
| 21:11 | amalloy | see above |
| 21:11 | dxeh | TimMc: i would probably just create a new class file |
| 21:11 | dxeh | depending on the size of struct/situtation etc |
| 21:12 | TimMc | amalloy: I meant the "struct-maps outliving MJ" part. Meh. |
| 21:12 | TimMc | dxeh: JS doesn't have classes. You mean a prototype? |
| 21:12 | amalloy | oh, i see |
| 21:13 | TimMc | dxeh: And that prototype would just be an Object... which is a hash map. |
| 21:13 | cemerick | amalloy: "almost a year"? struct-maps are alive and well, no? |
| 21:13 | dxeh | well yes Timmc in literal form i meant i would create a new javascript source file and handle it tha way with a prototype |
| 21:13 | amalloy | cemerick: they still exist as a deprecated feature, but as far as i know new code is supposed to act like they don't exist |
| 21:13 | TimMc | Wait, you'd create a new source file for every struct? |
| 21:14 | cemerick | oh, sure |
| 21:14 | amalloy | hah |
| 21:14 | amalloy | alas no |
| 21:14 | dxeh | TimMc: as i said depending on the situtation (and size of the struct) |
| 21:14 | cemerick | "Four more years!" :-P |
| 21:14 | amalloy | no feature will ever be removed from clojure, except the ones that cause rich a problem someday |
| 21:15 | dxeh | anyways where can i learn about records in clojure |
| 21:15 | cgag | I pulled some code out of one of my projects into its own project, ran `lein install`, then added the new project as a dependency of the old. When I run my project now I end up hitting runtime errors for missing dependencies, though I have these listed in the new projects project.clj. Am I doing anything obviously wrong (if you can tell from this vague description)? |
| 21:27 | TimMc | cgag: The new dependency, is it a SNAPSHOT version? |
| 21:29 | dxeh | TimMc: how can i store an array value within a record? |
| 21:29 | warz | is there a better way to pluck a key out of each map in a collection than using map? i can just do (map :key [ ... ]) and it seems to do what i want |
| 21:29 | warz | but idk if theres a better way |
| 21:31 | gfredericks | warz: that's it |
| 21:31 | gfredericks | I can't imagine a denser way of communicating that idea |
| 21:32 | warz | well me either, but ya never know! :) |
| 21:32 | warz | i tried (:key [ ... ]) |
| 21:32 | TimMc | dxeh: Clojure is dynamically typed, just like JS. You can just do {:foo ["bar" "baz"]} |
| 21:33 | gfredericks | warz: good point |
| 21:33 | gfredericks | if clojure were ruby I expect that would work |
| 21:33 | TimMc | dxeh: That's a map of one key-value pair, where the key is a keyword and the value is a vector (array-like thing). |
| 21:34 | warz | i dont really know ruby, i was just going off of my beginner's experience which is that "clojure seems to work as id expect" |
| 21:34 | warz | i didnt know if map would work because i didnt know if itd treat :key as a function, or whatever |
| 21:34 | warz | but it does |
| 21:34 | gfredericks | well that's not a feature of map |
| 21:34 | gfredericks | that's a feature of keywords |
| 21:34 | gfredericks | ,(ifn? :foo) |
| 21:34 | clojurebot | true |
| 21:34 | warz | ah, i see |
| 21:34 | warz | well that explains it |
| 21:35 | gfredericks | warz: also note ##(:foo {:bar 12, :foo 16}) |
| 21:35 | lazybot | ⇒ 16 |
| 21:35 | xeqi | dakrone: is there an example of using try+/catch with clj-http? |
| 21:36 | warz | yea thats why i tried (:foo [{ ... }, ... ]) |
| 21:36 | gfredericks | ,(:foo []) |
| 21:36 | clojurebot | nil |
| 21:37 | warz | i think its just the difference between applying :foo to each item in that collection versus the whole collection |
| 21:37 | gfredericks | warz: vectors are quasi-maps (with integer keys), so it's conceivable that somebody might try looking up a keyword in a vector |
| 21:42 | tommo | ,(re-seq #"(.+)\\1+" "apple") |
| 21:42 | clojurebot | nil |
| 21:43 | tommo | why doesn't it match "pp"? |
| 21:43 | gfredericks | ,(re-seq #"(.+)\1+" "apple") |
| 21:43 | clojurebot | (["pp" "p"]) |
| 21:43 | tommo | ahh ok |
| 21:44 | tommo | so it was escaping the literal 1? |
| 21:44 | tommo | why does that work in other languages then o.O |
| 21:44 | andyfingerhut | One gets so accustomed to double-backslashes in strings that it is easy to forget you don't need them in Clojure regexes |
| 21:44 | andyfingerhut | Clojure has special parsing for regexes that is different than how it does for strings. |
| 21:44 | tommo | fantastic, thanks alot |
| 21:45 | dxeh | why would (if (not= (.magic file) -889275714) be true and (if (not= (.magic file) 0xCAFEBABE) be false when -889275714 is equal to 0xCAFEBABE...? |
| 21:46 | gfredericks | ,0xCAFEBABE |
| 21:46 | clojurebot | 3405691582 |
| 21:46 | tommo | 3405691582 |
| 21:46 | gfredericks | ,(type 0xCAFEBABE) |
| 21:46 | clojurebot | java.lang.Long |
| 21:47 | dxeh | ah maybe its because in java its represented by 32 bit int but in clojure is int sized as 16? |
| 21:48 | cgag | TimMc, it's not a snapshot version |
| 21:48 | warz | i have a hard time figuring out when to insert new lines into my code, lol. my functions end up being all on the same line. |
| 21:48 | gfredericks | dxeh: it's a 64-bit long |
| 21:48 | TimMc | cgag: (I was thinking you might be getting Maven lookup failures if the dep only existing locally, and it *would* check for newer snapshots.) |
| 21:48 | cgag | if i run a repl for the library i made and call the function it works fine, when I call it from the code that depends on it, i get the dependency errors |
| 21:49 | TimMc | gfredericks: I always have to think "byte, short, int, long" to remember the number of bits in a long. |
| 21:49 | gfredericks | TimMc: that's weird; int/long have absolute meanings for me. byte and short I'd probably have to think about for a second. |
| 21:49 | TimMc | cgag: Are you sure you saved project.clj? :-P |
| 21:50 | warz | yea int/long same for me |
| 21:50 | TimMc | gfredericks: I just know that those double in size with each step. :-) |
| 21:50 | warz | thats why they easy to visualize though |
| 21:50 | hyPiRion | I have trouble with nibbles. |
| 21:50 | TimMc | Byte (thank god) has absolute meaning these days unless otherwise specified. |
| 21:50 | tommo | gotta love dat 4bit nipple |
| 21:51 | gfredericks | TimMc: I was wondering why bytes mattered anymore until I remembered that file sizes are based on them |
| 21:51 | dxeh | 8 16 32 64, byte short int long respectively (and usually) |
| 21:51 | hyPiRion | gfredericks: they're based on bits as well. Or longs, for that matter |
| 21:52 | hyPiRion | it's just a perspective |
| 21:52 | warz | just think in bits |
| 21:53 | dxeh | 11101001 |
| 21:53 | warz | and youll have an anjoyable time :p |
| 21:53 | dxeh | that twos compliment gets me every time xd |
| 21:53 | gfredericks | once you work out your endianness |
| 21:53 | hyPiRion | it's not that hard if you convert to hex |
| 21:55 | hyPiRion | 1110 -> E, 1001 -> 9, E*16+9 = 224 + 9 = 233 |
| 21:56 | dxeh | whats the BITWISE and operator in clojure |
| 21:56 | TimMc | ,(use 'clojure.repl) |
| 21:56 | clojurebot | nil |
| 21:56 | TimMc | ,(apropos "bitwise") |
| 21:56 | clojurebot | () |
| 21:56 | hyPiRion | ,(bit-and 1 3) |
| 21:56 | clojurebot | 1 |
| 21:57 | TimMc | ,(apropos "bit-") |
| 21:57 | clojurebot | (bit-or bit-set bit-xor bit-flip bit-and ...) |
| 21:57 | dxeh | o cool |
| 21:57 | dxeh | thanks |
| 21:59 | dxeh | err |
| 21:59 | dxeh | shift operators are ? hyPiRion |
| 21:59 | dxeh | nvm bit-shift-left i guess |
| 21:59 | tommo | bit-shift |
| 22:00 | tommo | ,(apropos "bit-shift") |
| 22:00 | clojurebot | (bit-shift-left bit-shift-right) |
| 22:01 | cgag | TimMc, where i put the dependency on my library in project.clj seems to matter, does that make any sense? |
| 22:02 | cgag | It's on the classpath either way, but I don't get class not found errors if i put the dep first in the list |
| 22:05 | hyPiRion | dxeh: you're sharp |
| 22:07 | TimMc | dxeh: And if you're looking for the *other* bit-shift-right, it's not there. |
| 22:08 | TimMc | I opened a ticket for it and attached a patch, but no luck so far. |
| 22:08 | dxeh | lol TimMc :( |
| 22:08 | dxeh | you mean unsigned right shift |
| 22:08 | dxeh | >>> |
| 22:09 | tommo_ | who even uses dat |
| 22:09 | TimMc | dxeh: Yeah. |
| 22:09 | dxeh | tommo_: its basically the same as doing >> & 0xFF (or FFFF, or FFFFFFFF etc depending on size of sign extension) |
| 22:10 | TimMc | tommo_: *shrug* It's missing, everybody else supports it, and there's no reason not to have it. |
| 22:10 | TimMc | How often do you use *any* of the bit shift operators? |
| 22:10 | dxeh | quite often actually |
| 22:10 | tommo_ | TimMic: gotta shift dem rgb bits |
| 22:10 | tommo_ | ! |
| 22:11 | dxeh | addin dat alpha |
| 22:11 | tommo_ | packin dem bits |
| 22:11 | hyPiRion | Oh right. |
| 22:11 | hyPiRion | ,0xFFFFFFFF |
| 22:12 | clojurebot | 4294967295 |
| 22:12 | hyPiRion | ^- Java return -1 there |
| 22:12 | hyPiRion | Be aware when you port stuff using e.g. RGBA. |
| 22:12 | tommo_ | ,(Integer/toBinaryString 0xFFFFFFFF) |
| 22:12 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for int: 4294967295> |
| 22:16 | dxeh | just wrote |
| 22:16 | dxeh | the most confusing line of my life |
| 22:16 | dxeh | http://pastebin.com/xT312bUW |
| 22:19 | cgag | looks like friend is importing an older version of one of the dependencies i use, so mine only worked if i played it before friend in the classpath |
| 22:19 | cgag | what would the proper way to have discoverd that have been? |
| 22:19 | cemerick | cgag: lein-pedantic |
| 22:19 | cgag | i just manually shifted the dep around until i isolated it and looked at friends project.clj |
| 22:19 | cgag | i'll check that out, thanks |
| 22:21 | amalloy | &(unchecked-int 0xCAFEBABE) |
| 22:21 | lazybot | ⇒ -889275714 |
| 22:31 | dxeh | hey amalloy |
| 22:31 | dxeh | how would i use an unchecked int to check if .magic == 0xcafebabe |
| 22:33 | cgag | that pedantic plugin found like a dozen other potential problems, good stuff |
| 22:34 | Frozenlock | Raynes: any plan to make clojurebot post a link to refheap whenever he sees a link to pastebin? |
| 22:36 | ChongLi | one thing that's annoying about refheap is that I can't paste with middle-mouse button into it |
| 22:36 | ChongLi | pastebin doesn't have that problem |
| 22:37 | ChongLi | I guess it's a codemirror problem? |
| 22:37 | Frozenlock | ChongLi: one thing I like about refheap is that I don't even need to use the mouse with refheap.el :P |
| 22:37 | ChongLi | ah, I wasn't aware of that |
| 22:38 | Frozenlock | If you use emacs, you can M-x refheap-paste-region and that's it! |
| 22:45 | callenbot | Frozenlock: didn't work last time I tried it. |
| 22:47 | Frozenlock | Paste-region? |
| 22:47 | callenbot | Frozenlock: da comrade |
| 22:47 | Frozenlock | Hmm no, it works :) |
| 22:47 | Frozenlock | https://www.refheap.com/paste/11271 |
| 22:48 | Frozenlock | Emacs, it just works™ |
| 22:50 | amalloy | Frozenlock: Raynes is never going to change clojurebot. and as for changes to lazybot, i think that would be an unwelcome source of extra noise |
| 22:51 | callenbot | speaking of noise, I need to ignore PARTs and JOINs in here |
| 22:51 | callenbot | too many pikers. |
| 23:05 | dxeh | are there anything like unions from C in clojure? |
| 23:05 | dxeh | or is it a type of map once again |
| 23:06 | callenbot | dxeh: whoa, you're comparing Clojure directly with C? |
| 23:06 | callenbot | dxeh: what book have you used to learn Clojure so far? |
| 23:06 | callenbot | I need to have a word with the author. |
| 23:06 | dxeh | not directly obviously but im looking to rewrite some of my C code and not sure the best way |
| 23:07 | dxeh | and i havent read any books, on anything really (other than a bit on compilers before) |
| 23:07 | callenbot | dxeh: are you a student? |
| 23:07 | callenbot | dxeh: you need to get a book and read it, performing all the exercises. You are seriously lost. |
| 23:07 | dxeh | yeah in highschool, been devving for 6 years |
| 23:07 | callenbot | dxeh: it's not the years, it's what you put in them. |
| 23:07 | dxeh | im not lost... im trying to find a way to rewrite some code |
| 23:07 | tmciver | dxeh: no unions in clojure and be thankful for it. |
| 23:08 | callenbot | dxeh: they're not languages used interchangeably, you're doing something very strange and alien and you *need a book* |
| 23:08 | dxeh | you can't be trying to tell me that just because i suck atm at clojure means i suck in every other language |
| 23:08 | callenbot | dxeh: get a goddamn book |
| 23:08 | tmciver | callenbot: settle down |
| 23:08 | callenbot | dxeh: http://www.clojurebook.com/ this is the best one out right now. |
| 23:09 | tmciver | callenbot: he's in high school, he knows C, learning clojure and on IRC . . . he's doing great! |
| 23:10 | cemerick | sounds like the next Raynes ;-D |
| 23:10 | callenbot | tmciver: needs a book. I used to be him, now I am helping him. |
| 23:10 | dxeh | not only C ^_^ multiple other languages |
| 23:10 | callenbot | cemerick: Raynes is more experienced. |
| 23:10 | dxeh | just never learned lisp |
| 23:10 | callenbot | cemerick: more meaningfully so. |
| 23:11 | callenbot | cemerick: and thanks for writing that book btw. It's still my favorite. I even used it as a reference to refresh myself from time to time. |
| 23:11 | cemerick | callenbot: Maybe, who knows. Perhaps dxeh can run circles around all of us. |
| 23:11 | cemerick | callenbot: thanks for recommending it, glad you enjoyed it :-) |
| 23:11 | tmciver | cemerick: coming to the Boston Clojure Meetup on Thursday? |
| 23:12 | cemerick | tmciver: Dunno, didn't realize it was scheduled yet, even. |
| 23:14 | tmciver | cemerick: I had to re-check but it is tomorrow night. Doesn't look like there's any info about speakers though. |
| 23:14 | cemerick | well, I shan't be there, then |
| 23:15 | tmciver | Wait a minute, I think it's cancelled anyway. :( |
| 23:15 | cgag | good or not you should get that book |
| 23:15 | tommo_ | callenbot were you trying to imply that dxeh was lost in the sense that he shouldnt be rewriting C in lisp |
| 23:16 | tommo_ | and that he should learn to write lisp |
| 23:17 | llasram | Not to speak for collenbot, but I do think the question "are there C-style unions in this garbage-collected language?" suggests that one might be wanting some pointers back to civilization |
| 23:18 | llasram | callenbot even |
| 23:18 | Raynes | dxeh: You trying to step on my turf, boy? |
| 23:18 | dxeh | perhaps you are stepping on my turf !@! |
| 23:18 | dxeh | lol |
| 23:18 | Raynes | I guess since I'm not in high school anymore someone has to take up the reins. |
| 23:18 | Raynes | Welcome to Clojureland! |
| 23:18 | Raynes | They're very accepting of us youngsters. |
| 23:18 | Raynes | You'll be right at home. |
| 23:19 | cgag | did you have to restrain yourself from saying raynes there or do i pronounce it wrong in my head |
| 23:19 | cemerick | If dxeh is in some remote locale (upstate Idaho?), then it's settled. |
| 23:19 | Raynes | callenbot: refheap.el doesn't work for you? |
| 23:19 | dxeh | nah near ottawa |
| 23:19 | dxeh | lol |
| 23:19 | Raynes | ChongLi: Something is wrong with codemirror on refheap? |
| 23:19 | ChongLi | Raynes: I can't paste with middle mouse button |
| 23:19 | Raynes | People suddenly complained about all my stuff but I missed the context! |
| 23:19 | Raynes | ChongLi: Yeah, that's a known problem in firefox, iirc. |
| 23:20 | cemerick | dxeh: Depending on who you talk to, that's roughly the same. :-P |
| 23:20 | Raynes | Firefox doesn't give you a way to grab the middle mouse click event. |
| 23:20 | Raynes | It should work in Chrome, IIRC. |
| 23:20 | callenbot | Raynes: it didn't a long time ago. |
| 23:20 | dxeh | llasram: and no that was not the case, i was looking for the best alternative to the c style'd union |
| 23:20 | dxeh | styled* lol |
| 23:20 | ChongLi | Raynes: it works fine on pastebin |
| 23:20 | Raynes | callenbot: If you try it again and it still doesn't work, let me know and I'll take a look. |
| 23:20 | Raynes | ChongLi: pastebin doesn't use codemirror. |
| 23:20 | callenbot | dxeh: get a book |
| 23:20 | ChongLi | codemirror must be doing some weird stuff then |
| 23:21 | callenbot | dxeh: the whole question is misconcieved. Get a book. |
| 23:21 | dxeh | stop telling me to get a book callenbot i wouldnt read it even if i had a book |
| 23:21 | callenbot | Raynes: hokay. |
| 23:21 | Raynes | Codemirror is not just a textarea. Firefox's textareas handle middleclicks themselves, of course. |
| 23:21 | callenbot | dxeh: you want to learn? |
| 23:21 | dxeh | because i dont _need_ a book, i never have, |
| 23:21 | dxeh | the only time i needed a book was when i was reading up on compilers a while ago |
| 23:21 | ChongLi | ahh, hmmm |
| 23:21 | callenbot | dxeh: impetuous fool. You're slowing yourself down with that stupidity. |
| 23:21 | callenbot | dxeh: you'd learn faster and more completely if you GOT A BOOK |
| 23:22 | ChongLi | firefox's gotta get on the ball! |
| 23:22 | dxeh | not sure if you are a troll or what but sometimes if you are truely intelligent you dont need a book |
| 23:22 | nightfly | dxeh: Someday you'll reach a point where you realize your knowledge is full of tiny little holes |
| 23:22 | Raynes | It's weird that they don't let you do anything with that event. IIRC, the codemirror guy had to use a hack to get it in chrome though too. |
| 23:22 | dxeh | if you can just pick things up quickly |
| 23:22 | callenbot | dxeh: that's a crock of shit. |
| 23:22 | callenbot | dxeh: I was you, 10 years ago. Comprende? I'm telling you how you can make better and faster progress than I did if you drop the prideful ignorance and GET A BOOK. |
| 23:22 | callenbot | dxeh: I did the same exact shit. I asked the same questions. |
| 23:22 | tmciver | callenbot: this is how you help? |
| 23:23 | callenbot | I wasted a huge chunk of my life being more ignorant than I needed to be because I thought I knew it all and didn't need a book |
| 23:23 | Raynes | Yes, this is how he helps. |
| 23:23 | callenbot | tmciver: ask Raynes how it looks when I don't care about helping. |
| 23:23 | Raynes | It looks bad, guys. |
| 23:23 | Raynes | Real bad. |
| 23:23 | dxeh | the question i had was only because i dont know clojure well yet, obviously i am aware there are different ways to do it and i wanted an alternative |
| 23:23 | ChongLi | yeah seriously |
| 23:23 | ChongLi | read all the books you can get your hands on |
| 23:23 | dxeh | such as there are no structs in java but you can easily get the same effect |
| 23:23 | callenbot | dxeh: the only answer you need is to get a book. |
| 23:23 | ChongLi | I think it's worth reading all of the clojure books |
| 23:23 | callenbot | dxeh: the most valuable thing you can do to learn is to get a book. |
| 23:23 | antares_ | callenbot: calm down |
| 23:24 | dxeh | you need to stop being so arrogant because you are getting no where with your petty little trolls |
| 23:24 | callenbot | dxeh: your next step should be logging into Amazon, not bickering on IRC. |
| 23:24 | Raynes | DRAMA |
| 23:24 | cemerick | as the coauthor of the book being recommended, can everyone please stop talking about books? |
| 23:24 | ChongLi | you can't force someone to buy a book, though |
| 23:24 | Raynes | o/ |
| 23:24 | Raynes | Go cemerick, it's ya birthday. |
| 23:24 | cemerick | \o |
| 23:25 | cemerick | dxeh: since I'm mostly a HLL fool, and don't remember what c unions are, could you describe what you're trying to accomplish? |
| 23:25 | antares_ | happy birthday cemerick :) |
| 23:26 | tommo | i heard a reference to Raynes, are you the current young prodigy or something :p? |
| 23:26 | callenbot | cemerick: he wants a map. |
| 23:26 | callenbot | cemerick: and dynamic typing. |
| 23:26 | callenbot | cemerick: incidentally, Clojure has both. |
| 23:26 | cemerick | antares_: it's actually not my birthday, I have no idea what Raynes is talking about :-) |
| 23:26 | Raynes | lol |
| 23:26 | callenbot | cemerick: too bad it's an incredibly malformed question indicative of severe brain damage. |
| 23:26 | callenbot | or lack of exposure...to books... |
| 23:26 | cemerick | callenbot: oh, honestly, please. |
| 23:26 | antares_ | cemerick: oh. Happy not-your-birthday then ;) |
| 23:27 | tommo | cemerick a union is where multiple elements can share the same memory, e.g. there can only be one variable residing in memory at one time |
| 23:27 | dxeh | callenbot i forgot you must be so smart cause you read 9000 books, o wait im 16 and still am intellectually superior to you without reading a single book |
| 23:27 | Raynes | tommo: I was pretty popular in 2010-11 because I was in high school and cemerick held a fundraiser to get me to the first Clojure conference. And I lived in a very small town in Alabama… And apparently I have a lot of popular projects. |
| 23:27 | dxeh | please explain your logic behind books = better |
| 23:27 | dxeh | and yes |
| 23:27 | callenbot | dxeh: your ignorant question says all it needs to. |
| 23:27 | dxeh | i just called you an idiot |
| 23:27 | callenbot | dxeh: I don't want to not be called an idiot, call me what you like. |
| 23:27 | callenbot | dxeh: I just want you to get a book. |
| 23:27 | callenbot | dxeh: I'll take all the abuse in the world - if you get a book. |
| 23:27 | dxeh | and you can want me to get a book, but it's not happening |
| 23:27 | Raynes | tommo: I'm still pretty popular. But now it's because I'm so darn awesome. |
| 23:27 | Raynes | ;) |
| 23:27 | cgag | you're better off reading a book that gives you a bigger picture idea than looking to piecemeal translate c code |
| 23:27 | tommo | sounds cool raynes, how old are you, and was clojure your first language? |
| 23:28 | callenbot | dxeh: well then you're going to have to put up with Diogenes of Sinope. |
| 23:28 | Raynes | tommo: I am 19 now. Haskell was my first language. |
| 23:28 | callenbot | Raynes: christ you're lucky |
| 23:28 | ChongLi | Raynes: oh nice |
| 23:28 | ChongLi | Haskell's a great first language |
| 23:28 | cemerick | Raynes: look, stop acting like you're so baller with your 'haskell was my first language' bit |
| 23:28 | Raynes | Hahaha |
| 23:28 | dxeh | and you will have to put up with the insanity of knowing how much time you wasted reading books once i'm superior in clojure as well |
| 23:28 | callenbot | took me ages to shake off the C-brain. |
| 23:28 | Frozenlock | Guys, stop being so entertaining :) |
| 23:28 | Raynes | cemerick: My secret is that nobody ever asks "How *good* were you with Haskell?" when they ask that question. |
| 23:29 | tommo | cool, i'm 17 atm and spent my programming upbringing in java, wish i was lucky enough to start with haskell/clojure lol |
| 23:29 | ChongLi | it's a lot easier to learn functional programming when you're not bogged down with an imperative mindset |
| 23:29 | callenbot | Raynes: did you get anything to compile? |
| 23:29 | Raynes | cemerick: I learned monads a couple of months ago. ;) |
| 23:29 | Raynes | callenbot: Sure, I wrote some stuff. |
| 23:29 | cemerick | hah, I knew it! |
| 23:29 | tmciver | dxeh: callenbot's advice to read books is certainly good even if he's being a jerk about it. |
| 23:29 | callenbot | Raynes: good enough. |
| 23:29 | cemerick | callenbot: waitaminute, you must be a common lisp fan, right? |
| 23:29 | callenbot | tmciver: you say that as if it's somehow the exception to the rule. |
| 23:29 | Raynes | tommo: You're fine. Still plenty young enough to shove it in your brain. |
| 23:29 | callenbot | cemerick: how'd you know? |
| 23:29 | cemerick | damn |
| 23:29 | cemerick | ~guards |
| 23:29 | clojurebot | SEIZE HIM! |
| 23:29 | callenbot | cemerick: no seriously...how'd you know? |
| 23:29 | cgag | tommo, you're lucky enough to be getting into it at 17 |
| 23:30 | callenbot | cemerick: I went from to C to CL, and stayed in CL for a long time until I started using Python professionally. |
| 23:30 | tommo | Raynes: hope so:P came to clojure to basically widen my perspective and learn how to now java'ise everything i write lol |
| 23:30 | Raynes | I got into Clojure at around 14-15 or something like that. |
| 23:30 | tommo | not* |
| 23:31 | dxeh | tmciver: it all depends on the person, i've learned everything i know about computers without reading a single book and i currently have a job at a professional android development country and will be having my code presented at droidcon 2013 in spain, im 16 |
| 23:31 | Raynes | I was *almost* one of the "I remember when the IRC channel had 6 people in it" people. |
| 23:31 | Raynes | But not quite. |
| 23:31 | callenbot | Raynes: I can say that I remember when rhickey would help people unfuck their classpath. |
| 23:31 | callenbot | Raynes: but not that small, no. |
| 23:31 | cemerick | callenbot: there's a certain Je ne sais quoi about interactions with CL-ers and former CL-ers online. ;-) |
| 23:31 | dxeh | so, all this book talk is really not helping me |
| 23:31 | Raynes | callenbot: Heh, I remember that too. |
| 23:31 | callenbot | cemerick: they were my tribe. >:) |
| 23:31 | dxeh | i just wanted to know the answer to a simple question |
| 23:31 | Raynes | I was probably one of those people. |
| 23:32 | callenbot | Raynes: I was too, I'd avoided the JVM as much as possible until Clojure. |
| 23:32 | Raynes | dxeh: What was the question, again? I don't think I saw it. |
| 23:32 | cemerick | dxeh: my Q probably got lost in the noise, but: what are you trying to do, specifically? |
| 23:32 | cemerick | callenbot: My condolences. :-) |
| 23:32 | dxeh | best alternative to C unions, in clojure, what would it be |
| 23:32 | cemerick | dxeh: assume I know nothing of c unions |
| 23:32 | cemerick | y'know, just for ha-has |
| 23:32 | callenbot | cemerick: they were good years man. Good years. I was more productive than most people I knew despite the janky stack. |
| 23:33 | callenbot | "just for ha-has" <--- I lol'd |
| 23:33 | cemerick | I also don't write bytes with a needle and a steady hand, so... |
| 23:33 | callenbot | cemerick: magnetic needle. |
| 23:33 | cemerick | callenbot: see, pedantry like that is a classic CL-er tell |
| 23:33 | antares_ | dxeh: probably a map (dictionary-like data structure). Getting all the memory layout efficiency aspects of C unions in a GC-ed language is not possible. |
| 23:33 | callenbot | cemerick: good ole (LOOP-MAGNETIC-NEEDLE ...) |
| 23:34 | cemerick | oh christ, ALL CAPS |
| 23:34 | callenbot | it's CL. |
| 23:34 | callenbot | of course it's all-caps. |
| 23:34 | cemerick | callenbot: bah, I found the way to make lispworks case-sensitive, so there :-P |
| 23:34 | Frozenlock | iirc CL could work in lowercaps. |
| 23:34 | cemerick | stupid read-table bollocks |
| 23:34 | callenbot | CL is a powerful language, so powerful, you can stop the heart of a programmer just by showing him a stacktrace. |
| 23:34 | llasram | dxeh: What are you doing with our current use of unions in C, vs e.g. just using a struct with the same members? |
| 23:35 | callenbot | Frozenlock: it was case-insensitive but the default canonical names were all-caps. |
| 23:35 | llasram | s,our,your, |
| 23:35 | cemerick | antares_: wait, we're talking about bit-packing or something similar? |
| 23:35 | dxeh | err antares_ basically the way i was using the union was a tagged union inside of a struct which would represent a type of constant pool entry, in java this can easily be represented by class abstraction/inheritance, in clojure, im not so sure |
| 23:36 | antares_ | cemerick: in C there's a way to have "polymorphic" data structures that are compiled efficiently |
| 23:37 | antares_ | dxeh: see http://clojure-doc.org/articles/language/polymorphism.html :) |
| 23:37 | llasram | cemerick: Yeah, basically you can access the same hunk of memory as different types |
| 23:37 | callenbot | guys don't start him down protocols and multimethods already |
| 23:37 | ChongLi | yeah if you love sum types and want functional programming with them try ML or Haskell |
| 23:38 | Frozenlock | "This website was developed by the Clojure Documentation Team." Wow, sounds like a group of superheroes. |
| 23:38 | llasram | dxeh: Although antares_'s link has merit, potentially more relevant -- a map is a map, no matter what keys it has. |
| 23:38 | cemerick | tommo: so you're a young'un as well? |
| 23:39 | tommo | cemerick: yeah i am, 17 :p |
| 23:39 | dxeh | we've got some prodigies up in this irccccccccc |
| 23:39 | tmciver | get off my lawn! |
| 23:39 | cemerick | excellent, new blood |
| 23:39 | antares_ | Frozenlock: just mere mortals who are fed up with clojure.org's documentation and contribution process |
| 23:39 | tommo | trying to wipe this java slate clean and start fresh |
| 23:39 | cgag | what site is that? is that on clojure-docs? |
| 23:39 | Frozenlock | antares_: At this point I was sure that #clojure was the official documentation. |
| 23:40 | antares_ | cgag: no, clojure-docs.org is API reference, http://clojure-doc.org is for guides |
| 23:40 | dxeh | anyways antares_ thanks for the link looks like it might be what i need |
| 23:40 | antares_ | Frozenlock: clojure-doc.org is not official |
| 23:40 | technomancy | Frozenlock: #clojure is way better than the official documentation =) |
| 23:40 | antares_ | Frozenlock: so you are basically correct :) |
| 23:41 | antares_ | dxeh: you are welcome. Sorry about the book thing earlier, people here are usually pretty nice |
| 23:41 | cgag | ah, i'll have to check that out, it looks good from a glance |
| 23:41 | cemerick | Frozenlock: were you the one that came up with 'don't get #=ed'? |
| 23:41 | cgag | particularly having a good ecosystem section |
| 23:41 | antares_ | cgag: if something does not, you can contribute to it on github ;) |
| 23:41 | antares_ | cgag: are you relatively new to clojure? |
| 23:41 | Frozenlock | cemerick: yeah. Pretty proud of it :p |
| 23:42 | cemerick | well done :-) |
| 23:42 | cgag | not really, but the ecosystem stuff was the biggest hurdle for me when i started |
| 23:42 | dxeh | no problem antares_ some people just arent open minded enough to see that some learn differently than others |
| 23:42 | antares_ | cgag: ok. I hope you are aware of http://clojurewerkz.org and http://www.clojuresphere.com |
| 23:43 | ChongLi | dxeh: if you really must have union types you can do that in typed clojure |
| 23:43 | cgag | clojurewerkz yeah, don't think i've seen clojuresphere |
| 23:43 | dxeh | ChongLi: its not a must have lol |
| 23:44 | dxeh | i was using the unions in C as a way to somewhat represent class polymorphism |
| 23:44 | ChongLi | ah ok |
| 23:44 | amalloy | haha, don't get #='ed? how do you pronounce that? |
| 23:44 | ChongLi | I thought you needed the type safety for something |
| 23:44 | amalloy | hasheq'ed? |
| 23:44 | ChongLi | sharp-equals |
| 23:44 | dxeh | nah for example ChongLi, in an expression tree, you have a left node and a right node |
| 23:45 | antares_ | dxeh: then maybe Scala or Haskell is what you want ;) |
| 23:45 | dxeh | now these nodes can have multiple different properties |
| 23:45 | dxeh | i was using a union to represent the different types of nodes in the syntax tree |
| 23:45 | ChongLi | sure |
| 23:47 | ChongLi | and a tree is effectively the product of the left and right node types, right? |
| 23:47 | ChongLi | Haskell allows you to express these things explicitly |
| 23:48 | dxeh | ChongLi: https://github.com/dxeh/sslick/blob/master/src/compiler.c https://github.com/dxeh/sslick/blob/master/src/syntaxtree.h |
| 23:48 | ChongLi | whereas in Clojure it's basically anything goes |
| 23:49 | dxeh | thats like a half done expression tree thats in an unstable state but you can get the idea of what im doing there |
| 23:51 | ChongLi | in haskell you might do something like this: |
| 23:51 | ChongLi | data Tree a = Leaf a | Branch (Tree a) (Tree a) |
| 23:52 | Rich_Morin | http://blip.tv/clojure/clojure-sequences-740581 (Clojure sequences) seems to be broken - how should I report this? |
| 23:53 | ChongLi | Rich_Morin: all the blip stuff is gone |
| 23:53 | antares_ | Rich_Morin: blip.tv pulled the plug on Clojure videos. See http://www.youtube.com/ClojureTV. |
| 23:54 | Rich_Morin | Actually, quite a few videos are working just fine on blip |