2009-07-25
| 01:13 | codyK | hahaha |
| 01:13 | codyK | got some more time to work on that circular reference issue |
| 01:13 | codyK | was actually a problem of binding / lazy map |
| 01:13 | hiredman | that'll do it |
| 01:14 | codyK | so seriously, do people just avoid using binding at all cost? |
| 01:15 | hiredman | nope |
| 01:15 | hiredman | but it is a common gotcha |
| 01:15 | hiredman | there has been some talk and proposals of various solutions |
| 01:16 | hiredman | I never paid too much attention |
| 01:17 | hiredman | mostly you just need to capture the dynamic environment (binding) in the static environment (a let) |
| 01:17 | hiredman | (binding [a 1] (let [a a] (map #(+ % a) (range 10)))) |
| 01:24 | codyK | that doesnt seem to be sufficient |
| 01:24 | lisppaste8 | codyK pasted "binding / laziness" at http://paste.lisp.org/display/84162 |
| 01:25 | codyK | ::js method will succeed, ::html method will fail |
| 01:25 | codyK | (where fail == recurse indefinitely) |
| 01:26 | codyK | forcing the map in the ::html method, works fine |
| 01:26 | codyK | or does interpose force . . . |
| 01:33 | iBong | simple question, trying to iterate over a an array from a java object, doseq gives (... doseq requires a vector binding) |
| 01:34 | Lau_of_DK | Is that a question? |
| 01:34 | iBong | No, not technically I suppose |
| 01:35 | iBong | how to iterate across a java array in clojure? (I'm out of my depth, trying to get my feet wet converting a java csv processing program to clojure) |
| 01:36 | Lau_of_DK | I believe doseq will get you where you need to go, depending a little on the purpose |
| 01:36 | Lau_of_DK | (its not lazy and primarily used for side-effects I believe) |
| 01:37 | iBong | something like (doseq java-array function)? from the error I surmised that either I was doing something very stupid syntactically or java-array's don't qualify as vectors |
| 01:37 | arbscht | iBong: that error suggests that your binding form is malformed. a syntax error perhaps? |
| 01:37 | iBong | probably |
| 01:38 | arbscht | (doseq [x (into-array [1 2 3])] (println x)) |
| 01:38 | Lau_of_DK | or (doseq [item (make-array String 20)] (println item)) |
| 01:41 | iBong | ah! I was indeed doing something very stupid (x was not inside brackets) thank you |
| 01:44 | Lau_of_DK | You'll get used to it quickly :) |
| 01:45 | iBong | hope so, clojure is very cool, all my ruby code is .map .inject lambda x now, want to start using it seriously as soon as I can grok it |
| 01:50 | iBong | another question, say I have 20 csv files I want to process with some function. Is it simple to fire up 20 threads? |
| 01:51 | hiredman | I doubt you want 20 threads |
| 01:52 | iBong | an optimal number then? |
| 01:52 | hiredman | maybe 20 tasks executed on four or five threads |
| 01:52 | hiredman | agents |
| 01:53 | iBong | will rtfm, thanks |
| 01:55 | hiredman | ,(map #(send-off %2 + %1) (range 10) (cycle (take 4 #(repeatedly (agent 0)))) |
| 01:55 | clojurebot | EOF while reading |
| 01:55 | hiredman | bah |
| 01:55 | hiredman | ,(map #(send-off %2 + %1) (range 10) (cycle (take 4 #(repeatedly (agent 0))))) |
| 01:55 | clojurebot | java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: sandbox$eval__3974$fn__3979 |
| 01:55 | hiredman | :/ |
| 01:55 | iBong | lol |
| 01:55 | Lau_of_DK | # too much |
| 01:55 | iBong | too bad emacs isn't lisp-aware in erc mode |
| 01:56 | iBong | that's quite dense, will have to thoroughly google agents |
| 01:56 | Lau_of_DK | iBong: You can make it that I think :) |
| 01:56 | hiredman | ,(map #(send-off %2 + %1) (range 10) (cycle (take 4 (repeatedly #(agent 0))))) |
| 01:56 | clojurebot | (#<Agent@151a9d4: 4> #<Agent@64cc22: 6> #<Agent@195f463: 2> #<Agent@1dfae24: 3> #<Agent@151a9d4: 4> #<Agent@64cc22: 6> #<Agent@195f463: 2> #<Agent@1dfae24: 3> #<Agent@151a9d4: 4> #<Agent@64cc22: 6>) |
| 01:56 | Lau_of_DK | iBong: hiredman is making it very complicated |
| 01:56 | iBong | Im dutr domronr hsd |
| 01:56 | iBong | Im sure someone has |
| 01:56 | Lau_of_DK | Its actually really easy |
| 01:56 | hiredman | what!? |
| 01:57 | hiredman | I am not |
| 01:57 | Lau_of_DK | (defn foo [a] (map parse-csv-file (get-list-of-csv-files))) |
| 01:57 | hiredman | ,(pmap #(send-off %2 + %1) (range 10) (cycle (take 4 (repeatedly #(agent 0))))) |
| 01:57 | Lau_of_DK | (send-off (agent 0) foo) |
| 01:57 | clojurebot | (#<Agent@1827697: 12> #<Agent@37eaa5: 6> #<Agent@10e1899: 8> #<Agent@7118a4: 10> #<Agent@1827697: 12> #<Agent@37eaa5: 6> #<Agent@10e1899: 8> #<Agent@7118a4: 10> #<Agent@1827697: 12> #<Agent@37eaa5: 6>) |
| 01:57 | Lau_of_DK | Thanks for spamming |
| 01:57 | hiredman | Lau_of_DK: that won't spread the work out over multiple agents |
| 01:58 | Lau_of_DK | No, but I dont think showing him send-off, cycle, repeatedly and agent will make it very clear to him what youre doing, so I opted to show send-off :) |
| 01:59 | hiredman | you would take my example, and replace (range 10) with a list of csv files and + with the csv processing function |
| 01:59 | hiredman | and capture the resulting sequence in a name somehow, most likely let, apply await, then reduce the results |
| 02:00 | hiredman | perfectly cromulent |
| 02:00 | Lau_of_DK | haha - I dont even know what cromulent mean, but I'll go look it up Mr. Scholar |
| 02:00 | piyo` | leveraging cromulent synergy |
| 02:00 | hiredman | it's a made up word, but I am sure some dictionary has it |
| 02:01 | hiredman | of course, wikictionary does |
| 02:01 | hiredman | http://en.wiktionary.org/wiki/cromulent |
| 02:01 | arbscht | embiggening one's vocabulary :) |
| 02:02 | Lau_of_DK | haha |
| 02:03 | Lau_of_DK | If you dont, communication with hiredman will be absolutely unpossible |
| 02:03 | Fossi | hi |
| 02:03 | iBong | I sheepishly admit I was only able to make sense of Lau's example |
| 02:03 | iBong | copied and pasted the above for reference |
| 02:05 | Lau_of_DK | Great :D |
| 02:05 | Fossi | hiredman: the definition of cromulent is pretty broad though |
| 02:05 | hiredman | iBong: first (agent 0) creates and agent holding the value 0, #(agent 0) creates an anonymous function that returns a new agent holding the value 0 everytime it is invoked |
| 02:06 | hiredman | repeatedly takes a function and creates a infinite lazy sequence of the result of invoking the function over and over again |
| 02:07 | hiredman | so (repeatedly #(agent 0)) creates an infinte sequence of agents holding 0 |
| 02:07 | Lau_of_DK | ~clojureql |
| 02:07 | clojurebot | clojureql is a quite impressive piece of work |
| 02:07 | Lau_of_DK | ~clojureql |
| 02:07 | clojurebot | clojureql is http://github.com/Lau-of-DK/clojureql/tree/master |
| 02:07 | Lau_of_DK | Right on both accounts |
| 02:08 | hiredman | take of course takes the first n of a sequence |
| 02:09 | hiredman | so (take 4 (repeatedly #(agent 0))) gives you a lazy-seq of four agents holding 0 |
| 02:09 | hiredman | ,(pl (λx.x 1)) |
| 02:09 | clojurebot | 1 |
| 02:11 | iBong | *iBong senses the fog thinning slightly |
| 02:12 | hiredman | cycle repeats the same four agents over and over |
| 02:12 | iBong | I'll try to plug it in to the program and see if its faster ;) |
| 02:12 | iBong | hopefully learn something along the way |
| 02:12 | hiredman | I wonder if you might as well just do a reduce of a pmap |
| 02:12 | Lau_of_DK | iBong: Generally I'd say, build working code first, if its too slow, then optimize |
| 02:13 | iBong | yeah, I could just grab the biggest function on the java class, but that would be cheating |
| 02:14 | Lau_of_DK | What I meant is, usually Clojure code runs quite fast without paying special attention to optimizing, so dont get ahead of yourself - This advice I got from Chouser has saved me lots of time in the past |
| 02:15 | iBong | 20 files, 20 sheets per file, many agents for sheets in file? agents for files? |
| 02:15 | iBong | good advice indeed |
| 02:15 | iBong | and QL looks very cool |
| 02:15 | iBong | cloned it for safe keeping |
| 02:16 | hiredman | there is overhead for managing threads and some for the agent system, so the work load has to be not insignificant for there to be a performance boost |
| 02:17 | iBong | it takes about 5 minutes now, so its not THAT slow, but a speed increase would noticeable, and the logic is quite simple so it seemed like a good learning experiment |
| 02:18 | Lau_of_DK | How large are the files in terms of mb ? |
| 02:18 | iBong | between 5 and 15 on avg |
| 02:18 | iBong | not taking every sheet, though its on the horizon |
| 02:19 | Lau_of_DK | Ok - Then I'd probably dispatch threads, if its something you have to sit and look at |
| 02:19 | iBong | excel files produced by an accounting organization that really should have gotten a database a long time ago |
| 02:20 | hiredman | man, I wish scopes would land |
| 02:20 | Lau_of_DK | Why? |
| 02:20 | hiredman | so useful for resource management |
| 02:23 | Lau_of_DK | I never looked at it, what would be the typical use case? |
| 02:31 | Lau_of_DK | @ hiredman |
| 02:33 | Fossi | time for clojure and android |
| 02:33 | Lau_of_DK | Which reminds me, anyone got Clojure going on the iphone? |
| 02:34 | Fossi | hmmm. why should that be problematic? bad jvm implementation? |
| 02:34 | JAS415 | how would i translate this to clojure: java.awt.Image image = java.awt.Toolkit.getDefaultToolkit().getDefaultToolkit().createImage(url); |
| 02:34 | JAS415 | ?? |
| 02:35 | JAS415 | tried a bunch of things but nothing seemed to work properly |
| 02:35 | JAS415 | seems to die on the .getDefaultToolkit thing |
| 02:35 | Lau_of_DK | (Image. (.. (getDefaultToolkit) (getDefaultToolkit) (createImage url)) I think |
| 02:36 | Lau_of_DK | if you import java.awt.Toolkit |
| 02:36 | JAS415 | hmm |
| 02:36 | JAS415 | okay |
| 02:37 | Fossi | without the Image. |
| 02:37 | Fossi | or well |
| 02:37 | Fossi | most likely you dont want it |
| 02:37 | JAS415 | hmm |
| 02:38 | JAS415 | seems to get confused on getDefaultToolkit stil |
| 02:38 | JAS415 | i had assumed i'd need the class |
| 02:38 | Fossi | at least i guess createImage already returns an Image |
| 02:38 | JAS415 | ahhh |
| 02:38 | JAS415 | there we go |
| 02:38 | JAS415 | okay |
| 02:38 | JAS415 | it is |
| 02:39 | JAS415 | (.. java.awt.Toolkit (getDefaultToolkit) (createImage url)) |
| 02:39 | slashus2 | JAS415: (.. (java.awt.Toolkit/getDefaultToolkit) (createImage url)) |
| 02:39 | slashus2 | Or that |
| 02:39 | JAS415 | seems like the second getDefaultToolkit was unnecessary |
| 02:39 | JAS415 | :-) |
| 02:39 | JAS415 | oh ok |
| 02:39 | JAS415 | so you can qualify them with /'s |
| 02:39 | JAS415 | that will be useful too |
| 02:40 | Fossi | "/ is for static stuff |
| 02:41 | hiredman | Lau_of_DK: instead of using with-open everywhere, functions can register a function to be run when a scope is exited |
| 02:42 | hiredman | so (reader …) which returns a Reader could register a function to close the reader it produces |
| 02:42 | hiredman | once you leave the (scope …) |
| 02:42 | hiredman | and it throws an exception if not called within a scope |
| 02:42 | Lau_of_DK | JAS415: (Image. (.createImage (java.awt.Toolkit/getDefaultToolkit) url)) How about that? |
| 02:43 | Lau_of_DK | Oh ok, thanks hiredman |
| 02:43 | hiredman | ~scopes |
| 02:43 | clojurebot | Pardon? |
| 02:43 | hiredman | ~scope |
| 02:43 | clojurebot | scope is at http://paste.lisp.org/display/73838 |
| 02:45 | Lau_of_DK | In that example, what is the 'scope' ? I'm confused that a string in the REPL triggers something, I had expected a reference to foo |
| 02:45 | Chouser | huh. When I push a patch authored by X that includes "Fixes #Y", assembla reports that X closed ticket Y. |
| 02:45 | hiredman | Chouser: cute |
| 02:45 | hiredman | Lau_of_DK: the string in the repl doesn't trigger something |
| 02:46 | Lau_of_DK | Git - Keeping you humble |
| 02:46 | Chouser | I mean, I guess that's right, but it's weird to see a change timestamped now when they're not even logged in. |
| 02:47 | hiredman | (when-scope :fails (prn "failed")) registers the action (prn "failed") to be performed if the scope fails to exit cleanly (uncaught exception, etc) |
| 02:48 | hiredman | the "exited" and "failed" just print'ed oddly |
| 02:48 | Chouser | where "the scope" is the outermost (scope ...) in the current dynamic context |
| 02:48 | hiredman | ~horizon |
| 02:48 | clojurebot | horizons is http://gist.github.com/51721 |
| 02:48 | Chouser | hm, was there talk of named or directed scopes, rather than all bubbling to the highest? |
| 02:48 | hiredman | yeah |
| 02:49 | Lau_of_DK | Ah ok |
| 02:49 | Lau_of_DK | What are you doing up Chouser? |
| 02:49 | Chouser | Tomorrow's my turn to sleep in, so I'm taking advantage of it. |
| 02:50 | Lau_of_DK | Ah I see |
| 02:50 | Chouser | but I've pretty much used up my time now... |
| 02:50 | Lau_of_DK | But did you get much done? |
| 02:52 | Chouser | not too bad. tested image-grid [OT] and cranked through 5 tickets |
| 02:53 | Chouser | hm.. I think that's an average of about 30 minutes per ticket. not so hot... |
| 02:53 | Lau_of_DK | I wouldnt know, were they complex? |
| 02:54 | Chouser | eh, not really. |
| 02:55 | Chouser | I mean, I'm not creating patches or anything, just double-checking the patch and doing "paperwork". |
| 02:55 | Chouser | anyway, bedtime. Y'all have fun, now. |
| 02:55 | Lau_of_DK | Thats geat |
| 02:55 | Lau_of_DK | great |
| 02:55 | Lau_of_DK | Al'right, good night |
| 03:02 | Fossi | people are so cool. a repl on the android. <3 |
| 03:02 | Fossi | time for breakfast first though :D |
| 05:52 | Jetien | Hello! I often like to write functions that don't care if the argument is a collection containing one element or just one element. Is there an elegant way to do this in clojure? |
| 05:53 | Jetien | i like to be a ble to write (f x) instead of (f (list x)) |
| 05:59 | Chousuke | Jetien: I think you'll need an if in the function |
| 06:00 | Jetien | okay |
| 06:00 | Jetien | thanks! :) |
| 06:24 | alinp | hi |
| 06:24 | alinp | I have a folder with some subfolders and some files (clj files) |
| 06:24 | alinp | how can I include all of these in the classpath ? |
| 06:25 | alinp | I tried -cp "${MY_FOLDER}/*" |
| 06:25 | alinp | but when doing the (require 'folder.examples) it doesn't work |
| 06:25 | alinp | doesn't find the folder/examples.clj file |
| 06:25 | alinp | although it exists there |
| 06:32 | rottcodd | if you use -cp dir then it will look in dir/folder/examples.clj |
| 06:33 | StartsWithK | try -cp ${MY_FOLDER}/sub1:${MY_FOLDER}/sub2 .. i assume subs have proper structure used by http://clojure.org/libs |
| 06:38 | StartsWithK | docs for remove-ns say: Removes the namespace named by the symbol. Use with caution. |
| 06:38 | StartsWithK | what problems could i create if i remove a namespace? |
| 06:46 | alinp | thanks guys |
| 08:33 | Fossi | Is Remco van 't Veer coming here? |
| 09:11 | Fossi | yay. got clojure to run on the android emulator. time for fun |
| 11:12 | krumholt_ | hiredman, that (pl ..) is that in clojure-contrib? |
| 11:25 | rhickey | lisppaste8: url |
| 11:25 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 11:26 | lisppaste8 | rhickey pasted "newnew syntax" at http://paste.lisp.org/display/84174 |
| 11:26 | rhickey | :as might be :this |
| 11:27 | rhickey | but the key is :volatile, allows keeping closure model, just a declaration affecting mutability in this scope, doesn't add new notion of 'field' |
| 11:54 | StartsWithK | rhickey: will you leave proxy and related functions? |
| 12:04 | dbaser | _ |
| 12:11 | rhickey | StartsWithK: yes |
| 12:11 | rhickey | but you won't generally want to use proxy once new new exists |
| 12:51 | Fossi | rhickey: i like how you kinda push/trash concurrency in practice at the same time in the concurrency speech :D |
| 12:52 | rhickey | Fossi: I don't think I trash it - I think it's very good and recommend it. I think doing the things it recommends is very hard work and easy to get wrong. |
| 12:53 | Fossi | yeah, i totally feel the same way |
| 12:54 | Fossi | and i guess prolly every person who read it |
| 13:25 | angerman | how would i wrap a few functions into an (if body |
| 13:25 | rhickey | angerman: they likely have side effects, so (do ...) |
| 13:26 | clojurebot | They found no relationship between a programmer’s amount of experience and code quality or productivity. |
| 13:27 | angerman | rhickey: thanks. I thought about the (do but wasn't sure if it was the way to go.. :) |
| 13:27 | angerman | I tried just wrapping the consecutive calls into () |
| 13:28 | angerman | yes. What I wanted was stmt; expr |
| 13:53 | krumholt | hi i am trying agents and i send a function to an agent which will send itself to the same agent. how can i make this agent stop? |
| 13:55 | mebaran151 | is there anything like a lazy conjoin? |
| 13:55 | mebaran151 | I'd like to add an element to aset but not realize it until its done? |
| 13:55 | mebaran151 | *until the collection is evaluated |
| 14:14 | mebaran151 | nvm the delay macro has me covered |
| 15:03 | angerman | ... egal is nota function i can relate to. |
| 15:14 | angerman | can someone help me on my macro: http://gist.github.com/154862 |
| 15:17 | Fossi | programming with java ui frameworks is kinda weird in clojure |
| 15:23 | angerman | Fossi: I think with a few macros (though I'm not good at macros yet) it's quite plesant compared to writing pure java |
| 15:23 | Fossi | i love it. but currently i try to write a android app and all this state is giving me headaches ;) |
| 15:28 | Fossi | so far it's nice that state is so explicit in clojure (compared to scala, groovy, jython) |
| 15:29 | Fossi | but the 'interfaces' between stateful java code and mine is always tricky to get right somehow |
| 15:30 | Fossi | if only for the mass of code wrapped in do that you have to write |
| 15:30 | angerman | I'm just to stupid to get it right now. |
| 15:32 | Fossi | well, look at the source? |
| 15:32 | Fossi | but i guess clojureql uses a pretty deep stack of macros |
| 15:32 | angerman | Fossi: I am ... :( |
| 15:34 | Fossi | it would be nice if there was a tool/program that would clean up imports |
| 15:34 | Fossi | the only thing i miss about eclipse really |
| 15:43 | hiredman | krumholt_: nope |
| 16:16 | Anniepoo | hmm... lookinf for some foomap that does (foo #(+ %1 %2) '(1 2 3) '(10 20 30)) => (11 22 33) |
| 16:16 | rhickey | ,(map + [1 2 3] [10 20 30]) |
| 16:16 | clojurebot | (11 22 33) |
| 16:19 | Fossi | ,(map #(+ %1 %2) '(1 2 3) '(10 20 30)) |
| 16:19 | clojurebot | (11 22 33) |
| 16:20 | Fossi | just checking my sanity... ;) |
| 16:20 | Anniepoo | ah, nice |
| 16:20 | Anniepoo | thanks! |
| 16:20 | Fossi | do you put your source dirs into the 'swank-clojure-extra-classpaths' in emacs? |
| 16:21 | Fossi | there prolly has to be a smarter way of making it find the classes it needs for :use |
| 16:21 | rhickey | there's no need for #(+ %1 %2), just map + |
| 16:22 | Fossi | sorry, i should've tested locally |
| 16:22 | Anniepoo | yah, I see |
| 16:22 | Anniepoo | that's one more insanely useful thing about Clojure |
| 16:22 | Fossi | rhickey: you still code in other languages for work? |
| 16:22 | clojurebot | for is not a loop |
| 16:23 | Fossi | clojurebot: for me, it is, sometimes |
| 16:23 | clojurebot | for is not used often enough. |
| 16:23 | Fossi | clojurebot: for that, i agree |
| 16:23 | clojurebot | for is a loop...in Java |
| 16:26 | Fossi | if i want to instantiate a gen-class from another gen-class, do i :use or import it? |
| 16:27 | Anniepoo | this is getting messy. |
| 16:29 | Anniepoo | I have a structure, a 'widget' that has a set of children and a set of slaves. |
| 16:30 | Anniepoo | I'm making each widget a structmap with a couple keys, :children, a vector of children, and |
| 16:30 | Anniepoo | :slaves, a vector of slaves |
| 16:31 | Anniepoo | now I need to traverse through this struct applying all sorts of changes to masters and slaves |
| 16:31 | Anniepoo | and it's messy |
| 16:33 | Fossi | no, it's beautiful :) |
| 16:33 | Anniepoo | LOL |
| 16:33 | Anniepoo | well, I could use less beauty and more functionality at the moment |
| 16:34 | Fossi | naturally depending on whether you find a good abstraction of your problem and a nifty way to handle it ;) |
| 16:34 | rhickey | Anniepoo: you know about get-in, update-in, assoc-in? |
| 16:34 | Anniepoo | no, I don't |
| 16:34 | rhickey | ,(doc get-in) |
| 16:34 | clojurebot | "([m ks]); returns the value in a nested associative structure, where ks is a sequence of keys" |
| 16:34 | Anniepoo | hitting doc now |
| 16:34 | Fossi | nested stuff still grows on me as well. takes a good while to grasp |
| 16:35 | Anniepoo | ah! This is perfect! |
| 16:35 | Fossi | as a collegue of mine said: even if your operation takes 24 lines of comments for each line of code, it will still be half of what you would've written in java :) |
| 16:37 | Anniepoo | it's striking - I actually started this project in Java. I felt my Clojure knowledge was too weak. |
| 16:37 | Anniepoo | I realized I'd never get it done in time, and switched to Clojure |
| 16:38 | Anniepoo | even given the extra time for my noobishness in Clojure my productivity is much higher |
| 16:39 | Anniepoo | actually, get-in won't work here |
| 16:39 | Anniepoo | because I have a vector of each thing I need to map over |
| 16:40 | Anniepoo | like the 2nd slave of the 3rd son of the 2nd slave of the 3rd prince of king kickipoo |
| 16:49 | Anniepoo | (get-in {:foo [{:mep "yup"} {:mep "no way"}] :bar "nope"} [:foo 0 :mep]) |
| 16:50 | Anniepoo | wow, that's insanely neat |
| 16:50 | MarkVolkmann | I've been studying the Clojure STM implementation because I want to understand it better and be able to explain it to others. |
| 16:51 | MarkVolkmann | I have focused primarily on LockingTransaction.java and Ref.java. |
| 16:51 | MarkVolkmann | I have a question about Refs and being "bound". |
| 16:51 | MarkVolkmann | I can't see in the code how it is possible for a Ref to be unbound. That means that its tvals field is null. I don't see how that can happen. |
| 16:53 | rhickey | MarkVolkmann: there was once a no-arg ctor and there may be again |
| 16:53 | MarkVolkmann | Ah ... that makes sense. Thanks! |
| 17:04 | Fossi | hmmm. i guess i should've started with the domain stuff instead of poking around android and opengles all evening |
| 17:07 | MarkVolkmann | I'm looking at how a ref gets "faults" in the doGet method of LockingTransaction. |
| 17:08 | MarkVolkmann | Since every Ref always has at least one TVal and the initial one has a "point" of zero, it seems that the line "ref.faults.incrementAndGet()" at the bottom of the doGet method will never execute. Is that correct? |
| 17:09 | MarkVolkmann | IOW, some TVal for each Ref will always precede the read point. |
| 17:11 | Anniepoo | beyond terseness is there some advantage to (swap! foo myfunc) over (reset! foo (myfunc @foo)) ?? |
| 17:17 | hiredman | reset! there is a race condition |
| 17:17 | Anniepoo | ah, thanks |
| 17:17 | hiredman | well, potential |
| 17:18 | Anniepoo | reset! isn't a transaction |
| 17:18 | hiredman | so? |
| 17:18 | Lau_of_DK | Did anybody get some sweet UI's going with Java FX ? |
| 17:18 | Anniepoo | I'm restating what you said |
| 17:18 | hiredman | that is not what I said |
| 17:19 | hiredman | you are presumably trying to set foo's value to some new value dependent on the old value |
| 17:19 | rhickey | MarkVolkmann: no, another transaction could have changed the ref subsequent to this transaction starting, and there isn't enough history |
| 17:19 | Anniepoo | yes |
| 17:19 | hiredman | like using inc |
| 17:19 | Anniepoo | sure |
| 17:19 | hiredman | so (myfunc @foo) executes and you get a new value for foo |
| 17:20 | hiredman | and then the new value is written to foo |
| 17:20 | hiredman | but in that time, foo's value could have changed |
| 17:20 | Anniepoo | ok, that's what I meant |
| 17:20 | hiredman | ok, you are correct |
| 17:20 | Anniepoo | swap! is ACI - not D |
| 17:21 | Anniepoo | thanks |
| 17:24 | Fossi | hmmm. not being connected through the repl to the phone is only half as productive |
| 17:26 | Fossi | i still don't get how :state works |
| 17:27 | hiredman | for gen-class? |
| 17:27 | Fossi | yeah |
| 17:27 | hiredman | it lates you create a place to store state |
| 17:27 | Fossi | the book is having a nice example, but that so doesn't fit my rl code |
| 17:28 | Fossi | yeah, and i can (swap! (.state this) (dosomething)) |
| 17:28 | Fossi | but then, the state does not seem to be changed |
| 17:29 | Fossi | at least i get a nullpointer trying to access what i put in there in the next called method |
| 17:30 | hiredman | do you have an :init function? |
| 17:32 | Fossi | yes, as such: [[] {}] |
| 17:32 | Fossi | ups |
| 17:32 | Fossi | yes, as such: [[] (atom {})] of course |
| 17:32 | hiredman | oh |
| 17:33 | hiredman | dosomething returns a keyword or a symbol? |
| 17:33 | Fossi | (swap! (.state this) conj {:view view}) |
| 17:34 | Fossi | (log-info (:view ( .state this))) |
| 17:34 | Fossi | NPE |
| 17:34 | Fossi | in another method that is |
| 17:34 | hiredman | uh |
| 17:34 | Fossi | do i have to dereference it? |
| 17:34 | hiredman | of course |
| 17:35 | hiredman | ,(conj {} {:view 'view}) |
| 17:35 | clojurebot | {:view view} |
| 17:35 | hiredman | seems like you could just use assoc |
| 17:35 | hiredman | ,(:view (atom {:view 1})) |
| 17:35 | clojurebot | nil |
| 17:36 | Fossi | i could, but i'll prolly add a few more fields later |
| 17:36 | hiredman | ,(:view @(atom {:view 1})) |
| 17:36 | clojurebot | 1 |
| 17:36 | hiredman | ,(assoc {} :view 'view :bar 'bar) |
| 17:36 | clojurebot | {:bar bar, :view view} |
| 17:36 | Fossi | not being able to test this without deploying to the emulator really sucks :\ |
| 17:37 | Fossi | i guess making a proxied clojure api wouldn't be too hard |
| 17:38 | Fossi | ok, that helped. next problem ;) |
| 17:44 | lbj | No takers on the JavaFX question? |
| 17:47 | Anniepoo | the answer for me is no |
| 17:48 | Anniepoo | but it sounds itneresting |
| 17:48 | Anniepoo | are you doing it? |
| 17:48 | lbj | So for GUI's we've got Swing, a cut-short Qt implementation and Awt ? |
| 17:48 | Anniepoo | SWT |
| 17:48 | lbj | Anniepoo: If the answer to the above question is no, then I might |
| 17:49 | Anniepoo | I know that in general there's a feeling you shouldn't need to wrap libs |
| 17:50 | lbj | I think it was AWizzard who had encountered some un-beatable obstacle in regards to FX |
| 17:50 | Anniepoo | yah, there's a fundamental problem with Clojure on android |
| 17:51 | lbj | I wasn't thinking android though, just for regular desktop apps |
| 17:51 | Anniepoo | the sandbox won't let dynamic compile happen |
| 17:51 | lbj | Swing always seems laggy somehow |
| 17:51 | hiredman | the prefered gui kit in #java seems be swing, surprisingly enough |
| 17:51 | hiredman | Anniepoo: I don't think it's the sandbox |
| 17:51 | Anniepoo | it's the bytecode verifier |
| 17:52 | hiredman | the asm library clojure uses emits jvm bytecode, but android runs on some other virtual machine |
| 17:52 | Anniepoo | this per George from the baclojure group - his day job is in Android - and a question he asked rhickey when he spoke at the not=-Javaone thing |
| 17:53 | Anniepoo | ok, believe hiredman, not me |
| 17:53 | Anniepoo | I could be misunderstanding |
| 17:53 | hiredman | *shrug* |
| 17:54 | hiredman | I can imagine the dalvik byte code verifier would choke on jvm byte code :P |
| 17:59 | Fossi | clojure works on android though |
| 17:59 | hiredman | but not eval |
| 17:59 | Fossi | it's only really slow for dynamic stuff |
| 17:59 | hiredman | oh |
| 18:00 | Fossi | and slow for reflection and functional programming as is |
| 18:00 | Fossi | somebody used the dalvik compiler to compile the bytecode realtime |
| 18:00 | Fossi | by converting it with itself to run on the phone |
| 18:00 | hiredman | yeah, so what happens is the jvm byte code is written to a file, then the translation tool is run, which turns jvm byte code into dalvik byte code then it loads the dalvik byte code |
| 18:01 | Fossi | which is slow in the first place |
| 18:01 | Fossi | but still, it *works* ;) |
| 18:02 | hiredman | I don't think there is a "dalvik compiler" just a tool that transforms the bytecode |
| 18:02 | Fossi | yeah, well, same thing really pretty much |
| 18:02 | hiredman | altering the eclipse java compiler to emit dalvik byte code might be interesting |
| 18:02 | Fossi | still wwouldn't solve the clojure problem though |
| 18:02 | hiredman | since ejc is written in java |
| 18:03 | Fossi | somebody spotted an asm version on the phone as well |
| 18:03 | Fossi | would be much more promising :) |
| 18:04 | Fossi | then again, i don't care too much about eval and such. i'm glad i can write my 'static' bytecode in clojure |
| 18:06 | hiredman | http://stackoverflow.com/questions/935103/how-do-i-execute-dalvik-op-codes |
| 18:06 | hiredman | answer is "You cannot" |
| 18:21 | Fossi | porting java to clojure is more annoying than i thought |
| 18:22 | Fossi | but finally, it's 'running'. a black opengl screen :) |
| 18:24 | lbj | Fossi, had a look at JMonkey ? |
| 18:26 | Fossi | i searched around, but didn't find any engine that had explicit android support |
| 18:26 | lbj | Argh, forgot about the Android angle :) |
| 18:26 | lbj | Hit me back when you find a way to execute on the iphone |
| 18:27 | Fossi | :) |
| 18:27 | Fossi | i guess somebody will prolly do dual boot android at some point |
| 18:27 | lbj | Probably |
| 18:28 | Fossi | and i guess you could use clojure on jailbreaked iphones with some shitty jvm and no hardware support |
| 18:28 | Fossi | but that's not so interesting/useful :) |
| 18:28 | Fossi | i guess since i want to do more gl and clojure i'll just roll my own |
| 18:29 | Fossi | my first project does not have big requirements anyway |
| 18:29 | Fossi | 2d with a little isometric should be sufficient |
| 18:29 | Fossi | and maybe some candy effects. maybe a particle system or two |
| 18:29 | lbj | Have fun, paste link to Github when done :) |
| 18:30 | Fossi | will do :) |
| 18:31 | lbj | Good night all |
| 18:31 | Fossi | n8 |
| 19:43 | mebaran151 | java.util.Timer doesn't seem to like my proxy object: how do I directly subclass |
| 19:46 | hiredman | mebaran151: you're proxy'ing TimerTask? |
| 19:46 | hiredman | I think the best advice for Timer is to use a ScheduledThreadpoolExecutor instead |
| 19:48 | rhickey | ,(.schedule (java.util.Timer.) (proxy [java.util.TimerTask] [] (run [] (prn "Hello World"))) (long 500)) |
| 19:48 | clojurebot | java.lang.RuntimeException: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers) |
| 19:48 | hiredman | :P |
| 19:48 | hiredman | but back when I used Timer proxy just worked |
| 19:49 | mebaran151 | hiredman, I was trying |
| 19:49 | rhickey | what I posted up should work |
| 19:49 | rhickey | does it? |
| 19:49 | mebaran151 | the timer class doesn't seem to recognize that method |
| 19:50 | mebaran151 | says it can't find a matching method schedule |
| 19:50 | hiredman | http://github.com/hiredman/clojurebot/blob/52a02ce8dae22034444fa42e6c2f8f4bb9b986b0/hiredman/schedule.clj is a bit of a wrper around scheduled threadpoolexec |
| 19:50 | rhickey | exactly what I posted? |
| 19:50 | hiredman | mebaran151: pastbin |
| 19:50 | hiredman | lisppaste8: url? |
| 19:50 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 19:50 | mebaran151 | rhickey, I'm testing yours now |
| 19:52 | mebaran151 | I think it pasted |
| 19:53 | lisppaste8 | mebaran151 pasted "TimerTask?" at http://paste.lisp.org/display/84193 |
| 19:53 | hiredman | yeah, you are missing the (long …) |
| 19:54 | mebaran151 | oh it won't make the cast for me |
| 19:54 | mebaran151 | I see |
| 19:54 | mebaran151 | but isn't current time already long |
| 19:54 | mebaran151 | oh, but I'm used period there, nvm |
| 19:55 | mebaran151 | thanks all |
| 19:55 | mebaran151 | I would have thought that the JVM would be smart enough to make lossless casts for me |
| 20:09 | fsm | Image quality getting better: http://tu.be/graphics/8ball.jpg |
| 22:26 | liron_ | question.. why do we have to call (shutdown-agents) in order to terminate a script that uses agents? |
| 22:45 | Raynes | Oh noes! A lispers worst nightmare... Mismatched parentheses! |
| 23:07 | mebaran151 | setting java -Xmx should set the largest maximum memory a java app can use right? |