2010-05-20
| 00:12 | defn | how would one go about integrating ruby on rails and clojure? |
| 00:12 | defn | jruby probably, id guess |
| 00:13 | lancepantz | we use clojure for a backend rest api |
| 00:13 | defn | lancepantz: do you have any public code floating about? |
| 00:13 | defn | lancepantz: using ring i presume? |
| 00:13 | lancepantz | rails just makes rest calls |
| 00:13 | lancepantz | yeah, with compojure |
| 00:13 | defn | k |
| 00:14 | lancepantz | and unfortunately we haven't open sourced any of that yet |
| 00:14 | defn | bummer |
| 00:14 | lancepantz | very much so |
| 00:14 | lancepantz | even worse of a problem with the 0.4 release |
| 00:15 | defn | yeah it's kind of unnerving |
| 00:15 | defn | what's the point of a framework with no documentation |
| 00:15 | lancepantz | agree |
| 00:15 | lancepantz | ring does a pretty good job w/ docs |
| 00:15 | defn | yeah, it's not very big and most of it is self-explanatory |
| 00:15 | lancepantz | i found the most helpful resource for compojure was the mailing list |
| 00:16 | defn | but compojure has made me want to rage on multiple occasions |
| 00:18 | defn | lancepantz: so you have two server instances? |
| 00:18 | defn | lancepantz: also, are you just running the clojure side of things in a REPL? |
| 00:19 | lancepantz | yes wrt instances, but we deploy a war |
| 00:19 | defn | bleh -- no clue what to do there |
| 00:20 | lancepantz | most people talk about deploying in a repl, which surprised me |
| 00:20 | defn | yeah it seems like a terrible way to do production stuff |
| 00:20 | defn | it just seems...impermanent |
| 00:20 | lancepantz | yeah, i just assumed they weren't working on production stuff |
| 00:21 | defn | i mean, im using it for getclojure.org:8080/examples/concat |
| 00:21 | defn | but that's staging -- i dont consider that a permanent solution |
| 00:21 | lancepantz | w/screen? |
| 00:21 | defn | yes |
| 00:22 | lancepantz | http://github.com/lancepantz/lein-war-example if you want something to work from |
| 00:23 | lancepantz | it's simple once you get it setup |
| 00:23 | defn | cool thanks |
| 00:23 | defn | lancepantz: have you noticed any pain with managed dependencies from 1.1.0 to 1.2.0 |
| 00:23 | defn | it seems like so many of the things i was using havent been upgraded to 1.2.0, and while i could do it myself im just making a bigger mess |
| 00:24 | lancepantz | not yet, but i haven't finished updating everything |
| 00:30 | defn | lancepantz: if/when you get something online id love to see a rails + clojure thingamajig working |
| 00:31 | lancepantz | will do, we should have it in production next week or so |
| 00:32 | lancepantz | gotta run for now, take care |
| 01:32 | slyrus | ack! the only thing scarier than whatever maven seems to want to download is the list of dependencies required to install maven2 in the first place! (at least via apt-get) |
| 01:40 | timmorgan | I'm a Ruby dude, a Clojure noob, and cannot figure out how to do the equiv of ruby_arr.include?(item) in Clojure |
| 01:41 | timmorgan | (some #(= item %) items) ? |
| 01:41 | timmorgan | or ((set items) item) |
| 01:41 | timmorgan | is there a more idiomatic way? |
| 01:42 | mmarczyk | timmorgan: if item is not nil or false, (some #{item} items) |
| 01:42 | mmarczyk | timmorgan: though #(= item %) is perfectly alright too |
| 01:43 | timmorgan | so, when treating a single-item set as a predicate, it tests to see whether its contents are present in the vector? |
| 01:43 | mmarczyk | it's not really a predicate |
| 01:44 | timmorgan | ok, a function |
| 01:44 | mmarczyk | it returns nil if it does not contain the given item, otherwise it returns the item itself |
| 01:44 | replaca | timmorgan: it can be an any-item predicate |
| 01:44 | mmarczyk | not a predicate in the sense of "a function which returns a Boolean", I mean |
| 01:44 | timmorgan | ok that makes sense |
| 01:45 | timmorgan | off to the repl I go |
| 01:45 | timmorgan | thanks guys |
| 01:45 | mmarczyk | yw :-) |
| 01:45 | replaca | for example (some #{:dog :cat} aseq) will tell me if dog or cat is in aseq |
| 01:46 | replaca | maxhodak: yeah, that's a fuzzy line in clojure. I tend to think of things as predicates more based on how I use them than on their defs |
| 01:46 | replaca | I meant mmarczyk :) |
| 01:56 | mmarczyk | replaca: :-) |
| 01:56 | mmarczyk | coming from Scheme, I'm used to the convention whereby anything with a name ending in ? returns Booleans only |
| 01:57 | remleduff | That's the convention in clojure too, that's why it's "some" and not "some?" |
| 01:57 | mmarczyk | yup, I know |
| 01:59 | mmarczyk | but whether it makes sense to take issue with a foo? function which might return nil seems to be a matter not everybody agrees on... I'm on the "switch to false or drop the ?" side personally ;-) |
| 02:01 | mmarczyk | incidentally, "some" as a name only makes sense to me as a predicate, "lookup" or sth would make more sense to me... or find-first, since it's just (comp first filter) anyway |
| 02:06 | TheBusby | Is there a clojure function for handling a queue between threads similiar to promise/deliver? |
| 02:07 | TheBusby | just conj a ref maybe? |
| 02:08 | wdouglas | Hey all, I'm having an odd to me problem of not being able to use the thrown?, thrown-with-msg? calls in clojure.test. I look at the source for 1.1 and I see the functions there but when I use clojure.test, not showing up. Probably something stupid but I can't seem to figure it out. |
| 02:09 | chouser | TheBusby: you might like java.util.concurrent.BlockingQueue |
| 02:10 | mmarczyk | TheBusby: have a look at seque and clojure.contrib.seq/fill-queue |
| 02:10 | chouser | mmarczyk: it's not (comp first filter), it's more like (first (filter identity (map ...))) |
| 02:10 | chouser | 'some', that is. |
| 02:10 | mmarczyk | though, yeah, LinkedBlockingQueue works just fine... except apparently it doesn't handle nils |
| 02:11 | TheBusby | looking in Java's concurrent section now, but producer cannot block, ConcurrentLinkedQueue maybe? |
| 02:11 | mmarczyk | ,(some #{:foo} [:foo :bar :quux]) |
| 02:11 | clojurebot | :foo |
| 02:11 | mmarczyk | ,((comp first filter) #{:foo} [:foo :bar :quux]) |
| 02:11 | clojurebot | :foo |
| 02:11 | mmarczyk | ,((comp first filter) #{:wibble} [:foo :bar :quux]) |
| 02:11 | clojurebot | nil |
| 02:12 | chouser | ,(some :a [{:a nil} {:a false} {:a :b}]) |
| 02:12 | clojurebot | :b |
| 02:12 | chouser | ,((comp first filter) :a [{:a nil} {:a false} {:a :b}]) |
| 02:12 | clojurebot | {:a :b} |
| 02:13 | chouser | but the real question is |
| 02:13 | mmarczyk | oh. |
| 02:13 | mmarczyk | thanks! |
| 02:13 | chouser | why the heck am I still up |
| 02:13 | mmarczyk | that goes for me as well |
| 02:13 | mmarczyk | 8:12 am here |
| 02:13 | TheBusby | chouser: thanks for the input |
| 02:13 | chouser | np |
| 02:13 | TheBusby | mmarczyk: thanks! |
| 02:13 | mmarczyk | yw |
| 02:14 | defn | does anyone here have cuke4duke working? |
| 02:14 | defn | I can't seem to get it running |
| 02:14 | mmarczyk | LinkedBlockingQueue has an .offer method |
| 02:14 | mmarczyk | or some such thing |
| 02:14 | mmarczyk | for putting things on the queue if possible, getting an indication of success and never blocking |
| 02:15 | mmarczyk | cuke4duke, wow 8-O |
| 02:15 | defn | ?? |
| 02:15 | mmarczyk | is this something to do with testing? |
| 02:15 | defn | yes. |
| 02:15 | mmarczyk | I mean the project name |
| 02:15 | defn | cucumber |
| 02:15 | mmarczyk | and duke? |
| 02:15 | defn | no clue |
| 02:15 | mmarczyk | right. |
| 02:16 | defn | lol oh god -- maven2 needs...113 packages for ubuntu |
| 02:17 | Chousuke | are you sure it's not installing recommended packages? |
| 02:18 | TheBusby | likely install an alternate version of Java too... |
| 02:19 | defn | i just let apt do its thing |
| 02:20 | defn | wait..maven2 is installing groovy? |
| 02:24 | tgk | I'm trying to think of a macro for getting a textual representation of a form while still evaluating it. Does anybody know if there is a way to do this? The textual representation should just be saved somewhere as a side effect. |
| 02:24 | LauJensen | Morning all |
| 02:25 | tgk | Here's a usage example: (text-copy (defn f [x] (* 2 x))) => #'user/f |
| 02:25 | tgk | I'm pretty sure it's possible, but I have no idea how to get started. |
| 02:27 | defn | tgk: read the form in as a string, add it to a ref, vector, map, whatever |
| 02:27 | defn | and then read-string |
| 02:27 | tgk | defn: how do I read the form in as a string? |
| 02:35 | defn | (read-string "(+ 1 2)") |
| 02:39 | tgk | Hmmm okay, it will read it from a string. But I need the reverse; I want to create a string from a form. E.g.: (string-from-form (def f [x] (+ 3 x))) => "(def f [x] (+ 3 x))" |
| 02:46 | tomoj | ,(str '(def f [x] (+ 3 x))) |
| 02:46 | clojurebot | DENIED |
| 02:46 | tomoj | bah |
| 02:46 | tomoj | ,(str '(df f [x] (+ 3 x))) |
| 02:46 | clojurebot | "(df f [x] (+ 3 x))" |
| 02:50 | tgk | But that requires that I put the ' there... Hmmm I guess that can be solved by using macros |
| 02:53 | tomoj | uhh |
| 02:53 | tomoj | what were you hoping to use? a function? |
| 02:55 | tgk | Oh no, not at all. I think I'll go tinker with it. |
| 02:55 | tomoj | if string-from-form is a function and you call (string-from-form (def f [x] (+ 3 x))), the first arg of the function will be bound to #'f |
| 02:56 | tomoj | well, it would be if (def f [x] (+ 3 x)) were fixed |
| 02:56 | tgk | I know, I was sure I needed to write a macro. |
| 02:57 | tomoj | oh |
| 02:57 | tomoj | do you want to figure the macro out on your own, then? |
| 02:58 | tgk | I'll try, I'll get back when I fail. |
| 02:58 | tomoj | good luck :) |
| 02:58 | tgk | Thanks :) |
| 03:02 | TheBusby | anyone have any experience using processBuilder? |
| 03:03 | arbscht | TheBusby: ask your real question and someone might answer |
| 03:06 | TheBusby | arbscht: thanks |
| 03:06 | TheBusby | Then, any idea how to turn the stdout out of a process created with processBuilder into a lazy-seq accessible by other threads? |
| 03:07 | TheBusby | evidently if the stdout isn't consumed quickly by clojure the process will freeze |
| 03:10 | TheBusby | duck-stream/copy works, reader + line-seq not so well... |
| 03:25 | stilkov | tgk: maybe you're looking or pprint |
| 03:26 | stilkov | s/or/for/ |
| 03:26 | sexpbot | tgk: maybe you're looking for pprint |
| 03:28 | stilkov | I use it to print code this way: (with-pprint-dispatch *code-dispatch* (pprint form)) |
| 03:28 | stilkov | form is something I read with read-string |
| 03:36 | tomoj | stilkov: what does that do differently than ugly printing? |
| 03:37 | tomoj | actually, hmm |
| 03:38 | tomoj | ,(require clojure.contrib.pprint) |
| 03:38 | clojurebot | java.lang.ClassNotFoundException: clojure.contrib.pprint |
| 03:38 | tomoj | darn |
| 03:38 | tomoj | (let [form '(fn [x] (+ x 2))] (= form (pprint/with-pprint-dispatch pprint/*code-dispatch* form))) |
| 03:38 | tomoj | that is true for me |
| 03:38 | tomoj | i.e. (partial with-pprint-dispatch *code-dispatch*) seems to be the identity |
| 03:39 | LauJensen | For those interested, we've picked a venue: http://conj-labs.eu/course.html#misc ! :) |
| 03:39 | sexpbot | "conjLabs - About Clojure" |
| 03:39 | stilkov | pprint prints to *out* |
| 03:39 | tomoj | nothing is printed for me |
| 03:39 | tomoj | it just returns the form |
| 03:39 | tomoj | strange.. |
| 03:39 | stilkov | if you want to get the string value, you need to use a stringwriter |
| 03:39 | stilkov | (binding [*out* (java.io.StringWriter.)] |
| 03:39 | stilkov | (with-pprint-dispatch *code-dispatch* (pprint code)) |
| 03:39 | stilkov | (.toString *out*) |
| 03:40 | tomoj | oh, whoops |
| 03:40 | tomoj | my problem was that I never called pprint |
| 03:40 | tomoj | ok, but still, looks just like ugly printing |
| 03:40 | tomoj | is it supposed to do something special? |
| 03:40 | stilkov | but what tgk seems to want is to get the string value and the eval'd result |
| 03:41 | stilkov | and the original form … |
| 03:41 | tomoj | I mean, (with-pprint-dispatch *code-dispatch* (pprint form)) and (println form) seem to have the same output |
| 03:41 | tgk | That is true, I think I have it solved. |
| 03:41 | stilkov | depends on the complexity of the form :-) |
| 03:41 | tomoj | ah, if it gets bigger it starts adding newlines etc? |
| 03:41 | stilkov | yep |
| 03:41 | tomoj | nice |
| 03:44 | eevar2 | LauJensen: the blog link on http://conj-labs.eu/instructors.html doesn't work |
| 03:44 | sexpbot | "conjLabs - Instructors" |
| 03:44 | LauJensen | eevar2: thanks! |
| 03:45 | LauJensen | eevar2: fixed |
| 03:45 | tomoj | brussels is disturbingly far away |
| 03:45 | eevar2 | what's with the rdbms hate btw? just stick a caching proxy in front if you're worried about efficiency ;) |
| 03:46 | LauJensen | tomoj: from where? |
| 03:46 | LauJensen | eevar2: you talking about my baking skills? |
| 03:46 | eevar2 | ^^ |
| 03:46 | tomoj | LauJensen: texas |
| 03:47 | LauJensen | tomoj: 9 hour flight? Thats the time it takes to write a fun 3d shooter in Penumbra, whats the problem ? |
| 03:47 | tomoj | heh |
| 03:47 | LauJensen | eevar2: There's so much more at stake than performance |
| 03:47 | LauJensen | There isn't a problem possible with my site, that I cant fix with scp, rsync or tramp |
| 03:48 | LauJensen | Wordpress has numerous vunerabilities, and new ones pop up - how are you going to crack a static file? :) |
| 03:49 | eevar2 | the comment system is still interactive, no? i think you might be adding complexity for no good reason, but maybe that's just me |
| 04:01 | LauJensen | eevar2: adding complexity? where? |
| 04:09 | eevar2 | a db would take care of the acid issues, for instance. even if a work queue + some file system operations isn't _that_ complex |
| 04:09 | esj | Morning Good People |
| 04:10 | stilkov | it seems something has changed in compojure's defroutes syntax recently - anybody able to point me to a working recent example? |
| 04:13 | LauJensen | eevar2: ah yes. Its true that in the single instance which needs to be dynamic on the server-side, you can argue that my system isn't simpler than a db-based on, thats true |
| 04:14 | LauJensen | esj: morning :) |
| 04:41 | hiredman | ping? |
| 04:41 | clojurebot | PONG! |
| 04:49 | LauJensen | pong? |
| 04:49 | clojurebot | Qinfengxiang! |
| 05:30 | esj | are there any examples out there of a java client consuming the interface generated by a protocol ? |
| 05:30 | _na_ka_na_ | hi, how do i clear the cache of a memoize fn? |
| 05:31 | hiredman | _na_ka_na_: you don't |
| 05:32 | _na_ka_na_ | hiredman: why?, i've a long running app, where the user loads a file, my app reads the file & caches the ds etc, ... then the user loads another file, in which case i want to clear the caches |
| 05:33 | _na_ka_na_ | maybe i should include the filename in all the fns .. |
| 05:33 | clojurebot | the unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation |
| 05:34 | esj | _na_ka_na_: to do this you need to reimplement memoize. Not hard. There is a great post on this here http://kotka.de/blog/2010/03/memoize_done_right.html |
| 05:34 | sexpbot | "Kotka : About Clojure… What else?" |
| 05:34 | esj | sexpbot: botsnack |
| 05:34 | esj | $botsnack |
| 05:34 | sexpbot | esj: Thanks! Om nom nom!! |
| 05:35 | _na_ka_na_ | esj: thanx lemme take a look @ that |
| 05:36 | esj | OK, I guess my question is more; is the method described in this link still current http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java |
| 05:36 | sexpbot | "Clojure Programming/Tutorials and Tips - Wikibooks, collection of open-content textbooks" |
| 05:40 | eintr | autodoc and clj 1.2 seem unhappy together. sadness ensues. all is quiet. undocumented. |
| 05:45 | LauJensen | esj: I think its still possible, but checkout cemericks Maven screencast, you see him doing a much simpler interop |
| 05:46 | stilkov | I'm running into UniCode problems with Compojure; anybody run into this yet? |
| 05:47 | esj | LauJensen: Thanks. I'll check it out. It looks like deftype may be the right stuff, but I'm haven't seen examples. |
| 05:55 | spariev | stilkov: what kind of problems do you have ? All mine Unicode troubles were with swank-clojure encoding settings |
| 05:55 | stilkov | my problem seems to be independent of swank, it happens if I start my webserver from the command line too |
| 05:57 | stilkov | in fact, if I get stuff from the backend with a remotely connected slime and write it to a file with UTF-8 encoding, everything's perfect |
| 05:57 | stilkov | it's as if compojure/ring didn't use UTF-8 encoding when writing |
| 05:58 | spariev | haven't tried 0.4 compojure yet, no problems with old 0.3.2 |
| 05:59 | esj | LauJensen: thanks, nice screencast. Not quite what I was after, but cool. |
| 06:25 | LauJensen | Ok :| |
| 06:41 | kasperlanger | Hi everyone. Is there a way to freeze the root-bindings of a namespace? |
| 07:55 | _na_ka_na_ | hi, I have a question regarding protocols and datatypes, |
| 07:56 | _na_ka_na_ | I'm defining a proto, as (defprotocol P (foo [this & args])) |
| 07:56 | _na_ka_na_ | then a datatype as, (deftype PImpl [] P (foo [this & args] (println this args))) |
| 07:56 | _na_ka_na_ | after that I eval, (foo (PImpl.) :x :y) |
| 07:56 | _na_ka_na_ | this prints... |
| 07:56 | _na_ka_na_ | #<PImpl iiit.PImpl@7c8865> :y |
| 07:56 | _na_ka_na_ | where did the :x go? |
| 07:57 | _na_ka_na_ | am I defining P, PImpl properly? |
| 07:58 | _na_ka_na_ | or is destructuring not possible in protos? |
| 07:58 | rhickey | fogus: yeah, read that earlier. The principle is correct, but the reality is that the declarative nature of Prolog is a somewhat a lie. Not that is didn't work for him, and the lesson is still a good one |
| 07:59 | raek | _na_ka_na_: are you running the latest version? previously the 'this' parameter has been handled in a different way |
| 08:00 | _na_ka_na_ | raek: I'm using clojure-1.2.0-master-20100518.110252-71.pom |
| 08:01 | _na_ka_na_ | its working if I do it w/o destructuring ... |
| 08:02 | fogus | rhickey: Intriguing. I used Prolog in school (who didn't) and most of the things we did seemed declarative. But at one point I worked with a guy who used it on a very large system, and his code didn't look anything like those school projects |
| 08:03 | _na_ka_na_ | rhickey: is destructuring possible in proto method declarations? |
| 08:03 | rhickey | fogus: three things rain on the parade in Prolog IMO: cut/fail, infinite evaluations, and clause order dependency |
| 08:04 | rhickey | together they truly prevent you from just thinking declaratively, and force you to consider the baked-in evaluation semantics |
| 08:04 | LauJensen | _na_ka_na_: http://bestinclass.dk/index.clj/2010/04/prototurtle-the-tale-of-the-bleeding-turtle.html |
| 08:04 | sexpbot | "Best In Class: ProtoTurtle - The tale of the bleeding turtle" |
| 08:04 | rhickey | _na_ka_na_: what would it mean to put destructuring in the declarations? destructuring is supported in the definitions |
| 08:04 | fogus | rhickey: I see what you mean now. For that angle I agree |
| 08:05 | fogus | s/For/From/ |
| 08:05 | sexpbot | rhickey: I see what you mean now. From that angle I agree |
| 08:05 | fogus | whoa! |
| 08:05 | _na_ka_na_ | :) |
| 08:07 | LauJensen | rhickey: any clues as to how close 1.2 is ? |
| 08:15 | _na_ka_na_ | rhickey: thanks! for the clue, got it - used a map to simulate, one more question: is it possible to declare methods with variable number of args in protos? |
| 08:15 | clojurebot | map is *LAZY* |
| 08:15 | _na_ka_na_ | clojurebot: not the fn, but the ds |
| 08:15 | clojurebot | |monads| is "yea, though I should walk in the valley of imperative code, I shall fear no evil, for your monad comforts me" - seen in #haskell |
| 08:16 | _na_ka_na_ | :) |
| 08:18 | rhickey | _na_ka_na_: no variadics in protocols, you can write a variadic fn that calls a protocol fn. Remember, a protocol is not (necessarily) a consumer API, it is an abstraction implementor's API |
| 08:19 | cemerick | I was way too overenthusiastic in my first run at using prolog. It was a trail of tears in the end, as I'll bet it is for most. |
| 08:20 | rhickey | LauJensen: close |
| 08:21 | LauJensen | Great |
| 08:21 | fogus | cemerick: More blood than tears for me |
| 08:23 | rhickey | for that subset of Prolog that it covers, Datalog is far superior IMO |
| 08:23 | cemerick | fogus: thankfully, I wasn't using it in conjunction with an active project, just research-y stuff. Lots of good lessons though. Prime among them being the declarative > imperative one. |
| 08:24 | npoektop | ,(str "\/") |
| 08:24 | clojurebot | Unsupported escape character: \/ |
| 08:24 | rhickey | fogus: yes, Bratko is great, but I just recommended it to someone and it appears to be running out of print!? |
| 08:25 | npoektop | can't write "\/", it says java.lang.Exception: Unsupported escape character: \/ |
| 08:25 | npoektop | ,(str "\/") |
| 08:25 | clojurebot | Unsupported escape character: \/ |
| 08:25 | gregh | ,(str "\\/") |
| 08:25 | clojurebot | "\\/" |
| 08:26 | gregh | is that what you're looking for? |
| 08:26 | npoektop | gregh, i need "\/", not "\\/" |
| 08:26 | fogus | rhickey: But the Clocksin and Mellish book will continue forever... there's no justice. |
| 08:27 | gregh | ,(print "\\/") |
| 08:27 | clojurebot | \/ |
| 08:27 | gregh | str is showing you the escaped representation of the string "\/" |
| 08:28 | npoektop | gregh, cool. thank you |
| 08:36 | fogus | There seems to be a steady flow of former Rubyists coming into Clojure. Maybe the Scala stream will start picking up soon. ;-) |
| 08:37 | ryoko-sha | Newbie apols in advance - (clojure.contrib.prxml/prxml [:p {:class "red"} "cat"]) => <p class="red">cat</p>nil where's nil coming from? |
| 08:37 | chouser | ryoko-sha: that's the return value |
| 08:38 | cemerick | fogus: are you still solidly in scala for work? |
| 08:38 | chouser | <p ...through p> is what prxml is printing, but then it returns nil which the repl prints for you. |
| 08:38 | ryoko-sha | chouser: thanks! |
| 08:39 | fogus | cemerick: The projects that I used it for are mostly stable now. Working on the Clojure sell at the moment. |
| 08:39 | rhickey | fogus: so, what is the Clojure sell to Scala folks? |
| 08:40 | chouser | I've recently begun starting my repl with non-default options so that I get a green ----- between prompts, and the return value prints in blue. |
| 08:40 | cemerick | Clojure: it eliminates the need for psychotherapy! |
| 08:40 | fogus | I hate to say it, but I haven't been pushing for Scala lately. |
| 08:40 | chouser | ryoko-sha: which helps point out the difference between printed and returned values. |
| 08:41 | eintr | chouser: that's neat, sort of like ipython's fanciful coloring. care to share? |
| 08:41 | chouser | hm, I suppose I should. |
| 08:42 | fogus | rhickey: The thing that I see coming up more and more is that people are blown away by the complexity of Scala (2.8 will only make that worse). Many people come into it thinking it's Java++ but find out that the ++ part is superficial |
| 08:43 | bozhidar | fogus: can you elaborate on the complexity part? |
| 08:43 | fogus | IMO, I think Scala should not try to sell itself as the "next Java" and just stand on its own merit and push an interop story instead. |
| 08:43 | rcg | chouser: how did you set these options? |
| 08:43 | cemerick | I thought the throwaway comment about the XML literals in that scala thread was a huge red flag. Not the kind of design work you want to see going into one's language. |
| 08:44 | bozhidar | I'll be doing a research for my company about modern alternatives to Java on the JVM that will be featuring Groovy, Clojure and Scala and of the three only Scala is a complete mystery to me at the this point |
| 08:44 | fogus | Also I think going half-heartedly at the mutability problem is wrong. But I do not have an appreciation for the complexities of immutable FP/OOP |
| 08:45 | cemerick | bozhidar: this is a popular recent thread that touches on the complexity/"large language" topic: http://scala-programming-language.1934581.n4.nabble.com/The-right-tool-td2220305.html |
| 08:46 | sexpbot | "Nabble - Scala - The right tool" |
| 08:46 | bozhidar | cemerick: thanks, I'll have a look at it |
| 08:46 | fogus | rhickey: I guess the sell is simplicity. Simplicity beyond the initial "Clojure looks weird" hurdle. |
| 08:47 | LauJensen | fogus: the simplicity, and the immutability are what put Clojure miles and miles and a few lightyears ahead of Scala |
| 08:47 | bozhidar | if it were up to me I'd be researching only Clojure, but my boss is convinced that Scala is the future top language for the JVM for some reason |
| 08:47 | rhickey | fogus: ok, thanks |
| 08:47 | fogus | cemerick: The sad part about that comment was that I was (at one point) maintaining that stuff. I guess I am glad that I got out when I did |
| 08:48 | bozhidar | I've noticed that the Groovy creator is currently spending more time on Scala than on Groovy, so I thought that the language probably has some merits |
| 08:48 | gregh | bozhidar: maybe because twitter uses it. :) |
| 08:48 | fogus | bozhidar: That thread (IMO) typifies Scala perfectly. |
| 08:49 | cemerick | typifies! Ha! |
| 08:49 | fogus | bozhidar: I think it has many merits. |
| 08:49 | bozhidar | I'm reading the thread right now :-) |
| 08:50 | cemerick | fogus: I just don't understand how it could have gotten in the first place. Perhaps part of it is that the language really is an academic experiment at its roots (i.e. trying to prove the applicability of FP in "practical" usage). Seeing XML literals in code like that is just *so* offensive. |
| 08:50 | bozhidar | fogus: I guess so, no language becomes that popular without merits |
| 08:50 | bozhidar | except maybe BASIC |
| 08:50 | bozhidar | :-) |
| 08:50 | Hodapp | *cough*C++*cough* |
| 08:50 | gregh | basic's merit was that it was the only choice :) |
| 08:51 | cemerick | bozhidar: don't hate on the BASIC. :-) RealBasic is pretty great for what it does. |
| 08:51 | fogus | cemerick: Having spent (more time than I'd like to remeber) time in that code, I can say that it is poorly implemented, wrongheaded, bolted on, and other things that I should not write in a public forum. |
| 08:51 | bozhidar | cemerick: haven't even heard of it |
| 08:51 | cemerick | fogus: I'll do you the favor of letting someone else send that OH tweet :-) |
| 08:51 | Hodapp | BASIC is great for teaching the... uh... basics, but it's the sort of language that needs to be moved on from before awful habits set in |
| 08:52 | bozhidar | Hodapp: I think Pascal better suits the learning bill |
| 08:52 | cemerick | bozhidar: it's a cross-platform RAD tool http://www.realsoftware.com/realbasic/ |
| 08:52 | sexpbot | "REAL Software: REAL Studio, Best Development Tool for Mac, Windows and Linux" |
| 08:52 | bozhidar | or Lisp of course |
| 08:52 | fogus | cemerick: ;-) |
| 08:52 | chouser | http://gist.github.com/407528 |
| 08:52 | cemerick | delivered my first paid consultant-ware with it |
| 08:52 | Hodapp | bozhidar: When I say "basics", I mean the really basic basics, like the fact that a program is a pile of instructions and has variables and that loops and branches can exist. |
| 08:53 | Hodapp | bozhidar: They man move into scoping and functions later. Like, a month or two later. |
| 08:53 | Hodapp | s/man/can/ |
| 08:53 | sexpbot | bozhidar: They can move into scoping and functions later. Like, a month or two later. |
| 08:53 | Hodapp | o_O WHAT!?!?! |
| 08:53 | ryoko-sha | chouser: thanks for that |
| 08:53 | bozhidar | Hodapp: I know what you mean, but what I meant was that Pascal was created to serve mostly educational purposes |
| 08:53 | bozhidar | and makes stuff clearer than basic does |
| 08:53 | Hodapp | but I'm rather glad it's rarely used anymore |
| 08:53 | bozhidar | at least in bulgaria all introductory programming courses are in Pascal |
| 08:54 | bozhidar | sometimes in C |
| 08:54 | Hodapp | it's mostly been replaced by Java here |
| 08:54 | bozhidar | but very very rarely |
| 08:55 | bozhidar | some mixture that was :-) |
| 08:55 | rcg | chouser: thanks :) |
| 08:55 | rsynnott | bozhidar: they were in the middle of transitioning to java |
| 08:55 | bozhidar | fogus: lucky bastard ;-) |
| 08:55 | rsynnott | if I'd been there a couple of years earlier it would have been scheme, as well |
| 08:56 | rsynnott | oh, we also did prolog as an introductory thing (though with a focus on AI-ish applications) |
| 08:56 | bozhidar | I'm not sure that Java is a good choice for a first programming language |
| 08:56 | ryoko-sha | Algol-60 & BCPL - I'm a little ancient |
| 08:56 | bozhidar | although I have to admit that I've thought introductory programming courses in the university with Java |
| 08:56 | rhickey | so, the current strategy for improving last-refer-wins is to preclude a referred var from overwriting an interned one |
| 08:57 | bozhidar | used to be perl before |
| 08:57 | rhickey | thoughts? |
| 08:57 | bozhidar | if I select some lisp dialect probably noone will come... |
| 08:58 | Bendlas | hi folks |
| 08:59 | cemerick | rhickey: reviewing my notes |
| 09:00 | chouser | so last would still win when something has been copied from contrib to core, or when you define something yourself that gets added to core. |
| 09:01 | rhickey | chouser: yes, same as now, only say, in repl, you won't be able to trash you own ns vars with a refer/use |
| 09:01 | rhickey | So, in reference to these problems: http://groups.google.com/group/clojure-dev/msg/fca78d8b00d3d6b7 |
| 09:01 | rhickey | #1 I consider a non-problem |
| 09:02 | rhickey | also, #2 seems under-motivated |
| 09:02 | rhickey | this fixes #3 |
| 09:03 | rhickey | and #4 |
| 09:03 | cemerick | rhickey: I'm surprised that #1 isn't an issue for you. |
| 09:04 | rhickey | cemerick: why? This is a Lisp and load == run all expressions |
| 09:05 | rhickey | :use load-cannons fire-cannons |
| 09:05 | rhickey | not that I'm recommending that :) |
| 09:06 | cemerick | Right, I think #1 not erroring on same-named vars being referred from 2 different ns' means that use is simply nuclear for any real code, unless you maintain the ns' being used. |
| 09:06 | cemerick | The appeal to Lisp is fine and all, but sort of ignores the practical consequences of using libraries. |
| 09:07 | rhickey | cemerick: I don't see how, there's a warning. It's not a silent switcheroo |
| 09:07 | cemerick | thus my instinct to make all ns-effecting changes fundamentally transactional, though that's certainly out of scope, and probably not going to happen |
| 09:08 | rhickey | cemerick: you wouldn't like the performance implications of that |
| 09:08 | cemerick | Warnings are noise. No one pays attention to them. |
| 09:08 | cemerick | really? That only impacts load-time, no? |
| 09:09 | rhickey | cemerick: no, how are you going to see any changes? |
| 09:09 | rhickey | calls do no lookup now, so you can't simply put a ns-map in an atom |
| 09:09 | rhickey | each var would have to be a ref |
| 09:10 | cemerick | I think you'd only have to have refs in Namespace, but yeah, I see your point. |
| 09:10 | rhickey | I considered it early on, but couldn't justify the overhead full-time on every call |
| 09:10 | rhickey | refs are not nothing |
| 09:11 | cemerick | The results of an ns decl could be unpacked after each ns-effecting action so as to avoid the costs. |
| 09:11 | rhickey | now, in a direct-linking world, that is very doable and fast |
| 09:11 | rhickey | cemerick: I don't see what you are saying re: unpacked |
| 09:13 | cemerick | rhickey: the contents of the mappings and aliases references could be lifted into refs (for all ns'es that are impacted by a load, etc), and then unpacked back into the AtomicReferences after the transaction has succeeded. |
| 09:14 | cemerick | ...but all this is sorta straying from the topic, unless drastic changes under the covers are on the table as a possibility. |
| 09:14 | rhickey | cemerick: so, you are really more interested in all-only-if-nothing-fails ns load than truly transactional visibility |
| 09:14 | cemerick | right |
| 09:15 | rhickey | cemerick: these loads and warning aren't runtime things, they are things you'll encounter during dev and work out |
| 09:15 | rhickey | I don't see the nuclear threat you do |
| 09:15 | cemerick | I think that's the common conception, and what I was referring to as the above potentially simplifiying the mental model people need to build to really understand namespaces, load, etc. |
| 09:17 | cemerick | say you have an ns that uses A and uses B. In a new version, B adds a fn that is similar to a fn found in A, and named the same. You get a warning, but ignore it because your tests pass. |
| 09:17 | cemerick | And we all know that all tests are entirely comprehensive in terms of prodding the full domain of the functions in question.... :-P |
| 09:17 | rhickey | cemerick: a big problem with 'transactional load', even if only for the all-succeed-or-no-effect, is that the vars truly need to be refs, and always, lest the loading code not see and use its own defs as it proceeds to load |
| 09:18 | cemerick | rhickey: bleh, good point. |
| 09:19 | rhickey | cemerick: so you'd be happ(y/ier) with a *treat-load-conflicts-as-errors* option? |
| 09:20 | cemerick | I doubt it. I'm hoping to see things get simpler, not add more options. :-) |
| 09:21 | rhickey | cemerick: then what is your version-to-version compatibility story "suck it up, and suffer until your lib vendors do the same"? |
| 09:21 | rhickey | or cgrand's :as-of lockdown? |
| 09:21 | cemerick | heh |
| 09:21 | cemerick | I have a lot of sympathy for those hitting conflicts arising from core adding things. |
| 09:22 | cemerick | I have much, much less sympathy for those doing blanket use all over the place. |
| 09:22 | rhickey | or core/this core/that everywhere? |
| 09:22 | cemerick | Of course, those doing that write a lot of useful libs people depend upon. |
| 09:23 | rhickey | cemerick: blanket use was never good, and still isn't. This isn't about enabling that |
| 09:25 | rhickey | I haven't seen many viable alternatives, but am still open |
| 09:29 | rhickey | no more additions to core? |
| 09:30 | cemerick | heh |
| 09:30 | cemerick | rhickey: why treat core refers the same as all other refers? |
| 09:30 | cemerick | I mean, beyond the appeal of simplicity. |
| 09:30 | rhickey | cemerick: vs what? |
| 09:37 | cemerick | Perhaps last-refer-wins should apply to core and nowhere else. |
| 09:37 | rhickey | cemerick: ah |
| 09:38 | SynrG | win 2 |
| 09:38 | cemerick | I think that's what chouser was driving at when we talked about this in the irc log I linked to in my post. |
| 09:38 | SynrG | buh |
| 09:38 | cemerick | it's certainly a complication, but there's already a special :refer-clojure form in ns |
| 09:42 | rhickey | cemerick: it is kind of special-case-y, but mirrors implicit refer of core |
| 09:42 | cemerick | rhickey: it'd actually have to be, last-refer-wins for any var name that is in core, not just for actual core vars |
| 09:42 | rhickey | ? |
| 09:43 | cemerick | e.g. ns A defines a reduce fn. ns B uses A. Presumably, that use shouldn't error out. |
| 09:44 | rhickey | I don't see the difference |
| 09:44 | cemerick | Maybe I'm overthinking it. |
| 09:45 | rhickey | you are never actually replacing something in core, only the slot in your ns |
| 09:45 | rhickey | which is re-filled with stuff from core |
| 09:45 | rhickey | pre-filled |
| 09:46 | cemerick | OK, say ns A defines a reduce fn, which takes precedence over core's reduce. |
| 09:47 | rhickey | ok |
| 09:47 | rhickey | then B uses A |
| 09:47 | cemerick | ns B then uses A. If last-refer-wins strictly applies only to core, then that use will fail, right? |
| 09:48 | rhickey | no, since the reduce in B refers to core/reduce, this rule applies. It's not different from (def reduce ...) in your own ns |
| 09:48 | rhickey | basically, you can't bump out references to core vars, by whatever means, with a warning |
| 09:48 | rhickey | corry - can bump out |
| 09:48 | rhickey | sorry, can't type |
| 09:48 | cemerick | ach, right, ok, I had things inverted |
| 09:50 | cemerick | rhickey: I think it's at least worth seeing how it plays, unless you dead-set against. |
| 09:50 | rhickey | so, I am inclined towards this restriction of last-var-wins |
| 09:50 | cemerick | Stellar. I think it's a big improvement on spec. |
| 09:50 | rhickey | would obviate the no-overwriting-interns, so no more complex |
| 09:50 | rhickey | and would still warn |
| 09:51 | cemerick | Falling back on warnings is such a red flag to me. Begs for a *strict*, which is yet another red flag. |
| 09:51 | rhickey | I wonder if it covers all migration pain cases |
| 09:52 | cemerick | That's what the beta/RC is for, I suppose. :-) |
| 09:53 | rhickey | cemerick: one problem is that te lib community is relatively responsive, so they will chase the changes. We won't find out about older/orphaned/in-house libs till later |
| 09:54 | rhickey | but this will let us ship the contrib code in place as dprecated for one release, which will prevent breakage of :use a-contrib-lib :only some-name-now-in-core |
| 09:54 | chouser | just flush them out -- find one important var from each major lib and add it to core. |
| 09:54 | cemerick | rhickey: I think that's going to be par for the course. |
| 09:54 | chouser | :-) |
| 09:55 | rhickey | chouser: http://github.com/stuarthalloway/argos |
| 09:55 | chouser | huh! |
| 09:55 | chouser | nice |
| 09:56 | cemerick | I suspect the rate of change isn't going to drop much for a long while, so stuff that languishes is going to have a rough time with each upgrade. |
| 09:56 | chouser | so I went to a meetup last night and found it energizing in roughly the way that writing a book is not. |
| 09:57 | rhickey | cemerick: need not with this mechanism, at least one release with libs in place, deprecated |
| 09:57 | esj | chouser: lol |
| 09:57 | chouser | rhickey: hm! interesting. why? |
| 09:57 | rhickey | chouser: :) |
| 09:57 | rhickey | I missed my NYC Clojure meetup thinking it was tonight :( |
| 09:57 | cemerick | rhickey: no, but ^ and who-knows-what-else will do it this time around |
| 09:58 | rhickey | chouser: why remove them? because they are ugly |
| 09:58 | chouser | fogus: seriously. gimme a break! ;-) |
| 09:58 | _na_ka_na_ | :rhickey IMO the focus should be the majority of noob/new developers (like myself) |
| 09:58 | cemerick | Makes for nicer interop, no? new my.clojure.function().invoke(foo, bar, baz) |
| 09:58 | fogus | chouser: I know what you mean though. |
| 09:58 | _na_ka_na_ | Not everyone (esp. newcomers), I figure read/care about the warnings, ref: app server warnings! |
| 09:59 | _na_ka_na_ | The lib writers / experienced coders will get around I'm sure, no matter what the final solution. |
| 09:59 | rhickey | cemerick: ouch! who's doing that? |
| 09:59 | _na_ka_na_ | Some people may blindly / unintentionally wrongly assume their code to be "1.2 complaint" when there are warnings.. |
| 09:59 | _na_ka_na_ | So I think overall *treat-load-conflicts-as-errors* would be better? |
| 09:59 | cemerick | rhickey: no one, but that would become possible given elimination of _1234, no? |
| 09:59 | Raynes | Ain't that the pot calling the kettle black! I fixed at least 4 mistakes fogus made in the tryclojure tutorial. ;) |
| 10:00 | rhickey | cemerick: I hope not. I'm not promising that fns can be created that way. Calling through vars vastly preferred |
| 10:00 | fogus | Raynes: Writing a book and spelling/grammar ability are orthogonal. :p |
| 10:00 | chouser | one thing I thought was interesting: almost everyone there claimed to have dabbled with clojure some (no questions about basic syntax), but almost none seemed confident about reference types. |
| 10:00 | cemerick | rhickey: Sure. Just trying to make my UI programming easier. :-) |
| 10:00 | rhickey | cemerick: but stack traces etc should clean up a good bit |
| 10:00 | cemerick | that's always good |
| 10:01 | cemerick | _na_ka_na_: more options are almost always bad, IMO. There should be a "right way", or at least an optimal compromise. Simpler is better. |
| 10:01 | fogus | chouser: Slides? |
| 10:01 | powr-toc | I'm using c.c.sql with-query-results, and I need to dissoc a key from the result set, obviously as it's a struct I can't... so whats my best approach? (dissoc (merge {} rs) :key) ? |
| 10:01 | rhickey | unfortunately the last step is a doozy, and I might back it out |
| 10:01 | chouser | fogus: http://github.com/Chouser/clojure-talk-conc |
| 10:02 | _na_ka_na_ | cemerick: thats my point *treat-load-conflicts-as-errors* is simpler for the majority? |
| 10:03 | cemerick | _na_ka_na_: the majority won't even know about the option to begin with :-) |
| 10:04 | _na_ka_na_ | cemerick: Of course I mean default *treat-load-conflicts-as-errors* to true :) |
| 10:04 | cemerick | _na_ka_na_: oh -- well, that was the default before :-) The aim is to cause a minimum of upgrade pain due to additions to core. |
| 10:05 | rhickey | the remaining hurdle is the redefs in core itself, related to e.g. bootstrapping w/o destructuring, then adding it etc |
| 10:05 | rhickey | I wonder how often other libs do similar things |
| 10:06 | _na_ka_na_ | cemerick: but the point is correctness might go for a spin, unintentionally |
| 10:17 | _na_ka_na_ | creating much up-gradation pain is preferable to shaky semantics? |
| 10:20 | cemerick | I think the hope is to satisfy both criteria. |
| 10:23 | _na_ka_na_ | Any idea about the error - "Can't find matching method: foo, leave off hints for auto match." ? |
| 10:24 | _na_ka_na_ | Proto: (defprotocol P (foo [this f])), Type: (deftype PImpl [] P (foo [this ^String f] (FileWriter. f))) |
| 10:24 | jweiss | cemerick: i notice you contribute to the clutch couchdb lib. i'm having trouble getting the view server to work, currently it just quits after couchdb starts it. i am not quite sure which version of clojure it's expecting me to be using |
| 10:25 | cemerick | jweiss: the master branch is 1.2 |
| 10:25 | jweiss | there's a 1.1 compatible branch, which oddly, when i run lein deps, installs clojure-1.2 snapshot jars |
| 10:25 | cemerick | hrm |
| 10:25 | jweiss | i can use 1.2, that's no problem |
| 10:26 | cemerick | jweiss: we're merging the two branches today-ish, and dropping 1.1. entirely. |
| 10:26 | cemerick | That's just FYI. |
| 10:26 | jweiss | cemerick: meaning that it won't work with 1.1? or it will work with either |
| 10:27 | cemerick | Meaning that it will probably not work with 1.1. I don't use 1.1 at all, and I don't think Tunde does either, so maintaining the 1.1 branch is problematic for us. |
| 10:28 | jweiss | cemerick: i see. isn't it unusual not to support the latest release of the language? :) |
| 10:28 | cemerick | Depending on my level of motivation, I may cut a final 1.1-compatible branch that will get no new features. |
| 10:28 | cemerick | jweiss: heh, perhaps. Clutch is decidedly scratch-my-itch territory though, and I haven't used anything on a 1.1 track since Novemberish I think. |
| 10:29 | jweiss | i see, well, if clojure-1.2 works for people here, it should work for my newb self |
| 10:29 | cemerick | Perhaps I'll stand up a public hudson. That'll make supporting different versions of these libs a lot easier. |
| 10:29 | cemerick | Understand, I'm not *opposed* to having a 1.1-compatible clutch, it's just a workload issue. |
| 10:30 | jweiss | cemerick: that's fine, i'm not constrained to a particular clojure version |
| 10:31 | jweiss | although i haven't actually tried with 1.2 yet, i hope compojure works with it, i assume so |
| 10:32 | cemerick | I think HEAD is. There are branches here and there of 1.2-compatible 0.3.x-era compojure as well. |
| 10:54 | Raynes | fogus: <3 for the encouragement. |
| 10:55 | Raynes | Extremely helpful for a young, terrified padawan such as myself. <3 |
| 10:58 | texodus | There's no way to attach metadata to Classes, I assume? |
| 10:59 | Chousuke | nope. |
| 11:00 | texodus | so documenting deftypes and defrecords is just plain out ... |
| 11:01 | Chousuke | texodus: hmm |
| 11:06 | eintr | chouser: modded your repl-init. added some flair to exceptions as well, and tuned colors for 256 color terms: http://gist.github.com/407622 |
| 11:06 | chouser | eintr: whew! |
| 11:07 | remleduff | Why do you do clojure.main -e "(my-repl)" rather than just calling (my-repl) at the end of repl-init? |
| 11:07 | chouser | hm. I dunno. |
| 11:08 | eintr | :) |
| 11:09 | sanityinc | I posted on the list about a sticky problem I'm having with protocols. Am I doing something obviously dumb? - http://groups.google.com/group/clojure/browse_thread/thread/e2e36ab8b7630e38 |
| 11:10 | rsenior | sanityinc: do you have AOT compiling enabled? |
| 11:10 | sanityinc | Only if that's the default. |
| 11:10 | jweiss | cemerick: i notice you also work on an ssh lib for clojure, that "with-ssh-agent" macro, is that using pre-decrypted private keys a la unix ssh-add? |
| 11:11 | jweiss | i have been looking for a way to do that with java (not necessarily with a unix ssh-agent, which i doubt is possible) but with any agent |
| 11:11 | cemerick | jweiss: it also supports passphrase-protected keys :-) |
| 11:11 | jweiss | cemerick: did you implement that or is it part of jsch |
| 11:12 | cemerick | that's all jsch. It definitely works, but is a miserable API. |
| 11:12 | rsenior | I had that issue when I had old class files sitting out there that were taking precedence over my newly evaluated protocol definition |
| 11:12 | cemerick | jweiss: hugod is actually your point man for clj-ssh stuff |
| 11:12 | jweiss | cemerick: so what ssh agent does it use? not compatible with linux's i assume |
| 11:12 | cemerick | no -- I'm pretty sure it's an in-memory impl provided by jsch |
| 11:12 | sanityinc | rsenior: I can reproduce the problem with a completely empty project |
| 11:13 | remleduff | sanityinc: I'm not sure it would make a difference, but does it change if you do (require 'protoproblem.proto :reload-all) instead of "load"? |
| 11:13 | jweiss | cemerick: oh, that's too bad. i was looking for a way to have my code not have to prompt my users (they could add their key via some other means and have it stay there even if the jvm goes away and comes back later) |
| 11:14 | sanityinc | remleduff: Nope, I tried that too |
| 11:14 | hugod | jweiss: pallet adds some code to query the osx keychain - I need to move that into clj-ssh |
| 11:14 | cemerick | jweiss: pallet has OS X keychain support, which will probably make its way into clj-ssh eventually. A linux-flavored impl is conceptually possible, but I don't know what that would look like. |
| 11:14 | hugod | snap |
| 11:15 | jweiss | cemerick: to use unix ssh-agent would require unix sockets which java doesn'tdo |
| 11:16 | jweiss | which is really irritating that basically java and ssh are incompatible |
| 11:16 | sanityinc | It's quite a surprising misbehaviour, and having to quit the JVM to fix it sucks. |
| 11:17 | jweiss | currently there is no way in java for people to use their "real" ssh key and not get prompted to unlock it every time they run a jvm |
| 11:17 | jweiss | we are currently just using a throwaway key with a password that we don't care if it sits in a plaintext file |
| 11:17 | jweiss | not secure, of course |
| 11:27 | sanityinc | Needless to say, since it seems like a class loading / caching issue, it's pretty much impossible to see what's going wrong. |
| 11:39 | hoeck | sanityinc: confirmed here, but after defining ArraySteps without a protocol (deftype ArraySteps []), and then redefinging the protcol-implementing ArraySteps type, it works :/ |
| 11:41 | sanityinc | hoeck: yikes. I've kinda assumed it's something to do with caching of protocol methods / classes. I'm going to try reify instead of deftype to see if the same thing happens. |
| 11:44 | hoeck | redefining the same ArraySteps over and over again doesn't change the Class |
| 11:45 | sanityinc | hoeck: Ah, now, using reify solves the problem. So it looks like deftype is broken, or at least doing something unexpected. |
| 11:46 | hoeck | see http://gist.github.com/407710 |
| 11:46 | sanityinc | hoeck: so (defn arraysteps [a] (reify proto/Steps ...)) is fine |
| 11:46 | hoeck | seems like deftype does some weird kind of caching |
| 11:48 | sanityinc | The macroexpansion suggests that, yes. But I'm not smart enough to see exactly what's going wrong. |
| 11:49 | hoeck | when you load your file the third time, the deftype is evaluated but nothing has changed in the deftype implementation, so the "redefined Steps protocol is not implemented |
| 11:50 | hoeck | maybe there is/was a reason to not create a new class for identical deftypes |
| 11:52 | sanityinc | I can see how that would be desirable, but changes in the underlying protocols should also be taken into account, I guess. |
| 11:52 | hoeck | right |
| 11:53 | sanityinc | So... does this warrant an Assembla ticket? |
| 11:53 | jweiss | cemerick: does clutch work with couchdb 0.10.2? |
| 11:54 | cemerick | jweiss: I'd hope. No? |
| 11:54 | hoeck | sanityinc: I guess you have to ask rhickey about this :) |
| 11:54 | jweiss | cemerick: i am still having the same problem with the view server after updating to clojure 1.2 |
| 11:54 | cemerick | what's the issue? |
| 11:55 | jweiss | it is exiting with return code 1 as soon as i try to load a view in futon |
| 11:55 | jweiss | i didn't check yet to see if it's the same error, but last time it was a JSON error |
| 11:55 | cemerick | hrm |
| 11:55 | jweiss | let me check the couchdb log |
| 11:58 | jweiss | cemerick: ah, trying to start the view server with the same cmd from the local.ini on the cmd line gives: |
| 11:58 | rhickey | sanityinc: yes, please create a ticket for this and set to milestone 1.2 |
| 11:58 | jweiss | Caused by: java.io.FileNotFoundException: Could not locate clojure/contrib/json/read__init.class or clojure/contrib/json/read.clj on classpath: |
| 11:58 | sanityinc | rhickey: Thanks - will do. |
| 11:58 | cemerick | jweiss: ah, well, that's a lot simpler of an issue :-) |
| 11:59 | jweiss | oh i fat fingered the classpath |
| 12:04 | jweiss | cemerick: looks like the same problem still- it's looking for contrib/json/read.clj but that's not in contrib-1.2 |
| 12:04 | jweiss | i am using clutch 0.2 from leiningen |
| 12:05 | jweiss | is there a newer jar i can point to in project.clj |
| 12:06 | cemerick | jweiss: if ashafa could talk, he'd say the jar in clojars is 1.1-only |
| 12:06 | cemerick | :-) |
| 12:07 | cemerick | I don't think any newer deployments have been done of it. |
| 12:12 | jweiss | cemerick: the view server and the clutch lib don't need to be the same version do they? |
| 12:12 | cemerick | hrm, probably not |
| 12:13 | cemerick | could get confusing though |
| 12:14 | cemerick | jweiss: ashafa says "if he uses clojure 1.1 in project.clj, he could just run lein superjar" |
| 12:15 | cemerick | (I guess he doesn't have voice here or something) |
| 12:15 | mmarczyk | he should register his nick with NickServ, then |
| 12:16 | cemerick | is that actually required to get voice? I haven't been anon in a long time, but I don't remember it being required. |
| 12:17 | mmarczyk | well, I've had connection problems a couple of times recently, reconnected with a temp nick (mmarczyk`) and couldn't talk here |
| 12:17 | mmarczyk | then reconnected in the usual way and all was fine... |
| 12:18 | mmarczyk | I guess that's not enough to draw the conclusion that registering is required, but it's worth a shot |
| 12:25 | esj | when using :gen-class and :extends on a java class I'm not getting the protected methods of that class. Is this expected ? |
| 12:29 | jfields | how do you filter nil objects? (filter x? coll) what's x? |
| 12:29 | remleduff | identity |
| 12:29 | chouser | esj: you need :exposes-methods |
| 12:30 | esj | chouser: I have em. |
| 12:30 | remleduff | Though identity will filter "false" too |
| 12:30 | Raynes | $(remove identity [1 2 3 nil 4 5 6 nil 7 nil 8]) |
| 12:30 | sexpbot | result: clojure.lang.LazySeq@745f |
| 12:31 | Raynes | $(remove nil? [1 2 3 nil 4 5 6 nil 7 nil 8]) |
| 12:31 | Raynes | Eh. |
| 12:31 | sexpbot | result: clojure.lang.LazySeq@6b4b5785 |
| 12:31 | esj | jfields: (complement nil?) might work too |
| 12:31 | jfields | remove does what I want. thanks |
| 12:32 | esj | chouser: using show from repl-utils lists all the superclass methods, even w/o :exposes-methods. But even with an explicit :exposes-methods I can't get the protected methods to join the party. Sulky. |
| 12:36 | remleduff | Hmm, gen-class documentation claims that it exposes all "non-private" superclass methods, which I'd think would include protected methods |
| 12:37 | esj | indeed.... let me mock up a toy example and get back to you all |
| 12:42 | remleduff | esj: Are you including the prefix? |
| 12:43 | esj | in the call ? no. just doing (.methodSure this arg) |
| 12:43 | esj | s/Sure/Super/ |
| 12:43 | sexpbot | in the call ? no. just doing (.methodSuper this arg) |
| 12:46 | remleduff | hm |
| 12:46 | sanityinc | Re. the protocol/deftype issue discussed earlier - looks like I can't file an Assembla ticket after all, as a non team member. Can anyone file it on my behalf pls? Steps to reproduce: http://groups.google.com/group/clojure/browse_thread/thread/e2e36ab8b7630e38 . Problem not present with reify; just a deftype quirk. |
| 12:48 | remleduff | You should be able to make a "support" ticket as a watcher |
| 12:48 | sanityinc | Aha, gotcha. Thanks. |
| 12:56 | arohner | can someone test https://www.assembla.com/spaces/clojure/tickets/285-make-it-easier-to-discover-the-source-of-compiler-exceptions-when-two-files-have-the-same-name-in---#last_comment so we can get it in? |
| 12:56 | sexpbot | "#285 - Make it easier to discover the source of compiler exceptions when two files have the same name in different directories (Test) | Clojure | Assembla" |
| 12:56 | sanityinc | Okay, support ticket filed, but perhaps a team member can move it to the 1.2 milestone as requested by rhickey? - https://www.assembla.com/spaces/clojure/support/tickets/353 |
| 13:00 | remleduff | Ha, I can't seem to do that for a support ticket |
| 13:03 | remleduff | There we go |
| 13:11 | esj | rats - in the toy example protected methods do appear |
| 13:11 | esj | more homework for me |
| 13:15 | esj | AHA ! its a protected FINAL method that won't come around. Should have read the FULL javadoc, not the summary line which didn't list the final. |
| 13:18 | esj | but that does not explain why :exposes-methods won't let me see it |
| 13:19 | sanityinc | remleduff: thanks |
| 13:20 | remleduff | Wow, generate-class is a huge function |
| 13:20 | esj | remleduff: oh yeha |
| 13:21 | esj | remleduff: i'm guessing that :exposes-methods creates a new method that in fact overrides the superclass with a thin wrapper |
| 13:21 | remleduff | But can't do that for final methods :\ |
| 13:22 | esj | indeed |
| 13:22 | esj | but now how do I get to the superclass method, which i don't want to override |
| 13:27 | remleduff | Can you paste your example code for me? I'm trying to follow along ;) |
| 13:27 | esj | sure: http://gist.github.com/407826 |
| 13:27 | esj | sorry... 1 sec |
| 13:28 | esj | http://gist.github.com/407831 |
| 13:29 | esj | I'm going to ask in the google group, I'm stumped |
| 13:30 | jweiss | can the stable release of leiningen be used to build projects that depend on clojure1.2? mine is failing all over the place |
| 13:30 | jweiss | http://fpaste.org/zYiL/ |
| 13:31 | powr-toc | Does anyone know a way to do the following? (apply (partial struct-map foo) { :foo :bar}) |
| 13:31 | powr-toc | I'd like to convert a map into a struct-map |
| 13:32 | chouser | wow, I just found my first use of :>> in condp |
| 13:32 | chouser | that is one obscure feature. |
| 13:35 | jweiss | cemerick: any idea why i get the error in that paste above trying to run lein install on clutch master branch? |
| 13:37 | remleduff | esj: Do you also get the message "java.lang.VerifyError: class foo.Foo overrides final method baz" that I'm seeing? |
| 13:37 | esj | that's the one |
| 13:38 | powr-toc | How can I do this? (struct-map foo {:foo :bar }) I need to convert a map into a struct map, as I want my keys to be in the order specified by struct-map |
| 13:39 | powr-toc | (well specified by the defstruct) |
| 13:39 | cemerick | jweiss: none off the top of my head -- I use maven though |
| 13:39 | cemerick | bbl |
| 13:39 | savanni | Hey, brief question today. What is the naming convention for functions that have side effects? In this case, I am writing a function that updates a database and then returns data based on that update. |
| 13:40 | esj | savanni: often they have a ! at the end of the name |
| 13:41 | savanni | k, I thought about that. The coding standard I am reading says to use ! for an unsafe STM transaction, but I don't know what it means to be unsafe in STM. |
| 13:41 | savanni | And, this database update is not happening in STM. |
| 13:42 | chouser | savanni: is it safe to do the same call a couple extra times, or does each call make more or different observable changes to the database? |
| 13:42 | savanni | Each call makes observable changes. |
| 13:42 | chouser | ok, that would not be safe to do in a transaction |
| 13:43 | chouser | so a ! suffix is appropriate |
| 13:43 | chouser | you can even use io! in the body of the function itself so that attempts to use it in a transaction will throw an exception instead |
| 13:44 | savanni | Wait, why is that unsafe? Is it because the database cannot be rolled back in the case of a failure? |
| 13:45 | Hodapp | yikes, the assholishness of ##c++ is astounding... |
| 13:50 | ataggart | savanni: it's because the STM transaction may be retried |
| 13:51 | savanni | Ah, I had not tohught of that. |
| 13:51 | savanni | Where is some good documentation on the subtlies of STM? Something that if I had read and thought about I would have realized that? |
| 13:52 | chouser | savanni: http://clojure.org/refs |
| 13:52 | chouser | "I/O and other activities with side-effects should be avoided in transactions, since transactions will be retried. The io! macro can be used to prevent the use of an impure function in a transaction." |
| 13:52 | savanni | Okay, awesome. Thank you! |
| 13:55 | esj | chouser: remleduff just pointed me to a post of yours http://osdir.com/ml/clojure/2009-09/msg00452.html which is exactly the problem I've just stubbed my toe on. Did you resolved it ? |
| 13:55 | sexpbot | "Re: Accessing a protected final method of the superclass - msg#00452 - clojure" |
| 13:57 | chouser | I don't recall that specific issue, and don't see any follow-up on the ggroup. So ... I guess not. |
| 13:57 | chouser | gah! expired paste!? |
| 13:57 | chouser | that really really sucks |
| 13:58 | chouser | makes my reply there alomst completely useless |
| 13:58 | esj | chouser: rats ! |
| 13:59 | remleduff | generate-class still calls non-private-methods which filters out final methods as well, so I don't think it's been fixed |
| 14:04 | jfields | is there a function that takes [1 -1 2 -2] and returns [[-1 -2] [1 2]]? |
| 14:07 | esj | so, in this case, assuming I can't use gen-class to make .class files, what other options do I have ? |
| 14:10 | esj | that many huh.... i feared so :) |
| 14:15 | chouser | esj: .java :-( |
| 14:17 | Borkdude | java? :( |
| 14:20 | Borkdude | Is there a way to find e.g. where partition-all is, without requiring its namespace (because I don't know it), with find-doc, or similar? |
| 14:21 | fogus | Borkdude: Google always works for me. ;-) |
| 14:22 | remleduff | esj: (def Hello-Forwarder (proxy [com.example.Hello] [] (yo [] (proxy-super yo)))) |
| 14:22 | remleduff | then (.yo Hello-Forwarder) |
| 14:24 | remleduff | But, that may not work depending on what you need to do in gen-class |
| 14:25 | esj | it is a new and different object |
| 14:26 | Borkdude | fogus: Google, yes, brilliant ;) |
| 14:27 | Borkdude | so, google is a function in what namespace exactly? ;) |
| 14:31 | Hodapp | Borkdude: ALL NAMESPACES! |
| 14:35 | mmarczyk | Borkdude: you can always use clojure.contrib.find-namespaces to require every namespace you've got on the classpath |
| 14:35 | mmarczyk | and then use find-doc |
| 14:43 | Lajla | Hodapp, how do namespaces work in Clojure? |
| 14:46 | Borkdude | mmarczyk: I did (find-namespaces-on-classpath) |
| 14:46 | Borkdude | mmarczyk: but it doesn't find e.g. mexpand-all |
| 14:46 | Borkdude | it=find-doc |
| 14:50 | Borkdude | mmarczyk: should I use map to require all of the namespaces returned by find-namespaces-on-classpath? |
| 14:56 | Borkdude | hmm, is clojure.walk/macroexpand-all a replacement for macro-utils/mexpand-all? |
| 15:23 | Borkdude | http://twitgoo.com/wjpd5 |
| 15:23 | sexpbot | "Hanging out with #deadline #clojure #compojure #appengine at #io2010" |
| 15:33 | chouser | what's going on here? http://gist.github.com/407980 |
| 15:33 | chouser | why doesn't (gettag x) return String ? |
| 15:36 | chouser | rhickey: any hints? |
| 15:40 | ninjudd | chouser: what does &env mean? i haven't seen that syntax |
| 15:41 | Borkdude | chouser: same question, it only works in 1.2 I just noticed |
| 15:44 | chouser | it's new macro magic |
| 15:45 | ninjudd | chouser: what does it mean? |
| 15:47 | chouser | if gives you the lexical scope at the point where the macro is expanding |
| 15:47 | chouser | it gives |
| 15:47 | Borkdude | hmm |
| 15:47 | chouser | which I'm abusing to do things that would otherwise require a code walker |
| 15:48 | remleduff | Does a &prefix have some special meaning? |
| 15:48 | chouser | not generally. macros now have &env and &form |
| 15:50 | Borkdude | chouser: is (find &env sym) to equivalent to [sym (eval sym)]? |
| 15:50 | mmarczyk | Borkdude: yeah, you'll have to use require on the namespaces |
| 15:50 | mmarczyk | Borkdude: find-namespaces-on-classpath only finds out which namespaces are available |
| 15:51 | Borkdude | mmarczyk: ic |
| 15:51 | Borkdude | mmarczyk: I used (map require (find-namespaces...)) |
| 15:51 | Borkdude | then I got an exception along the way, but it used most of them.... |
| 15:51 | mmarczyk | wrap it in a dorun if it's in a source file |
| 15:51 | mmarczyk | an exception? interesting |
| 15:52 | mmarczyk | anyway, wait a sec, I think I have a link for you |
| 15:52 | rhickey | chouser: did you intend to use the same local name twice? |
| 15:52 | mmarczyk | http://learnclojure.blogspot.com/2010/02/requiring-all-possible-namespaces.html |
| 15:52 | sexpbot | "Learning Clojure: Requiring all possible namespaces" |
| 15:53 | chouser | yes |
| 15:53 | chouser | this is generated code, and I'm trying to attach meta data on the inner one and pick it up in the macro |
| 15:54 | chouser | the compiler seems to do the right thing for :tag, but I can't seem to get at it using &env -- it finds the first local instead |
| 15:56 | chouser | Borkdude: no, not equivalent. |
| 15:57 | chouser | Borkdude: the values in the &env map are CompilerExpr objects (couldn't be runtime values as this is compile time) |
| 15:57 | chouser | Borkdude: the key returned by find should have the metadata attached to that local in the source, which may be different from the metadata on the sym I'm using to look it up. |
| 15:58 | chouser | which is the whole point. I know the name of the sym, but I want to know the metadata on the local of the same name. |
| 15:59 | chouser | I may be able to work around this, but it's bugging me. |
| 16:06 | rhickey | chouser: (map meta (keys (assoc {'^String x 11} '^Integer x 42))) |
| 16:06 | rhickey | ,(map meta (keys (assoc {'^String x 11} '^Integer x 42))) |
| 16:06 | clojurebot | ({:tag String}) |
| 16:07 | chouser | ah. so the compiler must be using something other than &env to figure out the :tag. |
| 16:07 | rhickey | chouser: the compiler is using the local binding info in the value, no longer the symbol after parsing |
| 16:08 | chouser | ah, right. hmph. |
| 16:09 | rhickey | (defmacro gettag [sym] (.tag (val (find &env sym)))) |
| 16:10 | rhickey | chouser: (defmacro gettag [sym] (.tag (get &env sym))) |
| 16:10 | tcrayford | chouser: I gave up on getting locally bound vars using the compiler, was too icky when the form was using def. Cheers for your help though |
| 16:16 | chouser | tcrayford: ok |
| 16:18 | Borkdude | mmarczyk: ah tnx, he catches Exceptions and wraps it in a doall, I see |
| 16:18 | chouser | rhickey: ok, I can get use .sym to get the metadata I really want. |
| 16:18 | chouser | not sure I want to do that though... hrm. |
| 16:19 | Borkdude | I'm wondering if at this time it's better to post examples of 1.1 or 1.2 (namespace-wise) on my Twitter account |
| 16:23 | chouser | oh, actually I *have* to do that, or when someone writing the code shadows something without my knowledge, I'll pick up the wrong metadata. drat. |
| 16:32 | riddochc | (str "Good " (timezone-appropriate-greeting recipient) ", everyone.") |
| 16:37 | Borkdude | riddochc: (printf "%du%d" 2 2) |
| 16:39 | The-Kenny | I read about a "irc standard greeting time" some time ago |
| 16:40 | The-Kenny | "If someone enters the channel, it's morning. Regardless of the actual local time. If someone leaves the channel, it's evening." |
| 16:42 | The-Kenny | http://www.total-knowledge.com/~ilya/mips/ugt.html "Universal Greeting Time" |
| 16:42 | sexpbot | "UGT" |
| 16:46 | riddochc | The-Kenny: That's rather amusing. |
| 16:47 | maxhodak | is there anything already for doing rule-based systems in clojure (i.e., logic programming)? |
| 16:48 | chouser | datalog? |
| 16:48 | tcrayford | maxhodak: I only know about http://github.com/jduey/mini-kanren |
| 16:49 | tcrayford | maxhodak: and the accomanying article: http://intensivesystems.net/tutorials/logic_prog.html |
| 16:49 | sexpbot | "Logic Programming for the Social Web" |
| 16:49 | remleduff | cascalog as well http://nathanmarz.com/blog/introducing-cascalog/ |
| 16:49 | sexpbot | "Introducing Cascalog: a Clojure-based query language for Hadoop — thoughts from the red planet" |
| 16:49 | riddochc | maxhodak: I'd heard of something not too long ago on clojure planet. |
| 16:49 | tcrayford | his monad articles are damn cool as well |
| 16:51 | maxhodak | riddochc: tcrayford: thanks guys |
| 16:51 | maxhodak | ill check those out |
| 18:57 | riddochc | Argh. I can't remember the name of the function I'm looking for... |
| 18:58 | riddochc | I know there's more than one way to do this, too... I've got a function that produces key/value pairs, and I want to call it with something that collects them all together into a map, preferably without having to use 'apply hash-map', so it's lazy... |
| 18:58 | Lajla | riddochc, I think it's the factorial. |
| 18:58 | Lajla | Ohh, not the factorial. |
| 18:58 | tcrayford | riddochc: zipmap? |
| 18:59 | tcrayford | ,(doc zipmap) |
| 18:59 | clojurebot | "([keys vals]); Returns a map with the keys mapped to the corresponding vals." |
| 18:59 | tcrayford | don't think its lazy though |
| 18:59 | riddochc | tcrayford: That seems more appropriate for two separate seqs, one of keys, one of vals, right? |
| 18:59 | tcrayford | confirm |
| 18:59 | tcrayford | you can do that by breaking out your original seq into two things |
| 19:00 | tcrayford | (and can almost definitely do that lazily, but I can't remember the name of the function that does it) |
| 19:01 | riddochc | Hm. Well, maybe I should step back a bit... I'm basically starting with something like (map #(let [[[all key val]] (re-pattern #"..." %)] {key val}) source) |
| 19:02 | riddochc | There's probably a more idiomatic way to use the results of re-pattern, collecting parts of my matches as key/value pairs. I keep thinking assoc... |
| 19:03 | riddochc | Hm. I could loop/recur over the source, and use assoc in the recursive step... |
| 19:03 | tcrayford | then wrap it with lazy-seq |
| 19:03 | mmarczyk | how would you go about constructing a map lazily? |
| 19:03 | mmarczyk | I mean, in principle |
| 19:03 | mmarczyk | what do you do if you attempt a lookup |
| 19:04 | riddochc | tcrayford: Yeah, that would work. I could swear I saw something really similar in either clojure or -contrib, though... |
| 19:05 | tcrayford | does it need to be lazy? |
| 19:05 | tcrayford | how big is "source" |
| 19:06 | riddochc | tcrayford: Not huge. Think email headers, for scale. (It's a git commit. So, rather short.) |
| 19:07 | riddochc | It doesn't really need to be lazy. |
| 19:07 | tcrayford | well just use apply then? |
| 19:07 | tcrayford | lazy maps don't really make much sense, as mmarczyk pointed out above |
| 19:07 | riddochc | Yeah, yeah, I just keep thinking, "Functional! Generic! Perfectionism!" and such. *sigh* |
| 19:07 | tcrayford | alternatively, you can use reduce |
| 19:08 | riddochc | Reduce! Duh. |
| 19:08 | riddochc | Reduce makes a *lot* of sense for this. |
| 19:08 | tcrayford | see http://www.tcrayford.net/2010/05/14/A-Tutorial-On-Reduce.html |
| 19:08 | sexpbot | "tcrayford" |
| 19:08 | mmarczyk | you could just use (comp reduce merge) |
| 19:08 | mmarczyk | meaning (reduce merge your-seq-of-single-binding-maps) |
| 19:09 | tcrayford | now we get point-free worked in as well |
| 19:09 | tcrayford | joy |
| 19:09 | mmarczyk | or (reduce into {} your-seq-of-key-value-pairs) |
| 19:09 | mmarczyk | :-) |
| 19:09 | riddochc | Yeah, I've used it before for other things, I think it didn't occur to me here because I'm still not used to thinking of my map as a reduceable. :) |
| 19:09 | tcrayford | reduce is so damn powerful |
| 19:09 | riddochc | mmarczyk: Awesome. |
| 19:09 | tcrayford | its crazy |
| 19:10 | mmarczyk | for breaking a seq into a seq of elements at odd positions and a seq of elements at even positions, (let [s input-seq p (partition 2 s) o (map first p) e (map second p)] [o e]) |
| 19:10 | mmarczyk | ;-) |
| 19:10 | tcrayford | is there a complement to create-ns? |
| 19:10 | tcrayford | that deletes namespaces? |
| 19:10 | mmarczyk | tcrayford: remove-ns, I think |
| 19:10 | riddochc | tcrayford: Quite right, it is. Map and reduce, man. Not to be confused with google's mapreduce. Feh. |
| 19:10 | mmarczyk | (doc remove-ns) |
| 19:10 | clojurebot | "([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace." |
| 19:10 | tcrayford | gotcha |
| 19:10 | tcrayford | cheers |
| 19:12 | riddochc | mmarczyk: Thanks for the (reduce into {} ...) - that's beautiful, I'm using it. |
| 19:12 | tcrayford | I think I prefer the comp one myself, but aye |
| 19:13 | riddochc | Hmm. I don't have a seq of single binding maps, but I could arrange for that... |
| 19:14 | riddochc | Wait, no, I suppose that's exactly what I have. |
| 19:14 | mmarczyk | tcrayford: Clojure refactoring -> cool :-) |
| 19:14 | mmarczyk | riddochc: happy to hear that :-) |
| 19:15 | tcrayford | mocking out filesystems and such looks to be a right pain :/ |
| 19:15 | mmarczyk | riddochc: if you had doubleton vectors (representing map entries), you could use (reduce conj {} seq-of-entries) |
| 19:17 | mmarczyk | tcrayford: I'd expect it to be :-( |
| 19:17 | tcrayford | if I want to change to a new namespace, and refer clojure.core in it (which it isn't using in-ns), how do I do that? |
| 19:18 | mmarczyk | there's a function called refer-clojure |
| 19:18 | mmarczyk | or is it a macro... hm |
| 19:18 | mmarczyk | (doc refer-clojure) |
| 19:18 | clojurebot | "([& filters]); Same as (refer 'clojure.core <filters>)" |
| 19:18 | mmarczyk | whatever. anyway, do (clojure.core/refer-clojure) |
| 19:18 | tcrayford | aha |
| 19:18 | tcrayford | cheers |
| 19:19 | riddochc | Well, re-seq gives a vector of results that I'm unpacking with a let... |
| 19:22 | riddochc | Hm. |
| 19:22 | mmarczyk | hm, maybe (reduce conj {} (map (partial subvec 1) (re-seq ...))) then? |
| 19:23 | tcrayford | if you're getting into mutliple nested seq functions, I'd reccomend using ->> |
| 19:23 | mmarczyk | yeah, good point |
| 19:23 | tcrayford | or just breaking them up into smaller ones |
| 19:23 | tcrayford | (or both) |
| 19:23 | mmarczyk | (->> (re-seq ...) (map (partial subvec 1)) (reduce conj {})) |
| 19:24 | riddochc | I haven't actually used ->> much yet. |
| 19:24 | tcrayford | its pretty useful for readability |
| 19:24 | mmarczyk | tcrayford: best not touch it if it doesn't break on its own ;-) |
| 19:25 | tcrayford | mmarczyk: that code is pretty much finished with for now anyway |
| 19:25 | tcrayford | besides, refactoring-mode can automatically thread stuff with ->> </blowing his own horn> |
| 19:25 | mmarczyk | cool! :-) |
| 19:26 | riddochc | There's certainly more than one way to do this. I'm not sure what I should do if the regex *doesn't* match... |
| 19:27 | mmarczyk | you could consider sth like 1.2's keep for throwing non-matches away |
| 19:28 | riddochc | That looks rather appropriate. re-seq gives a nil on non-matches... |
| 19:28 | tcrayford | heh |
| 19:28 | tcrayford | ,(filter identity [nil nil 1]) |
| 19:28 | clojurebot | (1) |
| 19:29 | riddochc | Cool. I'm using 1.2 anyway... |
| 19:29 | tcrayford | using keywords as arguments to filter is nice if you want only maps with certain keys |
| 19:29 | mmarczyk | though that would be most natural with (keep (partial re-find #"...") ...) |
| 19:30 | mmarczyk | for re-seq, good old filter identity is probably just as good, yeah |
| 19:30 | tcrayford | how do I add metadata to a function whilst I'm defining it? |
| 19:30 | tcrayford | is it (defn foo {:bar 1} [a] a) ? |
| 19:30 | mmarczyk | you could do that |
| 19:31 | tcrayford | I get an error here |
| 19:31 | mmarczyk | or add reader metadata to the symbol |
| 19:31 | tcrayford | how? |
| 19:31 | clojurebot | with style and grace |
| 19:31 | tcrayford | assuming 1.2 |
| 19:31 | mmarczyk | oh? I think you shouldn't get an error for that |
| 19:31 | mmarczyk | see if it works if you include a docstring before the map |
| 19:31 | tcrayford | still errors |
| 19:31 | tcrayford | (defn foo "" {:line 3 :file} "foo.clj" [a] a) |
| 19:32 | tcrayford | oh |
| 19:32 | tcrayford | fail |
| 19:32 | tcrayford | yeah the map was messed up |
| 19:32 | tcrayford | my installation of paredit in my repl is somewhat borked |
| 19:32 | mmarczyk | right |
| 19:32 | mmarczyk | as for the reader metadata solution |
| 19:33 | mmarczyk | (defn ^{...} foo ...) |
| 19:33 | mmarczyk | (or the old #^) |
| 19:33 | tcrayford | I should probably use old-style, as not all projects are using 1.2 atm |
| 19:33 | mmarczyk | oh, but the new style is so *pretty*! |
| 19:34 | mmarczyk | *khem* |
| 19:34 | mmarczyk | I guess you're right |
| 19:35 | mmarczyk | as soon as you use a protocol, though... :-) |
| 19:35 | tcrayford | now I have to decide: does my refactoring tool make the changes on disk, or do I send the changes to emacs so it can make the changes? |
| 19:36 | tcrayford | if my tool makes the changes then it has to handle undo, but I can test it better |
| 19:37 | mmarczyk | or make it configurable |
| 19:37 | mmarczyk | so it's somewhat usable with other editors too |
| 19:37 | mmarczyk | (hopefully) |
| 19:37 | tcrayford | well either route is pretty configurable |
| 19:38 | tcrayford | the emacs way of doing it would just send out s-expressions, which the other editors can parse and use |
| 19:38 | mmarczyk | personally I'd prefer changes to happen in the Emacs buffer |
| 19:38 | tcrayford | mmarczyk: the changes *will* happen in the buffer, I'll just call revert-buffer after making the change |
| 19:38 | mmarczyk | well that's not quite what I meant :-) |
| 19:39 | tcrayford | I can't change multiple files from one buffer |
| 19:39 | mmarczyk | I meant, "in the buffer first, w/o touching the file" |
| 19:39 | mmarczyk | if you need to create a new file, sure, go ahead |
| 19:39 | tcrayford | that's what happens currently, but you have to touch the file to change across multiple namespaces |
| 19:39 | tcrayford | *touch the files |
| 19:39 | mmarczyk | if you need to change a different, but already existing file, have find it in Emacs first |
| 19:39 | tcrayford | have the user, or the emacs mode? |
| 19:40 | mmarczyk | ouch... "have Emacs find it first" |
| 19:40 | mmarczyk | somehow ;-) |
| 19:40 | tcrayford | oh I can do that, its not hard |
| 19:40 | tcrayford | the other downside of that method is that I have to learn about stubbing the filesystem in emacs :( |
| 19:40 | tcrayford | oh |
| 19:40 | tcrayford | actually not |
| 19:40 | mmarczyk | that downside is also an upside ;-) |
| 19:41 | tcrayford | yeah I think I know where I'm going with this now |
| 19:41 | tcrayford | cheers |
| 19:41 | mmarczyk | cool |
| 19:41 | mmarczyk | I think I've seen you doing a screencast with an early version of this...? |
| 19:42 | tcrayford | the katacast? |
| 19:42 | mmarczyk | yup |
| 19:42 | tcrayford | yeah, the current version isn't much changed from that |
| 19:42 | mmarczyk | looked pretty cool |
| 19:42 | tcrayford | currently it just takes s-expressions (which you select in emacs), and then does stuff to them |
| 19:43 | mmarczyk | does it preserve line breaks at this time? |
| 19:43 | tcrayford | nope, that's still broken |
| 19:43 | mmarczyk | right |
| 19:44 | tcrayford | need to talk to somebody who knows emacs better than me for that |
| 19:46 | tcrayford | can you spot any errors with this: http://gist.github.com/408283 ? |
| 19:48 | tcrayford | basically create a new namespace, defines a function in it, then tries to find that function from another namespace using find-var |
| 19:48 | mmarczyk | actually in-ns creates the namespace if it doesn't exist already |
| 19:48 | tcrayford | yep |
| 19:48 | mmarczyk | the other in-ns should use a - in the namespace name instead of _ |
| 19:49 | tcrayford | that's me being bad, shouldn't break anything atm |
| 19:49 | tcrayford | ah |
| 19:49 | tcrayford | needed a call to require in the new namespace |
| 19:49 | Licenser | hmm I try to profile some clojure code with visual vm but oddly it does not seem to see any of the functions, the profile tree is more or less empty |
| 19:49 | Licenser | does anyone ever seen this? |
| 19:50 | mmarczyk | tcrayford: you mean to pull in clojure.test/is ? |
| 19:50 | tcrayford | mmarczyk: no, require the just-created namespace |
| 19:50 | mmarczyk | tcrayford: that's the next thing I thought would probably break |
| 19:50 | mmarczyk | um, right |
| 19:50 | mmarczyk | but I wonder if you need to pull in #'is |
| 19:51 | tcrayford | its in the top of the file |
| 19:51 | tcrayford | yeah, test works now |
| 19:51 | mmarczyk | oh good :-) |
| 19:52 | tcrayford | oh, maybe not, just throws an error that test-mode didn't highlight |
| 19:53 | mmarczyk | Licenser: check that you're not filtering too much stuff out |
| 19:53 | Licenser | mmarczyk: the filters are just set to sun and apple stuff |
| 19:54 | Licenser | grrr and now it stack overflows :( |
| 19:54 | mmarczyk | Licenser: weird... I suppose you've checked that you're connecting to the right jvm...? |
| 19:54 | Licenser | yes I see the stuff in the text console |
| 19:54 | mmarczyk | super weird. :-( |
| 19:55 | Licenser | yea eseically since it stack overflows now even it does not in the repl |
| 19:56 | mmarczyk | tcrayford: and the file that code comes from defines the namespace clojure-refactoring.rename-fn-test ? |
| 19:56 | mmarczyk | tcrayford: maybe check the _ -> - thing there too |
| 19:57 | tcrayford | mmarczyk: yes |
| 19:57 | mmarczyk | Licenser: is restarting the whole thing an option? |
| 19:57 | Licenser | it seems to entirely ignore my code |
| 19:57 | mmarczyk | oh, and btw |
| 19:57 | Licenser | mmarczyk: yes I cna reset everything I want |
| 19:58 | mmarczyk | hmmm |
| 19:58 | mmarczyk | maybe try running something like |
| 19:58 | mmarczyk | oh... um... |
| 19:58 | Licenser | rm -rf / |
| 19:59 | Licenser | for i in `find / -name "*java*"`; do rm -rf $i; done |
| 19:59 | mmarczyk | (loop [k 12345143265143256124351234512435 l 5471843290518432758102435 m 12354143256] (recur (mod (* k l 2) m) (mod (* k l 3) m) m)) |
| 19:59 | mmarczyk | Licenser: yeah, that's another option ;-) |
| 19:59 | Licenser | ^^ |
| 19:59 | Licenser | mmarczyk: what should that give me? |
| 19:59 | mmarczyk | some bignum arithmetic in an infinite loop might spin the whole thing up a bit |
| 19:59 | mmarczyk | then you'll see if visualvm picks it up |
| 20:00 | Licenser | ah good plan! |
| 20:00 | mmarczyk | I suppose you need bigger numbers, though |
| 20:00 | clojurebot | (pl reverse $ (↕reduce range $ 10 () λxy (↕conj inc $ y x))) |
| 20:00 | mmarczyk | actually a bigger m |
| 20:01 | mmarczyk | clojurebot: Clojukell? Hajure? |
| 20:01 | clojurebot | It's greek to me. |
| 20:02 | tcrayford | in theory you could write a clojure on top of haskell that uses the dot syntax for calling down to haskell |
| 20:02 | mmarczyk | Licenser: hmmm :-) |
| 20:02 | Licenser | mmarczyk: the CPU has fun, the profiler is calm and totally empty |
| 20:02 | defn | or you could just write haskell on clojure, right? |
| 20:02 | tcrayford | and all the way around |
| 20:02 | Licenser | it also says something like 22 methods instrumented, that shoulds like it would missing something |
| 20:02 | defn | I want to write Haskell in Clojure in Haskell in Clojure |
| 20:03 | Licenser | defn: you get an infinit implementation loop there :P |
| 20:03 | mmarczyk | tcrayford: with Clojure in Clojure, it might be fun to try building on all sorts of host platforms :-) |
| 20:03 | tcrayford | mmarczyk: when that's done I'm totally building clojure on top of javascript |
| 20:03 | mmarczyk | tcrayford: :-D |
| 20:03 | tcrayford | defn: spot the bug https://gist.github.com/408283/ee992633b8ddf64388d9f45b968b623e93ff8e1c |
| 20:03 | Licenser | mmarczyk: nope nothing in the profilerr even for an infinit loop |
| 20:03 | mmarczyk | tcrayford: I can't wait for that to happen |
| 20:04 | mmarczyk | tcrayford: I'll be able to write useful scripts for Web pages, finally :-P |
| 20:04 | tcrayford | either that or clojurescript will be finished/work without patching clojure core |
| 20:04 | Licenser | *looks if there is a newer version* |
| 20:04 | mmarczyk | Licenser: so, how are you doing things? |
| 20:04 | Licenser | nope |
| 20:04 | Licenser | lein jar |
| 20:04 | Licenser | java -cp clj-highlight.jar:lib/clojure-contrib-1.1.0.jar:lib/clojure-1.1.0.jar test |
| 20:05 | defn | tcrayford: defn a? |
| 20:05 | Licenser | in there is a read-line where the process waits, when it waits I connect the visualvm to the process, start the profiler and wait untill it says it is ready |
| 20:05 | mmarczyk | Licenser: and that process actually does stuff? as in, uses CPU time? |
| 20:05 | tcrayford | defn: explain? |
| 20:05 | defn | ive just never seen "defn a {} []" |
| 20:06 | Licenser | mmarczyk: certenly yes aside the fact that I could hear my cooler go crazy I could watch the usage meter paint the rocky mountains |
| 20:06 | tcrayford | defn: that works in the repl |
| 20:06 | defn | tcrayford: oh...color me a noob |
| 20:07 | mmarczyk | tcrayford: so, does the new version work? (sorry, I got confused) |
| 20:07 | Licenser | defn: I could make clj-highlight color noobs for you |
| 20:07 | tcrayford | mmarczyk: nope, still broken |
| 20:07 | defn | Licenser: you could rewrite it and then id be a happy man ;) |
| 20:07 | defn | Licenser: stupiddb (the new v) is pretty cool, i like that you added db-update-in |
| 20:08 | tcrayford | though actually clojure overwrites the :line and :file metadata when you define a function, so I can't really write this test anyway |
| 20:08 | Licenser | thanks mate :) |
| 20:08 | Licenser | it also uses gzip now to compress the DB |
| 20:08 | defn | tcrayford: meta on that macro seems problematic i guess |
| 20:08 | defn | tcrayford: just a hunch |
| 20:09 | tcrayford | defn: even if I remove the metadata the test still fails |
| 20:09 | Licenser | Is there any clojure profiler save visua vm |
| 20:09 | tcrayford | you *can* use yourkit, but its not free (15 day trial was good enough for me though) |
| 20:10 | tcrayford | though iirc that goes through the same mechanisms as visualvm |
| 20:10 | Licenser | *nods* |
| 20:10 | Licenser | I thought a clojure specific one that gives usage data about fn's and stuff |
| 20:10 | tcrayford | don't think it exists yet |
| 20:13 | Licenser | :( |
| 20:20 | tcrayford | hah |
| 20:20 | tcrayford | my issue works fine from the repl |
| 20:21 | tcrayford | debating posting to the mailing list now, this is getting annoying |
| 20:30 | Licenser | frustrating :( |
| 20:33 | mmarczyk | tcrayford: you could set your own :line and :file meta after the defn form returns |
| 20:35 | mmarczyk | Licenser: have you tried connecting running your code at the repl |
| 20:36 | mmarczyk | and connecting visualvm to that? |
| 20:36 | mmarczyk | that's what I've been doing usually |
| 20:36 | defn | visualvm is...not very helpful |
| 20:36 | defn | to me, anyway |
| 20:36 | Licenser | mmarczyk: that is an id |
| 20:36 | mmarczyk | defn: even with some filtering? like, no clojure.core functions? |
| 20:39 | Licenser | mmarczyk: it works, I can benchmark jinline :P |
| 20:39 | mmarczyk | tcrayford: you should really rename that namespace to use - and not _ |
| 20:39 | Lajla | So, Clojure is more of an implementation than a standard right? |
| 20:40 | mmarczyk | _ is not supposed to be used in namespace names at all |
| 20:40 | mmarczyk | (and - is not supposed to be used in Clojure source file names) |
| 20:41 | tcrayford | mmarczyk: yep I know, but it all works atm, and hence is on the todo list |
| 20:41 | alpheus | Hi. I'm just starting to learn Clojure. Just got connected to a REPL with SLIME. Is this the right channel for newbie questions? |
| 20:41 | tcrayford | sure |
| 20:42 | defn | mmarczyk: could you be more specific about "no clojure.core functions" |
| 20:42 | defn | Lajla: im not sure how you'd answer that -- it's...sort of...standard |
| 20:42 | defn | i mean, it has the stuff that makes lisp, lisp |
| 20:43 | Lajla | defn, I mean, it has a reference implementation opposed to a formal specification, right? |
| 20:43 | TimMc | chouser: Does Joy of Clojure go into stuff like how best to set up a workspace with tests, how to organize code in large projects, and related topics? |
| 20:43 | Lajla | Or as it seems, only one implementation which is the reference. |
| 20:43 | mmarczyk | defn: you can tell visualvm to skip certain classes when instrumenting your code for profiling |
| 20:44 | mmarczyk | defn: java.*, I think, is on the list by default |
| 20:44 | mmarczyk | defn: you can add clojure.* |
| 20:44 | Lajla | As in, it's a program that reads a programming language as opposed to a formal specification of a language. |
| 20:45 | tcrayford | TimMc: not to answer for chouser, but most of that is covered by lein these days |
| 20:46 | tcrayford | Lajla: clojure is too young to have a formal spec |
| 20:47 | defn | mmarczyk: oh man, i have no idea |
| 20:47 | TimMc | tcrayford: I suppose the workspace setup is, yes. |
| 20:47 | defn | had* |
| 20:47 | Licenser | hmm interesting the memory profiler seems to work, I get clojure in there |
| 20:47 | tcrayford | TimMc: otherwise for larger projects, listen to the tests/code, and look at swank-clojure for an example of organising stuff into namespaces |
| 20:48 | TimMc | You're saying swank-clojure is a good example project to paw through? |
| 20:48 | tcrayford | yeah |
| 20:48 | TimMc | OK, cool. |
| 20:48 | tcrayford | its largish, has had a few people work on it, etc |
| 20:49 | mmarczyk | tcrayford: wow, I actually had to type your code afresh to see what's going on |
| 20:49 | mmarczyk | I feel rather silly for it |
| 20:49 | mmarczyk | but I've answered on SO |
| 20:49 | Lajla | tcrayford, well, some languages start with a formal spec I guess. |
| 20:49 | Lajla | tcrayford, how old is it? |
| 20:49 | technomancy | it's ancient code. most of it was written before atoms were implemented, and a lot of it is awkward because it's a pretty literal port of the CL code. |
| 20:49 | mmarczyk | defn: hm? :-) |
| 20:49 | tcrayford | technomancy: I was just trying to find a largish project that was open source |
| 20:50 | technomancy | tcrayford: yeah... maybe incanter would be a better choice? |
| 20:50 | tcrayford | never looked through the code there |
| 20:50 | mmarczyk | defn: I found visualvm's profiler completely useless when not filtering clojure.* out; with filtering, it's actually pretty useful |
| 20:50 | technomancy | leiningen is clean, but it's only 700 lines |
| 20:50 | TimMc | technomancy: I learn best by absorbing code style and idioms. |
| 20:50 | tcrayford | TimMc: also check out ring and hiccup |
| 20:50 | TimMc | Oh, leiningen itself! Hadn't considered that. >_< |
| 20:50 | technomancy | it's not a large project by any means |
| 20:51 | tcrayford | technomancy: is there a decent way to get an sexp out of slime and print it into a buffer? |
| 20:51 | defn | technomancy: any chance you know the magic formula to get cuke4duke and lein-cuke working? :X |
| 20:51 | technomancy | tcrayford: from elisp? |
| 20:52 | tcrayford | technomancy: yeah |
| 20:52 | tcrayford | actually, that has to be *multiple* sexprs, but I guess I can wrap them all in one larger one and pull them out of that |
| 20:53 | technomancy | tcrayford: (insert (second (clojure-test-eval-sync "(and (:foo {:foo :bar}) 88)"))) |
| 20:53 | technomancy | defn: no, never heard of it |
| 20:53 | Licenser | java makes me sad :( |
| 20:54 | Licenser | tcrayford: go go go! |
| 20:54 | tcrayford | that should fix my newlines problem completely |
| 20:55 | technomancy | more power to you |
| 20:55 | tcrayford | before I was sending back a string and using read :( |
| 20:56 | mmarczyk | tcrayford: does the test work for you now? |
| 20:56 | tcrayford | mmarczyk: don't know. Stashed that stuff in a seperate git branch whilst I rewrite the elisp |
| 20:57 | mmarczyk | tcrayford: well, it should, anyway |
| 20:58 | tcrayford | If it works for you, that's good to hear. That stuff is all a long way off though. |
| 20:58 | mmarczyk | tcrayford: the ns name was wrong in the .../a symbol in find-var... no wonder it didn't work (but I'm blind and haven't noticed until I got to that while retyping :-/) |
| 20:58 | tcrayford | really? |
| 20:58 | tcrayford | hahaha |
| 20:58 | mmarczyk | ^hadn't |
| 20:58 | mmarczyk | yup :-P |
| 20:59 | tcrayford | it doesn't look wrong from here (referring to the stackoverflow q) |
| 20:59 | mmarczyk | (is (not= (find-var 'refactoring-test-fn-rename/a) nil)) |
| 21:00 | mmarczyk | notice the symbol |
| 21:00 | mmarczyk | ah, sorry, I just realised how I'm totally off base here :-P |
| 21:00 | mmarczyk | and also, I think, what might be wrong |
| 21:00 | tcrayford | I thought that was the same |
| 21:01 | mmarczyk | let me go off and check |
| 21:01 | mmarczyk | because the test does work with the modification |
| 21:01 | mmarczyk | hm, just a sec |
| 21:01 | defn | technomancy: lein-cuke + cuke4duke = cucumber + leiningen integration |
| 21:02 | defn | http://github.com/bgruber/lazytest-listen |
| 21:02 | defn | ha! awesome. |
| 21:03 | technomancy | defn: I'm working on a lein hook to play the Final Fantasy victory theme when your tests pass |
| 21:03 | defn | hahaha! |
| 21:04 | tcrayford | technomancy: are you interested in having the lein test output colored? |
| 21:04 | technomancy | tcrayford: yeah, you could do that in a plugin now that we have hooks |
| 21:04 | defn | technomancy: you're using lazytest |
| 21:04 | defn | ? |
| 21:04 | tcrayford | hooks make everything better |
| 21:04 | technomancy | defn: no, just clojure.test |
| 21:05 | defn | i really wish people with stuff like lazytest and lazytest-listen would release |
| 21:06 | technomancy | tcrayford: I'd eventually take it into lein proper, but I prefer doing it as a plugin first |
| 21:06 | tcrayford | technomancy: cool. Might be a bit before I actually do it though |
| 21:07 | Licenser | hmm okay the problem seems to be that visualvm filtern the clojure classes |
| 21:07 | tcrayford | mmarczyk: I'm fixing the filenames first now, cheers for the pointer |
| 21:11 | mmarczyk | tcrayford: I've updated the SO answer |
| 21:11 | mmarczyk | I think the current version works |
| 21:12 | mmarczyk | though I can't say I'm sure why the original doesn't |
| 21:13 | defn | [null] Unable to resolve artifact: The artifact has no valid ranges |
| 21:13 | defn | what's that mean? |
| 21:13 | tcrayford | mmarczyk: thanks, I'll check it out in a bit |
| 21:13 | mmarczyk | tcrayford: ok |
| 21:13 | Licenser | okay to get some more results I needed to set a starting class |
| 21:14 | defn | nvm, silly PEBKAC |
| 21:14 | Licenser | another question for you people |
| 21:15 | Licenser | I do (set! *warn-on-reflections* true) in repl then load my code, no reflection warnings but when I finally managed to profile a lot of time was in reflectiosn |
| 21:15 | mmarczyk | Licenser: I think you'll need to put this in your source file |
| 21:15 | mmarczyk | or at the very least do the set! before require |
| 21:15 | Licenser | I did that |
| 21:16 | mmarczyk | so that *warn-on-reflection* is true at compile time |
| 21:16 | mmarczyk | oh, and yeah, it's *warn-on-reflection* (no 's') |
| 21:16 | Licenser | *just tries it again** |
| 21:16 | tcrayford | I thought there was a lein option to set warn-on-reflection now? |
| 21:17 | mmarczyk | right, :warn-on-reflection |
| 21:17 | Licenser | on heat |
| 21:17 | tcrayford | mmarczyk: http://github.com/tcrayford/clojure-refactoring/commit/15cc3c0d56c151b6f5397d065528e838609aa39c |
| 21:18 | Licenser | nope no warn on reflections |
| 21:20 | remleduff | Wow tcrayford, that looks amazing |
| 21:21 | mmarczyk | Licenser: http://clj-me.cgrand.net/2009/08/06/what-warn-on-reflection-doesnt-tell-you-about-arrays/ |
| 21:21 | sexpbot | "Clojure and me » What *warn-on-reflection* doesn’t tell you about arrays" |
| 21:21 | mmarczyk | just sth of potential interest |
| 21:22 | mmarczyk | the thing which *really* should work is putting (set! *warn-on-reflection* true) in the source file before the namespace is required for the first time |
| 21:22 | mmarczyk | if it doesn't work for you, maybe there's nothing to be done |
| 21:23 | mmarczyk | to get rid of reflection, I mean |
| 21:23 | mmarczyk | or maybe cgrand's post can help :-) |
| 21:23 | mmarczyk | tcrayford: cool :-) |
| 21:23 | Licenser | mmarczyk: then it tells me that it can't alter the root binding |
| 21:23 | mmarczyk | tcrayford: I'd say that _ in function names is evil too :-P |
| 21:24 | mmarczyk | tcrayford: but it definitely shouldn't cause any breakage, so... |
| 21:24 | Licenser | Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set (test.clj:0) |
| 21:24 | Licenser | it says |
| 21:24 | Licenser | meeh |
| 21:24 | tcrayford | mmarczyk: I use it occasionally in test names if I want to name a test exactly the same as a function name (but that's rare) |
| 21:25 | mmarczyk | tcrayford: wouldn't work for a fn without a - :-) |
| 21:25 | mmarczyk | I prefer adding -test, but ok |
| 21:25 | mmarczyk | Licenser: oh bother :-( |
| 21:25 | Licenser | it's no fun |
| 21:27 | mmarczyk | could you gist that file? |
| 21:28 | mmarczyk | or, I don't know, just a couple of forms from the top |
| 21:31 | Licenser | mmarczyk: it's on github one second |
| 21:32 | Licenser | mmarczyk: http://github.com/Licenser/clj-highlight |
| 21:32 | Licenser | http://github.com/Licenser/clj-highlight/blob/master/src/test.clj to be precise |
| 21:33 | mmarczyk | thanks, I'll try to run it in a moment |
| 21:33 | mmarczyk | to witness the ridiculous error with my own eyes, as it were |
| 21:33 | mmarczyk | hopefully enlightenment follows ;-) |
| 21:33 | Licenser | heh thanks mmarczyk |
| 21:33 | Licenser | why do you know so much? |
| 21:35 | mmarczyk | not sure where that came from, I'm being totally unsuccessful at guessing what your profiling+testing woes are about just now :-) |
| 21:35 | Licenser | I am totally at a less here either |
| 21:36 | Licenser | *loss |
| 21:37 | mmarczyk | Licenser: try (set! *warn-on-reflection* true) |
| 21:38 | Lajla | mmarczyk, ah, so closure uses bangs? |
| 21:38 | Licenser | *runs that |
| 21:38 | tcrayford | ,(= '((defn to-i [x] (Integer. x)) (defn add [s] (for [x (re-split #"," s)] (to-i x)))) '((defn to-i [x] (Integer. x)) (defn add [s] (for [x (re-split #"," s)] (to-i x))))) |
| 21:38 | clojurebot | DENIED |
| 21:38 | tcrayford | hah, those are quoted lists |
| 21:38 | Licenser | mmarczyk: gives me Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set (test.clj:0) |
| 21:38 | tcrayford | clojurebot: you fail |
| 21:38 | clojurebot | Pardon? |
| 21:39 | mmarczyk | Licenser: you know, I think *warn-on-reflection* might be a binding established by the ns form |
| 21:39 | mmarczyk | Licenser: try moving the set! below it maybe |
| 21:39 | Licenser | tried that but I'll try it again |
| 21:40 | mmarczyk | Lajla: and ?s, conventions for use agree with those of Scheme |
| 21:40 | Licenser | sadly same :( |
| 21:40 | tcrayford | aha! |
| 21:40 | tcrayford | ,(= #"," #",") |
| 21:40 | clojurebot | false |
| 21:41 | mmarczyk | ,(.equals #"," #",") |
| 21:41 | clojurebot | false |
| 21:41 | remleduff | (class #",") |
| 21:41 | Licenser | hm hmmms |
| 21:41 | remleduff | ,(class #",") |
| 21:41 | clojurebot | java.util.regex.Pattern |
| 21:42 | remleduff | Did the prefix change? |
| 21:42 | Licenser | mmarczyk: can you profile the test file? |
| 21:42 | Licenser | it runs with java -cp clj-highlight.jar:lib/clojure-contrib-1.1.0.jar:lib/clojure-1.1.0.jar test |
| 21:42 | Licenser | ? |
| 21:42 | remleduff | I'm pretty sure there's a thread on clojure-dev about regex Patterns and the screwy equality semantics |
| 21:42 | remleduff | $(class #",") |
| 21:42 | sexpbot | result: class java.util.regex.Pattern |
| 21:43 | mmarczyk | Licenser: yup, I'll try in a moment |
| 21:43 | tcrayford | yeah, it ain't a bother, I'll just change the tests so they change different functions |
| 21:43 | Licenser | mmarczyk: thank you a lot! |
| 21:43 | mmarczyk | np :-) |
| 21:45 | mmarczyk | Licenser: I'm seeing totally weird breakage for now |
| 21:46 | Licenser | mmarczyk: yes that is something I know :P |
| 21:47 | mmarczyk | there's a double "fn" in clojure-keywords |
| 21:47 | mmarczyk | I mean it occurs twice in the literal |
| 21:47 | mmarczyk | Clojure 1.2 complains |
| 21:48 | Licenser | oh |
| 21:48 | mmarczyk | (I might restart with 1.1 though) |
| 21:49 | Licenser | wehn I set the stack size to 100M I can run bigger files |
| 21:49 | Lajla | mmarczyk, I take it the [ ... ] is optional and can be freely exchanged with ( ... )? |
| 21:49 | mmarczyk | Licenser: same goes for let and loop |
| 21:49 | Licenser | ^^ |
| 21:49 | mmarczyk | Lajla: you mean in Clojure syntax? |
| 21:50 | Lajla | mmarczyk, quite. |
| 21:50 | mmarczyk | Lajla: not at all, [...] is a vector, whereas (...) is a list |
| 21:50 | Licenser | mmarczyk: thanks all removed |
| 21:50 | Lajla | mmarczyk, ahhh |
| 21:51 | Lajla | mmarczyk, and vectors also are encounted in code I see? |
| 21:51 | mmarczyk | Lajla: note [...] is not like #(...) in Scheme |
| 21:51 | Lajla | mmarczyk, do go on. |
| 21:51 | mmarczyk | Lajla: Scheme's vector literals provide implicit quoting, while Clojure's don't |
| 21:51 | Lajla | I am imagining you speak with a French accent as to facilitate my attention span. |
| 21:51 | Lajla | mmarczyk, this means that vectors evaluate to things? |
| 21:52 | tcrayford | ,([1 2 3] 1) |
| 21:52 | clojurebot | 2 |
| 21:52 | mmarczyk | Lajla: so [(+ 1 2)] gives [3], whereas #((+ 1 2)) evaluates to a vector whose only element is '(+ 1 2) (the list of symbol +, numbers 1, 2) |
| 21:52 | Lajla | Ahh, they evaluate all arguments. |
| 21:52 | Lajla | And vector-ref does not exist |
| 21:52 | Lajla | Rather a vector is a procedure? |
| 21:52 | mmarczyk | Lajla: just a quick question on the side |
| 21:53 | Lajla | ,([1 2 3 4] 0) |
| 21:53 | clojurebot | 1 |
| 21:53 | Lajla | Cool |
| 21:53 | mmarczyk | Lajla: or actually, never mind |
| 21:53 | Lajla | mmarczyk, ask. |
| 21:53 | Lajla | Nahh, Now I want to know. |
| 21:53 | mmarczyk | Lajla: [ ] is just literal syntax for vectors |
| 21:53 | mmarczyk | like ( ) is for lists |
| 21:53 | Lajla | ,(+ 1 ([2 3] 0)) |
| 21:53 | clojurebot | 3 |
| 21:53 | Lajla | Cool |
| 21:53 | mmarczyk | in Scheme, ( ) is literal syntax for proper lists, or with the dot, improper lists |
| 21:54 | mmarczyk | and of course (1 . 2) is a pair (cons) |
| 21:54 | Lajla | (([+ *] 1) 1 2 3 4) |
| 21:54 | Lajla | ,(([+ *] 1) 1 2 3 4) |
| 21:54 | clojurebot | 24 |
| 21:54 | mmarczyk | the fact that those lists are evaluated the way they are is a different matter entirely |
| 21:54 | Lajla | Veeery cool |
| 21:54 | Lajla | mmarczyk, I understand |
| 21:54 | Lajla | but what did you want to ask? |
| 21:54 | mmarczyk | anyway, I'm off to bang on Licenser's code until it regrets it's been written :-P |
| 21:54 | Lajla | Noo, you wanted to ask something. |
| 21:54 | Lajla | I want to know what it is. |
| 21:55 | mmarczyk | that *warn-on-reflection* thing is annoying |
| 21:55 | Lajla | It's like a splinter in my mind. |
| 21:56 | mmarczyk | Licenser: funnily enough, when I removed duplicate keys from clojure-keywords and moved (set! *warn-on-reflection* true) inside the ns form |
| 21:56 | mmarczyk | Licenser: things started to work |
| 21:56 | mmarczyk | Licenser: actually, scratch that |
| 21:56 | Licenser | inside the ns form? |
| 21:56 | mmarczyk | Licenser: yes, but also |
| 21:56 | mmarczyk | I moved renamed the namespace to clj-highlight.test |
| 21:56 | mmarczyk | and moved the file to match the ns name |
| 21:56 | Licenser | *nods* |
| 21:56 | mmarczyk | going off to move it back and see if it breaks again |
| 21:57 | Licenser | I had a problem with that when I did that that lein was acting up with the - |
| 21:57 | mmarczyk | oh? |
| 21:58 | mmarczyk | hm, apparently it doesn't break if it's just src/test.clj, ns test |
| 21:58 | mmarczyk | I mean that's supposedly broken for different reasons ;-) |
| 21:58 | Licenser | yea if I added :main clj-highlight.test java was trying to call the class wiht - if I added clj_highlight lein was trying to compile the _ file |
| 21:58 | mmarczyk | but still, I can require it and *warn-on-reflection* gets set to true |
| 21:58 | Licenser | erm namespace |
| 21:59 | mmarczyk | Licenser: oh, I see |
| 21:59 | mmarczyk | Licenser: which version of lein are you using? I'm under the impression that this was fixed, but I might well be imagining things |
| 22:00 | Licenser | hmm *looks* |
| 22:00 | mmarczyk | Licenser: if it's an actual bug, I'd love to fix it :-) |
| 22:00 | Licenser | lein 1.1.0 |
| 22:00 | Licenser | not working either, says it can't find set! |
| 22:00 | tcrayford | reader macros really break the whole code is data thing sometimes :( |
| 22:01 | Licenser | tcrayford: yap |
| 22:01 | Licenser | then again if you use the reader, no:P |
| 22:01 | Lajla | ,[1 2 3] |
| 22:01 | clojurebot | [1 2 3] |
| 22:02 | tcrayford | (= #(identity %) #(identity %)) |
| 22:02 | tcrayford | ,(= #(identity %) #(identity %)) |
| 22:02 | clojurebot | false |
| 22:02 | mmarczyk | Licenser: :-( |
| 22:02 | Lajla | ,([1 2 3 5] +) |
| 22:02 | clojurebot | java.lang.IllegalArgumentException: Key must be integer |
| 22:02 | mmarczyk | it all runs fine here, with clj 1.2 |
| 22:02 | Licenser | mmarczyk: but I am way closer |
| 22:02 | mmarczyk | let's see with 1.1 |
| 22:02 | tcrayford | I kinda have to use the reader for this, seeing as I return sexps to emacs now :/ |
| 22:02 | Lajla | ,([1 2 3 4] -1) |
| 22:02 | clojurebot | java.lang.IndexOutOfBoundsException |
| 22:02 | Lajla | Hmm, no 4? =( |
| 22:02 | mmarczyk | incidentally, got any test data? |
| 22:03 | Licenser | mmarczyk: I get some kindof useful results when I use 100M stack space and then run a bigger file |
| 22:03 | mmarczyk | I'm running it with (with-in-str "some-clojure-form\nanother-one\nyet-another-one\n" (test/-main)) |
| 22:03 | mmarczyk | for now :-) |
| 22:03 | Licenser | heh |
| 22:03 | mmarczyk | Lajla: like your Python, do you ;-) |
| 22:04 | Licenser | Lajla: ,(last [1 2 3 4]) |
| 22:04 | Licenser | also last is evil :P |
| 22:04 | Lajla | mmarczyk, I don't, that rumour was formed while I was drunk! |
| 22:04 | mmarczyk | ,(peek [1 2 3 4]) |
| 22:04 | clojurebot | 4 |
| 22:04 | Lajla | I did not have a sexual relationship with that programming language. |
| 22:04 | Lajla | licenser, how to get the second-last? |
| 22:05 | mmarczyk | ,(peek (pop [1 2 3 4])) |
| 22:05 | clojurebot | 3 |
| 22:05 | Lajla | Just (- length 1) or some similar construct? |
| 22:05 | mmarczyk | Lajla: 'count' actually, but yeah |
| 22:05 | Licenser | see mmarczyk knows all |
| 22:05 | Licenser | Lajla: also idally you don't need last |
| 22:05 | Lajla | licenser, maybe mmarczyk is the third best progammer after me and the Chief Software Architect of Microsoft. |
| 22:06 | Licenser | wait that are odd standrds |
| 22:06 | Lajla | licenser, ahhh, do elaborate here. |
| 22:06 | Lajla | licenser, if I was normal I'd be programming in python rather in some bracketlang. |
| 22:06 | mmarczyk | Licenser: there's one thing I'm not very clear on |
| 22:06 | Licenser | I'd buy that you are the best but a microsoft guy the second best? |
| 22:06 | mmarczyk | Licenser: it's *the* Microsoft guy, actually ;-) |
| 22:06 | Lajla | licenser, well, he did come up with the original DOS filename system. |
| 22:06 | Lajla | 8 character limit, brilliant idea. |
| 22:07 | Lajla | Why didn't I think of that. |
| 22:07 | mmarczyk | Licenser: anyway, why do you use read-line and not read |
| 22:07 | Licenser | Lajla: from what I understood about functional programming it is all about consuming seq's (lists) and not peacking at specific points |
| 22:07 | Lajla | He also pioneered the concept of having to restart your computer either because it crashed or for trivial updates you have to do every six hours as some systray popup tells you. |
| 22:07 | Lajla | mmarczyk, explain? |
| 22:07 | Licenser | mmarczyk: because I was sure what read-line does :P and read is the reader isn't it? |
| 22:07 | mmarczyk | Licenser: ahhhhh, right, of course |
| 22:07 | mmarczyk | sorry :-P |
| 22:08 | Lajla | licenser, well, in lists, not in vectors. |
| 22:08 | mmarczyk | makes sense you'd want a string for a syntax highlighter :-) |
| 22:08 | Licenser | Lajla: you can treat vectors as lists ;) |
| 22:08 | mmarczyk | oh, oh! cookies are good :-) |
| 22:08 | Licenser | ^^ |
| 22:08 | Lajla | licenser, then I would use lists rather than vectors. |
| 22:08 | Lajla | Vectors are for peaking at a random index. |
| 22:09 | mmarczyk | Lajla: in Clojure, not at all |
| 22:09 | tcrayford | Lajla: most clojure programmers use vectors most of the time |
| 22:09 | mmarczyk | ,(conj [1 2 3] 4) |
| 22:09 | clojurebot | [1 2 3 4] |
| 22:09 | Lajla | in lieu of lists? |
| 22:09 | Lajla | Fr what advantage? |
| 22:09 | tcrayford | personally, I prefer the syntax |
| 22:10 | Licenser | also vectors add to the end, lists to the front, sometimes it makes a difference |
| 22:10 | Lajla | I see. |
| 22:10 | mmarczyk | Lajla: actually, if you're genuinely interested in Clojure, would you like to read a really good -- yet reasonably short -- intro? |
| 22:10 | Lajla | You have intruiged me with your unorthodox language, I might turn to the dark side. |
| 22:10 | Lajla | mmarczyk, sure. |
| 22:10 | mmarczyk | Lajla: not that I mind answering here, on the contrary, just to be clear |
| 22:10 | mmarczyk | but I think it's a great article |
| 22:11 | mmarczyk | and for a person coming from Scheme |
| 22:11 | Lajla | Coming from is the right word. |
| 22:11 | mmarczyk | might be enough to get a pretty good idea of what the language is about |
| 22:11 | Lajla | mmarczyk, sure, give me. |
| 22:11 | mmarczyk | Lajla: oh, I didn't see that coming :-) |
| 22:11 | mmarczyk | yup, just a sec |
| 22:12 | mmarczyk | http://java.ociweb.com/mark/clojure/ -- link to the current revision at the top, plus loads of other resources |
| 22:12 | sexpbot | "Mark Volkmann's Clojure Page" |
| 22:13 | Licenser__ | oh yes that one was good, I started with it! |
| 22:13 | mmarczyk | me too :-) |
| 22:13 | Licenser__ | ^^ |
| 22:13 | mmarczyk | and he's got another one on Clojure's STM, which is absolutely one of a kind |
| 22:14 | mmarczyk | http://java.ociweb.com/mark/stm/ |
| 22:14 | sexpbot | "Mark Volkmann's STM Page" |
| 22:14 | alpheus | Is "lein install" the right thing to use to put a jar file somewhere that "lein deps" can find it? |
| 22:15 | tcrayford | yes |
| 22:16 | mmarczyk | well I think lein install works on the current project |
| 22:16 | mmarczyk | for now |
| 22:16 | mmarczyk | and not an arbitrary jar |
| 22:16 | mmarczyk | for the latter case, you'd need mvn install (google for the correct command line options first) |
| 22:17 | Licenser | mmarczyk: even if not the reflection the big stack thing did the trick |
| 22:17 | alpheus | thanks |
| 22:18 | mmarczyk | Licenser: ok |
| 22:18 | alpheus | mvn manipulates maven repositories? |
| 22:18 | mmarczyk | Licenser: I'm still not clear on how you test it |
| 22:18 | mmarczyk | (read-line) reads one line |
| 22:18 | Licenser | mmarczyk: me neither |
| 22:19 | remleduff | Isn't it mvn deploy-file for an arbitrary jar? |
| 22:19 | mmarczyk | so you're colouring just three lines, which probably isn't a lot of work |
| 22:19 | mmarczyk | heh |
| 22:19 | Licenser | mmarczyk: the read-line is just so that I've time to fire up the visualvm |
| 22:19 | Licenser | otherwise the tests are over before the profiler has connected |
| 22:19 | mmarczyk | remleduff: tbh, it could very well be :-) |
| 22:20 | Licenser | what did the trick fir me: -Xss100M and add the clj_highlight.** to the classes that trigger profiling |
| 22:20 | mmarczyk | mvn install worked for me once or twice, but these days I mostly put stuff in lib/ by hand (I'm not saying it's pretty) |
| 22:20 | Licenser | http://grab.by/4uz9 is what I got |
| 22:21 | Licenser | so actually the regexps are sloow :P |
| 22:21 | mmarczyk | oh man, you've got your project.clj all on one line!!! |
| 22:22 | Licenser | mmarczyk: yea it's from lein-search |
| 22:22 | Lajla | mmarczyk, omg man, that sound when you start it. |
| 22:23 | Licenser | ~defn re-find |
| 22:23 | clojurebot | Huh? |
| 22:24 | Licenser | sorry clojurebot I enver can remember how you do that |
| 22:24 | mmarczyk | Licenser: so, the idea is that you want to run test as the main class |
| 22:24 | mmarczyk | Licenser: and it's supposed to do some work which you want to profile, right? |
| 22:25 | Lajla | I never really got what people find so difficult about switching to another paradigm though, but maybe that's just because I'm young. |
| 22:25 | Licenser | mmarczyk: exactly |
| 22:25 | mmarczyk | Licenser: well, the test.clj I pulled from your repo a short while ago |
| 22:25 | mmarczyk | Lajla: I've no idea what's difficult in switching from OOP to FP, but the other way around sure is hell |
| 22:26 | mmarczyk | ;-) |
| 22:26 | mmarczyk | Licenser: but why would you expect that test.clj to do anything? |
| 22:26 | mmarczyk | as far as I can tell, it's almost empty |
| 22:26 | mmarczyk | I mean in, devoid of computational challenge ;-) |
| 22:26 | mmarczyk | or do you have a fuller version you're actually using, not yet pushed to the repo? |
| 22:26 | bmason | are the javax packages a separate library from the main java spec? |
| 22:26 | Lajla | mmarczyk, ahaha, could be that the other way around is more difficult yes. |
| 22:26 | Licenser | mmarczyk: it grabs a file, and tokenizes it |
| 22:27 | Lajla | I don't like OOP though, I think it cripples the mind. |
| 22:27 | bmason | e.g. I'm trying to import javax.mail.internet.MimeMultipart |
| 22:27 | bmason | |
| 22:27 | Licenser | it does not look too much but there is a entire scanner for clojure code in the back |
| 22:27 | Licenser | and worst thing is, it is horribly slow |
| 22:27 | mmarczyk | Licenser: grabs a file? |
| 22:27 | clojurebot | amespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it |
| 22:28 | Licenser | I only get ~20k Tokens a second from the scanner |
| 22:28 | mmarczyk | Licenser: in the test.clj that I pulled there's no code for that |
| 22:28 | mmarczyk | Licenser: that's what I meant by "devoid of computational challenge", the scanner looks impressive |
| 22:28 | Licenser | line 9 |
| 22:28 | Licenser | a hidden slurp there |
| 22:28 | mmarczyk | oh wait, have I actually deleted a line |
| 22:28 | Licenser | :P silly |
| 22:29 | mmarczyk | lol, no, I've simply missed it |
| 22:29 | Licenser | remove the content and it is of cause missing any kind of challange |
| 22:29 | mmarczyk | I wonder if I should sleep more often :-) |
| 22:29 | Licenser | line 9 reads the file to a string line 13, 14, 15 and 18 parse the string into tokens and count them (to force the lazy seq) |
| 22:30 | mmarczyk | right, now I tried to restart VisualVM and started IntelliJ instead... :-( |
| 22:31 | Licenser | heh |
| 22:31 | Licenser | still you were good help mmarczyk thanks a lot! |
| 22:32 | rsh | do most people develop new clojure programs on v1.2? |
| 22:32 | mmarczyk | Licenser: :-) |
| 22:32 | alpheus | I asked the wrong question. I'd like to require a .clj file, not a .jar. It seems as if having the path to the .clj file on CLASSPATH is sufficient. Is that about right? |
| 22:32 | mmarczyk | Licenser: ok, so I'm running the test |
| 22:32 | mmarczyk | from the REPL |
| 22:32 | Licenser | now I just have to figure out why the java regexp does not only suck but is also slow like hell |
| 22:32 | mmarczyk | and the whole thing takes under 150 ms |
| 22:33 | Licenser | it seems close to impossible to write a good scanner in java |
| 22:33 | mmarczyk | is that really slow, or does it become slow with a significantly larger input...? |
| 22:33 | Licenser | mmarczyk: it is really slow |
| 22:34 | Licenser | coderay, a ruby highlighter is about 10x faster then this |
| 22:34 | remleduff | I think most people use a parser generator for something like that in Java |
| 22:34 | Licenser | and while I expected my crazy implementation with tons of functions would be the bottle nack the regexp is it |
| 22:34 | Licenser | remleduff: but that is so complicated |
| 22:35 | remleduff | Well, you're talking about java... |
| 22:35 | mmarczyk | Licenser: somewhat importantly, I can see it working in VisualVM |
| 22:35 | Licenser | mmarczyk: wow! |
| 22:37 | Licenser | but i get the feelings that some kind of other function is slow or a regexp is bad |
| 22:40 | mmarczyk | Licenser: ah, I think I might be on to the reason why the profiler doesn't pick things up |
| 22:40 | Licenser | oh? |
| 22:41 | Licenser | I had to add stuff to the class thing to the right |
| 22:43 | mmarczyk | yeah! got it |
| 22:43 | mmarczyk | (I think) |
| 22:43 | remleduff | Licenser: Might want to look at http://www.javaworld.com/javaworld/jw-09-2007/jw-09-optimizingregex.html as well |
| 22:43 | mmarczyk | it would seem to me that you need to move the test ns to clj-highlight.test |
| 22:44 | Licenser | really oi |
| 22:44 | mmarczyk | Licenser: because otherwise it ends up in the "default package" (is that the Java name?), which is a special situation which is wrong |
| 22:44 | mmarczyk | :-P |
| 22:44 | Licenser | yuck |
| 22:44 | Lajla | You know, this cojure actually has a lot in common in a language I once made wich treated vectors like functions that took in natural numbers and sets as praedicates. |
| 22:45 | Licenser | Lajla: then you'll feel right at home :D |
| 22:45 | Lajla | licenser, I do actually, I'm considering turning to the dark side here. |
| 22:46 | Lajla | Looks well thought off. |
| 22:46 | Licenser | mmarczyk: but how do I explain lein to do things right :( |
| 22:46 | mmarczyk | Licenser: I wouldn't bother |
| 22:46 | Licenser | hmm true I don't need to unless I do the executable jar stuff |
| 22:46 | mmarczyk | what I'm doing now is start it all in a repl |
| 22:46 | mmarczyk | wrap the test in a dotimes with some large number of iterations |
| 22:47 | mmarczyk | oh, and that's after telling VisualVM to skip clojure.*, swank.* and sun.rmi.* classes when profiling |
| 22:47 | mmarczyk | in addition to those which it skips anyway |
| 22:47 | mmarczyk | and start with clj_highlight.** (though that's probably optional) |
| 22:48 | Licenser | =) |
| 22:48 | mmarczyk | or should it be sun.rmi.transport.* |
| 22:50 | mmarczyk | et voila, 22% of the time spent in sth called re-token |
| 22:50 | Licenser | :D |
| 22:50 | Licenser | mmarczyk: you good sir are briliant! |
| 22:52 | mmarczyk | http://gist.github.com/408392 |
| 22:53 | Licenser | mmarczyk: only sad point is that the re-token just tells me that it is 'a' regular expression not which one :P |
| 22:53 | remleduff | Licenser: In your regex, basic-identifier has (?i) in it, and that ends up occurring several times in the final basic-identifier. Can you make that flag get turned on only once? |
| 22:53 | Licenser | yes I could |
| 22:56 | mmarczyk | Licenser: I guess so :-( |
| 22:56 | Licenser | *looks into it again* |
| 22:56 | riddochc | So, I know a suffix of 'M' on a number indicates that a literal should be treated as a bigdecimal. Is there something similar for a long? |
| 22:57 | mmarczyk | Licenser: I suppose it should be possible to wrap that function in sth to keep track of which regexp took how much time on average |
| 22:57 | mmarczyk | plus the number of times they were used |
| 22:58 | mmarczyk | interested? |
| 22:58 | Licenser | mmarczyk: I just did that |
| 22:58 | mmarczyk | oh :-) |
| 22:58 | mmarczyk | great |
| 22:58 | Licenser | at least the wrapping |
| 22:58 | Licenser | I want to see if it works |
| 22:58 | Licenser | killd the thing so with a slurp :P |
| 22:58 | mmarczyk | :-) |
| 22:59 | mmarczyk | I'll be back very shortly, need to go off for a moment |
| 23:00 | Licenser | thanks mmarczyk and take care |
| 23:02 | remleduff | $*clojure-version* |
| 23:02 | sexpbot | Command not found. No entiendo lo que estás diciendo. |
| 23:02 | remleduff | $(str *clojure-version*) |
| 23:02 | sexpbot | DENIED! |
| 23:02 | Raynes | Use $eval for stuff that isn't wrapped in parans. |
| 23:03 | Raynes | $eval *clojure-version* ; this still wont work though. |
| 23:03 | sexpbot | DENIED! |
| 23:03 | Raynes | I haven't whitelisted that. I need to. |
| 23:03 | Raynes | It's running 1.2, for the record though. |
| 23:04 | remleduff | Hmm, isn't *clojure-version* kind of a bad example of using earmuffs |
| 23:04 | remleduff | ? |
| 23:04 | remleduff | $(+ 100L 1) |
| 23:04 | sexpbot | Invalid number: 100L |
| 23:04 | remleduff | $(+ (long 100) 1) |
| 23:04 | sexpbot | result: 101 |
| 23:05 | remleduff | Wonder why the reader doesn't support the L suffix |
| 23:07 | riddochc | Wow, something's quite wrong. I'm using clj-time, which uses joda-time, and (time-coerce/from-long (long 1274244710)) evaluates to #<DateTime 1970-01-15T17:57:24.710Z> |
| 23:08 | remleduff | $(long 1274244710) |
| 23:08 | sexpbot | result: 1274244710 |
| 23:08 | remleduff | $(class (long 1274244710)) |
| 23:08 | sexpbot | result: class java.lang.Long |
| 23:09 | riddochc | I've got a :require clause, [clj-time [core :as time-core] [coerce :as time-coerce] [format :as time-format] |
| 23:09 | riddochc | (time-core/now) evaluates to #<DateTime 2010-05-21T03:06:33.674Z> |
| 23:10 | riddochc | Now, aside from the fact that I need to fix my NTP setup, something seems a bit screwy, don't you think? |
| 23:12 | remleduff | What does (time-coerce/to-long (time-core/now)) give you? |
| 23:12 | riddochc | Let's find out... |
| 23:12 | Licenser | *sigh* |
| 23:13 | riddochc | 1274411403008 |
| 23:13 | rava | Greetings programs :) |
| 23:14 | mmarczyk | Licenser: how are you doing? |
| 23:14 | Licenser | well trying things now but the repl crashes whenever I try to define the highlighter :P |
| 23:14 | remleduff | You shouldn't need the call to long when calling from-long should you? |
| 23:14 | mmarczyk | ouch |
| 23:15 | riddochc | Oh, I think I see. It expects *milliseconds*, not seconds. |
| 23:15 | Licenser | yea I've bad luck today :P |
| 23:16 | riddochc | (time-coerce/from-long (long (* 1000 1274244710))) -> #<DateTime 2010-05-19T04:51:50.000Z> |
| 23:16 | riddochc | Now that's more like it. |
| 23:16 | remleduff | Cool |
| 23:16 | remleduff | I think calling "long" there is redundant though, from-long does the type-hint internally |
| 23:18 | riddochc | It complained if I didn't and the time was closer to 1970... though for recent times, it should be fine. |
| 23:19 | Licenser | this is so frustrating :( |
| 23:19 | riddochc | clj-time has a type hint, [#^Long millis] in its param-list, but that doesn't seem to be the same as a coercion. Hm. |
| 23:19 | Licenser | I think it hates me o. |
| 23:19 | Licenser | o |
| 23:20 | TimMc | technomancy|away: Leiningen totally works! Thank you. :-) |
| 23:25 | Licenser | hmm okay finally :D |
| 23:27 | mmarczyk | oh good :-) |
| 23:28 | Licenser | mmarczyk: the identifyer token is the evil one |
| 23:29 | mmarczyk | um, shouldn't symbol* actually be called keyword* ? |
| 23:29 | Licenser | yes I guess so |
| 23:29 | bmason | what's with all these warnings: WARNING: flatten already refers to: #'clojure.core/flatten in namespace: compojure.html.form-helpers, being replaced by: #'clojure.contrib.seq-utils/flatten |
| 23:30 | bmason | does that have something to do with compojure moving stuff to ring, or am I referencing inconsistent versions of something? |
| 23:30 | mmarczyk | also, ::foo/bar is not a valid keyword literal |
| 23:30 | Licenser | hmm okay learned something new :) |
| 23:31 | mmarczyk | aaaahhhh, nope, wait |
| 23:31 | mmarczyk | it is |
| 23:31 | mmarczyk | sorry |
| 23:31 | Licenser | heh |
| 23:31 | mmarczyk | and it even works with aliases then :-) |
| 23:31 | Licenser | problem is this is a pretty ugly case :P |
| 23:32 | Licenser | I can't think of much to make this less ugly or faster |
| 23:32 | mmarczyk | what does (?i) do? |
| 23:33 | mmarczyk | hey, I just noticed sth |
| 23:33 | mmarczyk | you need to switch to regex literals! |
| 23:34 | mmarczyk | where possible |
| 23:34 | mmarczyk | mostly for prettiness' sake :-P |
| 23:36 | remleduff | Licenser: Would it help to change basic-identifier to lazy rather than eager by changing the * to *? ? |
| 23:37 | remleduff | You'd need a token on the other side to match though |
| 23:37 | Licenser | hmm hmm I'm not an expert on regexps sadly :P |
| 23:38 | Licenser | mmarczyk: (?i) makes it case insensitve |
| 23:38 | Licenser | mmarczyk: yea but composing them isn't as nice |
| 23:39 | remleduff | What are you trying to match exactly? |
| 23:39 | TimMc | Ooh, Clojure has sexp-based regexes available? (Or is it a lib?) |
| 23:40 | Licenser | remleduff: clojure symbols ^^ |
| 23:40 | remleduff | Something like #".*/.*" but with only clojure allowed characters? |
| 23:41 | Licenser | remleduff: well more or less yes |
| 23:45 | remleduff | I think you'd be better off just putting A-Z in your character classes rather than turning on and off case insensitivity like that |
| 23:45 | remleduff | But I'm having a hard time figuring out exactly what you're matching :) |
| 23:45 | Licenser | remleduff: o.O Me to! |
| 23:49 | Licenser | remleduff: sadly didn't changed too much |
| 23:51 | remleduff | What are you matching at the end of identifier? It has to match any character or any two characters? |
| 23:53 | Licenser | remleduff: ny two? |
| 23:53 | Licenser | not sure what you mean |
| 23:55 | remleduff | I just am not sure what the "\\.\\.?" at the end of your regex is intended to do |
| 23:55 | Licenser | well . and .. are both symbols |
| 23:59 | remleduff | You want to avoid the | alternation as much as possible I think |
| 23:59 | Licenser | *nods* I just pulled the regexp apart and made 3 rules out of it |