2012-04-27
| 00:02 | emezeske | mefesto: I don't know whether :libs searches recursively; I think you might need to specify files one-by-one |
| 00:02 | emezeske | mefesto: Basically everything I know about that option comes from this blog post: http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html |
| 00:02 | mefesto | was reading this and managed to confuse myself even more :) https://groups.google.com/forum/?fromgroups#!searchin/clojure/clojurescript$20third$20party/clojure/96QKwRAkLfU/usQryPg_4d4J |
| 00:05 | emezeske | mefesto: I *think* you're on the right track with using :libs. |
| 00:05 | mefesto | emezeske: necessary to specify the file extension? |
| 00:06 | emezeske | mefesto: I believe so. Not certain, though. |
| 00:06 | ben_m | Why is :only a list and everything else a vector in :use? e.g. (:use [ring.util.serve :only (serve)]) |
| 00:07 | emezeske | ben_m: I'm pretty sure they're interchangeable; I know (:use [ring.util.server :only [serve]]) works, and I'm pretty sure all parens does too |
| 00:07 | ben_m | Ah, okay :) |
| 00:08 | ben_m | Thanks, that makes sense. |
| 00:08 | emezeske | I'm not sure which one is preferred, though |
| 00:09 | technomancy | ben_m: :only should be a vector |
| 00:09 | tomoj | huh, I always use a list there |
| 00:09 | ben_m | Oh, I found it like this in some example code. Will fix. |
| 00:09 | technomancy | because then it indents correctly if you have to drop to another line |
| 00:10 | technomancy | I mean it'll work either way, but vectors for :use/:require and lists for :import gives you the right indentation |
| 00:10 | ben_m | Ah, yeah, that's a good reason. |
| 00:10 | tomoj | like (import (package.name Foo Bar)) ? |
| 00:11 | tomoj | strangely that indents just like a vector for me |
| 00:11 | Gurrag | is the statement "closure is similar to lisp" true? |
| 00:11 | Gurrag | clojure*, sorry |
| 00:11 | ben_m | Gurrag, Clojure is a Lisp. |
| 00:11 | Gurrag | oh cool! |
| 00:12 | Gurrag | thanks for the info |
| 00:28 | amalloy | TimMc: i can't remember, do you use slime? |
| 00:28 | amalloy | cause if so you could use the slime inspector instead of your handy/show |
| 00:52 | kovasb | is there an equivalent of *clojure-version* for clojurescript? |
| 01:21 | technomancy | huh: http://www.meetup.com/Seattle-Software-Developers/events/62334172/?a=socialmedia |
| 01:22 | replaca | technomancy: more going on in Seattle than you know about? |
| 01:22 | ibdknox | totally not cool |
| 01:23 | ibdknox | technomancy has to approve all clojure things happening in seattle ;) |
| 01:23 | technomancy | replaca: apparently |
| 01:23 | technomancy | that name sounds familiar; probably from the mailing list |
| 01:24 | ibdknox | he's around here sometimes |
| 01:24 | technomancy | ibdknox: on irc? |
| 01:24 | ibdknox | yeah |
| 01:24 | technomancy | huh, he has a refheap fork |
| 01:24 | replaca | derrida: I don't think so. I asked around for one a while back and none of the usual org-mode suspects seemed to know of one |
| 01:25 | derrida | replaca: yeah, i found nothin |
| 01:26 | derrida | would be nice though :) |
| 01:26 | replaca | technomancy: Raynes credits him on the refheap github |
| 01:27 | technomancy | I should bug him to attend seajure; what the heck |
| 01:27 | replaca | derrida: agreed. it would give me new ways to procrastinate all the things in my org-mode files :) |
| 01:27 | technomancy | but it's cool that he's presenting to a wider audience |
| 01:27 | technomancy | I tried that once and had a hard time; I just can't put myself back in the shoes of an OO-head |
| 01:27 | derrida | replaca: indeed |
| 01:27 | hiredman | technomancy: at least they didn't schedule it for the first thursday |
| 01:27 | technomancy | "it's like... you have these values; see? and they're stable over time." |
| 01:28 | technomancy | hiredman: srsly |
| 01:28 | hiredman | I am almost tempted to go, to see what kind of turn out there is |
| 01:29 | technomancy | yeah, me too |
| 01:30 | hiredman | I must know someone who works at the amazon campus |
| 01:30 | technomancy | I don't think you need a friend to sneak you in; you can just rsvp =) |
| 01:31 | technomancy | oh yeah, and they have a zoka down there now |
| 01:31 | hiredman | hwa |
| 01:31 | replaca | it's all about the coffee for you guys, isn't it? :) |
| 01:32 | hiredman | *cough* |
| 01:32 | technomancy | replaca: I haven't gotten hiredman hooked yet; he's all tea |
| 01:33 | replaca | and they allow him is Sea-Tac. I thought there was some kind of law |
| 01:33 | replaca | *in Sea-Tac? |
| 01:45 | muhoo | &(map #(first %) {:foo 1, :bar 2}) |
| 01:45 | lazybot | ⇒ (:foo :bar) |
| 01:45 | muhoo | &(map #([(first %) (second %)]) {:foo 1, :bar 2}) |
| 01:45 | lazybot | clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector |
| 01:45 | muhoo | why? |
| 01:45 | clojurebot | why is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone |
| 01:47 | muhoo | aha, reader macro ##(map #(vector (first %) (second %)) {:foo 1, :bar 2}) |
| 01:47 | lazybot | ⇒ ([:foo 1] [:bar 2]) |
| 01:48 | muhoo | &(map #(hash-map (first %) (second %)) {:foo 1, :bar 2}) |
| 01:48 | lazybot | ⇒ ({:foo 1} {:bar 2}) |
| 01:50 | emezeske | &(map #(apply hash-map %) {:foo 1, :bar 2}) |
| 01:50 | lazybot | ⇒ ({:foo 1} {:bar 2}) |
| 01:52 | muhoo | this is fun, but a bit orthogonal to what i set out to do, which is: to map over a map, applying a function to each of the values but leaving the keys the same |
| 01:53 | muhoo | i mean (vals ...) sure, but then i lose the keys. i'm missing something fundamental and important. |
| 01:53 | technomancy | muhoo: no, it sucks that the function you want isn't in clojure |
| 01:53 | technomancy | (zipmap (map f1 (keys m)) (map f2 (vals m))) ; is the best you can do |
| 01:54 | muhoo | really? wow. |
| 01:54 | muhoo | ok, thanks. |
| 01:56 | muhoo | https://refheap.com/paste/2393 and that'll play |
| 01:57 | zakwilson | Clojure does primative math by default now and doesn't need unchecked-* to be as fast as Java, right? |
| 02:11 | muhoo | is the only way to map a macro to do (map #(name-of-macro %) coll) ? |
| 02:12 | muhoo | i can live with that, but it seems... hackish |
| 02:14 | wmealing | or you could put the map inside the macro |
| 02:14 | wmealing | if its only going to be mapping |
| 02:14 | muhoo | it's not my macro |
| 02:15 | amalloy | technomancy: ewwww. surely (into {} (for [[k v] m] [(f1 k) (f2 v)])) is better than that zipmap/map/map/keys/vals nonsense |
| 02:16 | replaca | amalloy: I agree. And easy to wrap into a nice func |
| 02:16 | amalloy | and muhoo, if you don't mind depending on useful, you can write it as (into {} (map (knit f1 f2) m) |
| 02:17 | wmealing | oh i see. |
| 02:21 | amalloy | or i suppose you could use useful.map/map-vals, but i kinda prefer the generalized knit |
| 02:26 | zakwilson | It's amazing how much flatland.useful looks like my own utilities file. |
| 02:31 | zakwilson | Is there a way to have leiningen run swank without compiling the project? |
| 03:12 | TheBusby | any idea how to access the version tag specified in the leiningen project.clj file from code? |
| 03:27 | muhoo | amalloy: knit is very cool, thanks |
| 04:10 | ktsuji | TheBusby: for my own class, it was (System/getProperty "myclass.version"). |
| 04:11 | TheBusby | ktsuji: thanks, it looks like if Leiningen was writing the "Implementation-Version:" value in the META-INF/MANIFEST.MF file it generates for jars then it could be extracted via .getPackage.getImplementationVersion() |
| 04:12 | TheBusby | unfortunately no such luck it seems, maybe a good patch for leiningen? |
| 04:15 | kral | namaste |
| 04:17 | wmealing | Clojure Programming is more expensive through oreilly pdf than it is on amazon kindle. |
| 04:17 | wmealing | thats.. not what i expected. |
| 04:17 | ktsuji | it seems like you can specify arbitrary key/value pars for manifest :manifest {"Project-awesome-level" "super-great"} |
| 04:17 | ktsuji | TheBusby: https://github.com/technomancy/leiningen/blob/master/sample.project.clj, but that will be duplicate input so as you mentioned, |
| 04:18 | ktsuji | TheBusby: it might be great if it is done by leiningen. |
| 04:22 | TheBusby | ktsuji: yep, since version is already defined earlier in the project it would be nice to have it Implementation-Version default to that if possible |
| 04:56 | AWizzArd | Java 7 Update 4 is now available, and it includes JavaFX 2.1 and the GC1 (: |
| 06:12 | dxlr8r | I don't know how to explain this. but I'll try. I try to learn clojure, so I do things to complex for a reason (to learn). |
| 06:14 | dxlr8r | http://pastebin.com/QAtfAmh8 |
| 06:15 | dxlr8r | and get the error at line 11 |
| 06:16 | dxlr8r | but If I paste and replace ":authors2 [:id "integer primary key"]" with "data" on line 9 it works |
| 06:16 | clgv | dxlr8r: your 'intern looks wrong if you only want to use an api |
| 06:17 | dxlr8r | I have tried to replace it with a regular call to. same thing |
| 06:17 | dxlr8r | like: |
| 06:17 | dxlr8r | (create-table data)) |
| 06:17 | dxlr8r | same thing |
| 06:18 | dxlr8r | I have: (:use [clojure.java.jdbc :only (with-connection create-table)] in the ns to |
| 06:18 | clgv | did you try a simple tutorial example first to avoid environment pitfalls? |
| 06:18 | dxlr8r | yeah |
| 06:18 | dxlr8r | I'll stupify it |
| 06:18 | dxlr8r | wait |
| 06:19 | clgv | did it work? |
| 06:20 | dxlr8r | http://pastebin.com/cHg3T2S4 |
| 06:20 | dxlr8r | same thing |
| 06:20 | dxlr8r | tried that to |
| 06:20 | muhoo | as lovely as clojure and noir is, there just doesn't seem to be a hard floor on how much suck can be removed from html forms |
| 06:21 | muhoo | mistyped, there does in fact seem to be one. the suck remains. |
| 06:21 | dxlr8r | if I replace "data" on line 13 with: ":authors2 [:id "integer primary key"]"., it works |
| 06:22 | dxlr8r | so it doesn't seem like I can pass stuff to it :/ which is a shame |
| 06:23 | dxlr8r | (class data) => clojure.lang.ArraySeq |
| 06:26 | dxlr8r | clgv: ? you know :) |
| 06:29 | dxlr8r | hmm. I applied apply, works now :P |
| 06:29 | clgv | dxlr8r: did you check the documentation: http://clojure.github.com/java.jdbc/#clojure.java.jdbc/create-table ? |
| 06:29 | dxlr8r | I have been reading the source code, but it seemed to work with apply |
| 06:31 | dxlr8r | but this line: (intern 'clojure.java.jdbc (symbol action)) , did you have anything to say there? |
| 06:31 | clgv | dxlr8r: it's rubish. dont use intern. |
| 06:31 | dxlr8r | how else should I do it? |
| 06:31 | dxlr8r | how else can I do: (dbdo "create-table" :authors3 [:id "integer primary key"]) |
| 06:32 | clgv | if you want to call the static method 'action in that clas just write: (clojure.java.jdbc/action ...) |
| 06:32 | dxlr8r | the "create-table" part. it could be anything |
| 06:32 | clgv | lol wait |
| 06:32 | clgv | just put 'action into the :only list |
| 06:34 | dxlr8r | ok? |
| 06:34 | clojurebot | book is http://www.pragprog.com/titles/shcloj/programming-clojure |
| 06:34 | dxlr8r | (:use [clojure.java.jdbc :only ('action)] ) |
| 06:34 | clgv | without the quote |
| 06:35 | clgv | and you probably need the other functions you are using in there as well |
| 06:36 | dxlr8r | I want to do: |
| 06:36 | dxlr8r | (dbdo "create-table" :authors3 [:id "integer primary key"]) |
| 06:36 | dxlr8r | or |
| 06:36 | dxlr8r | (dbdo "insert-records" :authors3 {:first_name "Simen"}) |
| 06:37 | clgv | why? |
| 06:37 | clojurebot | why is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone |
| 06:38 | clgv | there is the 'with-connection macro for that use case |
| 06:38 | dxlr8r | I want to be able to call dbdo from other files |
| 06:38 | dxlr8r | I'll look into |
| 06:40 | clgv | dxlr8r: you should want to encapsulate the low level api and not to distribute database statement in all other namespaces ;) |
| 06:40 | dxlr8r | I want that function and the file to do all the db stuff. to speak with the jdbc and so on… all I want to is to include the dbdo file and call the dbdo function with what I want to do |
| 06:43 | clgv | dxlr8r: you wont reach it if you let other namespaces call (dodb "create" ..) or (dodb "update" ...) ... |
| 06:43 | dxlr8r | it already works in other namespaces with "intern" |
| 06:43 | dxlr8r | (ns no.ifixit.telephonebook.index |
| 06:43 | dxlr8r | (:use [no.ifixit.telephonebook.db])) |
| 06:44 | dxlr8r | then I can call dbdo with whatever I want to do on the db |
| 06:44 | dxlr8r | without haveing to care for anything else |
| 06:44 | clgv | if you are programming a usual clojure app you should not use intern. |
| 06:46 | dxlr8r | then what should I use? |
| 06:47 | dxlr8r | you understand what I want to do? I want a generic function that other namespaces can call to do stuff with the database, without them needing to know anything about databases |
| 06:47 | clgv | simply call the function after you :use or :require the namespace |
| 06:48 | dxlr8r | I want the other namespaces to decide what function they want to call |
| 06:49 | clgv | clojure has first-class functions. you can simply pass a function as parameter to another function |
| 06:50 | dxlr8r | how would I do that? |
| 06:50 | dxlr8r | sorry |
| 06:50 | dxlr8r | got it :P |
| 06:50 | dxlr8r | (dbdo create-table :authors4 [:id "integer primary key"]) |
| 06:50 | clgv | you shoud read some introductory material |
| 06:51 | dxlr8r | no quotes, no apostrophes, no nothing |
| 06:51 | dxlr8r | I actually have read 50-60 pages |
| 06:51 | dxlr8r | from the clojure book |
| 06:52 | dxlr8r | then never spoke about sending functions as parameters, but that is really nice :) |
| 06:54 | clgv | which clojure book? the wikibook? |
| 06:55 | dxlr8r | "Practical Lisp for The Java World" |
| 06:56 | dxlr8r | and when I try: |
| 06:56 | dxlr8r | (dbdo create-table :authors4 [:id "integer primary key"]) |
| 06:56 | dxlr8r | from another ns it doesn't work :( |
| 06:56 | dxlr8r | IllegalStateException Attempting to call unbound fn |
| 06:56 | clgv | look at the files and lines in the stacktrace to find out where it happened |
| 06:57 | dxlr8r | I know what's going on. it tells me that I can't do that :P |
| 06:57 | dxlr8r | IllegalStateException Attempting to call unbound fn: #'no.ifixit.telephonebook.index/create-table clojure.lang.Var$Unbound.throwArity (Var.java:43) |
| 06:57 | clgv | the book is "Clojure Programming"? |
| 06:58 | clgv | post another paste of the complete file |
| 06:59 | dxlr8r | http://pastebin.com/5wcvPUeR |
| 07:00 | dxlr8r | and yeah, that's the title :) |
| 07:00 | dxlr8r | read "Down the rabbit hole" |
| 07:00 | clgv | can you restart your repl? |
| 07:01 | clgv | probably the results of your strange 'intern code are still present |
| 07:02 | dxlr8r | I'll try |
| 07:03 | dxlr8r | CompilerException java.lang.RuntimeException: Unable to resolve symbol: create-table in this context, compiling:(NO_SOURCE_PATH:1) |
| 07:22 | dxlr8r | can I (ns) use several other namespaces? |
| 07:22 | dxlr8r | :use |
| 07:32 | dxlr8r | or several refers? |
| 07:37 | madsy | dxlr8r: Only one can be current, but you can refer to many namespaces. |
| 07:38 | dxlr8r | ok? how can I refer to many namespaces? |
| 07:52 | joegallo | dxl8r: http://clojuredocs.org/clojure_core/clojure.core/ns see the two last examples near the bottom. |
| 07:52 | clgv | dxlr8r: yes, you can declare multiple :refer and :use statements in the 'ns form |
| 07:52 | joegallo | dxlr8r: ^ (sorry for the typeo) |
| 07:53 | dxlr8r | yeah, thanks, I actully found it out by myself. I actually am starting to learn this. I guess my brain is starting to get into clojure mode from java mode |
| 07:55 | madsy | So I'm trying to reason about how Clojure does evaluation. First it transforms the text as according to the (static) reader rules, then macro expansion, and then evaluation? |
| 07:55 | clgv | dxlr8r: try to read some more chapters of the book ;) |
| 07:55 | dxlr8r | it's so boring! programming is far more fun |
| 07:55 | dxlr8r | I read for 3 days :P |
| 07:56 | Chousuke | madsy: hm, not quite |
| 07:56 | madsy | I'm unsure at which point clojure stops compiling data to code, if ever |
| 07:57 | Chousuke | I'm not quite sure how things work with AOT compilation, but mh |
| 07:58 | dxlr8r | I actually read about AOT in the book. so atleast it's there if you have that book |
| 07:58 | Chousuke | basically macro expansion is part of the evaluation step and evaluation happens line-by-line |
| 07:59 | madsy | Chousuke: Yeah, so it keeps macroexpanding and evaluating ad-finitum until there is nothing more to macroexpand and compile then |
| 07:59 | Chousuke | clojure reads a single form, macroexpands, compiles the result, and then runs the compiled code |
| 08:00 | Chousuke | the line between evaluation and macroexpansion is a bit hazy because macros can do whatever they want, but it happens before the final evaluation of the form that is being macroexpanded. |
| 08:01 | madsy | I'm still a bit confused why printing a compiled function doesn't give me its form though |
| 08:02 | Chousuke | that's because it's just a java object, and it doesn't store its source form anywhere |
| 08:02 | Chousuke | after the function is compiled it only exists as jvm bytecode |
| 08:02 | madsy | Okay, so in order to do that, I would need to store it myself by using quote. |
| 08:04 | Chousuke | IIRC clojure creates a class for each function, and then instances of that class for each closure (if there are any) |
| 08:05 | madsy | Makes sense. Thank you. |
| 08:05 | Chousuke | you can probably understand it better if you just go read the cljs compiler or something :) |
| 08:06 | Chousuke | or the clojure-jvm compiler if you like reading Java |
| 08:06 | madsy | Maybe I'll be that bold later :) |
| 08:06 | Chousuke | it's not too complicated. |
| 08:06 | madsy | I guess not. I've picked up Clojure miles faster than Common Lisp. |
| 08:07 | Chousuke | heh |
| 08:07 | Chousuke | I think Clojure is easier to learn than CL, yes |
| 08:07 | madsy | The language seems much easier and compact |
| 08:08 | madsy | Read about CL's eval-when and your head explodes |
| 08:08 | Chousuke | functional programming is a bit of a mindbender at first but precisely because Clojure is opinionated it's easier to get started |
| 08:08 | Chousuke | it's not a bag of possibilities with no clear indicator of what is good and what is not like CL |
| 08:12 | Chousuke | oh, and I really like Clojure having useful evaluation semantics for vectors and maps |
| 09:01 | fliebel | Are there any successful Clojure freelancers in Europe? (and how did you get into that?) I'm a freelancer, but I haven't had any Clojure projects so far. |
| 09:05 | dxlr8r | I am :P and I am a noob. but the firm that hired me has one dude that is clojure guru, and I am willing to learn |
| 09:08 | Licenser | dxlr8r you have your tongue hanging out? |
| 09:08 | dxlr8r | yeah, I am a labrador |
| 09:09 | Licenser | cool can you make a picture of your tail - I need that icon for a project of mine *runs for cover* |
| 09:10 | clgv | dxlr8r: which company? |
| 09:11 | dxlr8r | Licenser: :) |
| 09:12 | dxlr8r | clgv: small stuff. some sellsmen, two clojure programmerings (incl.) me and one php guy that is going over to clojure soon to |
| 09:12 | dxlr8r | we make a website |
| 09:13 | clgv | which country? |
| 09:13 | dxlr8r | the main clojure guy has made the webside in clojure, he has even made a long polling api |
| 09:13 | dxlr8r | we are named feelgood |
| 09:13 | fliebel | dxlr8r: norway? |
| 09:14 | dxlr8r | yeah |
| 09:17 | TimMc | amalloy_: No, I don't use SLIME yet. But I have some ideas for my show fn -- filtering on return type, method name... |
| 09:18 | dxlr8r | fliebel / clgv: happy :P |
| 10:10 | dxlr8r | (str "1" "\n" "2") |
| 10:10 | dxlr8r | I want a new line there, doesn't work |
| 10:11 | joegallo | doesn't work how? |
| 10:11 | joegallo | ,(str "1" "\n" "2") |
| 10:11 | clojurebot | "1\n2" |
| 10:11 | dxlr8r | ,(char-escape-string \newline) |
| 10:11 | clojurebot | "\\n" |
| 10:12 | joegallo | ,(println (str "1" "\n" "2")) |
| 10:12 | clojurebot | 1 |
| 10:12 | clojurebot | 2 |
| 10:12 | dxlr8r | I want it to return it |
| 10:12 | dxlr8r | not print it |
| 10:12 | joegallo | i don't follow... |
| 10:12 | joegallo | the newline *is* there |
| 10:13 | dxlr8r | I see |
| 10:13 | dxlr8r | it does work then, hehe |
| 10:13 | joegallo | the repl is showing it inside the string -- it won't show as an actual newline (multiple lines printed at the repl) unless you actually println |
| 10:13 | joegallo | (str "\"" "\t" "\n") |
| 10:14 | joegallo | ,(str "\"" "\t" "\n") |
| 10:14 | clojurebot | "\"\t\n" |
| 10:14 | joegallo | which is how it appears to behave for specials characters inside strings generally. |
| 10:15 | dxlr8r | ok :) nice to know |
| 10:16 | joegallo | yeah, that's something that still surprises me from time to time. i'm sure there's a very logical explanation for why it's that way, i just don't happen to know it. :) |
| 10:17 | dxlr8r | can you have constructors in conjure? like (defn x [a b] (x a b 1)) (defn x [a b c] (+ a b c)) |
| 10:18 | fdaoud | dxlr8r: yes, (defn x ([a b] (x a b 1)) ([a b c] (+ a b c))) |
| 10:19 | dxlr8r | ahhh |
| 10:19 | dxlr8r | nice |
| 10:22 | TimMc | &[\a \b \u0000 \c \d] |
| 10:22 | lazybot | ⇒ [\a \b \ |
| 10:23 | TimMc | ^ Does anyone else see lazybot's response stop at the NUL byte? |
| 10:23 | stuartsierra | yes |
| 10:23 | halgari | ditto |
| 10:23 | TimMc | Wasn't sure if it was my client. |
| 10:23 | TimMc | Could be the IRC server, too. |
| 10:24 | TimMc | Works fine in my REPL... sort of: [\a \b \ \c \d] |
| 10:25 | clgv | ,[\a \b \u0000 \c \d] |
| 10:25 | clojurebot | [\a \b \ |
| 10:25 | fliebel | clgv: Whats \u0000? |
| 10:25 | TimMc | &"ab\u0000cd" |
| 10:25 | lazybot | ⇒ "ab |
| 10:25 | TimMc | fliebel: NUL byte. |
| 10:26 | clgv | ,(pr-str [\a \b \u0000 \c \d]) |
| 10:26 | clojurebot | "[\\a \\b \\ |
| 10:26 | clgv | uuh |
| 10:26 | ben_m | This kills the bot. |
| 10:26 | TimMc | Messes up a lot of C programs, which often use NUL-terminated strings. |
| 10:27 | TimMc | &(map char (range 5)) ;; this is how I ran across it |
| 10:27 | lazybot | ⇒ (\ |
| 10:27 | fliebel | Is it my client that does not display anything after the nul, or is it the bot? |
| 10:27 | mefesto | I'm trying to (:require [goog.net :as net]) in ClojureScript but getting an error: 'required "goog.net" namespace never provided'. A quick scan of goog.jar seems to include this namespace. Am I requiring this incorrectly? |
| 10:27 | mefesto | other requires work fine |
| 10:27 | TimMc | fliebel: Not sure how to determine that. |
| 10:28 | TimMc | ,"ab\u0000cd" |
| 10:28 | clojurebot | "ab |
| 10:30 | fliebel | TimMc: Send a real nul byte to lazybot? |
| 10:30 | fliebel | &(println ",'ab\u0000bc") |
| 10:31 | lazybot | ⇒ ,'ab |
| 10:31 | fliebel | ,(println "&'ab\u0000bc") |
| 10:31 | clojurebot | &'ab |
| 10:31 | lazybot | ⇒ ab |
| 10:33 | TimMc | clever |
| 10:34 | TimMc | ,(println "&(last \"ab\u0000bc\")") |
| 10:34 | clojurebot | &(last "ab |
| 10:34 | lazybot | java.lang.RuntimeException: EOF while reading string |
| 10:35 | TimMc | &(map char (range 1 32)) |
| 10:35 | lazybot | ⇒ (\ \ \ \ \ \ \backspace \tab \newline \ \formfeed \return \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \) |
| 10:35 | TimMc | Err, I hope that didn't BEL anyone. |
| 10:36 | Fossi | haha |
| 10:37 | Fossi | that's so ancient :) |
| 10:37 | Fossi | at least my client didn't vertical tab :) |
| 10:37 | Fossi | don't know why actually |
| 10:54 | mefesto | ah this person set me straight on my goog.net worries: http://sunng.info/blog/2011/08/using-google-closure-library-with-clojurescript/ |
| 10:57 | Hali_303 | hi! why is (set? (keys mapinstance)) false? |
| 10:58 | joly | ,(class (keys {:a 1 :b 2})) |
| 10:58 | halgari | keys is a seqence, not a set |
| 10:58 | clojurebot | clojure.lang.APersistentMap$KeySeq |
| 10:58 | mefesto | ,(doc keys) |
| 10:58 | clojurebot | "([map]); Returns a sequence of the map's keys." |
| 10:58 | joly | ,(seq? (keys {:a 1})) |
| 10:58 | clojurebot | true |
| 10:59 | halgari | @Hali_303 Part of the reason for this is that if you have 1000 keys in a map, it's a bit wasteful to copy all those into a new structure. Instead it's much faster to simply iterate over each key and return one at a time |
| 10:59 | halgari | lazy seqs ftw! |
| 11:00 | Vinzent | halgari, there is no copying in clojure actually |
| 11:01 | Vinzent | Hali_303, it returns ordered seq so you can e.g. (zipmap (keys m) (vals m)) |
| 11:01 | halgari | @Vinzent...copy is a poor choice of words...to create a set you'd have to grab all 1000 keys, and then put them into a set. Yes you're right, no copying, but still, slower than using a lazy seq |
| 11:04 | Hali_303 | I see |
| 11:04 | Hali_303 | thanks, good to know |
| 11:05 | TimMc | Hali_303: There's another reason, actually. |
| 11:05 | TimMc | Sets are not ordered, and it is useful for (keys m) and (vals m) to be in the same order as each other. |
| 11:06 | TimMc | &(type (keys {:a 1})) |
| 11:06 | lazybot | ⇒ clojure.lang.APersistentMap$KeySeq |
| 11:10 | Vinzent | halgari, hmm, but items can be added to set on assoc in the same way as they're added to seq? |
| 11:10 | Vinzent | TimMc, that's actually exactly the reason I had in mind :) |
| 11:11 | TimMc | Vinzent: Oops, didn't see your msg. Your nick is the same color and length as halgari's in my client. |
| 11:13 | mefesto | is there a page that documents ClojureScript's notation for getting/setting js properties? i've just been finding things on random blogs -- most of which are out-dated since they don't use the new (.-prop obj) style |
| 11:13 | Vinzent | ah, ok |
| 11:14 | Vinzent | mefesto, there is cljs cheatsheet |
| 11:15 | mefesto | Vinzent: just found the one by fogus. i'm assuming that's the same one you are talking about? |
| 11:16 | mefesto | Vinzent: thanks |
| 11:16 | halgari | @Vinzent, I'm not sure I understand, about assoc and seqs |
| 11:17 | mefesto | here's the link for anyone else (pdf): https://github.com/fogus/clojure-cheatsheets/blob/master/pdf/cljs-cheatsheet.pdf?raw=true |
| 11:17 | halgari | @Vinzent, the performance hit is that assoc on a set requires several hash compares, and copying parts of a set tree. doing cons on a seq is just a single allocation. Therefore it's much faster to return a seq from keys |
| 11:17 | Vinzent | mefesto, yeah this is it |
| 11:20 | Vinzent | halgari, yes, but when assoc'ing to a map these hash compares have to be done anyway, so I think it'd be done effectively if that was a purpose |
| 11:32 | neotyk | emacs question: how can I batch exporting of org file to html? |
| 11:34 | bradwright | neotyk: you probably want #emacs for that |
| 11:35 | neotyk | bradwright: true, or even orgmode |
| 11:35 | bradwright | Or that :) |
| 11:36 | neotyk | but it doesn't hurt to ask best channel on intertubes ;-) |
| 11:39 | smeltzek | When using Emacs+swank/slime, is there a way to avoid having to call (use somenamespace) whenever I reload the file? I use C-c C-l, and old definitions are updated fine, etc. but new functions are not visible until I call (use) again |
| 11:41 | Vinzent | smeltzek, I'm not sure what you're talking about, I'm using C-c C-k (bound to C-s) to save and compile the whole buffer and it works fine for all changes |
| 11:42 | smeltzek | vinzent, even if you write a new toy function you can immediately resolve the symbol in a REPL upon compiling it? |
| 11:42 | raek | smeltzek: I usually try out the functions from within the namespace they are defined in |
| 11:42 | Vinzent | smeltzek, if I have REPL in the same namespace - yes |
| 11:43 | raek | smeltzek: press C-c M-p to change the repl namespace to match the current buffer |
| 11:44 | Vinzent | it's also handy to bind (fset 'to-repl-in-ns [?\C-c ?\M-p return ?\C-c ?\C-z]) this to some key |
| 11:44 | smeltzek | Ah, thanks. My problem is that I wasn't adjusting the namespace of the REPL, just manually calling (use whatever). Using C-c M-p gets things working as expected |
| 12:05 | dnolen | a good read - Clojure's IFn vs. Python's call http://clojure-py.blogspot.com/2012/04/ifn-vs-call.html |
| 12:08 | dnolen | raph_amiard: ^ definitely something to keep in mind when doing the Lua stuff. |
| 12:14 | alexyakushev | Didn't quite get this one: "So this is why Clojure-JVM never allows direct invocation of static methods." |
| 12:15 | alexyakushev | Is it about something different from ,(Integer/parseInt "42") ? |
| 12:15 | hiredman | alexyakushev: I dunno, I have generally found the clojure-py blog to be a bad source of information |
| 12:16 | hiredman | really he should be able to at compile time figure out if the symbol at the start of a list refers to a python function or not |
| 12:17 | hiredman | alexyakushev: I believe he means something like "so this is why clojure doesn't treat static methods as functions" |
| 12:18 | hiredman | but the real issue there is usage as values |
| 12:18 | alexyakushev | hiredman: Thank you. I got it now. |
| 12:20 | alexyakushev | Could anyone please tell how to add an external dependency (like :extra-classpath-dirs) in Leiningen 2.0.0? The previous method doesn't seem to work. |
| 12:22 | nDuff | cemerick: wrapping a new, empty URLClassloader around the OSGI classloader before calling (swank/start-server). Ugly bit is that the OSGI classloader can't be imported directly due to the sandbox, so I'm looking at its name to detect it. |
| 12:22 | technomancy | alexyakushev: the only good way to get jars on the classpath is to declare them as dependencies |
| 12:23 | cemerick | nDuff: sounds like it's solidly in the realm of "gonna break real soon now" ;-) |
| 12:24 | alexyakushev | technomancy: could I specify a local jar in the dependencies or it should be only something on the Clojars/Maven/etc? |
| 12:25 | technomancy | it should be something in ~/.m2 |
| 12:25 | technomancy | there are ways to do it without getting it in m2, but not good ways |
| 12:27 | alexyakushev | technomancy: I need to get the Android SDK libs on the classpath. Does it mean I should search for a Maven repo with android jars? |
| 12:27 | technomancy | alexyakushev: that would be best, yeah |
| 12:29 | halgari1 | @alexyakushev what I mean by "direct invocation of a static method" means that you can't do something like this in Clojure-JVM (let [x (.-toHextString Integer)]) |
| 12:32 | muhoo | are defs's thread-specific[D[D[D[D[D? |
| 12:32 | muhoo | sorry are def's thread-specific? |
| 12:32 | alexyakushev | technomancy: I'm working on a leiningen android plugin and I don't feel very well about making the user to download all the necessary libs again (and for different Android versions). Could you please at least give a hint on these "not very good ways" so I had something to play around for a starter? |
| 12:33 | technomancy | alexyakushev: sure; I understand the situation with android is different from most libraries. your best bet might be to call add-hook on leiningen.core.classpath/get-classpath to make it return the extra entries you need. |
| 12:35 | alexyakushev | technomancy: that's another story, thank you! |
| 12:35 | technomancy | alexyakushev: sorry I missed your /msgs earlier; I'm on an IRC bouncer that is not the most reliable |
| 12:39 | alexyakushev | technomancy: No problem. I use a web client since my router doesn't let any IRC connections, so I'm never sure if my messages come through:) |
| 12:42 | raek | muhoo: values bound using 'binding' are local to the thread which executed the 'binding' (and are mutable) |
| 12:43 | raek | the root binding is the same in all threads (and should normally not change) |
| 12:43 | gtuckerkellogg | anyone here use clojure-test-mode and midje-mode side by side? |
| 12:44 | alexyakushev | halgari1: yes, thank you, hiredman has already explained that to me. |
| 12:45 | muhoo | raek: thanks, that explains what i was seeing |
| 12:45 | nDuff | cemerick: sadly so. I'd have hoped that Spring DM's classloaders would be implementing an interface from the org.osgi namespace, to at least provide cross-vendor detection, but no such luck. |
| 12:48 | dnolen | this'll be fun https://gist.github.com/2510566 |
| 12:49 | devn | cemerick: I'm logged in on Clojure Atlas but I don't see the |
| 12:49 | devn | cemerick: "Your Atlas" link that used to be there |
| 12:49 | cemerick | devn: are your prior purchases listed on the "Your account" page? |
| 12:50 | devn | how do I get to that? :) |
| 12:50 | technomancy | alexyakushev: it may be that you can use :dependencies of :type "provided" for something like the android libs; support for this was recently added to Leiningen, but I am not sure of the details |
| 12:50 | cemerick | devn: if you're logged in, it's the fourth link from the left in the top bar. |
| 12:50 | technomancy | or maybe :scope "provided"? |
| 12:50 | technomancy | cemerick: would that be appropriate? |
| 12:51 | devn | cemerick: I'm logged in but I don't see that link. |
| 12:51 | mefesto | dnolen: is that clojurescript -> lua ? |
| 12:52 | devn | cemerick: https://skitch.com/thinkslate/8scmc/clojure-atlas-an-experimental-visualization-of-the-clojure-language-and-its-standard-library |
| 12:52 | alexyakushev | technomancy: There is a :scope kw in the sample.project.clj but according to grep it is used only in pom.clj |
| 12:53 | technomancy | alexyakushev: it may be used by the pomegranate lib |
| 12:53 | mefesto | in cljs, does :libs ["closure/library/third_party/closure"] work? i keep reading varying things online. some say it works, others say they had to build a custom goog.jar that included those things. |
| 12:53 | cemerick | devn: oh, I'll bet Google is sending a different OpenId for your login. ~10 others have had this problem too. /msg me your email addy. |
| 12:54 | mefesto | i just want goog.dom.query :) |
| 12:57 | alexyakushev | technomancy: then I'll take a look at pomegranate. Is it by the way more tolerant to non-repo dependencies? Because from what I see on the github page it is targeted at Maven as well |
| 12:57 | technomancy | alexyakushev: from what I understand :scope "provided" is a way of saying "it should exist on my machine" for things that might come with the JDK |
| 12:58 | technomancy | it's more of a maven thing than a pomegranate thing I believe |
| 12:58 | technomancy | but I haven't used it myself, sorry |
| 12:59 | dnolen | mefesto: looks like it |
| 13:00 | cemerick | technomancy, alexyakushev: yes, :scope "provided" should work. |
| 13:00 | alexyakushev | technomancy: oh, since we are talking about the provided dependencies I remembered another issue. I was trying to run the swank-cdt thing but that requires having JDK's tools.jar on the classpath. Do I have to use pomegranate for it too? |
| 13:01 | alexyakushev | cemerick: thanks! Could you please tell how to specify where this "provided" libs should be? |
| 13:02 | cemerick | alexyakushev: where? |
| 13:02 | technomancy | alexyakushev: actually tools.jar might be another good use of :scope provided |
| 13:02 | technomancy | I guess I should read up on this =) |
| 13:02 | cemerick | like, how to specify one? [com.foo/bar "1.0.0" :scope "provided"], if memory serves |
| 13:02 | technomancy | cemerick: don't you have to give it a path though? |
| 13:03 | cemerick | hrm, perhaps I need to re-read the question :-P |
| 13:03 | alexyakushev | cemerick: I mean where do I specify where are the libs located (the folder)? |
| 13:04 | cemerick | oh, you're talking about system scope. I'm pretty sure pomegranate doesn't support that. |
| 13:04 | cemerick | alexyakushev: what are you trying to accomplish? |
| 13:05 | cemerick | (sorry, I had killed my log) |
| 13:05 | alexyakushev | cemerick: put Android jars on the classpath |
| 13:05 | technomancy | cemerick: or tools.jar |
| 13:05 | cemerick | and they're not in central or elsewhere? |
| 13:07 | technomancy | in most cases with jars that aren't in central I tell people to file a bug with the project, but I have a feeling Google will just tell you to piss off |
| 13:07 | alexyakushev | Or perhaps, adding a hook is the best option. This would let the user specify the root path to Android SDK and the desired version and the hook will automatically generate the path to an actual files |
| 13:08 | technomancy | that's what they told me when I filed a bug report about their ant tasks giving the wrong error message when there was a 32/62-bit mismatch =( |
| 13:08 | alexyakushev | Anyway thank you both! I very appreciate your help. |
| 13:08 | cemerick | technomancy: I'm pretty sure aether doesn't even implement system scope. Maven's configuration involves a <systemPath>, but aether's object model has no analogue. http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html |
| 13:09 | technomancy | cemerick: hm; so no dice on tools.jar either then |
| 13:09 | technomancy | crappé |
| 13:09 | cemerick | I'll bet mvn handles such things directly, since such "dependencies" are really just classpath entires, not Dependencies (tm) |
| 13:09 | cemerick | er, ™ |
| 13:10 | cemerick | Lein could quite easily pull :scope "system" deps out of the map (or maybe we can offer a :path "~/evil/path.jar" option and not abuse :scope like mvn seems to) |
| 13:10 | cemerick | …and add that path to the classpath returned from get-classpath, etc. |
| 13:11 | technomancy | yeah, that might be the way to do it |
| 13:11 | technomancy | what exactly does :provided mean then? |
| 13:11 | technomancy | if it's in the JDK, why declare it? |
| 13:13 | dnolen | nice post from raph_amiard http://raphamiard.posterous.com/gsoc-2012-pluggable-backend-infrastructure-an |
| 13:15 | cemerick | technomancy: provided is the same as the default "compile", but the dep (and its transitive deps) shouldn't be added to uberjars, etc. |
| 13:15 | cemerick | mmm, and it's not transitive itself |
| 13:16 | cemerick | technomancy: meditation on the definitions in http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html is warranted :-P |
| 13:16 | jweiss | idiomatic clojure way to "split a list at the first item that's in an even index (zero based) that is not a keyword"? |
| 13:18 | mdeboard | take-while? |
| 13:18 | mdeboard | er, split-by |
| 13:19 | jweiss | mdeboard: how does the predicate know what the index is? |
| 13:19 | jweiss | i guess i'd have to employ an indexed list or somethig |
| 13:19 | mdeboard | Maybe like (split-by #(and (even? (get % coll)) (not (keyword? %)))) |
| 13:19 | jweiss | i think that was in contrib someplace |
| 13:19 | mdeboard | that's untested btw |
| 13:19 | mefesto | dnolen: woah, scripting native libs using clojurescript via lua backend... wild :) |
| 13:19 | mdeboard | I might also be getting `get` backward |
| 13:20 | mdeboard | like, it looks up based on index, I can't renember |
| 13:20 | jweiss | mdeboard: yeah that looks close enough, thanks :) |
| 13:21 | mefesto | is crate top-of-the-food-chain when it comes to client-side templates in clojurescript? soy used by anyone? |
| 13:21 | halgari1 | dnolan: from what I understand we'll still have to use Java to compile ClojureLua to Lua? |
| 13:28 | dnolen | halgari1: Until somebody actually bootstraps the compiler infrastructure, I don't see that changing anytime soon. |
| 13:32 | goodieboy | if i deref a delay object from 2 threads at the "same time", will the thread that derefs last be blocked until the delay value is delivered? |
| 13:49 | jweiss | ,(into {} [1 2]) |
| 13:49 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 13:49 | jweiss | hm, apparently i forgot how into works... weird. |
| 13:49 | jweiss | i could have sworn that used to work |
| 13:50 | Bronsa | , (into {} [[1 2]]) |
| 13:50 | clojurebot | {1 2} |
| 13:51 | jweiss | i thought you could use 'into' to make maps without pairing the k/v first? |
| 13:51 | Bronsa | jweiss: you can use hash-map for that |
| 13:51 | Bronsa | ,(apply hash-map [1 2]) |
| 13:51 | clojurebot | {1 2} |
| 13:51 | raek | ,(conj {} [1 2]) |
| 13:51 | clojurebot | {1 2} |
| 13:52 | nDuff | goodieboy: easy enough to test from the repl |
| 13:52 | goodieboy | nDuff: true, just found out for myself :) |
| 13:54 | y3di | whats the time complexity of inserting into a vector |
| 13:54 | raek | y3di: O(log_32 n) |
| 13:55 | gf3 | raek: Really? |
| 13:55 | y3di | 32? |
| 13:56 | mefesto | who needs goog.dom.query... |
| 13:58 | raek | y3di: gf3: if you have a vector with 1 000 000 000 elements, then an update operation is 6 steps |
| 13:59 | nDuff | y3di: IIRC, Phil Bagwell's talk went into that at the conj last year |
| 13:59 | nDuff | y3di: http://blip.tv/clojure/phill-bagwell-striving-to-make-things-simple-and-fast-5936145 |
| 14:01 | nDuff | y3di: ...again IIRC, worst-case given the maximum size possible is something like 6 or 7 hops, making it close enough to O(1) to not matter much. |
| 14:02 | nDuff | ("amortized constant time") |
| 14:03 | nDuff | ...wait, that's lookups. |
| 14:04 | nDuff | appending is (32/5)lgN |
| 14:05 | raek | nDuff: why 32/5? |
| 14:07 | nDuff | raek: section 3.2 of Bagwell's paper on RRB trees. |
| 14:14 | nDuff | What's convention for managing namespaces when forking someone else's code? |
| 14:15 | nDuff | If I'm creating my own fork of org.clojars.rabbitmq, should I be renaming it to net.dyfis.rabbitmq? |
| 14:16 | mefesto | nDuff: if you plan on contributing back you should keep the same style as the original project |
| 14:16 | technomancy | rule 1 is to not do it if at all possible |
| 14:16 | nDuff | mefesto: the original project seems pretty dead |
| 14:16 | technomancy | nDuff: more common is to use org.clojars.$YOUR_CLOJARS_USERNAME |
| 14:16 | nDuff | ahh. |
| 14:17 | mefesto | nDuff: have you looked for other libs that might do what you want? *cough* wabbitmq :) |
| 14:17 | nDuff | ...hmm, hadn't heard of that one. *looks* |
| 14:17 | nDuff | mefesto: nice, thanks! |
| 14:17 | technomancy | yeah, and if that doesn't cover it, there are five other rabbitmq wrappers you could try |
| 14:19 | mefesto | been meaning to re-write that readme :-\ |
| 14:25 | nDuff | ...hmm. Ought to be a better way to plug in encoding/decoding mechanisms; seems silly to have the unconditional json dependency. |
| 14:26 | mefesto | nDuff: yeah you can plugin your own those just happen to be included |
| 14:26 | mefesto | which i was wanting to break out into another project |
| 14:26 | mefesto | sorry, was thinking about another project :) |
| 14:31 | nDuff | ...hmm; leiningen supports flagging dependencies as optional; might make sense to just go that route (and move the json bits into their own namespace, only usable if that optional dep is brought in). |
| 14:32 | nDuff | mefesto: ...moving namespaces around would be an interface change, but we're pre-1.0... so what would your thoughts be on accepting such a patch? |
| 14:32 | jlongster | dnolen: where do I filed bugs for clojurescript? |
| 14:32 | jlongster | *file |
| 14:33 | mefesto | nDuff: works for me. i was thinking about redoing the namespaces anyway to follow what seems to be the convention: wabbitmq.core, wabbitmq.content, etc... |
| 14:34 | mefesto | or wabbitmq.json ... whatever sounds good |
| 14:36 | dnolen | jlongster: http://dev.clojure.org/jira/browse/CLJS |
| 14:39 | jlongster | dnolen: thanks |
| 14:40 | dnolen | jlongster: np |
| 14:41 | timvisher | &(isa? java.util.Map {}) |
| 14:41 | lazybot | ⇒ false |
| 14:41 | timvisher | anyone care to explain? ;) |
| 14:42 | timvisher | &(isa? clojure.lang.IPersistentMap {}) |
| 14:42 | lazybot | ⇒ false |
| 14:42 | raek | timvisher: both arguments need to be classes |
| 14:42 | raek | &(isa? java.util.Map (class {})) |
| 14:42 | lazybot | ⇒ false |
| 14:42 | timvisher | &(isa? clojure.lang.IPersistentMap (class {})) |
| 14:42 | lazybot | ⇒ false |
| 14:42 | stuartsierra | &(instance? java.util.Map {}) |
| 14:42 | lazybot | ⇒ true |
| 14:43 | timvisher | oh boy |
| 14:43 | timvisher | now my mind's really blown... :) |
| 14:43 | raek | (isa? (class {}) java.util.Map) |
| 14:43 | raek | ,(isa? (class {}) java.util.Map) |
| 14:43 | clojurebot | true |
| 14:43 | technomancy | you want instance? rather than isa? |
| 14:43 | timvisher | ok... off to read the docs i suppose. :) |
| 14:44 | stuartsierra | `isa?` checks child-parent relationships in a user-defined hierarchy, optionally including Java types. |
| 14:45 | stuartsierra | `instance?` is more or less equivalent to Java's `instanceof` operator. |
| 14:45 | technomancy | isa? is not about "Is X a Y", which is confusing. |
| 14:45 | timvisher | technomancy: definitely was my assumption |
| 14:45 | stuartsierra | yes |
| 14:46 | timvisher | given the preponderance of `is a` vs `has a` relationship discussions in OO land |
| 14:46 | dnolen | stuartsierra: any thoughts on when the next CLJS release will go out? |
| 14:46 | stuartsierra | dnolen: you want one/ |
| 14:46 | stuartsierra | ? |
| 14:46 | technomancy | also the arg ordering is confusing; you nearly always want instance? anyway |
| 14:46 | dnolen | stuartsierra: actually ... not quite yet. we need to re-precate ObjMap first. |
| 14:47 | stuartsierra | dnolen: ok |
| 14:47 | fliebel | dnolen: reprecated? ObjMap? |
| 14:47 | mefesto | i've been having trouble using :libs ["closure/library/third_party/closure"] ... is it me or a known thing? |
| 14:47 | technomancy | so apparently lua doesn't have immutable data types. that's worrisome. =\ |
| 14:47 | mefesto | i've read that some people were creating their own goog.jar to get around it |
| 14:48 | dnolen | fliebel: we deprecated ObjMap a bit too eagerly when PHMs went out. |
| 14:48 | stuartsierra | mefesto: I've been thinking of making a goog-third-party JAR. Just haven't had time. |
| 14:48 | ibdknox | my goog-jar includes the third party extensions |
| 14:49 | mefesto | stuartsierra: whenever the next cljs release is, would it include that? |
| 14:49 | pandeiro | technomancy: i was reading your article and kept wondering 'what about JS? (no immutable data types right?)' |
| 14:49 | stuartsierra | mefesto: probably not, but you could add it as an extra dependency. |
| 14:49 | technomancy | pandeiro: JS has immutable strings |
| 14:50 | pandeiro | ah yeah |
| 14:50 | technomancy | IIUC cljs has to do some translation between clojure lists and js objects anyway |
| 14:51 | technomancy | though admittedly I haven't looked at it closely |
| 14:52 | pbostrom_ | mefesto: what ended up working for me was :libs ["goog/dom/query.js"] |
| 14:54 | mefesto | pbostrom_: this works with a fresh clojurescript clone? (i.e. no customized jars) |
| 14:54 | stuartsierra | If somebody can send me a goog-third-party JAR with a POM file like the one we made for goog-closure, I can release it to central repositories. |
| 14:55 | timvisher | i have a defrecord form in my core namespace that i can access at the repl after `use`ing that namespace but my tests can't see it. they can see functions defined by that namespace though just fine |
| 14:56 | timvisher | neither clojure-test-mode or `lein-test` seem to be able to find it |
| 14:56 | timvisher | everyone reports that they can't resolve the classname |
| 14:56 | S11001001 | timvisher: what are you using the classname for? |
| 14:57 | timvisher | to create a new instance of that record as per http://clojuredocs.org/clojure_core/clojure.core/defrecord |
| 14:57 | S11001001 | use the ->blah or map->blah functions it made for you instead |
| 14:58 | pbostrom_ | mefesto: I'm trying to remember how I set it up, it's been a while, let me take a look |
| 14:59 | mefesto | pbostrom_: hmm i added that to my lein-cljsbuild config and restarted lein cljsbuild auto but no go |
| 15:00 | mefesto | (:require [goog.dom :as dom]) followed by (.log js/console (str "query? " dom/query)) |
| 15:01 | Borkdude | I would like to iterate recursively over a map and use destructuring |
| 15:01 | Borkdude | can I write smith like [[k v] & rkeyvals] to get the first key-value pair from the map? |
| 15:01 | timvisher | S11001001: i don't see any methods like that reported by .getMethods |
| 15:02 | raek | Borkdude: sure. you can also use map, for, doseq, and reduce if any of those functions "threads" the data in the rigth way |
| 15:02 | pbostrom_ | (:require [goog.dom.query :as gquery]) |
| 15:03 | S11001001 | timvisher: they're functions |
| 15:03 | Borkdude | raek: what's wrong here? http://cljbin.com/paste/4f9aeb74e4b0ee8eed133fc2 |
| 15:03 | pbostrom_ | mefesto: ^ |
| 15:03 | raek | if you can express the map processing as operations on sequences of pairs, then you can use the usual sequence functions |
| 15:04 | mefesto | pbostrom_: oh, thanks :) |
| 15:04 | timvisher | S11001001: hmm. forgive me but i'm completely lost |
| 15:04 | timvisher | :) |
| 15:05 | raek | hmm |
| 15:06 | Borkdude | raek: maybe I have to pass it explicitly as a seq? |
| 15:06 | mefesto | pbostrom_: ok i think i got it now thanks! |
| 15:06 | raek | Borkdude: ok, it looks like you can't destructure maps as sequences directly... |
| 15:06 | Borkdude | raek: so (seq decimal-roman) |
| 15:07 | raek | Borkdude: yeah, I tried that in my repl and it worked |
| 15:07 | mefesto | pbostrom_: it's weird how that requires but it's available under goog.dom/query |
| 15:07 | mefesto | pbostrom_: was expecting it to be (gquery/query ...) |
| 15:08 | S11001001 | wondering about environments |
| 15:08 | S11001001 | ~(defrecord blah [x y]) |
| 15:08 | clojurebot | ,(let [testar (fn [x y] (if (= (reduce + (filter odd? (range 0 x))) y) (str y " is an square perfect")) )] (testar 10 25)) |
| 15:08 | S11001001 | something |
| 15:08 | S11001001 | ,(defrecord blah [x y]) |
| 15:08 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 15:08 | S11001001 | ok then |
| 15:09 | S11001001 | timvisher: functions, you know, like those things you make with defn? Nothing to do with methods. You get ->blah and map->blah when you defrecord blah. |
| 15:09 | Borkdude | raek: hmm (seq decimal-roman) turns the order around… I didn't even mean sorted, but order-preserving.. |
| 15:10 | Borkdude | raek: I guess I want to sort from high to low |
| 15:10 | mefesto | pbostrom_: you have no idea how much time i burned trying to get to that one function! thanks again :) |
| 15:10 | mefesto | https://refheap.com/paste/2400 |
| 15:11 | raek | Borkdude: yeah, you can use sorted-map-by. sorted-map does not maintain the order you instered with |
| 15:13 | raek | Borkdude: ##(seq (sorted-map-by #(compare %2 %1) :a 1 :b 2 :c 3)) |
| 15:13 | lazybot | ⇒ ([:c 3] [:b 2] [:a 1]) |
| 15:13 | mefesto | pbostrom_: i was able to remove the :libs section from my config and rebuild my js file and it still works. i think it was this weird namespacing thing that was the cause the whole time |
| 15:13 | Borkdude | raek: tnx |
| 15:14 | Roxxi | Can anyone share an example of declaring a function that takes some params + optional keyword arguments (e.g. (foo a b key1: c key2: d) ) |
| 15:16 | raek | Roxxi: (defn foo [a b & {:keys [key1 key2]}] [a b key1 key2]) |
| 15:16 | raek | (foo 1 2 :key2 3 :key1 4) => [1 2 4 3] |
| 15:16 | mefesto | is there a way to convert js arrays to clojure in cljs? |
| 15:16 | Roxxi | and if I call (foo 1 2) ? |
| 15:16 | raek | you get nil for key1 and key2 |
| 15:16 | Roxxi | Is there a way to specify defaults? |
| 15:17 | Borkdude | raek: works now, I used reverse, http://cljbin.com/paste/4f9aeeb3e4b0ee8eed133fc3 |
| 15:17 | raek | Roxxi: you can also provide defaults defn foo [a b & {:keys [key1 key2]} :or {key1 :default1, key2 :default2}] [a b key1 key2]) |
| 15:18 | Roxxi | Hm. Thanks raek. |
| 15:18 | pbostrom_ | mefesto: yeah, I struggled with it for a while myself; I actually didn't even use it that long before I switched to just using jQuery for everything |
| 15:18 | mefesto | pbostrom_: im really close to doing that too but im trying to see how far gclosure gets me |
| 15:19 | mefesto | pbostrom_: gclosure libs are pretty painful imo |
| 15:24 | juhu_chapa | zamaterian: is clojure-config still unstable? |
| 15:24 | pbostrom_ | mefesto: array-seq |
| 15:25 | mefesto | hm is there a cljs contrib? |
| 15:26 | stuartsierra | mefesto: no |
| 15:26 | stuartsierra | But there could be. |
| 15:26 | stuartsierra | For easier DOM-manipulation in ClojureScript, look at Luke VanderHart's Domina. |
| 15:27 | mefesto | stuartsierra: will do, thanks |
| 15:28 | mefesto | found myself writing this and thinking there must be a ton of these out there: https://refheap.com/paste/2403 |
| 15:28 | timvisher | S11001001: cheeky. ;) The part i'm lost about is that i didn't know a side-affect of defrecord was creation of functions |
| 15:28 | timvisher | is there an example of that online that I can look at? |
| 15:28 | angerman | what can I do about this error: |
| 15:28 | angerman | Unable to resolve artifact: Unable to get dependency information: Unable to read the metadata file for artifact 'commons-codec:commons-codec:jar': Cannot find parent: org.apache.commons:commons-parent for project: commons-codec:commons-codec:jar:1.4 for project commons-codec:commons-codec:jar:1.4 |
| 15:28 | angerman | commons-codec:commons-codec:jar:1.4 |
| 15:28 | angerman | ? |
| 15:29 | mefesto | but domina looks like it eliminates my need for goog.dom/query |
| 15:30 | dnolen | mefesto: yeah I would use domina |
| 15:30 | stuartsierra | angerman: Your local Maven repository cache may corrupted by a bad file. |
| 15:30 | stuartsierra | mefesto: Try deleting ~/.m2/repository/commons-codec |
| 15:30 | angerman | stuartsierra: how to easily fix? rm ~/.m2 ? |
| 15:30 | ibdknox | I thought domina used goog.dom/query |
| 15:30 | stuartsierra | ^ I meant angerman |
| 15:30 | dnolen | ibdknox: it does underneath yeah. |
| 15:31 | angerman | stuartsierra: kk. |
| 15:31 | angerman | did not fix it though :/ |
| 15:31 | dnolen | one annoying thing is that I don't think domina is careful about its declares. with lein-cljsbuild it'll spew lots of warnings. |
| 15:31 | ibdknox | dnolen: yeah he just uses my goog-jar :) |
| 15:31 | mefesto | dnolen: yeah i noticed that and it scared me off |
| 15:32 | mefesto | temporarily, but just an hour or so ago it looks like a new domina release is out |
| 15:32 | Raynes | ibdknox: You're going to have to offer nudies if you ever want to see 200k. |
| 15:33 | ibdknox | dnolen: strange loop talk submitted :) |
| 15:33 | ibdknox | Raynes: that's my last ditch effort at the end ;) |
| 15:33 | pandeiro | ibdknox: in korma if i nest a values call in an insert fn, do i still need the query argument? |
| 15:33 | angerman | stuartsierra: no idea what was wrong. but rm -fR ~/.m2 helped |
| 15:33 | ibdknox | pandeiro: I didn't follow that |
| 15:33 | stuartsierra | angerman: probably a corrupted metadata file somewhere in the tree |
| 15:33 | Raynes | ibdknox: Also, stop with the damned talks. How do you get energy for all of that crap? I did one talk and crawled into a whole for 4 months. |
| 15:34 | pandeiro | ibdknox: sorry the docstring shows values as having arity 2, but your examples on the korma site show it with just the map/vector of data |
| 15:35 | dnolen | ibdknox: exciting! |
| 15:35 | ibdknox | pandeiro: keep in mind all of the insert/select/etc functions have implicit ->'s |
| 15:35 | ibdknox | pandeiro: so the query is being threaded through |
| 15:36 | pandeiro | ibdknox: yeah ok now the docstring makes sense |
| 15:42 | ibdknox | Raynes: I'm only good at talking, so I gotta milk that for what it's worth ;) |
| 15:43 | Raynes | Psh. |
| 15:44 | mefesto | yea ibdknox, you're all talk :P |
| 15:45 | mefesto | pfft, only 53 public repos :) |
| 15:46 | Raynes | Yikes, I have 88. |
| 15:46 | ibdknox | dude you're like 50% more involved than I am |
| 15:47 | ibdknox | technomancy has more than 100 last time I looked |
| 15:47 | ibdknox | 118 |
| 15:50 | mefesto | getting this error when pulling the deps for the latest domina 1.0.0-beta4: https://refheap.com/paste/2405 |
| 15:51 | dnolen | mefesto: the latest release is 1011, they must be requesting their own build. |
| 15:54 | mefesto | is it bad manners to paste a stacktrace on the mailing list? refheap it instead? |
| 15:56 | mefesto | i guess i'll find out if someone yells at me |
| 15:59 | goodieboy | i have a ring app that has a couple of init functions. These functions setup some state, and prepare things like http client pools, search engine instance etc.. What can I do to ensure that these functions only get called once, no matter what... even while in development mode using emacs/slime? |
| 16:00 | goodieboy | I'm using something like this at them moment: (def inited? (delay (init-stuff...))) and later @inited? |
| 16:01 | metajack | goodieboy: there's defonce |
| 16:01 | goodieboy | metajack: yeah i thought about that too. but I've heard from a few developers that defonce is "evil", not thread safe etc.? |
| 16:02 | metajack | goodieboy: korma uses it for exactly this purpose, which is used by lots of ring apps. |
| 16:02 | goodieboy | interesting |
| 16:02 | pandeiro | dnolen: have you used swank.js at all? was considering setting it up for some js dev but curious if it's worth the hassle (and how much hassle, incompatability with slime version used by swank clojure) |
| 16:03 | dnolen | pandeiro: I looked at it a couple of times, but didn't think it was worth the hassle. |
| 16:04 | pandeiro | cool, thanks.. i actually like regular js mode but am missing an easy repl |
| 16:06 | jsabeaudry | Is there a clojurescript repl running online somewhere? Something like jsfiddle but with clojurescript |
| 16:07 | pandeiro | jsabeaudry: himera.herokuapp.com |
| 16:07 | dnolen | jsabeaudry: a JSFiddle like service for ClojureScript would be pretty awesome, at the moment we just have Himera |
| 16:08 | dnolen | jsabeaudry: a CLJSFiddle service could probably just use Himera. |
| 16:09 | jsabeaudry | pandeiro, dnolen: thans for the link, this will do perfectly fine :) |
| 16:09 | chouser | Does anyone know the justification for defrecords including type in their equality test (and yet lists/vectors not doing so)? |
| 16:10 | dnolen | chouser: I vaguely remember when rhickey made that decision. |
| 16:10 | dnolen | chouser: in general I don't see why you wouldn't want that behavior, you could have just used a map then. |
| 16:11 | mefesto | how does one listen for the document ready event in domina? |
| 16:12 | nDuff | mefesto: have you looked into what's going on with the type-hinting? I'm having trouble getting type-hints for (defn- channel ^Channel [] ...) to stick -- calls to (channel) are still going through introspection unless I hint the result, ie. ^Channel (channel) |
| 16:12 | pandeiro | mefesto: any reason you don't wanna use jayq (just curious)? |
| 16:12 | mefesto | i tried (events/listen! (css/sel "body") :load (fn [event] ...)) |
| 16:12 | chouser | dnolen: we ran into it because we |
| 16:12 | mefesto | nDuff: no i never noticed any issues with the type hints |
| 16:13 | nDuff | mefesto: how many lines of output does "lein2 check" give on your system? |
| 16:13 | dnolen | chouser: here's the ML post from rhickey http://groups.google.com/group/clojure/msg/a7413f4fc8cdd929 |
| 16:13 | mefesto | nDuff: unfortunately im at work and can't mess with it atm but i'll check it out when i get home |
| 16:13 | nDuff | mefesto: ...I get 63 from "lein2 check 2>&1 | wc -l" |
| 16:13 | nDuff | mefesto: *nod*. I'll file a ticket in github to track, then. |
| 16:14 | mefesto | pandeiro: jayq a jquery wrapper? |
| 16:14 | pandeiro | mefesto: :) |
| 16:14 | chouser | dnolen: we ran into it because we were serializing in a way that treated all maps the same, but then got back maps that were not equal to what we sent |
| 16:14 | mefesto | nDuff: i guess i never really viewed creating a channel has a hotspot perf wise and never worried about it |
| 16:15 | chouser | dnolen: thanks, I'd found that one. I'm not interested in user-defined equality, I'm just surprised concrete type is included in the standard equality |
| 16:15 | nDuff | mefesto: ...if it were only happening on creation I'd be less worried |
| 16:15 | nDuff | mefesto: this is happening on anything that tries to grab the current channel to call something on it |
| 16:15 | jsabeaudry | In clojurescript is (nth something 0) the right way to write something[0] ? |
| 16:15 | clojurebot | ,(let [testar (fn [x y] (if (= (reduce + (filter odd? (range 0 x))) y) (str y " is an square perfect")) )] (testar 10 25)) |
| 16:15 | chouser | and using .equals to get the other behavior doesn't really help me understand why = does what it does |
| 16:15 | mefesto | nDuff: oh ok yeah that doesn't sound good |
| 16:15 | nDuff | mefesto: ...(.basicGet (channel)), (.basicRecover (channel)), etc |
| 16:15 | mebaran151 | what's the easiest way to say take every 2 elements from a collection? |
| 16:16 | nickmbailey | take elements 2 at a time or take every second element? |
| 16:16 | mebaran151 | ,(partition-by #(Character/isUpperCase %1) "AbcDefHij") |
| 16:16 | clojurebot | ((\A) (\b \c) (\D) (\e \f) (\H) ...) |
| 16:16 | mefesto | pandeiro: i guess i wanted to avoid jquery since gclosure can't do its magic. is that the case with jayq? |
| 16:17 | pandeiro | jsabeaudry: aget also works |
| 16:17 | pandeiro | mefesto: i think ibdknox has the definitive rationale in the jayq readme... not sure about the advanced optimization issue though |
| 16:17 | jsabeaudry | pandeiro, I'll try aget because nth doesnt work |
| 16:18 | pandeiro | jsabeaudry: nth worked for me on himera just now... i think js arrays implement ISeq ? |
| 16:18 | dnolen | chouser: here's you and lpetit and rhickey debating the finer points http://clojure-log.n01se.net/date/2010-07-30.html#12:11a |
| 16:19 | mebaran151 | I want every capitalized group (ie (\A) with its uncapitalized tail (\b \c) so to speak (for an uncamelcase function)) |
| 16:19 | mebaran151 | "AbcDefHij" => "abc-def-hij" |
| 16:20 | mefesto | pandeiro: yeah makes sense although im just learning clojurescript now so i'd like to do that with a fresh state of mind instead of just using it as a layer ontop of jquery |
| 16:21 | jsabeaudry | pandeiro, new FormData(cljs.core.nth.call(null, jayq.core.$.call(null, "form.channelconfig"), 0)) FAILS but new FormData(jayq.core.$.call(null, "form.channelconfig")[0]) WORKS (im really stretching the paste limit :P |
| 16:21 | nickmbailey | ,(re-seq #"[A-Z][a-z][a-z]" "AbcDefHij") |
| 16:21 | clojurebot | ("Abc" "Def" "Hij") |
| 16:21 | pandeiro | mefesto: gotcha... in that case if you're just learning you can wrap document.querySelector and document.querySelectorAll since modern browsers have those |
| 16:21 | nickmbailey | mebaran151: ^ |
| 16:22 | mebaran151 | nickmbailey: there could be any number of characters lowercased |
| 16:22 | nickmbailey | obviously adjusting that regex for whatever you really want |
| 16:22 | mebaran151 | ie (IWantToHandleThisToo) |
| 16:23 | nickmbailey | #"[A-Z][a-z]*" |
| 16:23 | jsabeaudry | now what I need is clojurescript to output that "[0]" because it doesnt work without it and neighter aget or nth work |
| 16:23 | mefesto | pandeiro: cool thanks. although i did manage to get goog.dom/query working :) |
| 16:23 | emezeske | pandeiro, mefesto: jayq works perfectly with advanced optimization -- jquery is left unmolested, and the externs file keeps the optimizer from mangling the jquery calls in your code |
| 16:23 | mebaran151 | nickmbailey: great solution! thanks |
| 16:24 | pandeiro | mefesto: cool... https://refheap.com/paste/2409 just to give you an idea |
| 16:24 | pandeiro | emezeske: right but what about that feature of closure compiler that removes/inlines extraneous code... obviously it won't touch the minified jquery yeah? |
| 16:25 | xeqi | &(re-seq #"[A-Z][a-z]*" "Uñicode") |
| 16:25 | emezeske | pandeiro: Yeah, but you don't want that anyway, you should have the client get jquery from a CDN |
| 16:25 | lazybot | ⇒ ("U") |
| 16:25 | emezeske | pandeiro: It's basically certain that they'll already have it cached |
| 16:26 | pandeiro | emezeske: makes sense, except there's also like 16 different jquery versions being used |
| 16:26 | emezeske | pandeiro: Well, obviously you grab the version you need from the CDN. It's still extremely likely to just already be cached. |
| 16:28 | jsabeaudry | Anyone aware of a html5 file upload example with clojurescript? |
| 16:29 | jayunit100 | man... .not alot of resource on cascalog out there. |
| 16:30 | dnolen | jlongster: CLJS-209 is probably not going to go anywhere. Clojure doesn't support inner defines like scheme does. |
| 16:30 | dnolen | jlongster: defs are only top level. |
| 16:31 | jsabeaudry | When using (first foo) to try to obtain foo[0] I get Illegal operation on WrappedNative prototype object |
| 16:31 | angerman | does clojure 1.4 provide convenece methods to format dates? |
| 16:32 | pandeiro | jsabeaudry: something funky going on? old version of cljs? works fine on himera |
| 16:33 | jsabeaudry | pandeiro, perhaps, I didnt install it myself I let cljsbuild take care of that for me |
| 16:33 | jsabeaudry | I'll see if there is a new version out |
| 16:34 | goodieboy | could someone tell me whether or not defonce is considered bad practice? I have a friend who swears it's the devils making, any opinions on defonce? |
| 16:34 | pandeiro | as for file upload, if you know how to do it in JS, it's basically the same... i use FileReader (https://developer.mozilla.org/en/DOM/FileReader) for drag/drop uploading |
| 16:35 | dnolen | goodieboy: defonce is fine |
| 16:35 | goodieboy | dnolen: thank you. Any problems with thread safety and defonce? |
| 16:35 | tmciver | goodieboy: does your friend give reasons for that sentiment? |
| 16:36 | dnolen | goodieboy: like what? |
| 16:37 | goodieboy | i think his thought is, if two threads attempt to set a defonce at the same time, then "bad" things can happen, unlike refs and atoms |
| 16:37 | goodieboy | this is mostly talk when in development, using swank and reloading namespaces etc.. |
| 16:37 | jsabeaudry | pandeiro, I don't actually im trying to follow this: http://stackoverflow.com/posts/8758614/revisions |
| 16:38 | jsabeaudry | pandeiro, but in stuck on the form data creation... |
| 16:38 | dnolen | goodieboy: why would two threads "set" a defonce? |
| 16:41 | dnolen | goodieboy: even so I don't see how that could be a problem, val field of Var marked volatile. But perhaps someone who understands the finer points of volatile can point out problems. |
| 16:41 | jsabeaudry | emezeske, is there a setting to enable a timestamp on the build result ? |
| 16:41 | jsabeaudry | (in cljsbuild) |
| 16:41 | jsabeaudry | (when running in auto) |
| 16:42 | emezeske | jsabeaudry: You mean, print out the current time at which a build completed? |
| 16:42 | goodieboy | dnolen: This is more to the point of his concern: If the goal is to share state amongst threads then he would consider it really bad usage. |
| 16:42 | jsabeaudry | emezeske, exactly |
| 16:42 | emezeske | jsabeaudry: No, there's no setting for that. I could see that being handy |
| 16:42 | goodieboy | I would agree, sharing state, especially if that state is meant to be mutable |
| 16:42 | pandeiro | jsabeaudry: emezeske: cljs-template does that by default |
| 16:43 | dnolen | goodieboy: defonce isn't for sharing mutable state |
| 16:43 | goodieboy | yeah, i guess it's all in the name! :) |
| 16:43 | jsabeaudry | I often look at the build window and wonder, did it build? Then I try to remember the last build time and trigger another build by saving the file again) :P |
| 16:44 | emezeske | Yeah, I can see that. I guess I haven't noticed because I always keep the auto output window visible |
| 16:44 | emezeske | I might just make it always print a timestamp; there's not much reason not to |
| 16:44 | goodieboy | dnolen: thanks, you've given me some relief in using defonce, and right about now it could be very helpful for me |
| 16:45 | jlongster | dnolen: oh! I didn't realize that |
| 16:46 | jlongster | dnolen: sorry for not doing the proper research |
| 16:47 | timvisher | is it expected that defrecords are not exposed when useing the namespace they're defined in? |
| 16:47 | daniel_ | ,(unchecked-byte 128) |
| 16:47 | clojurebot | -128 |
| 16:47 | dnolen | jlongster: it's ok, common source of confusion coming from Scheme :) |
| 16:47 | daniel_ | why isnt it working in my repl??? :'( |
| 16:48 | daniel_ | java.lang.Exception: Unable to resolve symbol: unchecked-byte in this context (NO_SOURCE_FILE:1) |
| 16:48 | xeqi | ,*clojure-version |
| 16:48 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: *clojure-version in this context, compiling:(NO_SOURCE_PATH:0)> |
| 16:48 | xeqi | ,*clojure-version* |
| 16:48 | clojurebot | {:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"} |
| 16:48 | stuartsierra | timvisher: Yes. defrecords are not Vars, but they do create constructor functions like ->RecordName |
| 16:49 | timvisher | ah, _that_ is what M. S11001001 was talking about |
| 16:49 | timvisher | is there documentation on all this other than the docstring? |
| 16:50 | daniel_ | hmm, im 1.2.1 |
| 16:50 | timvisher | i don't see any of this mentioned in the docstring or in the datatypes section on clojure.org or in the clojuredocs.org documentation either |
| 16:51 | daniel_ | yay, 1.4.0 works |
| 16:52 | kovasb | timvisher: yeah the first time i became aware of it, was just noticing it in people's code |
| 16:52 | kovasb | timvisher: wondering if it was some kind of convention on library author's part or something |
| 16:53 | timvisher | and defrecord's docstring is _still_ marked as alpha, subject to change |
| 16:53 | timvisher | which still makes me nervous about even talking about |
| 16:53 | timvisher | about it* |
| 16:53 | stuartsierra | timvisher: Rich likes to hedge |
| 16:53 | technomancy | wow, rich talks about simple vs easy at railsconf and the very next week, rails talks about adding a queueing system. hard to imagine a more spectacular way to miss the point. |
| 16:53 | timvisher | stuartsierra: yes he does |
| 16:54 | jsabeaudry | timvisher, As someone here explain to me before, it's marked as alpha as in "alpha male" |
| 16:54 | kovasb | lol |
| 16:54 | timvisher | jsabeaudry: hah! |
| 16:54 | stuartsierra | technomancy: I miss the days when Rails was simple. |
| 16:54 | timvisher | i still think the documentation for defrecord and deftype needs some serious beefing up |
| 16:54 | cemerick | technomancy: clearly, there needs to be a web framework that's less enterprisey. :-P |
| 16:54 | kovasb | technomancy: I think in the original version of that talk, he hypes queues |
| 16:54 | metajack | my wife went to that talk at railsconf. she liked it :) |
| 16:54 | timvisher | i find them to be very surprising animals |
| 16:54 | metajack | which is funny because i've been trying to get her to watch the strangeloop keynote for months. |
| 16:55 | timvisher | especially when comparing their actual behavior and usage to the documentation available for them |
| 16:55 | technomancy | kovasb: queues are great; they are nice and orthogonal =) |
| 16:55 | timvisher | metajack: i find myself trying to get everyone around me to watch that talk, over and over again |
| 16:55 | timvisher | that talk was seriously transformative for me |
| 16:55 | timvisher | really drove home the simple ain't easy talk stu gave |
| 16:57 | kovasb | timvisher: yeah they are serious constructs. pretty much need to go to outside sources (books etc) for a in-depth treament |
| 16:58 | timvisher | kovasb: which books cover them? |
| 17:00 | jlongster | dnolen: so there aren't inner-defs anywhere? it's always `let`? |
| 17:01 | dnolen | jlongster: defs are always top level. |
| 17:01 | jlongster | is there are a site that shows a bunch of idiomatic Clojure examples? |
| 17:01 | jlongster | that's interesting |
| 17:01 | dnolen | jlongster: and you have a quite a few let forms: let, left, if-let, when-let, etc. |
| 17:02 | dnolen | left -> letfn |
| 17:02 | aniero | left! |
| 17:02 | jlongster | heh, weird :) |
| 17:02 | dnolen | jlongster: if-let / when-let are awesome |
| 17:02 | dnolen | something I grind my teeth about when using other langs. |
| 17:02 | jlongster | dnolen: I was just gonna say that, assuming they are like the `and-let` I use |
| 17:03 | jlongster | I gotta say though, I'm gonna miss inner defs |
| 17:03 | dnolen | jlongster: I never really like them in Scheme. |
| 17:04 | jlongster | dnolen: so you never use inner functions in Javascript? |
| 17:05 | dnolen | jlongster: of course, but it's pretty much equivalent to var foo = function() {}. same in Clojure, use let / letfn. |
| 17:06 | jlongster | dnolen: true, but (def (fn x) ...) is a bit cleaner than (letfn [(fx [x] ...)] ...) :) |
| 17:06 | jlongster | also doesn't require indentation, which I like |
| 17:06 | jlongster | but still, I'm sure nothing like that's going to change, heh |
| 17:07 | dnolen | jlongster: fwiw I also got used to Dan Friedman's style, he never uses inner defines in his Scheme code. |
| 17:07 | dnolen | jlongster: let, letrec |
| 17:07 | jlongster | dnolen: it's not too bad, but I think it's harder for people coming from javascript |
| 17:08 | dnolen | jlongster: huh, the thought never crossed my mind coming from JS -> Clojure. Even after dabbling with SICP (lots of inner defines) and some CL. |
| 17:09 | dnolen | or if it did, it didn't bother me for long. |
| 17:10 | jtoy | do people use in cater for a bays classifer? |
| 17:10 | jtoy | im |
| 17:10 | jlongster | dnolen: it does for me at least, but it must just be something I do by default |
| 17:11 | dnolen | jlongster: now that I think about it, I'm not even sure what Scheme's scoping rules are for inner defines |
| 17:11 | jtoy | trying to find a bays classifier for clojure and that is what comes up first |
| 17:11 | jtoy | i just want something simple |
| 17:11 | jlongster | dnolen: you're only allowed to use `define` at the beginning of expressions, so it's not arbitrary |
| 17:12 | jlongster | like right after a `define`, `let`, and `begin` |
| 17:12 | jlongster | so it's basically like let, but without the extra syntax/indentation |
| 17:12 | dnolen | jlongster: yeah so a little bit less typing and more ways of doing things. Probably why Dan avoid it's. |
| 17:12 | dnolen | avoids it. |
| 17:13 | jlongster | dnolen: I think having to introduce something like letfn is more confusing |
| 17:13 | jlongster | just have `define` and `let` |
| 17:13 | dnolen | jlongster: letfn is more like letrec so not really the same. |
| 17:14 | jlongster | true, but `let` could also behave more normally and allow references between variables |
| 17:16 | dnolen | jlongster: references between variables less useful interesting I think then recursive local fn definition. |
| 17:16 | dnolen | jlongster: rarely wanted the former. |
| 17:17 | jlongster | dnolen: really? I do things like (let ((x (foo (bar y))) (y (+ x 1))) ... ) |
| 17:17 | jlongster | all the time |
| 17:18 | jlongster | (I know that's hard to read) |
| 17:18 | raek | does the former even make sense in a language with strict evaluation? |
| 17:19 | jlongster | raek: why not? just evaluate the first form, assign it to a variable and add to env, evaluate the next form, etc |
| 17:19 | jlongster | it's very practical |
| 17:19 | raek | jlongster: but what is the value of y when the first form is evaluated? |
| 17:19 | dnolen | jlongster: what raek said. |
| 17:19 | jlongster | y doesn't exist yet |
| 17:20 | jlongster | it's sequential |
| 17:20 | jlongster | hm, I thought clojure allowed that |
| 17:20 | S11001001 | jlongster: it's sequential, not mutually recursive |
| 17:20 | raek | but in order to evaluate (foo (bar y)) you must look up the value of y |
| 17:21 | langmartin | jlongster: y is an box that gets set-box!'ed when the second line is evaluated |
| 17:21 | raek | (assuming 'foo' and 'bar' are not macros) |
| 17:21 | jlongster | raek: oh yikes, sorry, that was a bad typo |
| 17:21 | langmartin | is scheme in a letrec, that is |
| 17:21 | jlongster | langmartin: oh hai! |
| 17:21 | dnolen | jlongster: k, heh the world was turned upside down there for a second. |
| 17:21 | jlongster | right, letrec is different |
| 17:21 | dnolen | jlongster: Clojure let is sequential too. |
| 17:21 | jlongster | dnolen: sorry, total fail. |
| 17:22 | jlongster | haha, ok, that's what I thought. |
| 17:22 | raek | but in non-strict languages you can actually do crazy stuff like that |
| 17:22 | jlongster | yes yes. sorry, I'll go back into my hole now. |
| 17:22 | raek | but yes, you can access x from the second form |
| 17:23 | jlongster | yeah, it's very practical |
| 17:23 | raek | indeed |
| 17:23 | raek | you get non-let* for free with destructuring too |
| 17:23 | raek | (let [[x y] [y x]] ...) |
| 17:24 | jlongster | raek: hot |
| 17:53 | hcumberdale | Hi ;) |
| 17:56 | Raynes | &(clojure-version) |
| 17:56 | lazybot | ⇒ "1.4.0" |
| 17:56 | Raynes | Cool. |
| 18:07 | hcumberdale | yeah! |
| 18:07 | hcumberdale | How can I get the context of my web application?! |
| 18:08 | hcumberdale | http://abc.com/xyz << http://abc.com |
| 18:08 | muhoo | that's really weird. getting UnknownHostExceptions using clutch, connecting to cloudant, but i can wget/curl/firefox to it no problem. |
| 18:10 | ibdknox | hcumberdale: that information is in the ring request |
| 18:11 | hcumberdale | ibdknox how to extract it? |
| 18:11 | gfredericks | dnolen: just created confluence page for numerics. I will add more to it soon if no one else does. |
| 18:12 | ibdknox | hcumberdale: ring requests are just maps :) |
| 18:12 | joegallo | https://github.com/mmcgrana/ring/blob/master/SPEC |
| 18:12 | dnolen | gfredericks: I'm sure no one else will :) go to town! |
| 18:13 | joegallo | looking there, i'm betting it would be :server-name. |
| 18:14 | ibdknox | joegallo: depends on what parts he needs :) |
| 18:14 | ivan | why does ClojureScript look for JS in the classpath? |
| 18:14 | dnolen | gfredericks: well I might of course - I think Rich's advice is good. Figure out the ideal goal - and work out how we can get perf back. |
| 18:14 | ivan | er, CLJS |
| 18:14 | joegallo | right, i was just practicing my googling |
| 18:14 | ibdknox | joegallo: e.g. server-name for http://localhost:8077 will just be localhost |
| 18:14 | hcumberdale | ibdknox, what key is it? uri? |
| 18:15 | joegallo | ibdknox: yes, i'd expect that to be so |
| 18:15 | ibdknox | hcumberdale: you can get it from a combination of :scheme :server-name and :server-port |
| 18:16 | ibdknox | hcumberdale: if you're only accepting on port 80, which is most likely, you'd just need :scheme and :server-name |
| 18:16 | joegallo | ooh, ooh, and if you're not worried about ssl, you could just use :server-name ;) |
| 18:17 | ibdknox | lol |
| 18:17 | ibdknox | :D |
| 18:17 | muhoo | here's a general clojure/couch/lein question: what's the best strategy for keeping views in sync between the source code base and the running (live) db? |
| 18:17 | muhoo | i'm thinking i could just have (set-views ...) run everytime the slug starts up on heroku maybe |
| 18:18 | muhoo | and just overwrite whatever views were there with whatever's new... instant migration. |
| 18:18 | technomancy | muhoo: should probably happen at slug compilation time |
| 18:18 | muhoo | where would i hook that in, inside my project? |
| 18:18 | gfredericks | dnolen: I'm browsing clojure.lang.Numbers to try to get a handle on how the double dispatch works |
| 18:19 | hcumberdale | nope, uri is just everything after / |
| 18:19 | gfredericks | hcumberdale: maybe the host header? |
| 18:19 | technomancy | muhoo: if you set user_env_compile (https://devcenter.heroku.com/articles/labs-user-env-compile) you can do "heroku config:add LEIN_BUILD_TASK="set-views, compile :all" |
| 18:19 | technomancy | muhoo: provided there's a lein task for set-views |
| 18:20 | technomancy | muhoo: maybe LEIN_BUILD_TASK="run -m myapp.set-views, compile :all" |
| 18:20 | clojurebot | clojure-maven-plugin is http://github.com/talios/clojure-maven-plugin |
| 18:20 | technomancy | shaddup clojurebot |
| 18:21 | hcumberdale | (do (map #(info (% request)) [:scheme :server-name :server-port]) ,.... |
| 18:21 | hcumberdale | it does not work? |
| 18:27 | daniel_ | i want to split a 64 character string into a list of 8 separate strings, how can i do this? |
| 18:27 | AimHere | daniel > Use the partition function |
| 18:28 | daniel_ | thanks AimHere |
| 18:28 | AimHere | ,(map #(apply str %) (partition 8 "abcdefghijklqeqopweqeqepqeo")) |
| 18:28 | clojurebot | ("abcdefgh" "ijklqeqo" "pweqeqep") |
| 18:30 | daniel_ | yup, beautiful |
| 18:31 | AimHere | You could probably do something with repeated take-whiles, or some jiggery-pokery with subs, but I think partition looks more idiomatic |
| 18:33 | hcumberdale | (str "http://" (:server-name request) (:server-port request)) ) << can it be done smarter? |
| 18:34 | daniel_ | is there an easy method of finding the length of a string? |
| 18:34 | hcumberdale | (str "http://" (:server-name request) ":" (:server-port request)) << |
| 18:35 | raek | daniel_: count |
| 18:35 | AimHere | daniel_, count. Think of strings as sequences of chars |
| 18:35 | daniel_ | ah count |
| 18:35 | daniel_ | yeah, just found it |
| 18:48 | daniel_ | i have a list like ("line1" "line2" "line3") and im doing (map #(println %) list) |
| 18:49 | daniel_ | println also returns nil after printing so i dont get a nice output, can i avoid that somehow? |
| 18:49 | daniel_ | actually, i guess i want to compile it into one string with \n's |
| 18:49 | daniel_ | and then ill only get one nil |
| 18:50 | daniel_ | how can i slot in "\n" in between each value in the list? |
| 18:50 | hcumberdale | can write a middleware to store the current url to some global ring var ? |
| 18:50 | pipeline | interleave |
| 18:50 | daniel_ | interleave, thats it |
| 18:50 | daniel_ | i was thinking interweave |
| 18:50 | pipeline | that might be it |
| 18:50 | banjiewen | interpose, more likely |
| 18:51 | pipeline | interwangle |
| 18:52 | emezeske | daniel_: What is your goal? Just to print a few lines of output? |
| 18:53 | daniel_ | yeah, its looking good except i also get the parens around the list |
| 18:53 | daniel_ | i want these out as well |
| 18:53 | ipostelnik | if you want just the side-effect of printing, use doseq |
| 18:54 | daniel_ | now i have (println (interleave (repeat "\n") ("lin1" "line2" "line3"))) |
| 18:54 | emezeske | daniel_: map is lazy, you shouldn't do I/O stuff inside it |
| 18:54 | daniel_ | ipostelnik: i think i want doseq |
| 18:54 | pipeline | daniel_: println appends a newline to everything anyway |
| 18:55 | pipeline | so doseq println woulda done you nicely |
| 18:55 | emezeske | (doseq [x [1 2 3 4]] (println x)) |
| 18:56 | daniel_ | right pipeline |
| 18:56 | daniel_ | thanks guys |
| 18:57 | tmciver | daniel_: fyi, you could also just add 'apply str' to what you had: (println (apply str (interleave '("lin1" "line2" "line3") (repeat "\n")))) |
| 18:57 | njdirk | are clojars .jar uploads from lein jar or uberjar? |
| 18:57 | technomancy | njdirk: just jars |
| 18:58 | njdirk | thanks, t -- so where's the resolution of the "dependencies - sub-dependencies" occur? |
| 19:00 | daniel_ | got it working fine, not sure if its good code https://gist.github.com/2514050 |
| 19:00 | daniel_ | having such a complex seq in the bindings |
| 19:00 | daniel_ | maybe i can split it into more functions |
| 19:01 | technomancy | njdirk: I can't tell what you're asking |
| 19:01 | emezeske | daniel_: My suggestion would be to just add more let bindings, for intermediate results |
| 19:03 | emezeske | daniel_: Also, I think (str (apply str... is redundant |
| 19:03 | emezeske | daniel_: nevermind that ^ |
| 19:03 | emezeske | daniel_: I didn't read it right |
| 19:04 | njdirk | sorry, I'm assuming I don't need the fatter standalone jar since lein deps et'al will recurse as necessary to resolve any nested dependencies -- right? |
| 19:06 | technomancy | njdirk: yeah, that's right |
| 19:06 | njdirk | coo -- thx again, t |
| 19:06 | jtoy | what bayes classifier do you guys normally use with clojure? |
| 19:06 | daniel_ | thanks emezeske |
| 19:11 | daniel_ | can anyone suggest how this can be made more 'DRY'? https://gist.github.com/2514097 |
| 19:13 | rbuchmann | whats the best way to destructure a list into the last element and everything before? I arrived at [[prev [last]] (partition-all (dec (count col)) col)] |
| 19:13 | mmarczyk | daniel_: (apply bit-xor (for [op [bit-shift-left bit-shift-right] arg [1 8 7 9]] (op board arg))) ? |
| 19:14 | rbuchmann | [(butlast col) (last col)] walks twice, right? |
| 19:15 | daniel_ | mmarczyk: nice, thanks |
| 19:15 | mmarczyk | np |
| 19:15 | technomancy | you could use juxt! |
| 19:15 | rbuchmann | [[prev last] (juxt [butlast last] col) ? |
| 19:16 | mmarczyk | still walks twice |
| 19:16 | mmarczyk | split-at walks twice too |
| 19:16 | rbuchmann | but cool :) |
| 19:16 | mmarczyk | yeah :-) |
| 19:16 | rbuchmann | hmm |
| 19:17 | mmarczyk | although actually |
| 19:17 | mmarczyk | (partition-all (dec (count coll)) coll) walks twice too, lol |
| 19:17 | mmarczyk | if coll is not counted |
| 19:17 | rbuchmann | not if counted? col, right? |
| 19:17 | mmarczyk | so there may be not different |
| 19:17 | mmarczyk | argh |
| 19:17 | aniero | (let [v (vec coll)] [(last v) (pop v)]) |
| 19:17 | rbuchmann | ^^ |
| 19:18 | aniero | why not that? pop/last are constant time on vectors |
| 19:18 | mmarczyk | I'm not even sure which of the possible correct versions of the above sentence I meant originally :-P |
| 19:18 | aniero | ... i think |
| 19:18 | rbuchmann | hehe |
| 19:18 | mmarczyk | (juxt peek pop) |
| 19:18 | mmarczyk | last is not, but peek is |
| 19:18 | aniero | ah! |
| 19:18 | rbuchmann | that looks good actually |
| 19:18 | rbuchmann | thanks! |
| 19:19 | mmarczyk | :-) |
| 19:19 | jtoy | ? |
| 19:19 | aniero | so it's ((juxt peek pop) (vec coll)) as the final solution? |
| 19:20 | rbuchmann | I guess |
| 19:20 | rbuchmann | walks once, is concise, probably no better |
| 19:21 | technomancy | well it uses juxt, so it does have that going for it |
| 19:21 | technomancy | clojurebot: juxt? |
| 19:21 | clojurebot | juxt is usually the right answer |
| 19:22 | technomancy | ~botsnack |
| 19:22 | clojurebot | Thanks! Can I have chocolate next time |
| 19:22 | mmarczyk | looking @ partition-all's source, it uses (take n s) then nthrest, so no chance of a single walk |
| 19:23 | nDuff | How can I tell if an interface is applicable to an object? |
| 19:23 | mmarczyk | nDuff: instance? |
| 19:23 | mmarczyk | &(instance? clojure.lang.IPersistentMap {}) |
| 19:23 | lazybot | ⇒ true |
| 19:26 | mmarczyk | technomancy: am I correct in surmising lein2 is complete enough that there's not reason not to switch at this point? in particular, no breaking changes likely between the current preview and 2.0? |
| 19:26 | technomancy | mmarczyk: yeah, I recommend upgrading; it's very stable |
| 19:27 | mmarczyk | technomancy: fantastic, thanks! |
| 19:27 | technomancy | mmarczyk: there is one breaking change planned: creating a clojars releases repository and dropping the existing snapshots repository from the default repo list. but that's about it. |
| 19:28 | mmarczyk | technomancy: oh good, I'd like *that* a lot |
| 19:28 | mmarczyk | technomancy: anything in particular that needs to be done to make this happen soon? |
| 19:29 | nDuff | Blerg. |
| 19:29 | technomancy | mmarczyk: a few things: http://groups.google.com/group/clojars-maintainers/msg/75593b0a3ea6023f |
| 19:29 | technomancy | mmarczyk: would love to get help on that if you are interested. right now xeqi is leading the charge, but I hope to be able to pick it back up in a few weeks |
| 19:30 | mmarczyk | technomancy: yeah, I was hoping to get back into developing lein |
| 19:30 | mmarczyk | technomancy: I'll be moving a largish project over to lein2 over the weekend, I'll use this as an opportunity to get to know the new codebase |
| 19:33 | mmarczyk | technomancy: incidentally, I wanted to do a little bit of work on the Clojars front-end in the coming week or two -- add a few minor prettification-type touches to the website and maybe display some additional project info when available in project.clj; who do I send pull requests to? |
| 19:35 | hcumberdale | how can I control the header for ring responses? |
| 19:37 | mmarczyk | hcumberdale: headers are attached to the :headers key in the response map in the form of a map from header name to content; modify that as appropriate |
| 19:38 | technomancy | mmarczyk: sorry, lost my connection |
| 19:38 | mmarczyk | hcumberdale: e.g. (update-in [:headers] response merge {"Cache-Control" "max-age=0"}) |
| 19:39 | technomancy | mmarczyk: I was going to say, check out the "preview4" milestone https://github.com/technomancy/leiningen/issues?milestone=4&page=1&state=open&utf8=%E2%9C%93 |
| 19:39 | technomancy | mmarczyk: and the #leiningen channel is pretty active for discussing development |
| 19:40 | technomancy | mmarczyk: xeqi and I both have access on _ato's fork, so just send pull reqs there |
| 19:40 | mmarczyk | technomancy: oh good, will do |
| 19:42 | technomancy | also anyone else interested in contributing to leiningen should check that link out; I've tagged low-hanging fruit with the "newbie" tag |
| 19:42 | mmarczyk | technomancy: so, I'm getting started on my move to lein2 -- once that's done, I'll get started on some of the issues (some will definitely bite me sometime soon if not tackled, so I'll be well motivated :-P) |
| 19:42 | mmarczyk | dnolen: ping? |
| 19:44 | hcumberdale | mmarczyk, how do I construct the map? |
| 19:45 | mmarczyk | hcumberdale: well, it's just a regular Clojure map, so no different to how you'd normally construct a map |
| 19:46 | mmarczyk | hcumberdale: only thing to keep in mind is that any valid Ring handler returns a response with a :headers key; if you're wrapping a handler -- writing a piece of middleware, that is -- you'll probably want to add to that map rather than replace it |
| 19:46 | dnolen | mmarczyk: pong |
| 19:47 | mmarczyk | hcumberdale: for which you can use the code from my earlier msg |
| 19:47 | hcumberdale | ahh,.... |
| 19:47 | hcumberdale | I uderstand |
| 19:47 | mmarczyk | dnolen: hi |
| 19:47 | mmarczyk | dnolen: I've seen your comment on the ObjMap ticket, so about that -- |
| 19:47 | hcumberdale | how to force UTF-8 instad of ISO-8859-1 ? |
| 19:48 | mmarczyk | dnolen: I've got a port of PersistentArrayMap almost ready -- it's so simple it'd be a shame not to see if it makes sense in cljs |
| 19:48 | mmarczyk | dnolen: so I'll be wiring all this together and rolling a few jsperf tests |
| 19:48 | dnolen | mmarczyk: sure, worth testing. |
| 19:49 | mmarczyk | dnolen: but that'll probably take me a day or two, I've got a slightly overloaded work queue atm |
| 19:50 | dnolen | mmarczyk: sure, was just wanting to push out a release so more people play around with the new stuff. |
| 19:51 | mmarczyk | dnolen: sure, that'd be great |
| 19:52 | mmarczyk | dnolen: just wanted to let you know I've got a handful of related patches coming over the next two to three days, so maybe this can all get released together |
| 19:52 | dnolen | mmarczyk: sounds like a plan. |
| 19:52 | mmarczyk | dnolen: one more thing -- do you know if anybody's working on tagged literals for cljs? |
| 19:53 | dnolen | mmarczyk: fogus started a branch. |
| 19:54 | kovasb | one thing that really troubles me about tagged literals.. |
| 19:54 | dnolen | kovasb: ? |
| 19:54 | kovasb | if you don't have the definition for the tag, the reader explodes |
| 19:54 | dnolen | in Clojure? |
| 19:54 | kovasb | which means its impossible to pass data through the system without every step knowing about what it is |
| 19:54 | kovasb | yes |
| 19:54 | mmarczyk | dnolen: good to know, thanks |
| 19:55 | kovasb | it should just return some inert generic record instead, which will then reserialize with the appropriate tag |
| 19:55 | dnolen | kovasb: sounds like something worth bringing up on the ML. |
| 19:56 | mmarczyk | kovasb: it would be easy enough to provide an UnknownLiteral wrapper, but this is probably a ggroup topic |
| 19:56 | kovasb | yeah, i thought about it but didn't want to sound like a whiner |
| 19:56 | kovasb | :) |
| 19:56 | kovasb | yeah, something like that would be great. otherwise the purpose is kinda defeated :/ |
| 19:56 | dnolen | kovasb: I think the tagged literal design work didn't really make it as far as handling the general extension case. |
| 19:57 | kovasb | dnolen: yeah, somewhat under-baked. which is surprising since I thought it was there because of datomic's needs |
| 19:58 | hcumberdale | Damn! |
| 19:58 | kovasb | will bring it up on mailing list.. |
| 19:58 | hcumberdale | (defn respond "resp 200 with spec header" [body ctype] {:status 200 :headers { "Content-Type" ctype "Character-Encoding" "UTF-8" } :body body}) |
| 19:59 | hcumberdale | jetty doesn't respond in UTF-8 |
| 19:59 | hcumberdale | It's still ISO-8859-1 |
| 19:59 | hcumberdale | Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 |
| 19:59 | hcumberdale | ENV vars also set to UTF-8 |
| 19:59 | hcumberdale | mhh |
| 20:00 | xeqi | what is ctype? |
| 20:01 | hcumberdale | "application/rss+xml" |
| 20:06 | mmarczyk | hcumberdale: you'll probably want to add ";charset=UTF-8" to that |
| 20:11 | hcumberdale | works, thx mmarczyk |
| 20:11 | mmarczyk | np |
| 20:20 | jimi_hendrix | is there a way to get all but the first n items of a vec? |
| 20:21 | dnolen | drop |
| 20:21 | jimi_hendrix | that gives me a seq though |
| 20:22 | jimi_hendrix | basically, i have a string. i want to drop the first n words. so far i am splitting it up via clojure.string/split, which returns a vec, but calling drop makes it a seq. |
| 20:22 | jimi_hendrix | which i dont think i can easily manipulate |
| 20:24 | mdeboard | &(rest [1 2 3 4]) |
| 20:24 | lazybot | ⇒ (2 3 4) |
| 20:24 | mdeboard | &(vec (rest [1 2 3 4])) |
| 20:24 | lazybot | ⇒ [2 3 4] |
| 20:24 | jimi_hendrix | ooh |
| 20:24 | jimi_hendrix | ok |
| 20:24 | jimi_hendrix | thanks |
| 20:25 | mdeboard | np |
| 20:25 | jimi_hendrix | hmm |
| 20:26 | muhoo | technomancy: wow, could it really be that simple? i could just call a function in main that updates whatever couchdb the thing is connecting to, with the most current views. they'll never be out of sync |
| 20:26 | hcumberdale | is there a way to show all the loc in a github project for a specific folder? |
| 20:26 | mdeboard | &(clojure.string/split "Hello world") |
| 20:26 | lazybot | clojure.lang.ArityException: Wrong number of args (1) passed to: string$split |
| 20:26 | technomancy | muhoo: maybe; I haven't used couch views |
| 20:27 | muhoo | i can't see any reason why it won't work. i could even spin up a thread so it doesn't delay the app coming up. |
| 20:28 | technomancy | muhoo: if it happens during git push time that's not an issue |
| 20:28 | muhoo | oh, good point. that'd be a good reason to do it in user_env_compile then |
| 20:28 | mmarczyk | jimi_hendrix: you could also use subvec, though note that it prevents the original vector from being GC'd |
| 20:29 | jimi_hendrix | mmarczyk, i wont use that then :P |
| 20:29 | mdeboard | &(vec (rest (clojure.string/split "Hello World Potato" #" "))) |
| 20:29 | lazybot | ⇒ ["World" "Potato"] |
| 20:29 | mmarczyk | jimi_hendrix: well, it's the same as with String.substring, for the same reasons |
| 20:29 | jimi_hendrix | right |
| 20:30 | mdeboard | World potato |
| 20:30 | jimi_hendrix | now, is there an easy way to stringify that vector? if i just call (str my-vec), then i get something like "[\"a\" \"b\"]" |
| 20:30 | Iceland_jack | jimi_hendrix: (apply str ...) ? |
| 20:30 | jimi_hendrix | ooh duh |
| 20:31 | mmarczyk | if that's all you want to do with it, then subvec's totally fine |
| 20:31 | jimi_hendrix | now is there a way to throw in a space between each word? |
| 20:32 | mmarczyk | interpose " " |
| 20:32 | mmarczyk | &(apply str (interpose " " ["a" "s" "d" "f"])) |
| 20:32 | lazybot | ⇒ "a s d f" |
| 20:32 | jimi_hendrix | thanks |
| 20:33 | mdeboard | no |
| 20:33 | mdeboard | &(clojure.string/join " " ["Hello" "World" "Potato"]) |
| 20:33 | lazybot | ⇒ "Hello World Potato" |
| 20:33 | mdeboard | amalloy_ will have a stroke if you use apply & interpose :P |
| 20:34 | mmarczyk | true, join's better |
| 20:37 | mmarczyk | NB. taking the substring comprising the first n words is possible with just a regex pattern |
| 20:37 | mmarczyk | &(re-seq #"(\w+\W+){5}" "Foo bar baz quux wibble wobble.") |
| 20:37 | lazybot | ⇒ (["Foo bar baz quux wibble " "wibble "]) |
| 20:38 | mmarczyk | (guess that needs a little polishing) |
| 20:38 | mmarczyk | (but still.) |
| 20:38 | alexbaranosky | maybe use ? to stop the greediness |
| 20:38 | alexbaranosky | &(re-seq #"(\w+\W+){5}?" "Foo bar baz quux wibble wobble.") |
| 20:38 | lazybot | ⇒ (["Foo bar baz quux wibble " "wibble "]) |
| 20:39 | alexbaranosky | hmmm, not sure... but don't want to spam the channel with code |
| 20:39 | mmarczyk | could use (\w+\W+){4}\w+ or sth |
| 20:40 | mmarczyk | or use non-greedy * in place of + after \W |
| 20:40 | mmarczyk | (\w+\W*?){5} |
| 20:51 | dgrnbrg | I have a fn, and I want to call it from an eval'ed piece of code |
| 20:51 | RickInGA | if anyone in here has Alex Miller's email address, could you let him know that the security certificate for thestrangeloop.com has expired |
| 20:51 | dgrnbrg | I tried (eval `(~f)) but that doesn't work |
| 20:52 | dgrnbrg | ,(eval `(~(fn [] (println "hi")))) |
| 20:52 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 20:52 | dgrnbrg | well, it actually works on my machine |
| 20:53 | dgrnbrg | but i'm seeing an exceptionininitializer error in the lisp reader when I eval |
| 20:54 | RickInGA | dgrnbrg can't you just do (eval (function-name)) |
| 20:54 | dgrnbrg | I get the function as an argument |
| 20:54 | dgrnbrg | so no, it wouldn't work |
| 20:54 | RickInGA | without the tic and the tilde |
| 20:55 | dgrnbrg | then i'd eval the function immediately |
| 20:55 | RickInGA | do you have the function in parens? |
| 20:55 | RickInGA | ah, ok |
| 20:55 | dgrnbrg | I actually do (eval `(fn [] ~expr)) |
| 20:55 | dgrnbrg | where expr is of one of 2 forms: |
| 20:56 | dgrnbrg | `(apply ~some-fn ~some-args) ;some-fn and some-args are objects, probably not readable |
| 20:56 | RickInGA | so what are you trying to do? define an anonymous function that you don't evaluate? |
| 20:56 | dgrnbrg | or a regular fragment of clojure |
| 20:56 | dgrnbrg | I'm writing a clojure code generator |
| 20:56 | dgrnbrg | and i am currently using anonymous function chains to build it |
| 20:57 | mdeboard | dgrnbrg: (future f) ? |
| 20:57 | dgrnbrg | but for architecture and performance reasons, I want to construct a single fn and then eval it to compile it to byte code, then rerun as needed |
| 20:57 | dgrnbrg | it needs to be evaled |
| 20:59 | dgrnbrg | i am trying to do a gradual migration between the systems |
| 20:59 | dgrnbrg | perhaps that's not possible, and i just need to rewrite everything at once |
| 21:00 | RickInGA | I don't have any experience with eval, I thought it was for executing strings as s-expressions |
| 21:00 | RickInGA | Do you just want to define a function? |
| 21:18 | hcumberdale | (GET "/feed" request (content-type (response (render-rssfeed (:host request))) "application/rss+xml;charset=UTF-8")) << damn |
| 21:18 | hcumberdale | response is text/plain |
| 21:26 | creese | Can someone help me get started with java interop? My test project isn't working. |
| 21:30 | alexbaranosky | creese, what in particular? |
| 21:49 | creese | can someone clarify the syntax for ns :import? |
| 21:49 | creese | page 108 of clojure in action has the following: |
| 21:50 | creese | (ns com.clojureinaction.book (:import (java.util Set))) |
| 21:51 | alexbaranosky | creese, the ns macro is notorious for having different syntax variations that work |
| 21:52 | creese | Here is what I'm trying: |
| 21:52 | creese | (ns javatest.core |
| 21:52 | creese | (:import (namesforall TestFile inc get sqr))) |
| 21:53 | alexbaranosky | (ns javatest.core (:import [namesforall TestFile] )) ;; will work |
| 21:53 | creese | I don't need the method names? |
| 21:53 | alexbaranosky | (ns javatest.core (:import (namesforall TestFile) )) ;; try this, maybe it works too ;) |
| 21:53 | alexbaranosky | you import classes like in Java |
| 21:54 | alexbaranosky | you call the method name on the objects |
| 21:54 | creese | right |
| 21:54 | creese | I knew that |
| 21:55 | alexbaranosky | (.inc (MyObject.)) |
| 21:56 | creese | I tried (def x (TestFile.)) |
| 21:57 | creese | and it doesn't work |
| 21:57 | creese | Unable to resolve classname: TestFile |
| 22:01 | creese | I can't create the object. |
| 22:06 | alexbaranosky | we need someon who has compiled Java alongside Clojure |
| 22:06 | alexbaranosky | I haven't ever needed to do that |
| 22:09 | creese | righ |
| 22:09 | creese | t |
| 22:10 | alexbaranosky | creese, usually there are a lot of people to help you here, but I guess because it is Friday they're hard to find tonight |
| 22:11 | creese | I am getting a warning when I compile to jar |
| 22:12 | alexbaranosky | paste it? |
| 22:12 | creese | it says, "No namespaces to :aot compile listed in project.clj." |
| 22:12 | creese | that might be a problem |
| 22:12 | alexbaranosky | ah you might have to add a key to the project map in project.clj |
| 22:13 | alexbaranosky | { ... :aot my.namespace ...} |
| 22:15 | creese | I found something that said to add |
| 22:15 | creese | :main amr_db.core |
| 22:15 | creese | where the argument is the ns in your core.clj file |
| 22:15 | alexbaranosky | try both :) |
| 22:15 | alexbaranosky | see which works |
| 22:26 | creese | :main doesn't seem to help |
| 22:26 | creese | I can't get leiningen to accept anything with :aot |
| 22:26 | creese | do you know how make a repl forget everything you've told it? |
| 22:32 | creese | now I'm getting something different: |
| 22:32 | creese | x already refers to: #'javatest.core/x in namespace: user |
| 22:32 | creese | which happens when I try: (def x (TestFile.)) |
| 22:33 | alexbaranosky | sounds like you are shadowing x |
| 22:33 | tmciver | creese: are you in the 'user' namespace? Did you (use 'javatest.core)? |
| 22:34 | tmciver | creese: you could remove-ns ##(doc remove-ns) |
| 22:34 | lazybot | ⇒ "([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace." |
| 22:34 | tmciver | creese: but it might be easier to just restart the repl |
| 22:47 | yoklov | creese: are you still trying to aot something? |
| 22:47 | yoklov | its not { :aot my.namespace }, its { :aot [my.namespace] } |
| 22:50 | creese | what do the { } brackets mean? are you just saying type what's inside? |
| 22:50 | creese | I'm still getting an exception |
| 22:50 | tmciver | creese: no, you type the {} |
| 22:51 | tmciver | it's a map literal |
| 22:53 | tmciver | creese: actually, it's part of your project.clj; so you don't type the {} in this case; you put ':aot [some.ns]' in your project file |
| 22:53 | creese | I don't see brackets in the sample.project.clj |
| 22:53 | leo2007 | is clojure programming out for sale? |
| 22:54 | tmciver | leo2007: yes |
| 22:55 | leo2007 | why do clojure introduce so many syntaxes? |
| 22:56 | creese | can someone explain the difference between a jar and an uberjar? |
| 22:56 | creese | I think that may be what I'm doing wrong |
| 22:57 | xeqi | jar is just your project code/resources; uberjar is your code/resource + jars of all the dependencies |
| 22:58 | xeqi | jars are convienent for libraries, uberjars for running from a single jar |
| 22:58 | yoklov | creese: what are you trying to do |
| 23:03 | creese | so I shouldn't need to uberjar if I'm calling java from the repl |
| 23:05 | xeqi | nope |
| 23:06 | xeqi | if you paste some code on refheap.com I might be able to help |
| 23:06 | creese | I have a paste bin, let me update it |
| 23:06 | xeqi | if you have a specific problem w/ java interop |
| 23:06 | xeqi | ah |
| 23:16 | sandaemc | Hi there, I'm looking for tutorial on how to create a nested map data structure. Do I have to use "ref" for that? I'm used to PHP's $data['key']['nested-one'] = $value and don't know how I can do that in Clojure. |
| 23:17 | xeqi | ,{:first-level {:second-level "value"}} |
| 23:17 | clojurebot | {:first-level {:second-level "value"}} |
| 23:17 | sandaemc | Note: I want to create that during a loop. |
| 23:18 | Raynes | You probably don't want to do it the way you think you want to do it. |
| 23:18 | yoklov | sandaemc: you can't quite do it the same as in php |
| 23:18 | Raynes | update-in is what you're looking for. |
| 23:18 | Raynes | But it doesn't modify the map, it creates and returns a new one. |
| 23:18 | yoklov | (update-in data "key" "nested-one" value) |
| 23:19 | Raynes | So if you're going to build this map in a loop, the map should be one of the params of your loop. |
| 23:19 | Raynes | Um, no. |
| 23:19 | xeqi | ,(update-in {} [:a :b] :c) |
| 23:19 | clojurebot | {:a {:b nil}} |
| 23:19 | yoklov | oh yeah |
| 23:19 | Raynes | &(update-in {:foo {:bar []}} [:foo :bar] conj 1) |
| 23:19 | lazybot | ⇒ {:foo {:bar [1]}} |
| 23:19 | xeqi | oh, right... update-in not assoc-in |
| 23:20 | yoklov | though, php's arrays do autovivification |
| 23:20 | sandaemc | Okay, I'll try update-in. Thanks. |
| 23:20 | yoklov | so it makes the nested levels |
| 23:20 | yoklov | as you go |
| 23:21 | yoklov | yeah looking at that question, i think thats what he's asking |
| 23:22 | Raynes | &(loop [x {:foo {:bar []}} y 0] (let [y (inc y)] (if (< y 10) (recur (update-in x [:foo :bar] conj y) y) x))) |
| 23:22 | lazybot | ⇒ {:foo {:bar [1 2 3 4 5 6 7 8 9]}} |
| 23:23 | yoklov | in php if you have $data = array(); then do $data["deeply"]["nested"]["array"] = 3 it will make the nested hashes for you. |
| 23:23 | xeqi | ugh |
| 23:23 | yoklov | does update-in do that? |
| 23:23 | yoklov | oh |
| 23:23 | Raynes | Yes. |
| 23:23 | yoklov | yeah |
| 23:23 | yoklov | huh |
| 23:23 | yoklov | I should use that more |
| 23:24 | Raynes | &(reduce #(update-in % [:foo :bar] conj %2) {} (range 10)) |
| 23:24 | lazybot | ⇒ {:foo {:bar (9 8 7 6 5 4 3 2 1 0)}} |
| 23:25 | Raynes | &(assoc-in {} [:foo :bar] (range 10)) |
| 23:25 | lazybot | ⇒ {:foo {:bar (0 1 2 3 4 5 6 7 8 9)}} |