2011-09-02
| 00:34 | skelternet | (doc sleep) |
| 00:34 | clojurebot | Huh? |
| 00:36 | amalloy | $javadoc Thread sleep |
| 00:36 | lazybot | http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html#sleep(long) |
| 00:49 | jli | ibdknox: I might have tiny patches for cljs-watch. how do you like them? |
| 00:49 | ibdknox | jli: for what exactly? |
| 00:49 | ibdknox | jli: and pull requests will be fine :) |
| 00:52 | jli | ibdknox: nothing real yet. bthe current java heap options prevent it from running on my laptop with only 2g ram |
| 00:53 | ibdknox | I just used the same options that clojurescript used I believe |
| 00:53 | jli | yeah, I had the same problem there. it's just a performance optimization for long-running programs, right? |
| 01:03 | ibdknox | jli: it's the overall amount of memory the heap can take up, it's likely important if you're compiling a large project, where the heap might get quite large |
| 01:12 | MasseR | What's square root named in clojure? |
| 01:13 | MasseR | Just the java version, Math/sqrt? |
| 01:13 | jli | MasseR: yes |
| 01:14 | MasseR | Ok |
| 02:30 | jblomo | what's the naming convention for a constant? |
| 02:32 | jblomo | what if I only want a Var to be dynamic during testing |
| 03:08 | raek | jblomo: vars are usually constants, so no special naming |
| 03:09 | raek | jblomo: I think there is something like 'with-redefs' in Clojure 1.3 that you can use in tests. it replaces the root binding, so the var does not need to be dynamic |
| 03:10 | jblomo | ah cool, makes sense. thanks |
| 05:43 | jedahu | I have a macro problem |
| 05:43 | jedahu | http://paste.lisp.org/+2O01 |
| 05:43 | jedahu | I need to aot compile a gen-class definition |
| 05:44 | jedahu | this works fine except when gen-class is nested in another macro |
| 05:45 | jedahu | any ideas? |
| 05:45 | raek | jedahu: try `(do (gen-class ...) (defn ...)) |
| 05:46 | raek | otherwise the top let form in the macro throws away the gen-class code |
| 05:46 | jedahu | aha! |
| 05:46 | jedahu | thankyousomuch! :-) |
| 05:46 | raek | jedahu: use macroexpand-1 or macroexpand to se what your macro does |
| 05:47 | raek | ,(macroexpand-1 '(when condition expr1 expr2)) |
| 05:47 | clojurebot | (if condition (do expr1 expr2)) |
| 05:48 | jedahu | I used both but didn't twig to what they were telling me |
| 05:48 | jedahu | end of a long day :-) |
| 06:17 | lnostdal_ | classes can't be used as a test-constant in case? |
| 06:18 | lnostdal_ | seems odd; not knowing java very well, a class is constant isn't it? |
| 06:18 | lnostdal_ | e.g. (case (type []) clojure.lang.PersistentVector (println "hi")) |
| 06:19 | bendlas`` | lnostdal_: I noticed that too, a few days ago |
| 06:20 | bendlas`` | One reason might be, that instead of class switches, one should use protocols |
| 06:20 | bendlas`` | anyway, you can do (case (.getName (type [])) "clojure.lang.PersistentVector" ..) |
| 06:21 | lnostdal_ | hah, nice hack there :) |
| 06:40 | ambrosebs | have some fun playing with relational arithmatic with core.logic https://github.com/frenchy64/Logic-Starter/wiki/Arithmatic |
| 06:41 | michaelr525 | hello! |
| 07:05 | clgv | lnostdal_: another way is to use cond and instance? see ##(doc instance?) |
| 07:05 | lazybot | ⇒ "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false" |
| 07:08 | pigeons | I'm not a dev, but want to try someone's project, I'm on debian and have the "clojure" package installed. Project comes with a project.clj file. How do I build it? Thanks ;) |
| 07:08 | lnostdal_ | ah, yeah, clgv |
| 07:08 | clgv | ambrosebs: how about arithm*e*tic? ;) |
| 07:08 | ambrosebs | clgv: ... |
| 07:09 | ambrosebs | live and learn |
| 07:09 | clgv | pigeons: install leiningien and do a lein uberjar and then sart it like a jar |
| 07:09 | pigeons | thanks! |
| 07:09 | clgv | pigeons: https://github.com/technomancy/leiningen/blob/master/README.md |
| 07:10 | clgv | ambrosebs: where is aleph on that page? ;) |
| 07:11 | clgv | I want to add multiples of infinity ^^ |
| 07:18 | ambrosebs | new link https://github.com/frenchy64/Logic-Starter/wiki/Arithmetic :) |
| 07:18 | ambrosebs | sigh |
| 07:21 | clgv | :D |
| 08:13 | aleonhardt | call me mad, but i've been trying to get clojure to work with matlab via JVM bridge. that is, i define java classes with gen-class and try to instantiate them from matlab. |
| 08:14 | aleonhardt | doesn't work at all, though. |
| 08:14 | aleonhardt | using lein to produce an uberjar, matlab doesn't want to find my generated classes. |
| 08:14 | aleonhardt | jar works from java, scala, groovy, mirah... |
| 08:15 | aleonhardt | haven't been able to pinpoint the problem. one apparent issue seems to be that matlab can't import clojure.lang.RT for whatever reason. |
| 08:16 | aleonhardt | does anyone have any idea where to continue looking? |
| 08:16 | ordnungswidrig1 | aleonhardt: which jvm version does matlab use? |
| 08:16 | aleonhardt | ordnungswidrig1: let me check. |
| 08:17 | kephale | aleonhardt: if you're on OS X matlab uses the apple JVM, other OSes it uses a built in JVM |
| 08:17 | kephale | and you have to change it manually somehow, but i forgot those details |
| 08:17 | ordnungswidrig1 | maybe it's due do classfile version or like that. |
| 08:17 | aleonhardt | Java 1.6.0_04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode |
| 08:17 | aleonhardt | i've set the JVM to my system one, using MATLAB_JAVA. |
| 08:18 | ordnungswidrig1 | aleonhardt: that should be fine for clojure. what is the exact error message from matlab? |
| 08:19 | aleonhardt | ordnungswidrig1: it's fairly generic. "??? Error using ==> import Import argument 'org.bla.MyTest' cannot be found or cannot be imported." -- unfortunately. |
| 08:19 | aleonhardt | interestingly, clojure.lang.Compiler, clojure.lang.Var, etc. import without hiccups -- clojure.lang.RT, though, can't be found. |
| 08:20 | aleonhardt | but that may be irrelevant. |
| 08:20 | aleonhardt | as i said, using gen-class, not invoke. |
| 08:20 | ordnungswidrig1 | hmm |
| 08:21 | ordnungswidrig1 | I don't know matlab, so I think I cannot help any further. |
| 08:21 | aleonhardt | thanks anyway. |
| 08:22 | kephale | hrm… *boots matlab* |
| 08:22 | aleonhardt | it's odd: the jar works from any JVM-using environment. groovy shell, scala shell, java applications. with matlab -- even using system JVM! -- it simply dies. |
| 08:23 | aleonhardt | kephale: hey, that'd be wonderful. if you can get even the tiniest clojure class to work, then I at least know that it's my set-up. |
| 08:26 | kephale | you get that error on a "javaaddpath" call? |
| 08:30 | aleonhardt | kephale: nope. javaaddpath('/path/to/package.jar') runs fine. |
| 08:30 | aleonhardt | it's the actual import statement that fails. |
| 08:35 | aleonhardt | i'm on R2008b, for what it's worth. |
| 08:40 | pigeons | clgv: thanks for helping this newbie. I can't get the lein generated uberjar to work yet, some manifest signature and classpath issues, but I can run the project just fine with "lein run", and that's all I need for now |
| 08:40 | clgv | pigeons: good :) |
| 08:42 | clgv | How can I define a project neutral way to detect whether I am within a jar or not? |
| 08:42 | kephale | aleonhardt: well, i can confirm clojure.lang.Compiler loads fine |
| 08:42 | clgv | previously I checked for one of my clj files. but that wont work in a different project. |
| 08:43 | kephale | but i have a cannot be found error for importing the user-defined class |
| 08:47 | aleonhardt | kephale: got disconnected. any luck? |
| 08:48 | kephale | i have clojure.lang.Compiler loaded |
| 08:48 | kephale | but matlab can't even find the user-defined class |
| 08:50 | aleonhardt | alright, so it's a real problem... |
| 08:52 | kephale | i dont get the RT issue though |
| 08:52 | aleonhardt | interesting. |
| 08:53 | aleonhardt | hm, i'm pretty sure that i don't know enough about java classloader stuff to get anywhere. damn shame. |
| 08:53 | kephale | but, depending what you're doing in matlab, you might be able to work the other way |
| 08:53 | kephale | and have clojure call matlab with matlabcontrol |
| 08:55 | aleonhardt | in this case, unfortunately not. i'm writing a matlab toolbox wrapping a bunch of clojure functions. |
| 08:56 | kephale | mmm… well if you figure it out post it somewhere/here, i'm probably going to have to get this running before long as well : P |
| 08:57 | aleonhardt | will do. thanks for your help! |
| 08:58 | kephale | good luck |
| 09:09 | pyr | damn you clojure, now i have to gain tomcat knowledge |
| 09:09 | pyr | i have successfully avoided that for 10 years |
| 09:11 | manutter | hmm, is there a #tomcat channel |
| 09:12 | pyr | manutter: i'm sure there is :) |
| 09:12 | manutter | I may need that myself some day soon |
| 09:44 | michaelr525 | pyr: why tomcat? |
| 09:46 | michaelr525 | why not some lightweight alternative such as http://tjws.sourceforge.net/ or winstone? |
| 09:58 | pyr | michaelr525: good question |
| 09:58 | pyr | i want good mechanisms for pushing a simple (ring) webapp to multiple servers |
| 10:01 | pyr | michaelr525: seems like winstone is out because it hosts a single webapp perserver |
| 10:03 | coopernu_ | pyr: perhaps jetty? |
| 10:04 | pyr | is that a general recommendation, to stay away from tomcat for deploys ? |
| 10:04 | chewbranca | I need to stop programming ruby in clojure, I find myself making lots of little utility functions and comprising primary functions out of those utilities, which I don't think is the clojure way |
| 10:04 | pyr | sorry to go a bit off topic |
| 10:04 | pyr | (even though it's directly related to clojure) |
| 10:05 | coopernu_ | pyr: tomcat is totally fine -- it just sounds like you wanted to avoid it |
| 10:05 | chewbranca | although, it is beneficial for getting familiar with things, make something small work, move onto the next bit, and once you get these small bits working, recombine them into something bigger and refactor |
| 10:05 | coopernu_ | jetty has less configuration |
| 10:05 | coopernu_ | both can host multiple war files, which sounds like one of your requirements |
| 10:06 | michaelr525 | i'm also thinking what servlet container to use for scalable web app |
| 10:06 | michaelr525 | .. |
| 10:07 | chewbranca | how much do you guys break apart functionality? so for instance right now I'm writing a function that will split a block of text on newlines, and then it will split up the words for each line, right now I have a split-lines function, split-words function and a split text function that basically does (map #(split-words %) (split-lines text)) |
| 10:08 | coopernu_ | chewbranca: that seems reasonable |
| 10:09 | coopernu_ | michaelr525: tell me more about scalable. are you doing a normal webapp, or are you using websockets/comet/long polling |
| 10:09 | pyr | coopernu_: i'm not trying to avoid tomcat in particular |
| 10:10 | michaelr525 | i made a rule for myself that a function should express genrally just one idea |
| 10:10 | pyr | coopernu_: i'm not really trying to avoid anything,really |
| 10:10 | chewbranca | coopernu_: ok cool, so basically having wrapper functions isn't necessarily frowned upon, I guess it depends on whether you want to use those pieces again |
| 10:10 | coopernu_ | pyr: ok, well tomcat is certainly stable |
| 10:10 | michaelr525 | coopernu_: normal |
| 10:10 | coopernu_ | chewbranca: yep, I think for clojure, small functions are good. easy to test |
| 10:11 | chewbranca | michaelr525: typically I agree, but is it worth doing (defn split-words [line] (split line #"\s+"))? |
| 10:12 | coopernu_ | michaelr525: ok, then jetty or tomcat would both be fine. if you're using HttpSessions, then you might look at tomcat + this session store: http://code.google.com/p/memcached-session-manager/ |
| 10:12 | michaelr525 | sure, it let's you write the program in english like language |
| 10:12 | coopernu_ | another option is to punt and use a PaaS offering like GAE or heroku |
| 10:12 | coopernu_ | or elastic beanstalk |
| 10:12 | chewbranca | ok I'll agree with that, just seems like clojure gives you enough expressive power that actually declaring the function is almost as verbose as the function itself |
| 10:14 | pyr | coopernu_: yeah looks like jetty is very interesting too |
| 10:14 | chouser | maybe (def word-boundry #"\s+") ... (split line word-boundry) |
| 10:14 | coopernu_ | pyr: yes, at this point they're more similar than different. jetty has a history of being easier to embed/smaller. e.g. ring bundles it as a dev dependency. tomcat is bigger |
| 10:15 | coopernu_ | but in a production environment that isn't a consideration |
| 10:15 | pyr | yes |
| 10:15 | pyr | even if i was using jetty |
| 10:15 | pyr | i still wouldn't use the embedded version but war deploys |
| 10:15 | coopernu_ | right |
| 10:16 | pyr | much easier to integrate with jenkins |
| 10:16 | coopernu_ | ah, do you plan on hot deploying from jenkins to your app servers? |
| 10:17 | pyr | probably for staging |
| 10:18 | coopernu_ | ok |
| 10:18 | pyr | production will pull from blobstore and use pallet most likely |
| 10:18 | pyr | i don't want auto deploys to production, never a great idea :) |
| 10:18 | pyr | but still want one click |
| 10:19 | coopernu_ | cool, I wasn't familiar with pallet |
| 10:19 | pyr | pallet is going to be really big |
| 10:19 | coopernu_ | googling.. |
| 10:19 | pyr | it's the first all in one tool for cloud orchestration, scaling, command and control and configuration management |
| 10:20 | pyr | (in clojure, mind you!) |
| 10:20 | coopernu_ | yeah, I'm reading the github readme.. looks like chef or puppet, but written in clojure |
| 10:21 | pyr | yep |
| 10:21 | pyr | only it goes one step further than chef & puppet |
| 10:21 | pyr | which i like about it |
| 10:21 | coopernu_ | tell me more |
| 10:22 | pyr | it was meant from the ground up to spawn vms |
| 10:22 | pyr | then apply configuration to it |
| 10:22 | coopernu_ | reading docs.. "No server".. thank god |
| 10:23 | coopernu_ | that is what kept me away from puppet |
| 10:23 | pyr | :) |
| 10:23 | srid | pallet paas in clojure? never heard of it |
| 10:23 | pyr | it's not paas, it's a library |
| 10:23 | pyr | to let you build your automation |
| 10:24 | manutter | hmm, would pallet work with virtualbox on my local dev machine? |
| 10:24 | pyr | coopernu_: the great thing is that being a clojure library, you can very easily integrate it in your favorite IRC bot, internal webapp, ... |
| 10:24 | pyr | manutter: yep |
| 10:24 | manutter | :D |
| 10:24 | pyr | manutter: through vmfest |
| 10:24 | manutter | got some more googling to do I see |
| 10:24 | coopernu_ | pyr: yes, I very much like what I'm reading |
| 10:24 | pyr | manutter: so test your cloud deploy locally, validate, push to EC2/rackspace/... |
| 10:24 | coopernu_ | I may have use for this |
| 10:25 | manutter | me too, most definitely |
| 10:25 | srid | yes, not bad for a relatively new language |
| 10:26 | srid | because of existing java libraries, I think |
| 10:26 | coopernu_ | srid: agreed, and the build tools like lein, which make it trivial to consume that ecosystem |
| 10:26 | pyr | it relies on jclouds so most of the vm building stuff was done, still |
| 10:27 | pyr | the crate language is very cool |
| 10:27 | coopernu_ | lein/clojars is what I always wished maven was |
| 10:32 | pyr | i'll just say it again, while we're on the subject, if someone wants to come work on that kind of problem (infrastructure, backend, storage, recommendation) all in clojure, my company is recruiting in .ch |
| 10:33 | srid | wish i lived in swiz |
| 10:34 | pyr | it's become more & more attractive with the current state of the economy ;) |
| 10:34 | coopernu_ | me too. visited zurich during euro 2008 and loved it |
| 10:35 | pyr | in that case it's lausanne, the french speaking part |
| 10:37 | lnostdal_ | hm, functions to search in non-associative structures seem to be somewhat lacking |
| 10:37 | lnostdal_ | (?) |
| 10:38 | dnolen | lnostdal_: like searching for something in tree structures? |
| 10:38 | lnostdal_ | nope, searching in vectors and lists |
| 10:39 | mmarczyk | lnostdal_: vectors are associative, you search by index |
| 10:39 | mmarczyk | get-in / assoc-in / update-in all work |
| 10:39 | dnolen | lnostdal_: something more than some, filter? |
| 10:39 | lnostdal_ | mmarczyk, by value |
| 10:39 | mmarczyk | ah |
| 10:40 | lnostdal_ | oh, i guess some+identity will work .. err, gonna try |
| 10:40 | lnostdal_ | , dnolen |
| 10:40 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: dnolen in this context, compiling:(NO_SOURCE_PATH:0)> |
| 10:41 | lnostdal_ | #(= % <my item>) ;; i mean |
| 10:41 | lnostdal_ | thanks .. forgot about some |
| 10:44 | raek | lnostdal_: once you find the item, what are you going to do with it? if you just want to check whether it's there, consider using a set and 'contains?' instead? |
| 10:44 | raek | *instead. |
| 10:44 | lnostdal_ | set doesn't work since there might be multiple entries of the same object |
| 10:45 | lnostdal_ | (set [1 2 2 3]) => #{1 2 3} |
| 10:46 | manutter | ,(map #(#{2}) [1 2 2 3]) |
| 10:46 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox$eval1915$fn> |
| 10:46 | manutter | ,(map #(#{2} %) [1 2 2 3]) |
| 10:46 | clojurebot | (nil 2 2 nil) |
| 10:47 | raek | ,(map #{2} [1 2 2 3]) |
| 10:47 | clojurebot | (nil 2 2 nil) |
| 10:47 | manutter | ,(some #{2} [1 2 2 3]) |
| 10:47 | clojurebot | 2 |
| 10:48 | raek | lnostdal_: but in that ^ example there is two 2s, and you don't know which one it matched with. so in a sense it's the same thing there |
| 10:48 | TimMc | ,(some #{nil} [1 2 nil]) |
| 10:48 | clojurebot | nil |
| 10:49 | manutter | $findfn #{life universe everything} 42 |
| 10:49 | lazybot | java.security.PrivilegedActionException: java.lang.Exception: Unable to resolve symbol: life in this context (NO_SOURCE_FILE:0) |
| 10:49 | manutter | o snap |
| 10:49 | TimMc | lazybot: How about alife? |
| 10:49 | TimMc | How about alife??? |
| 10:49 | lazybot | TimMc: How could that be wrong? |
| 10:49 | TimMc | much better |
| 10:53 | stuarthalloway | what say we release Clojure 1.3? |
| 10:53 | stuarthalloway | anybody got a bug that says we shouldn't ? |
| 10:53 | lnostdal_ | what about the contribs? |
| 10:53 | stuarthalloway | lnostdal_: ok, fair |
| 10:53 | stuarthalloway | which ones in particular? |
| 10:54 | stuarthalloway | stuartsierra is working on setting up a matrix build in Hudson to verify all the modular contribs against 1.2 and 1.3 |
| 10:54 | lnostdal_ | oh, and i sometimes miss recur from within catches |
| 10:54 | stuarthalloway | all the ones I use are working well, and have been for a while |
| 10:54 | lnostdal_ | http://dev.clojure.org/jira/browse/CLJ-667?page=com.atlassian.jira.plugin.system.issuetabpanels%3Achangehistory-tabpanel .. i think, but i just googled that right now |
| 10:56 | lnostdal_ | yeah, i think that's the one .. the patch applies to 1.3 from git with some slight modifications and it seems to work for me |
| 10:56 | stuarthalloway | lnostdal_: I just moved that ticket into approved backlog |
| 10:56 | stuarthalloway | don't think I would hold release for it though |
| 10:58 | TimMc | stuarthalloway: So it is definitely not going to be 2.0? |
| 10:59 | stuarthalloway | TimMc: true |
| 10:59 | TimMc | Oh well. I'm sure it has been argued to death on the ML. |
| 11:00 | mmarczyk | stuarthalloway: I've got sth |
| 11:00 | mmarczyk | ,(contains? (transient {:foo}) :foo) |
| 11:00 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Map literal must contain an even number of forms> |
| 11:00 | mmarczyk | ,(contains? (transient #{:foo}) :foo) |
| 11:00 | clojurebot | false |
| 11:00 | mmarczyk | ,(contains? #{:foo} :foo) |
| 11:00 | clojurebot | true |
| 11:00 | mmarczyk | looks buggy...? noticed it recently and didn't post on the ggroup yet |
| 11:00 | stuarthalloway | mmarczyk: is that the same as http://dev.clojure.org/jira/browse/CLJ-829 ? |
| 11:02 | stuarthalloway | transients have oddities, but they are still alpha |
| 11:02 | mmarczyk | stuarthalloway: well, I can't see it being the same at first glance |
| 11:02 | mmarczyk | but wouldn't no for sure without investigating |
| 11:02 | stuarthalloway | and in absence of patches from the community I would ship with known issues in transients |
| 11:02 | mmarczyk | ok; will posting a ticket about this and trying to come up with a patch be fine? |
| 11:03 | mmarczyk | even if it's for post-1.3 |
| 11:03 | stuarthalloway | sure |
| 11:03 | mmarczyk | ok, thanks; will do |
| 11:03 | stuarthalloway | thank you! |
| 11:03 | mmarczyk | stuarthalloway: one more thing |
| 11:04 | mmarczyk | I might be crazy, but I recently noticed that :doc metadata appears to be ignored on symbols naming namespaces |
| 11:04 | mmarczyk | if you include the doc string in the ns form as a string, it gets attached to the ns object |
| 11:05 | mmarczyk | if you attach it as :doc meta to the ns name, it doesn't |
| 11:06 | mmarczyk | ,(:doc (meta (the-ns 'clojure.core))) |
| 11:06 | clojurebot | "Fundamental library of the Clojure language" |
| 11:06 | mmarczyk | ,(:doc (meta (the-ns 'clojure.set))) |
| 11:06 | clojurebot | #<RuntimeException java.lang.RuntimeException: java.lang.Exception: No namespace: clojure.set found> |
| 11:06 | mmarczyk | oh, whatever; it's nil at my repl |
| 11:07 | pjstadig | shipit! |
| 11:08 | stuartsierra | Speaking of CI builds... |
| 11:08 | stuartsierra | Anybody here familiar with using Zippers for XML parsing |
| 11:08 | stuartsierra | ? |
| 11:08 | stuarthalloway | member:mmarczyk: patch welcoe |
| 11:08 | mmarczyk | hm, I went off to find the docs promising meta :doc would be honoured, but cannot find any... nvm & sorry then |
| 11:08 | stuarthalloway | ...welcome |
| 11:09 | mmarczyk | stuarthalloway: yeah, I'll write one as an enhancement |
| 11:09 | mmarczyk | for 1.4 :-) |
| 11:09 | mmarczyk | stuartsierra: why? |
| 11:09 | stuarthalloway | after 1.4 we get to jump straight to 5.0. It is a JVM tradition |
| 11:10 | raek | :) |
| 11:10 | stuartsierra | mmarczyk: Just looking for some advice |
| 11:11 | chouser | stuartsierra: that's cool as long as we can *also* refer to 5.0 as 1.5 and 6.0 as 1.6. Because otherwise it's just not as much fun. |
| 11:11 | chouser | er, stuarthalloway ^^ |
| 11:12 | stuarthalloway | chouser: of course! |
| 11:13 | stuartsierra | There's got to be a better way to do this: https://gist.github.com/1188879 |
| 11:14 | TimMc | Can we have clojure-lang 2.0 and Clojure™ 1.3? |
| 11:14 | chouser | stuartsierra: zip-filter? |
| 11:15 | stuartsierra | is that what I need? |
| 11:15 | chouser | it might help. That's what it was made for, extracting useful bits from XML trees. |
| 11:16 | TimMc | Actually, the way I refer to the current version of Java is "Java 7" or "Java v1.7" <- "v" means "API version" to me |
| 11:18 | joegallo | Clojure 2.0 SE, v1.3 |
| 11:18 | TimMc | yeah |
| 11:18 | TimMc | Except it would be Clojure 1.3 SE, v2.0 |
| 11:19 | joegallo | nah, the 2 is the marketers, the 1.3 is the engineers, just like java. |
| 11:19 | TimMc | since Clojure is making big ol' breaking changes without bumping the major number, and Java made (mostly) non-breaking changes while bumping the minor version. |
| 11:19 | joegallo | then we can skip straight on to Clojure 5, v1.4 |
| 11:19 | tomoj | &(class (hash-map)) |
| 11:19 | lazybot | ⇒ clojure.lang.PersistentArrayMap |
| 11:19 | joegallo | like winamp |
| 11:19 | tomoj | hmm |
| 11:19 | TimMc | joegallo: Right, but the marketing version of Clojure *is* 1.3, as it stands. |
| 11:20 | TimMc | Anyway, I *really* shouldn't haul the IRC channel into this again. |
| 11:20 | TimMc | tomoj: How about them hashmaps! |
| 11:20 | joegallo | heh |
| 11:21 | TimMc | joegallo: Actually, I think that's a safe topic, even for versioning: Both Winamp and the Canon Powershot S# skipped version "4" -- and I think it has to do with some Asian language. |
| 11:22 | TimMc | It's either zn or jp where "four" sounds like "death". |
| 11:23 | TimMc | zh, excuse me |
| 11:25 | Kototama | hello i'm having some trouble with compojure |
| 11:26 | Kototama | i have a formular on / and i do a POST on /files but when i click the button, the browser open the /files URL |
| 11:26 | Kototama | i just want to process the POST request but stay on the same page |
| 11:26 | coopernu_ | Kototama: can you make a gist with your code? |
| 11:26 | Kototama | sure |
| 11:27 | manutter | Kototama: sounds like your form is missing an action tag |
| 11:27 | manutter | or malformed somehow. |
| 11:27 | manutter | have you done View Source on the page where the form is? |
| 11:27 | TimMc | Kototama: If you are on / and you POST to /files, the browser is expected to go there. |
| 11:27 | TimMc | perhaps you want target="_blank"? |
| 11:28 | Kototama | i just copied some Java servlet code and it seems to POST /files and the browser stay on / |
| 11:28 | Kototama | the target is an iframe in this code |
| 11:28 | manutter | doh, I'm thinking ajax stuff |
| 11:28 | TimMc | Sounds like an HTML issue, not a compojure problem. |
| 11:29 | TimMc | My guess is that you need to fix your target attribute on the form. |
| 11:29 | Kototama | a POST to any URL redirect the browser to it? |
| 11:29 | TimMc | in general, yes |
| 11:29 | manutter | Kototama: is there javascript on the page in the original servlet? |
| 11:30 | manutter | Kototama: it may have some client-side code that intercepts the submit and turns it into an ajax call |
| 11:30 | Kototama | yes there are some js |
| 11:30 | Kototama | https://gist.github.com/1188930 |
| 11:31 | Kototama | https://gist.github.com/1188935 |
| 11:32 | manutter | Kototama: the other possibility is that the original servlet receives the POST on /files, and then does a redirect back to / |
| 11:33 | Kototama | what should go in the {:body} of a function responding to a POST so that the page does not change? |
| 11:35 | Kototama | the original servlet is here https://github.com/carneades/carneades/blob/webservice-01/src/CarneadesWebGUI/src/main/java/org/fokus/carneades/carneadeswebgui/CarneadesServlet.java |
| 11:35 | coopernu_ | Kototama: you could try setting the name attribute on the iframe |
| 11:35 | Kototama | i don't see any redirection but i'm really new to web dev |
| 11:35 | coopernu_ | [:iframe {:id "lkif-source" :name "lkif-source" ... |
| 11:35 | coopernu_ | see - http://stackoverflow.com/questions/168455/how-do-you-post-to-an-iframe |
| 11:36 | coopernu_ | but so far it's not really a clojure problem |
| 11:37 | Kototama | ok but then for compojure should it makes more sens to post to / then ? |
| 11:37 | coopernu_ | no, I think what you have is fine |
| 11:37 | coopernu_ | regarding the compojure routes |
| 11:37 | TimMc | Kototama: No, the "POST, redirect to GET" is a common pattern. |
| 11:38 | TimMc | Kototama: https://secure.wikimedia.org/wikipedia/en/wiki/Post/Redirect/Get |
| 11:38 | Kototama | seems to work now |
| 11:38 | coopernu_ | great |
| 11:38 | Kototama | maybe it was just the name in the iframe? |
| 11:38 | TimMc | that would do it |
| 11:38 | coopernu_ | yeah, I think you need the name attribute |
| 11:38 | Kototama | is target targetting a name or an id? |
| 11:38 | coopernu_ | name |
| 11:39 | Kototama | cool |
| 11:39 | Kototama | i feel better :-) |
| 11:39 | coopernu_ | excellent |
| 11:39 | Kototama | thanks all for the quick help! |
| 11:39 | Kototama | one more piece of java code that will disappear from this earth |
| 11:39 | coopernu_ | heh |
| 11:47 | stuartsierra | chouser: Thanks, much better now. https://gist.github.com/1188879#gistcomment-48813 |
| 11:49 | Raynes | Kototama: It wont disappear. Once created, it can never be destroyed. It'll always exist down there, deep in the trenches of version control. Waiting... |
| 11:51 | Kototama | :-) |
| 11:51 | Kototama | but if all go fine, next trainee will have to learn clojure ;-) |
| 11:52 | Raynes | mmarczyk: Long time no chat. I recently stumpled upon the cup of coffee you sent me and smiled. <3 |
| 11:53 | mmarczyk | Raynes: indeed! I stumbled upon one of the photos yesterday :-) |
| 11:53 | coopernu_ | just wrote my first test today that used (proxy) to mock a java interface.. wow. much less verbose than jmock/easymock |
| 12:00 | mmarczyk | Raynes: congrats on the book deal, I'll be ordering a copy as soon as that becomes possible :-) |
| 12:00 | Raynes | <3 |
| 12:14 | alpheus | Raynes wrote a book? I've been a way from #clojure way too long! |
| 12:14 | Raynes | Still writing it, but yes. |
| 12:17 | pyr | title ? |
| 12:23 | TimMc | That is the last thing one writes. |
| 12:31 | edoloughlin | I'm implementing a REST api using Clojure as the backend and am beginning to feel that I need the equivalent of XML Schema for the maps I'm building. Is there an idiomatic way of doing this? |
| 12:31 | coopernu_ | edoloughlin: tell us more about why you feel you need XML Schema. for validation? |
| 12:33 | edoloughlin | Perhaps I haven't structured my code well (this is my 1st serious Clojure project), but I find that the maps I build and then convert to XML/JSON have fields & sub maps added in different .clj files. I'd like there to be a central place where I define the structure of these maps before things get out of hand... |
| 12:37 | coopernu_ | I see |
| 12:41 | coopernu_ | maybe use defrecord for each element? |
| 12:41 | coopernu_ | that would at least provide an artifact in the code that would self document the expected properties of each element |
| 12:44 | edoloughlin | coopernu_: I might do that. Seems like the best option. |
| 12:44 | edoloughlin | coopernu_: Thanks. |
| 12:44 | coopernu_ | edoloughlin: no problem. another interesting thing you can do if you use defrecord, is make a serialize protocol, and make json and xml impls |
| 12:45 | coopernu_ | and the protocols can switch based on the type of record. that would put all your xml and json serialization for related records in a single place |
| 12:45 | coopernu_ | I'm just speaking off the top of my head, I haven't written anything like this myself. but I think that's one of the advantages of using records vs plain maps |
| 12:45 | coopernu_ | is that you can use them with protocols |
| 12:46 | edoloughlin | Hmm. Wish I'd known about that a while ago ;-/ |
| 12:46 | coopernu_ | I bet it wouldn't be a terrible refactor |
| 12:46 | edoloughlin | Yeah, s'pose most of the hard work's done. It would make things a lot cleaner. |
| 12:56 | michaelr525 | back |
| 13:20 | amcnamara | o/ |
| 13:40 | TimMc | `fogus: Can you give a succinct problem statement, or a link to a blog entry about it? |
| 13:45 | amalloy | TimMc: i think the problem is basically: (let [x (. obj method)] (x)) is not equivalent to (. obj (method)) |
| 13:46 | amalloy | but that's just what i remember hearing; i don't do any cljs |
| 13:46 | TimMc | Something to do with methods vs. functions, then? |
| 13:46 | TimMc | OK |
| 13:47 | Scriptor | iirc, methods can't be used as first-class functions if you do it like that |
| 13:47 | amalloy | right. js objects have a `this` pointer, which normally gets set to the object they're a method of even if you pass them around some other way, but clojure uses a lower-level mechanism that bypasses that |
| 13:48 | TimMc | I wonder how Mozilla's JavaScript handles Java interop. |
| 13:48 | TimMc | amalloy: I'm not sure that's correct. [].slice doesn't have a "this", you have to bind it. |
| 13:49 | amalloy | TimMc: well, if i'm wrong then let me say in my defense i don't know much about javascript either, i just like answering questions |
| 13:50 | TimMc | heh |
| 13:50 | TimMc | typeof java.lang.String.toString -> "function" |
| 13:52 | TimMc | It looks like MozJS can wrap methods. |
| 13:56 | `fogus | TimMc: http://dev.clojure.org/display/design/this |
| 13:56 | TimMc | thanks |
| 14:41 | TimMc | `fogus: (defn whee-python [self, a, b] ...) |
| 14:41 | TimMc | :-P |
| 14:49 | TimMc | Is there a REPL I can check out somewhere? I'd like to see what CLJS compiles into. |
| 14:51 | ibdknox | Is the person who owns learn-clojure.com on here? |
| 14:56 | TimMc | Ah, never mind -- for some reason I thought it was already self-hosted. |
| 14:57 | amalloy | TimMc: ask ibdknox, he can probably compile cljs in his head |
| 14:57 | ibdknox | lol |
| 14:57 | ibdknox | Basically. |
| 14:58 | TimMc | OK, so what does (defn foo [a b] ...) actually compile into? |
| 14:59 | TimMc | (currently, I suppose) |
| 14:59 | imade | hello, quick question, I have a function that has a parameter with long and decriptive name, but inside the function body I would like to use a shorter name for the same parameter, is (let []) the only way to achieve this? |
| 14:59 | ibdknox | TimMc: myns.foo = function(a, b) { ....} |
| 14:59 | amalloy | well. as written, probably the empty string, because the compiler sees that "foo" is unused and omits it |
| 14:59 | ibdknox | amalloy: not until it hits the gclosure compiler |
| 15:00 | amalloy | imade: can you imagine a more convenient syntax that would make sense? |
| 15:01 | imade | amalloy: I sort of remember there was smth just for that, but let is fine also |
| 15:01 | manutter | imade: (let []) is the best way to do it afaik |
| 15:01 | imade | amalloy: k thx will use let then |
| 15:02 | manutter | imade: you might be thinking of the :as tag in destructuring? |
| 15:02 | ibdknox | (inc manutter) |
| 15:02 | lazybot | ⟹ 3 |
| 15:02 | imade | amalloy: yep, but that works for collections |
| 15:03 | TimMc | THe only other renaming support I can think of is in :use. |
| 15:03 | TimMc | or :require, I guess |
| 15:03 | manutter | imade: right, it's not what you're really looking for, but I thought you might have been vaguely remembering it |
| 15:04 | imade | amalloy: as a first attempt I did use :as but then remembered that wait a moment... |
| 15:04 | TimMc | `fogus: So what's wrong with just special-casing the symbol "this" so that it can always be used? |
| 15:04 | TimMc | Pretend it is a global. |
| 15:05 | `fogus | TimMc: Because we do not want to preclude the use of this as a legal ClojureScript name |
| 15:05 | TimMc | I was afraid of that. |
| 15:07 | `fogus | (extend-type Foo Bar (baz [this a b] ...)) |
| 15:07 | imade | btw, one more general question. Some problems/algorithms are more suited for imperative style or perform much better in imperative style. How do you deal with this kind of situation in clojure if you can't think of a effective way to implement it in a functional style? One way is to implement that algorithm in Java and call it from Clojure. Just curious. |
| 15:08 | TimMc | `fogus: Right, the Python-style approach. (I don't know the actual origin of that style in OOP.) |
| 15:08 | `fogus | imade: If that's ever the case, then you can bang away at mutable Java things easily with Clojure. |
| 15:08 | `fogus | TimMc: I guess you could look at it that way |
| 15:09 | TimMc | imade: Look into transients. |
| 15:09 | amcnamara | imade: also note that let bindings hold intermediary state. (ie. let [a 1 b a]) |
| 15:09 | amcnamara | which can take care of 99% of those imperative-like calculations |
| 15:09 | `fogus | TimMc: Although this in the Clojure code does not refer to the same thing as Python |
| 15:09 | `fogus | 's self |
| 15:10 | TimMc | `fogus: Is the issue then that you don't want to have more reserved names in cljs than in clj? |
| 15:10 | imade | k thanks for the inputs |
| 15:10 | `fogus | TimMc: I don't follow |
| 15:10 | TimMc | Right, Python is more strict about context. |
| 15:11 | TimMc | ,(let [do "`fogus"] do) |
| 15:11 | clojurebot | nil |
| 15:11 | TimMc | ^ example of a reserved name |
| 15:11 | TimMc | Hah, this reminds me of anaphoric macros. |
| 15:13 | `fogus | TimMc: If we can avoid adding reserved words then we will |
| 15:13 | TimMc | OK. |
| 15:15 | dnolen | amalloy: mind answering the clojure-dev thread for match? |
| 15:15 | TimMc | Anyway, I think I've misunderstood the problem. You want implicit context-binding when (.method obj) returns the function, yeah? |
| 15:26 | amalloy | dnolen: link? |
| 15:26 | TimMc | Is there really a use case for functions that can both have and not have a context? |
| 15:27 | TimMc | ibdknox: What currently happens if you use "this" as a variable name? Does it just get munged? |
| 15:28 | amalloy | never mind. response shortly |
| 16:17 | jli | I believe it's the case that javascript regexs can be used for global replace with a flag in the regex, but there's no corresponding flag in java regexes |
| 16:18 | jli | so, is the only way to do global replaces in clojurescript to use javascript's regex literals with js*? |
| 16:18 | jli | e.g. (js* "/regexp?/g") |
| 16:26 | dnolen | amalloy: thx |
| 16:27 | amalloy | (doto #"regexp?" (-> (.global) (set! true))) |
| 16:27 | fdaoud | quick question: is there a function that takes two seqs, e.g. [1 2 3] and [a b c], and returns [[1 a][2 b][3 c]]? (nevermind vectors vs lists) |
| 16:27 | amalloy | clojurebot: zip? |
| 16:27 | clojurebot | zip is not necessary in clojure, because map can walk over multiple sequences, acting as a zipWith. For example, (map list '(1 2 3) '(a b c)) yields ((1 a) (2 b) (3 c)) |
| 16:28 | amalloy | jli: which expands to (let [r #"regexp?"] (set! (.global r) true) r) |
| 16:28 | fdaoud | thanks amalloy! |
| 16:31 | stuartsierra | Boom! We have Matrix CI jobs. http://build.clojure.org/ |
| 16:45 | coopernu_ | nice! |
| 16:47 | hiredman | amalloy: you should have replied with "and my axe!" |
| 16:48 | amalloy | feh |
| 16:48 | amalloy | someone would file a jira ticket about my insufficiently-formal agreement |
| 16:48 | hiredman | yes |
| 16:48 | hiredman | I would |
| 16:48 | dnolen | stuartsierra: hey that is coooool. |
| 17:05 | amcnamara | Random thought: "Rich Hickey and the Stuarts" would make a great band name. |
| 17:06 | Bronsa | lol |
| 17:11 | stuartsierra | I wanted to make a Clojure/Conj band and call it "Function of the Past" |
| 17:14 | amcnamara | stuartsierra: If you do that I'll make a band called Lazy. I'll only play one note at a time, and only when asked. |
| 17:14 | Bronsa | lol |
| 17:15 | stuartsierra | "Rich Hickey and the Lazy Cons Cells" |
| 17:23 | jli | amalloy: ho. so "global" is a field on javascript regexs, not java ones, is that right? |
| 17:23 | amalloy | yes |
| 17:24 | amalloy | it's kinda absurd for it to be a field on regexes at all. it should be an argument to replace |
| 17:25 | jli | amalloy: well, what about the other flags? idmsux and all |
| 17:25 | amalloy | what about them? |
| 17:25 | jli | do you think they should be arguments to regex functions vs. regex fields? |
| 17:25 | jli | oh, nevermind |
| 17:25 | jli | I understand |
| 17:32 | jli | hum, why are \uFDD0 and \uFDD1 safe to use as keyword and symbol prefixes? |
| 17:32 | stuartsierra | I think they're in the "private use area" of unicode. |
| 17:34 | jli | ah. |
| 17:39 | lobotomy_ | hmm, i take it the clojure.contrib.combinatorics/combinations function is efficient? |
| 17:40 | lobotomy_ | doing a combinatorial search algorithm and for some reason i decided to generate combinations in the inner loop |
| 17:40 | lobotomy_ | which hopefully isn't actually necessary, but still: probs not worth implementing my own combination generator for that? :) |
| 17:41 | lobotomy_ | to elaborate, i'm using the combinations to avoid duplicates, since i often have many identical pieces |
| 17:43 | amalloy | uhhh |
| 17:44 | amalloy | finding the combinations of a seq of length N is necessarily O(n!). it can't be more efficient than that, so doing it in some inner loop when you don't have to is probably not a good idea |
| 17:46 | amalloy | modulo my bizarre inability to consistently choose either N or n |
| 17:57 | lobotomy_ | amalloy, well, if i have say two knights to put on the board, i need some way of not generating the duplicate solutions |
| 17:58 | lobotomy_ | i have to go through each combination of all-free-squares choose 2 in any case |
| 17:58 | lobotomy_ | so the O(n!) seems unavoidable - and usually (but not quite always) there aren't a gazillion combinations |
| 18:02 | lobotomy_ | sure, in e.g. the 8 queens puzzle my solution would first generate the 64 choose 8 different ways of putting every queen on the board, but i guesstimate that in the general case, 1) there will be fewer combinations and 2) there won't really be a better way to deal with duplicate non-generation anyway |
| 18:06 | amalloy | 64c8 is a hideously inefficient way to solve N-queens. just do the simple optimization of only looking at each column (say) once, then it's just 8^8 |
| 18:13 | dnolen | has some exciting news about solving problems like nqueens in Clojure ... keeps your eyes peeled ... |
| 18:14 | grios | hi. Does "#(% x)" stand for "(fn[x] x)"? |
| 18:14 | Bronsa | no |
| 18:14 | Bronsa | more like (fn [y] (y x)) |
| 18:15 | scottj | grios: #(identity x) is as close to (fn [x] x) as you can get |
| 18:15 | scottj | #(identity %) rather |
| 18:15 | amalloy | scottj: #(do %) |
| 18:15 | scottj | oh yeah, forgot about that one |
| 18:15 | amalloy | and #(identity %) is just identity anyway |
| 18:16 | grios | ok thanks |
| 18:16 | grios | #(do %) ... interesting |
| 18:27 | lobotomy_ | amalloy, my point was that since i'm not doing the 8 queens puzzle, the solution isn't completely terrible, like it would be for the 8 queens puzzle |
| 18:29 | grios | see you guys |
| 18:29 | grios | bye |
| 20:16 | livingston | if I want to expose some clojure code to java callers, I can easily use defrecord/defprotocol etc. for instances but what if I have what in java would be a static method on a class? how do I expose something like that? |
| 20:17 | livingston | basically I have a clojure function that I'd like java users to call like they usually would a static, but with out the RT.load(...) RT.var("ns", "function") rigamarole that looks "foreign" |
| 20:21 | livingston | this is the best I've found so far http://java.dzone.com/articles/java-clojure-interop-calling using gen-class |
| 20:25 | tomoj | livingston: that's the best there is I believe |
| 20:26 | livingston | tomoj: thanks, i'm trying to decide just how much it's worth trying to hide RT |
| 20:27 | livingston | if you do you can tell Java people "oh, it's just a library" but once RT etc. shows up they start to say "wait a minute..." |
| 20:29 | tomoj | does it pain you to use gen-class? |
| 20:31 | tomoj | that there is no nicer way to call regular clojure fns is deliberate, see http://dev.clojure.org/display/design/Improvements+to+interop+from+Java (esp. first comment) |
| 20:34 | livingston | tomoj: yeah I'm mostly sympathetic to all that... but importing is still a bit of an issue. people have RT.load before they can find the var. |
| 20:35 | livingston | that's not that huge an issue but it ups the "weirdness" ante. |
| 20:36 | tomoj | and then it's all invoke |
| 20:37 | tomoj | I don't see how anything but gen-class could make them happy, even if there _were_ an easy way to get ahold of the var |
| 20:37 | tomoj | s/easy/easier/ |
| 20:38 | livingston | the invoke I'm ok with. that's ok. I think the java guys can deal with that. the dynamic code loading though a call may be bothersome (nevermind that's what the java class loader is doing) |
| 20:39 | tomoj | and then everything is Object too? |
| 20:39 | livingston | java people (that do interesting things) aren't un-use to things like .invoke() because if they do anything with visitors / call-backs that's the only way for them. |
| 20:39 | livingston | will they have to type-cast ever return? as function parameters that not a deal, the compiler will silently lift them to Object for them. |
| 20:40 | tomoj | yeah, they will |
| 20:40 | livingston | tomoj: yeah they will ? have to cast every return? |
| 20:40 | tomoj | yeah |
| 20:40 | tomoj | gen-class lets you specify param and return types |
| 20:41 | livingston | hm. that may bother them a bit. |
| 20:41 | livingston | can I specify return types on defprotocol? not yet right? |
| 20:42 | tomoj | dunno, if you can I think just for clojure's sake, not to change the actual type signature |
| 20:43 | livingston | that would be highly useful for this. |
| 20:43 | tomoj | what's wrong with gen-class? |
| 20:44 | livingston | otherwise you would have to use actual java interfaces instead of protocols |
| 20:44 | livingston | tomoj: I have a lot of record/protocols already set up on the clj side, I just wanted to expose them to the java guys. |
| 20:45 | livingston | the "constructors" though are pure functions right now, that get you one of those, then they have protocols to call, that's easy, but the return types are still mildly problematic. |
| 20:45 | livingston | (stupid statically typed language ;) ) |
| 20:49 | tomoj | well, I guess you could provide any statics with gen-class and also expose the stuff you've got :/ |
| 20:49 | livingston | at this point I"m resigning to just have them deal with it ;) |
| 20:55 | livingston | is there a simple way to call a function that would take key word parameters from java? or do they have to get the keyword symbols to pass into invoke? |
| 21:00 | amalloy | how else could it work? |
| 21:00 | amalloy | haha whoops, missed a chance to use a bot. could it work any other way?? |
| 21:00 | lazybot | amalloy: Definitely not. |
| 21:00 | livingston | magic, I don't know... I didn't think so, just checking |
| 21:01 | amalloy | *shrug* you could write a little clojure wrapper that does the keyword conversion |
| 21:01 | livingston | i'm just afraid they'll look them up everytime. |
| 21:01 | amalloy | but i guess then you couldn't pass any strings that *aren't* keywords |
| 21:36 | Netpilgrim | Hi. I'm playing around with records and protocols for the first time and get an exception with a few simple code lines as shown here: https://gist.github.com/1190370 Could somebody have a look and explain the problem to me? |
| 21:37 | Netpilgrim | Argh, never mind! |
| 21:37 | amcnamara | paste the exception |
| 21:37 | Netpilgrim | Damn typo, I hadn't seen after reading the code a dozend times. |
| 21:38 | livingston | ,(doc reduce) |
| 21:38 | clojurebot | "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i... |
| 21:41 | Netpilgrim | But perhaps someone could look at the posted problem nevertheless and explain the following to me: I had mistyped a function name add-conn as add-con but the exception message reads “Can't define method not in interfaces: add_conn” – it doesn’t refer to the mistyped function name. |
| 21:46 | dnolen | Netpilgrim: you can't define multiple arities for protocol fns. |
| 21:46 | livingston | yes you can but not like that |
| 21:47 | Netpilgrim | livingston: How would I do it? |
| 21:47 | livingston | you have to do (defprotocol p (fn [x] [x y])) |
| 21:47 | Netpilgrim | livingston: Ah, thanks. |
| 21:47 | icey | dnolen: your link on HN in the "Clojure Hills of Abstraction" thread (http://news.ycombinator.com/item?id=2955389) is [dead]ed - I'm guessing your comment double posted and you deleted the wrong one. Anyways, you're the only one who suggested slimv and VimClojure... you might want to re-add your comment |
| 21:48 | dnolen | icey: ? looks ok here. |
| 21:49 | icey | dnolen: look at the thread in anonymous mode - it will look fine to you if you're logged in as you |
| 21:49 | icey | err, incognito mode |
| 21:50 | livingston | Netpilgrim: the second definition clobbers the first and it says there is no two argument version |
| 21:51 | icey | dnolen: crazy, it killed the second one too. i wonder if one of the links is banned or something |
| 21:51 | Netpilgrim | livingston: That explains it. |
| 21:52 | tomoj | wow |
| 21:52 | tomoj | I didn't think protocol fns could have multiple arities either |
| 21:52 | dnolen | livingston: wow, somehow I totally missed that. |
| 21:52 | dnolen | livingston: I guess rest args is what aren't supported. |
| 21:53 | livingston | I would assume that could be done to, you can do it in java too but I've never tried |
| 21:53 | tomoj | so how do you implement both arities? |
| 21:53 | tomoj | java's is just compiler sugar over an array as last param, isn't it? |
| 21:53 | dnolen | icey: weird, oh well. |
| 21:53 | livingston | tomoj: Netpilgrim had it right except for the protocol def |
| 21:54 | Netpilgrim | tomoj: https://gist.github.com/1190395 |
| 21:54 | icey | dnolen: I'll send an email, maybe it will get fixed. It sucks, because nobody else has mentioned VimClojure or slimv in that thread |
| 21:54 | tomoj | thanks |
| 21:54 | livingston | oh well then maybe it couldn't do it since there's no way to make a jave interface of it, but I think it could with the var arg, it would take some messing with to get the code right though |
| 21:58 | tomoj | an & in the arglist seems to be interpreted as a regular parameter |
| 21:58 | livingston | in the protocol? lol |
| 21:58 | tomoj | e.g. (deftype T [] P (p [x & z] &)) returns the second arg |
| 21:58 | amalloy | protocols don't have varargs |
| 21:59 | amalloy | and never will; it is an undesired feature |
| 21:59 | livingston | amalloy: why? |
| 21:59 | tomoj | and by whom? :) |
| 22:00 | amalloy | http://stackoverflow.com/questions/5401378/do-clojure-protocols-allow-one-to-have-a-variadic-method-the-way-funcions-do-wit |
| 22:02 | livingston | there's not much detail in that |
| 22:04 | amalloy | "Protocol methods are intended to be a "low-level" mechanism, with higher-level APIs, including variable arity, built out of ordinary functions." how much more is there to say? |
| 22:04 | livingston | it seems like that could just create a var-arg interface signature -- you wouldn't get destructuring but you'd get the array, although even the destructuring doesn't seem hard, grab the array, destructure it in a let and then call the function implementation |
| 22:05 | livingston | you also get java interop with the protocol and that seems oddly limiting |
| 22:06 | livingston | I mean you could just accept an array too, it's not that huge, but whatever |
| 22:07 | tomoj | huh |
| 22:07 | tomoj | when I look at that google groups post, there is a break right in the spot where you have a nbsp |
| 22:07 | tomoj | odd |
| 22:08 | fbru02 | hi ! where is re-gsub in 1.3 ? |
| 22:08 | amalloy | $findfn "jaja" #"a" "b" "jbjb" |
| 22:09 | lazybot | [clojure.string/replace] |
| 22:09 | amalloy | tomoj: i replaced the newlines with spaces when pasting? is that what you mean? |
| 22:09 | fbru02 | amalloy: thanks |
| 22:10 | amcnamara | whoa, how does that function work?! |
| 22:10 | amcnamara | $findfn "a" "o" "ao" |
| 22:11 | lazybot | [clojure.core/str clojure.contrib.string/as-str] |
| 22:11 | amcnamara | damn that's cool |
| 22:12 | tomoj | amalloy: no, your message had a no break space in between "ordinary" and "functions", where I see a break in the browser |
| 22:12 | tomoj | what's a no break space for anyway? |
| 22:12 | amalloy | dunno |
| 22:12 | tomoj | figured it was for.. no breaks |
| 22:13 | livingston | tomoj: it is |
| 22:13 | livingston | where is this though? |
| 22:13 | amcnamara | its for words you don't want to appear on separate lines, like names |
| 22:13 | tomoj | oh, I don't see the nbsp in the browser. that's comforting :) |
| 22:14 | livingston | if there is any other whitespace around it though it'll then break... |
| 22:14 | livingston | or if it's not actaully there,.. |
| 22:14 | amcnamara | also good for keeping empty table cells from collapsing :) |
| 22:15 | livingston | amcnamara: wasn't that only due to some crappy non-compliance in one of the browsers during the browser wars? |
| 22:16 | amcnamara | livingston: Probably, the 90s were full of i'll-fix-this-later hacks... that are still around |
| 22:16 | amalloy | amcnamara: it iterates through a few namespaces (core, string, set, contrib/string) and calls every function with the supplied args, to see which ones return the right result |
| 22:16 | livingston | I do remember no end of futzing with crap like that (back when I uses to work with ASP 1) |
| 22:19 | amcnamara | amalloy: Neat concept. Though probably heavy to process. |
| 22:19 | livingston | if you know the order of the arguments |
| 22:20 | amcnamara | livingston: I'm actually worried that the same thing is happening again, with all the talk of HTML5 browsers are in a race to put non-finished standard components into their releases |
| 22:20 | livingston | yeah we shall see |
| 22:21 | livingston | having the acid tests (or whatever the hell they are called) out before the spec seems to be helping some |
| 22:21 | amcnamara | 10 years from now we'll be pulling our hair out over old chrome and ff idiosyncracies. |
| 22:21 | livingston | maybe although two viable free browsers seems to be producing some stability |
| 22:22 | livingston | is chrome actually really in the wild or is it just a geek toy still? |
| 22:22 | amcnamara | I think its picking up popularity |
| 22:22 | amcnamara | but my opinions are pretty skewed. |
| 22:23 | amalloy | livingston: clojure functions generally take their arguments in a pretty predictable order |
| 22:24 | livingston | for the most part |
| 22:24 | amalloy | granted it takes some time to get used to that, but i didn't know $findfn was going to return string/replace; i just asked it for a function that takes its args in the order that replace "must" |
| 22:24 | amalloy | yeah, everything but nth. grrrrr nth |
| 22:26 | amcnamara | nth gets me every time. |
| 22:26 | livingston | (doc ,nth) |
| 22:26 | clojurebot | "([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences." |
| 22:26 | amcnamara | maybe they'll fix it for clojure 2.0 |
| 22:28 | livingston | why is that anyway? |
| 22:28 | amalloy | amcnamara: bet you a dollar? |
| 22:28 | amalloy | $google common lisp elt |
| 22:28 | lazybot | [lispdoc documentation for "elt"] http://lispdoc.com/?q=elt |
| 22:28 | livingston | that would break a ton of stuff |
| 22:29 | amalloy | livingston: i assume it's a holdover from some other lisp |
| 22:29 | livingston | oh huh, I forgot elt was that way |
| 22:29 | livingston | I only even remembered elt as being 0-based and nth being 1-based |
| 22:30 | livingston | I rarely called elt (although I knew it was there and understood it) |
| 22:31 | amcnamara | I'll open a bug report and patch it myself! |
| 22:31 | amcnamara | amalloy: for a beer. |
| 22:31 | amalloy | amcnamara: i hope your soul can survive being crushed |
| 22:31 | amalloy | by the patch being soundly rejected |
| 22:31 | livingston | right... because it's a simplifed form of aref |
| 22:32 | srid | i am using cake. 'cake repl' launches faster and that convinces me to keep using cake. i do wonder if I can launch a cake repl client within emacs (analogous to M-x clojure-jack-in) |
| 22:32 | livingston | it makes sense when I look at the other things around it. |
| 22:32 | amalloy | srid: cake swank |
| 22:32 | livingston | srid: why do you need to keep launching it? I've been known to keep development repls open for weeks even months |
| 22:33 | srid | livingston: i keep running non-repl commands (eg: `lein run`) that has startup cost which accumultates to the point of frustration |
| 22:33 | srid | and i have to relaunch repl after 'lein deps' |
| 22:33 | amcnamara | srid: M-x term, never leave the comfort of emacs. |
| 22:34 | amalloy | srid: lein interactive |
| 22:34 | srid | amcnamara: nice, cake autocomp. wonders in m-x term |
| 22:36 | srid | except terminal locks up all the C-x ... bindings |
| 22:37 | amcnamara | yeah, if it didn't you wouldn't be able to quit out-of-control procs |
| 22:37 | amcnamara | but I'm trying to figure out a way to toggle focus, if I do I'll ping you. |
| 22:37 | amalloy | why not just use M-x shell? |
| 22:38 | amalloy | i guess i don't understand what issue you're trying to solve |
| 22:38 | srid | cake autocomp. doesn't work in M-x shell |
| 22:39 | srid | likely possible to disable emacs's TAB complete. whatever. enough yak shaving |
| 22:41 | srid | anyway, settled on `cake swank` and M-x slime-connect. repl in emacs with autocomp goodies. |
| 22:46 | tomoj | lein interactive somehow lets you not restart the repl after deps? |
| 22:46 | tomoj | oh, no, just startup alleviation, huh |
| 22:46 | amalloy | right |
| 23:03 | amcnamara | srid: got it! http://www.gnu.org/s/libtool/manual/emacs/Term-Mode.html |
| 23:03 | amcnamara | one C-c will get you C-x bindings |
| 23:04 | amcnamara | two will send kill signal to term process |
| 23:56 | jblomo | is there a function that will seqify something if it doesn't implement ISeq |
| 23:56 | jblomo | like stick it in a list? |
| 23:56 | jblomo | (seq' 5) |
| 23:56 | amalloy | jblomo: that's probably not what you want |
| 23:57 | amalloy | since ##(instance? clojure.lang.ISeq [1]) |
| 23:57 | lazybot | ⇒ false |
| 23:57 | livingston | jblomo: huh? |
| 23:57 | livingston | list ? |
| 23:57 | livingston | ##(list 5) |
| 23:57 | lazybot | ⇒ (5) |
| 23:57 | amalloy | livingston: he wants to leave '(5) alone, and turn 5 into '(5) |
| 23:57 | jblomo | exactly |
| 23:58 | jblomo | amalloy: you're right, I don't care about instance? ISeq |
| 23:58 | amalloy | jblomo: (a) your specification is probably wrong, because ISeq doesn't describe all seqable things, and (b) when you want to do this, it's usually because you've written something else badly |
| 23:58 | livingston | (defn huh [x] (if (seq x) x (list x))) |
| 23:58 | amalloy | livingston: (huh 5) ; exception |
| 23:58 | livingston | or rather (if (seq? x) ... I think |
| 23:59 | jblomo | amalloy: i'm writing a fucntion that can either take a string or list of strings |
| 23:59 | amalloy | jblomo: see, told you you'd written something wrong already :) |
| 23:59 | jblomo | haha |
| 23:59 | amalloy | just make it take a list of strings. if you want to special-case the length-one list, then go ahead |