2011-10-12
| 01:20 | qed | He had to modem in to the agency and say that there was an emergency and that he was posting an e-note on a colleague's TP asking her to cover his calls for the rest of the week because he'd be out of contact for several days due to this emergency. He had to put an audio message on his answering device saying that starting that afternoon he was going to be unreachable for several days. |
| 01:21 | qed | Expressivity is nebulous. |
| 01:26 | pdk | i'm reading proust in 2 lines |
| 01:27 | jli | well then |
| 01:30 | qed | pdk: I don't follow |
| 01:31 | jli | not sure how I FEEL about this http://www.kk.org/thetechnium/archives/2011/04/born_digital.php |
| 01:32 | qed | jli: your emphasis on "FEEL" worries me |
| 01:32 | qed | I ranted on HN the other day about the reactions to Dart -- so superficial and full of emotion |
| 01:33 | qed | "feel" is a recipe for poor decision-making |
| 01:33 | qed | unless it is well-tempered by reality |
| 01:34 | jli | what were the reactions? something along the lines of "WHY BOTHER WE HAVE JAVASCRIPT"? |
| 01:35 | qed | jli: to respond to that link: I think the only reason we wonder is because we're secretly afraid we're dinosaurs |
| 01:35 | qed | and the truth is: we are. |
| 01:36 | qed | by the same token, we're just getting warmed up |
| 01:36 | ivan__ | im sure this arguement is made every generation |
| 01:36 | ivan__ | about different stuff |
| 01:37 | qed | ivan__: indeed. it is an age-old argument. |
| 01:37 | ivan__ | i rofl when people say that creativity is dying |
| 01:37 | jli | I accept being a 20-something grouchy old man |
| 01:37 | qed | jli: if you were truly grouchy you couldn't type that with confidence |
| 01:37 | qed | clearly you *aren't* a grouchy old man |
| 01:38 | qed | ivan__: Books! Print is dead! Long live the web! (btw, I like physical copies of books, do you have XYZ?) |
| 01:38 | qed | (I'll pay for it) |
| 01:39 | ivan__ | they had it so good in the olden days, what with much lower life expectancies, no real medical knowledge, having to hand wash clothes etc etc |
| 01:40 | qed | Anyway, this rant brought to you by: people's reaction to Dart, the sorry state of communication in our communities, and lack of personal responsibility |
| 01:40 | qed | ivan__: heh -- I MISS OUTHOUSES! OH BOY WE HAD IT SO GOOD WITHOUT PLUMBING! |
| 01:41 | ivan__ | how about lead piping :) |
| 01:41 | jli | temperments are remarkably robust |
| 01:42 | todun | srid: ok. |
| 01:47 | todun | brehaut: require what? |
| 02:15 | lnostdal | i'm not sure where to begin looking, but perhaps someone already knows how to go about getting Meta-Point (Alt-. or "slime-edit-definition") to lead to the actual source files of some dependency and not just the (read-only) contents of .jar files? |
| 02:42 | tomoj | lnostdal: I think you want checkout dependencies? |
| 02:43 | tomoj | e.g. in leiningen create a checkouts directory in the root of the project and put symlinks in it to other leiningen projects you depend on |
| 02:43 | todun | finally got emacs for clojure up and running. |
| 02:43 | todun | thanks for all the help. |
| 02:44 | tomoj | then M-. will go to the source file in the other project because lein has put the symlinked code on the classpath |
| 02:45 | lnostdal | cool, will try that, tomoj .. thanks :) |
| 02:45 | clojurebot | thanks for your suggestion, but as usual it is irrelevant |
| 02:45 | tomoj | note you still need to explicitly include the dep in your project.clj |
| 02:45 | lnostdal | clojurebot, be quiet you |
| 02:45 | clojurebot | I don't understand. |
| 02:45 | lnostdal | ok |
| 02:45 | amalloy | (inc clojurebot) |
| 02:45 | lazybot | ⟹ 5 |
| 02:46 | todun | I'm following the steps for newbies at http://dev.clojure.org/display/doc/Getting+Started |
| 02:46 | todun | I'm trying to do https://github.com/relevance/labrepl |
| 02:46 | todun | do I just download it into some folder then |
| 02:46 | todun | at the repl do lein ? |
| 02:47 | tomoj | seems strange that the readme doesn't say how to use it |
| 02:48 | todun | tomoj: I didn't quite follow the readme. sorry about that. |
| 02:49 | todun | tomoj: all I really see is that I should run the test with lein test...not sure what tests or why |
| 02:50 | tomoj | no clue, sorry, never used it |
| 02:51 | tomoj | just seems like a funny readme for a project for people new to clojure.. :) |
| 02:51 | tomoj | maybe they're supposed to find it some other way? |
| 02:51 | todun | tomoj: oh ok. I linked to it from the newbie page I listed above. |
| 02:52 | tomoj | http://foognostic.net/labrepl-summary/ |
| 02:52 | tomoj | looks like there are some working instructions there |
| 02:52 | todun | tomoj: thanks. checking it out now.. |
| 02:52 | tomoj | of course, if you're set up with swank.. :/ |
| 02:53 | todun | tomoj: swank...how do I do so, what can it do for me? |
| 02:53 | todun | I just finished with leiningen, emacs start kit |
| 02:53 | tomoj | hmm |
| 02:53 | todun | I dont mind throwing in swank in there if it's useful |
| 02:53 | tomoj | have you got a clojure repl inside emacs? |
| 02:54 | todun | tomoj: how do I check if I do? |
| 02:55 | tomoj | uhh, dunno |
| 02:55 | tomoj | you'd have to have set something up |
| 02:55 | tomoj | dunno what you've done already |
| 02:55 | todun | tomoj: ok. |
| 02:56 | tomoj | did you set up marmalade like it says at http://dev.clojure.org/display/doc/Getting+Started+with+Emacs ? |
| 02:56 | todun | yes |
| 02:56 | tomoj | think you should be able to install slime, slime-repl, clojure-mode from it |
| 02:56 | todun | ok. how so? |
| 02:57 | todun | to what end? |
| 02:57 | ibdknox | todun: what editor do you normally use? I'm not sure that trying to learn emacs while also trying to learn Clojure is a wise decision |
| 02:57 | tomoj | https://github.com/technomancy/swank-clojure |
| 02:57 | tomoj | readme here is helpful too |
| 02:59 | todun | ibdknox: I'm trying to get more comfortable with emacs. so I'll be using emacs. Everything about emacs I'm familiar with, it's just that using M-x as a way to install stuff is so cool and new to me that I'm curious to know more. |
| 02:59 | todun | anyways, using it for typing and such I'm familiar with |
| 02:59 | ibdknox | righto |
| 03:00 | tomoj | slime is an emacs package for working with lisps |
| 03:01 | tomoj | swank-clojure provides clojure support, the readme there describes setup |
| 03:01 | tomoj | just need to `M-x package-install` slime-repl and clojure-mode I think |
| 03:01 | tomoj | plus the lein plugin in the readme there |
| 03:02 | tomoj | maybe clojure-mode depends on slime now, dunno.. |
| 03:03 | todun | tomoj: it's installing with lein now.. |
| 03:04 | tomoj | so I imagine script/swank in labrepl is what you want, then M-x slime-connect to get into the repl |
| 03:04 | todun | tomoj: what do I do after I start the swine sever? |
| 03:04 | tomoj | or maybe you can just jack in to labrepl..? |
| 03:04 | todun | tomoj: when I try to start the swine server, I get the following error: |
| 03:04 | todun | Debugger entered--Lisp error: (error "Could not start swank server: Couldn't find project.clj, which is needed for jack-in |
| 03:04 | todun | ") |
| 03:04 | todun | signal(error ("Could not start swank server: Couldn't find project.clj, which is needed for jack-in\n")) |
| 03:04 | todun | error("Could not start swank server: %s" "Couldn't find project.clj, which is needed for jack-in\n") |
| 03:04 | todun | clojure-jack-in-sentinel(#<process swank> "exited abnormally with code 1\n") |
| 03:04 | amalloy | heehee. swine server. a lovely combination of swank/slime |
| 03:05 | todun | oops! sorry people, I should have pastebined that |
| 03:05 | todun | amalloy: haha. actually that was a typo. but it's all good. |
| 03:05 | tomoj | hmm, I dunno anything about jack-in.. |
| 03:06 | tomoj | if you're running script/swank in labrepl I think you'd want to M-x slime-connect, not use jack-in. if you're jacking in I guess you need to do it while visiting a file in labrepl's project directory |
| 03:08 | todun | tomoj: I don't follow. I'm using the instructions at https://github.com/technomancy/swank-clojure |
| 03:09 | todun | tomoj: doing it with your suggestion, where do I get to labrepl for instance? |
| 03:09 | tomoj | that is, you're running M-x clojure-jack-in ? |
| 03:10 | todun | yes |
| 03:10 | tomoj | hmm |
| 03:11 | tomoj | don't know how that would work |
| 03:11 | todun | tomoj: dont know what it does. you're suggesting I try labrepl. |
| 03:11 | todun | how so? |
| 03:12 | tomoj | the only easy way I see is to download labrepl and run script/swank |
| 03:12 | tomoj | then in emacs do `M-x slime-connect` instead of `M-x clojure-jack-in` |
| 03:13 | tomoj | just curious, what platform are you on? |
| 03:14 | todun | osx |
| 03:14 | tomoj | whew |
| 03:14 | todun | tomoj: I should follow the instructions here http://dev.clojure.org/display/doc/Getting+Started+with+Emacs ? |
| 03:14 | todun | tomoj: whew? |
| 03:15 | tomoj | all of the instructions there up to "... install clojure-mode by pressing M-x package-install and choosing clojure-mode." |
| 03:16 | tomoj | then download labrepl and run script/swank inside it, and M-x slime-connect from emacs |
| 03:16 | nybbles | anyone know how i can get sort and floor functions? i gather than i have to install math.numeric-tower, but not sure how to do that using leiningen |
| 03:18 | todun | tomoj: downloading labrepl by zip? if so, then what? https://github.com/relevance/labrepl |
| 03:19 | ibdknox | ,(doc sort) |
| 03:19 | clojurebot | "([coll] [comp coll]); Returns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator." |
| 03:19 | ibdknox | ,(doc floor) |
| 03:19 | clojurebot | Pardon? |
| 03:19 | ibdknox | ,(Math/floor 3.12434545) |
| 03:19 | clojurebot | 3.0 |
| 03:19 | ibdknox | nybbles: ^ |
| 03:19 | tomoj | todun: do you know how to use the terminal? |
| 03:20 | ibdknox | nybbles: you don't need anything special for sort or floor |
| 03:20 | tomoj | ,*clojure-version* |
| 03:20 | clojurebot | {:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"} |
| 03:21 | tomoj | ,(require 'clojure.math.numeric-tower) |
| 03:21 | clojurebot | #<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate clojure/math/numeric_tower__init.class or clojure/math/numeric_tower.clj on classpath: > |
| 03:21 | nybbles | ibdknox: ahhhh okay i'll try it out |
| 03:21 | tomoj | the floor there just behaves differently than the regular one? |
| 03:22 | ibdknox | huh? |
| 03:22 | todun | tomoj: yes. I'm using it now. |
| 03:22 | ibdknox | how can floor behave differently? |
| 03:22 | todun | tomoj: but I'm no terminal guru or anything like that. |
| 03:22 | tomoj | todun: ok, you just need to unzip labrepl, cd into it, and you will find a script/swank inside it, run that |
| 03:23 | todun | tomoj: ok. will do. apprise you of my progress.. |
| 03:25 | todun | tomoj: all I did was double click it. will that give the same effect? |
| 03:27 | tomoj | maybe.. I don't remember osx very well |
| 03:27 | tomoj | if it works, http://localhost:8080/ should have clojure stuff on it |
| 03:28 | todun | tomoj: I ask because I get this error when I run it from terminal like so |
| 03:28 | todun | http://pastebin.com/S4kvEg49 |
| 03:28 | todun | tomoj: localhost is error for me |
| 03:29 | tomoj | run `lein deps` in labrepl first |
| 03:31 | todun | tomoj: but I dont have labrepl, or I thought I didn't hence all this. |
| 03:31 | tomoj | hmm |
| 03:32 | tomoj | where'd script/swank come from? |
| 03:32 | ibdknox | todun: he means in the project directory |
| 03:32 | todun | tomoj: the download of labrepl |
| 03:32 | tomoj | right.. where you typed `script/swank` type `lein deps` first |
| 03:33 | todun | ibdknox: oh ok. |
| 03:33 | todun | tomoj: k.. |
| 03:33 | todun | downloading.. |
| 03:34 | todun | then do 'script/swank' ? |
| 03:34 | tomoj | yep |
| 03:35 | todun | uhm ok. nice. it started another repl. |
| 03:35 | todun | thanks guys. |
| 03:35 | todun | tomoj: what does this do for me? how does it differ from lein's repl? |
| 03:36 | todun | which should I use now that I have this setup? |
| 03:36 | tomoj | by "lein's repl" do you mean something you got by running `lein repl`? |
| 03:37 | tomoj | script/swank just starts up labrepl, so you can get to it at http://localhost:8080/ and connect from emacs with M-x slime-connect |
| 03:37 | todun | tomoj: yes |
| 03:37 | tomoj | normally you can just jack-in to your project or run `lein swank` in the project directory |
| 03:37 | tomoj | once you start building your own projects |
| 03:38 | Blkt | good morning everyone |
| 03:38 | tomoj | it differs from `lein repl` because you can connect to it in slime to have the repl in emacs |
| 03:39 | tomoj | then you get code completion and lookup and macroexpansion etc in emacs too |
| 03:39 | tomoj | as opposed to trying to balance parentheses on a repl in some terminal |
| 03:40 | todun | tomoj: I tried M-x, slime-connect...that didn't work. |
| 03:41 | todun | tomoj: it seems you're saying that I can use emacs to write my code then M-x slime-connect to sort of "compile" it? |
| 03:41 | tomoj | when you ran `script/swank`, did it say "Starting swank..." |
| 03:41 | tomoj | and perhaps "Connection opened on local port 4005" ? |
| 03:42 | tomoj | ..or did it just give you a repl in the terminal there? |
| 03:42 | tomoj | I guess it starts a repl in the terminal too |
| 03:44 | tomoj | M-x slime-connect hooks slime up to a running jvm with the project's code (in this case, the labrepl code), so you get a repl inside emacs |
| 03:44 | tomoj | then you can also load files you're working on in that running jvm once connected, with C-c C-k |
| 03:44 | tomoj | among other things, I think summarized in the swank-clojure readme |
| 03:44 | ejackson | morning all |
| 03:44 | todun | tomoj: I said that, yes. Clojure 1.3.0-beta1 Starting swank... |
| 03:45 | todun | tomoj: then the repl |
| 03:45 | todun | in terminal |
| 03:46 | tomoj | hrmm |
| 03:46 | todun | tomoj: ok. now I have the option of doing M-x, clojure-jack-in |
| 03:47 | todun | should I do it? |
| 03:47 | tomoj | well |
| 03:47 | tomoj | you could |
| 03:47 | tomoj | do it starting from a file in the labrepl project directory |
| 03:47 | tomoj | the problem is, labrepl has some extra startup code sitting off in script/run.clj |
| 03:48 | tomoj | this is what script/swank is supposed to run, but yours apparently fails to start swank |
| 03:48 | tomoj | if you C-x C-f to, say, project.clj in the labrepl directory, and run M-x clojure-jack-in, it should start swank and give you a repl |
| 03:49 | todun | tomoj: oh ok. my next question answered. don't delete the zip folder downloaded from labrepl, it will break everything, yes? |
| 03:49 | tomoj | yeah you need that to use labrepl |
| 03:51 | todun | does it matter if I move the dir i dowloaded? |
| 03:52 | tomoj | you can move it, but don't move it while you're connected with jack-in or slime-connect or editing files in it |
| 03:54 | todun | tomoj: dont have slime-connect in emacs just jacked-in |
| 03:55 | tomoj | ah, right |
| 03:55 | todun | tomoj: when I do jack-in I get a similar error like before... |
| 03:55 | tomoj | jack-in sends slime over the wire |
| 03:55 | todun | http://pastebin.com/TSagcJr0 |
| 03:55 | tomoj | you could do M-x package-install slime-repl |
| 03:55 | tomoj | then you should have M-x slime-connect |
| 03:55 | tomoj | dunno how to get jack-in working, I never use it |
| 03:56 | todun | tomoj: I have slime-(stuff) not connect though |
| 03:56 | tomoj | weird |
| 03:56 | todun | tomoj: oh. so I dont need jack-in |
| 03:56 | todun | just slime? |
| 03:56 | tomoj | jack-in is the currently recommended method I think |
| 03:56 | tomoj | I just do it the old way because I haven't figured jack-in out yet |
| 03:57 | todun | tomoj: what is this old way, if you dont mind my asking(I just want to get this up and running so I can write beautiful clojure)? |
| 03:57 | tomoj | the old way, you install slime-repl (and slime, slime-repl depends on slime, so you can just install slime-repl) with package-install, run `lein swank` (`script/swank` for labrepl), and M-x slime-connect |
| 04:00 | todun | tomoj: ok, trying that now.. |
| 04:00 | todun | btw, all I need is the script/swank dir, right? |
| 04:01 | todun | that is to say, I can get rid of everything else.... |
| 04:04 | tomoj | no |
| 04:05 | tomoj | certainly some of the stuff in there you don't need, but just keep it all |
| 04:08 | todun | tomoj: ok. will try all you said and let you know asap |
| 04:11 | todun | tomoj: when I launch emacs, must I be in script/ ? |
| 04:13 | tomoj | doesn't matter |
| 04:19 | todun | k. I'm guessing because of the setup at path, yes? |
| 04:22 | tomoj | dunno what you mean |
| 04:22 | tomoj | emacs is happy to run from anywhere |
| 04:23 | tomoj | it's common to only run one emacs |
| 04:28 | amalloy | chouser: i see you finished all of our dang problems. mission accomplished? |
| 04:30 | todun | tomoj: ok. |
| 04:31 | todun | tomoj: Ok I tried the following : install slime-repl (and slime, slime-repl depends on slime, so you can just install slime repl) with package-install, run `lein swank` (`script/swank` for labrepl), and M-x slime-connect |
| 04:31 | todun | install slime-repl works. |
| 04:31 | todun | lein-swank says... |
| 04:31 | todun | Couldn't find project.clj, which is needed for swank |
| 04:31 | todun | that was step 2. |
| 04:32 | todun | step 3 is M-x slime-connect |
| 04:32 | tomoj | if you want to run labrepl, run `script/swank` in the labrepl dir |
| 04:32 | todun | it asks for port localhost etc, then says... |
| 04:32 | tomoj | don't run `lein swank` |
| 04:32 | todun | make client process failed: connection refused, :name, SLIME Lisp, :buffer, nil, :host, 127.0.0.1, :service,\ |
| 04:32 | todun | 4005, :nowait, nil |
| 04:33 | todun | tomoj: oh ok. why not though? |
| 04:33 | tomoj | it fails to run extra labrepl startup code |
| 04:33 | tomoj | which will make things easier when using labrepl |
| 04:35 | todun | tomoj: that's 'lein swank' I presume. |
| 04:35 | todun | tomoj: as per the slime-connect issue, what's up with that error? |
| 04:36 | tomoj | you didn't start swank |
| 04:37 | todun | I thought I did as per your instructions. |
| 04:37 | tomoj | you either have to run script/swank in the labrepl dir or `lein swank` in any lein project dir to start swank first |
| 04:37 | tomoj | when it said "Couldn't find project.clj, which is needed for swank", it meant that it failed to start, I believe |
| 04:38 | tomoj | probably because you weren't in a project directory when running `lein swank` |
| 04:39 | todun | tomoj: what is a project dir then? I have a folder that I've been dumping all the stuff into. |
| 04:39 | tomoj | the labrepl zip you downloaded contained the labrepl project dir |
| 04:40 | tomoj | if you cd into it, and run `script/swank`, it should start swank for the labrepl projec |
| 04:40 | tomoj | a project dir is just a dir that contains a project.clj file |
| 04:46 | todun | tomoj: ok will try that. thanks. |
| 05:23 | eiro | hello |
| 05:25 | eiro | (line-seq (slurp "http://khatar.phear.org")) doesn't work because slup returns a string, not a reader |
| 05:25 | eiro | any function to return http flow line by line ? |
| 05:25 | raek | eiro: you probably want to use clojure.java.io/reader here |
| 05:26 | raek | slurp is an alternative to line-seq + reader for the case when you want one big string |
| 05:28 | eiro | actually i don't want a big stream but i thought everything was lazy so slurp read my http flow line by line |
| 05:28 | eiro | i investigate reader |
| 05:29 | raek | line-seq reads lines lazilly |
| 05:29 | raek | in clojure only seqs are lazy so slurp has to be strict since it returns a (java) string |
| 05:31 | raek | so to print each line in the stream: (let [stream (reader url)] (doseq [line (line-seq stream)] (println line)) (.close stream)) |
| 05:31 | raek | the (let [x ...] ... (.close x)) thing can be replaced by (with-open [x ...] ...) |
| 05:32 | raek | (which additionally makes sure that .close is called even when an exception is thrown) |
| 05:44 | eiro | i tried slurp* from contrib.io but it doesn't work |
| 05:44 | eiro | it seems i have a classpath pb: i can't figure out where contrib is installed :) |
| 05:46 | raek | eiro: you don't need contrib for this. the stuff in contrib.io became clojure.java.io in clojure 1.2 |
| 05:46 | raek | and slurp is now in clojure.core |
| 05:46 | eiro | slurp* isn't :) |
| 05:46 | raek | eiro: http://clojuredocs.org/clojure_core/clojure.java.io |
| 05:47 | raek | eiro: what was the difference from slurp? |
| 05:47 | raek | some functions was refactored in the process. the "new way" is the recommended one |
| 05:48 | eiro | raek, it seems to me that slup returns a string when slurp* returns a "stream" |
| 05:48 | eiro | ok so with-open is my friend |
| 05:48 | eiro | i want to fix my classpath pb anyway :) |
| 05:48 | raek | eiro: ah. originally clojure.core only accepted a filename as a string as its argument |
| 05:48 | raek | but since clojure 1.2 it calls clojure.io.reader to open the stream |
| 05:49 | eiro | oh |
| 05:49 | eiro | ok |
| 05:49 | raek | so it accepts streams just like clojure.contrib.io/slurp* |
| 05:49 | raek | slurp* accepted a stream. it did not return one |
| 05:50 | raek | eiro: for the classpath problems, use a build tool like Leiningen to manage dependency libraries (e.g. contrib) and the classpath for you |
| 05:51 | raek | if you just want to learn the language, you don't gain much by managing the classpath yourself |
| 05:55 | eiro | it seems i'll be hooked to closure soon :) |
| 05:58 | raek | eiro: http://pastebin.com/xKzVnmTX |
| 06:00 | eiro | thansk |
| 06:00 | eiro | raek, i use lein but it's boring when you have lot of scripts you want to launch |
| 06:01 | eiro | (or i missed something) |
| 06:01 | eiro | you have to file project.clj:main and test/script1.clj-main constantly |
| 06:03 | eiro | it seems i just have to put a jar in $CLOJURE_HOME :) |
| 06:15 | dbushenko | what's the most idiomatic way to write to file with clojure 1.3? |
| 06:16 | clgv | dbushenko: clojure.java.io |
| 06:17 | dbushenko | are there any examples? bcs I just don't understand this API |
| 06:19 | clgv | dbushenko: you can do something like (with-open [w (writer "my-file.txt)] (binding [*out* w] (print "My data text line"))) |
| 06:19 | clgv | s/txt/txt"/ |
| 06:19 | lazybot | <clgv> dbushenko: you can do something like (with-open [w (writer "my-file.txt")] (binding [*out* w] (print "My data text line"))) |
| 06:19 | dbushenko | oh, this is great! |
| 06:19 | dbushenko | and how about reading? |
| 06:19 | dbushenko | what it could look like? |
| 06:20 | clgv | humm that depends what you write. do you write text lines like above? |
| 06:20 | dbushenko | yep |
| 06:20 | dbushenko | I know about slurp |
| 06:20 | dbushenko | but how to do that with clojure.java.io? |
| 06:21 | clgv | clojure.java.io is the namespace that contains reader and writer |
| 06:22 | clgv | for reading lines you can do: (with-open [r (reader "my-file.txt")] (line-seq r)) |
| 06:22 | dbushenko | thanks! |
| 07:20 | raek | dbushenko: you need to force the whole seq inside the with-open form some how. either do the procedding there or add a doall: (with-open [r (reader "my-file.txt")] (doall (line-seq r))) |
| 07:21 | dbushenko | raek: thanks! |
| 07:22 | raek | also, reader/writer are for text. for binary data, use input-stream/output-stream. you might need to use java interop for those (see the javadoc for InputStream and OutputSteam for the methods) |
| 07:25 | raek | eiro: you can use lein run like this: "lein run some.other.namespace" |
| 07:26 | raek | eiro: sorry, that should be "lein run -m some.other.namespace" |
| 07:27 | raek | see "lein help run". it also explains how you can give the namespaces shorter aliases |
| 07:30 | todun | when I run 'lein swank' from a directory with project.clj in it, I get the following exception trace: http://pastebin.com/u6CwMWza |
| 07:30 | todun | am I doing something wrong? |
| 07:31 | raek | I think that happens when you have two versions of swank-clojure on the classpath at the same time |
| 07:31 | todun | the goal is to use emacs to write clojure. |
| 07:31 | raek | for instance one as a :dev-dependency and one as a leiningen plugin |
| 07:31 | todun | raek: oh ok. how do I remove it? |
| 07:31 | todun | raek: I first installed leiningen then emacs starter kit |
| 07:32 | todun | then I tried jack-in from emacs |
| 07:32 | todun | that didn't work |
| 07:32 | todun | then I installed labrepl |
| 07:32 | todun | then swine as per the recommendations of tomoj |
| 07:32 | raek | jack-in didn't work for a clean new project? |
| 07:32 | todun | raek: yes. hence the swine suggestion |
| 07:32 | raek | swine? |
| 07:33 | todun | raek: slime |
| 07:33 | raek | swank-clojure? |
| 07:33 | clojurebot | see swank |
| 07:33 | todun | raek: sorry. been making that mistake throughout the installation. |
| 07:33 | todun | raek: yes. swank |
| 07:33 | raek | sometimes a dependency brings in an old version of swank-clojure, and that can mess everything up |
| 07:34 | raek | todun: did you try jack-in for a clean leiningen project? |
| 07:34 | todun | raek: after all those installations, these are the steps I've taken to try to get this off the ground: -install slime-repl (and slime, slime-repl depends on slime, |
| 07:34 | todun | so you can just install slime-repl) with package-install, |
| 07:34 | todun | -run `lein swank` (`script/swank` for labrepl), |
| 07:34 | todun | and M-x slime-connect |
| 07:34 | raek | todun: also: do you want to work on your own project or someone else's? |
| 07:34 | todun | raek: on my own project. |
| 07:35 | todun | raek: if a clean project means, have I written any clojure code/script, no! I've been trying to make this work. |
| 07:36 | todun | raek: all the code I've done so far is in the repl so I can follow along the docs. will this make leiningen "unclean"? |
| 07:36 | raek | if you make a clean new project (lein new), remove everything in ~/.lein/plugins, install the swank-clojure plugin (lein plugin install swank-clojure 1.3.1) and then try jack-in, what happens? |
| 07:37 | raek | by "clean" I meant a project with no :dependencies declared in its project.clj file |
| 07:38 | raek | also, labrepl is a tutorial, I think. it will certainly not make it simpler to set up your IDE. |
| 07:39 | todun | raek, translating what you're saying to this. lein new, rm -rf ~/.lein/plugins, M-x install-package swank-clojure |
| 07:40 | todun | raek: from where in my dir should I run lein new? |
| 07:40 | todun | raek: is it from the place where I have my project.clj ? |
| 07:41 | raek | no, not M-x swank-clojure |
| 07:41 | raek | that is a deprecated elisp package that predates leiningen |
| 07:42 | raek | lein new myproject && rm -rf ~/.lein/plugins && cd myproject && lein plugin install swank-clojure 1.3.1 |
| 07:42 | raek | then C-x C-f myproject/src/myproject/core.clj |
| 07:42 | raek | then M-x clojure-jack-in |
| 07:42 | todun | raek: myproject? |
| 07:43 | raek | the name you give to the project |
| 07:43 | todun | raek: I don't have a project. Do I need one? |
| 07:43 | raek | the project is the set of source files the clojure instance will have access to and the libraries it will use |
| 07:43 | raek | yes |
| 07:43 | todun | raek: what I mean is that I'm not sure what a project means here. |
| 07:44 | todun | raek: so is it like a java project? |
| 07:44 | raek | yes, the JVM doen't really like the "current working directory" approach |
| 07:44 | todun | raek: so I cannot have a folder for all my stuff. |
| 07:44 | raek | when you use lein to start the swank server, it will make sure that the source directories and all jars of the dependencies are on the classpath |
| 07:45 | raek | well, the project is a folder |
| 07:46 | todun | raek: will it allow me to have a "workspace" then separate folders in that workspace representing separate projects? |
| 07:46 | raek | sure |
| 07:47 | raek | a project is just a directory with a project.clj file in it and some other dirs (src/, lib/, test/, etc...) |
| 07:48 | raek | you can put the project folder in any other folder you like |
| 07:48 | todun | raek: can I use lein to create a new project then? so lets say I'm in some folder, I call 'lein make-project'. will it generate all that for me? |
| 07:49 | raek | todun: yes, calling "lein new myproject" will create the myproject/ folder in the current folder |
| 07:50 | todun | raek: now the folder it creates it in will be like my "workspace", correct? |
| 07:50 | raek | I guess. that folder does not have any special meaning for Leiningen, though |
| 07:50 | todun | raek: ok. just trying to wrap my mind around this all. |
| 07:51 | raek | put in Eclipse terms, that would be the Workspace |
| 07:51 | todun | raek: I'm trying the commands now... |
| 07:51 | raek | inside the project folder, you can use "lein repl" to get a repl in the terminal |
| 07:52 | raek | that repl can access the source files in src/ and all the dependencies of the project |
| 07:53 | raek | you use swank-clojure (indirectly, if you are using jack-in) when you want a repl in Emacs |
| 07:53 | todun | raek: ok. everything done. what is and where do I do then C-x C-f myproject/src/myproject/core.clj ? |
| 07:53 | todun | raek: in emacs |
| 07:53 | todun | raek: while in the /myproject ? |
| 07:54 | raek | todun: you need to open some file that belongs to the project. myproject/src/myproject/core.clj is a good place to start |
| 07:55 | raek | when you have that file opened (assuming you did the "lein plugin instal..." step) you should be able to do "M-x clojure-jack-in" |
| 07:55 | raek | and then a repl should pop up |
| 07:56 | todun | raek: all in emacs? |
| 07:58 | todun | raek: ok. doing that in emacs. It says starting swank server... |
| 07:58 | todun | raek: do I have to do all these steps for each project I make? |
| 07:59 | todun | can I not just have one universal project with the core.clj? |
| 07:59 | raek | you need to run "lein new ..", open a file in the project and invoke clojure-jack-in, yes |
| 07:59 | todun | raek: I get error in process filter: Symbol's value as variable is void: Copying |
| 07:59 | raek | sure. I think it's pretty common to have a "scratch" project |
| 08:00 | todun | when I do jack-in |
| 08:00 | raek | todun: that probably means you have installed an incompatible slime version in emacs |
| 08:00 | raek | try to remove all slime, slime-repl, swank-clojure, slime-clj and swank-clj packages |
| 08:00 | raek | only keep clojure-mode |
| 08:01 | raek | swank-clojure comes with a compatible version which clojure-jack-in uses |
| 08:01 | todun | raek: how do I remove all those? |
| 08:01 | raek | so you don't need to install slime |
| 08:02 | raek | M-x package-list-packages |
| 08:04 | raek | then you should be able to mark a package for deletion by pressing "d", I think |
| 08:04 | raek | and then "x" to apply |
| 08:05 | raek | if you don't have any important packages installed, maybe it's simpler to just wipe ~/.emacs.d/elpa/ and reinstall clojure-mode |
| 08:07 | todun | raek: trying all that now.. |
| 08:07 | todun | raek: I have quite a few things there so I'll keep elpa |
| 08:08 | todun | so I should delete anything that has slime on it? |
| 08:08 | raek | yes |
| 08:08 | raek | and anything that mentions swank |
| 08:09 | todun | raek: I see these for slime: slime-clj 0.1.6 available Slime extensions for swank-clj |
| 08:09 | todun | slime-fuzzy 20100404 available Fuzzy symbol completion for Slime |
| 08:09 | todun | slime-ritz |
| 08:10 | todun | raek: so I move the cursor to the same line as 'slime-clj' press d and then x... |
| 08:11 | todun | emacs indicates I've selected nothing. |
| 08:12 | todun | raek: for swank, this is all I find: swank-cdt |
| 08:24 | raek | todun: if those are installed, remove them |
| 08:24 | todun | raek: yes. the d then x doesn't work for me though |
| 08:26 | jcromartie | hm, so you can't attach metadata to a ref huh |
| 08:26 | raek | I guess you can remove them from ~/.emacs.d/elpa/ manually |
| 08:26 | raek | jcromartie: alter-meta! |
| 08:26 | duck1123 | I've never had much luck deleting packages through elpa |
| 08:26 | todun | raek: in there, I have slime-20100404.1 slime-repl-20100404 |
| 08:26 | todun | delete those two folders? |
| 08:27 | raek | ok, delete those |
| 08:27 | todun | raek: ok. done. |
| 08:27 | jcromartie | interesting, thanks raek |
| 08:27 | raek | jcromartie: with-meta returns a new object, but for a ref you want to change the meat for *the* ref |
| 08:27 | jcromartie | ah ha... that makes sense |
| 08:28 | raek | todun: restart emacs and try clojure-jack-in again |
| 08:28 | jcromartie | this is perfect :) thanks |
| 08:29 | todun | raek: ok. it seems to work. I get this: ; SLIME 20100404 |
| 08:29 | todun | user> |
| 08:29 | raek | todun: congratulations! |
| 08:30 | todun | raek: how do I write clojure code |
| 08:30 | todun | I'm guessing you just run your code in that repl |
| 08:30 | raek | you can evaluate expression in the repl directly |
| 08:30 | raek | yes |
| 08:30 | raek | quickly on how to use source files: |
| 08:31 | raek | add (defn hello [] (println "Hello, world!")) below the (ns ...) line in myproject/core.clj |
| 08:31 | raek | press C-c C-k in that buffer |
| 08:32 | raek | and then C-c M-p <RET> (after this, the repl should change to myproject.core>) |
| 08:32 | raek | then you can eval (hello) in the repl |
| 08:32 | raek | when you make changes to a defn or a def, press C-M-x inside it to reload that def |
| 08:32 | raek | press C-c C-k to reload the whole file |
| 08:33 | todun | raek: I get the following error http://pastebin.com/GypgAceq |
| 08:34 | raek | todun: you accidentally copied the word "below" too |
| 08:34 | raek | press 0 to close that window |
| 08:34 | todun | raek: oops. it looked like clojure code :-P |
| 08:34 | todun | ok. closed |
| 08:35 | raek | write that in the file, not in the repl |
| 08:35 | todun | raek: but how do I get to the file? |
| 08:35 | raek | todun: change to that buffer |
| 08:35 | raek | the usual way |
| 08:36 | raek | C-x b |
| 08:36 | raek | or maybe you already have it in split screen. it depends on your emacs setup |
| 08:37 | todun | raek: ok. |
| 08:37 | todun | using C-x b gets somewhere I can type into. |
| 08:37 | todun | Ive pasted it in there. now what? |
| 08:37 | duck1123 | C-x C-b brings up a nice list |
| 08:38 | duck1123 | C-x b is faster if you know the name of the buffer |
| 08:38 | raek | todun: save the file (C-x C-s) and load it (C-c C-k) |
| 08:38 | raek | and then enter its namespace (C-c M-p <RET>) |
| 08:39 | todun | raek: I can give it any name, right? |
| 08:39 | raek | give whay any name? |
| 08:39 | todun | I'm going with one.clj |
| 08:39 | todun | it says save in path.. |
| 08:39 | raek | as long as you put it inside the src/ directory |
| 08:39 | todun | no file name? |
| 08:40 | raek | you didn't open the src/myproject/core.clj file? |
| 08:40 | Zolrath | same filename as its ending namespace |
| 08:40 | Zolrath | If the project is hellokitty and the filename is socute.clj |
| 08:40 | todun | so core.clj? |
| 08:40 | Zolrath | the namespace would be (ns hellokitty.socute) |
| 08:41 | raek | if the top of the file says (ns myproject.core) the file should be in src/myproject/core.clj |
| 08:41 | todun | this is the path I have |
| 08:41 | todun | "/src/first_project/core.clj" |
| 08:41 | raek | dots becomes slashes, hyphens become underscores |
| 08:42 | raek | ok |
| 08:42 | raek | then there should be a (ns first-project.core) in the top of that file |
| 08:42 | raek | (note the hyphen) |
| 08:43 | todun | this is the new file: |
| 08:43 | todun | (ns first_project.core) |
| 08:43 | todun | (defn hello [] (println "Hello, world!")) |
| 08:44 | Zolrath | the underscore from the file is a dash when in the namespace |
| 08:46 | todun | Zolrath: oh ok. |
| 08:46 | todun | do I overwrite core.clj? |
| 08:46 | todun | that was generated by lein |
| 08:47 | raek | todun: if that file is called src/first_project/core.clj, then yes |
| 08:47 | todun | (ns first-project.one) |
| 08:47 | todun | (defn hello [] (println "Hello, world!"))File to save in: ~/Dropbox/CLOJURE/first_project/src/first_project/one.clj |
| 08:48 | todun | sorry about that... |
| 08:48 | todun | I meant to type this. |
| 08:48 | todun | (ns first-project.one) |
| 08:48 | todun | (defn hello [] (println "Hello, world!")) |
| 08:48 | todun | File to save in: /first_project/src/first_project/one.clj |
| 08:48 | Zolrath | correct |
| 08:49 | todun | so this means in reality all I need is to save the files in /src/ |
| 08:50 | todun | just so I understand the steps: |
| 08:51 | todun | 1.) connect to swank server: M-x, clojure-jack-in |
| 08:51 | todun | 2.) C-x b to leave the repl to a place I can input my code. |
| 08:52 | todun | 3.) C-x s save the file to some place in /src/ |
| 08:52 | todun | 4.) ? |
| 08:52 | todun | 1 - 4) must I have a split screen? |
| 08:52 | todun | makes it impossible to write a full length app |
| 08:52 | raek | no, but I personally find it convenient |
| 08:52 | duck1123 | C-x C-s saves a file |
| 08:53 | raek | to split the emacs frame vertically |
| 08:53 | raek | I usually have the file I'm working on the one side and the repl on the other |
| 08:54 | todun | raek: how do I split vertically? |
| 08:54 | duck1123 | C-x 3 |
| 08:54 | raek | todun: C-c C-k to load the file. C-c M-p to make the repl be in the namespace of the file |
| 08:55 | raek | then you have a repl in the right namespace and you can evaluate code that uses the functions that you have defined in the file |
| 08:55 | duck1123 | I have (global-set-key (kbd "C-c s") 'slime-selector) so that I can hit C-c s r to get to my repl |
| 08:55 | todun | when I do C-x b to get to repl, I fall into oblivion. |
| 08:56 | todun | duck1123: sounds like a good idea. how did you set that up? |
| 08:57 | duck1123 | I have ~/.emacs.d/duck.el just pasted that there |
| 08:57 | todun | should I make mine duck.el? |
| 08:58 | duck1123 | I don't use jack in, so I also have a fn to connect to slime on 127.0.0.1/4005 that I've bound to a handy key combo |
| 08:58 | duck1123 | no, whatever your username is |
| 08:58 | todun | ok |
| 08:58 | todun | how do I find out my user name or it that of my computer? |
| 08:58 | duck1123 | you login name for the computer |
| 08:59 | duck1123 | near the end of starter kit's setup it looks for a file with your username and loads that |
| 09:03 | todun | how to un-split screens? |
| 09:04 | duck1123 | C-x 1 |
| 09:04 | duck1123 | or C-x 0 to just remove a split |
| 09:05 | todun | so there is a repl, then are namespaces and something else. |
| 09:05 | todun | how do I move through all of them? |
| 09:06 | todun | my last attempt sent me somewhere else. |
| 09:07 | duck1123 | all of your open buffers? C-x b if you want to type a name, C-x C-b if you want to pick from a list, C-x [right] if you just want to cycle |
| 09:09 | todun | duck1123: what is a name and/or name space in clojure? |
| 09:09 | todun | what is a list? |
| 09:10 | duck1123 | todun: I'm not sure I understand your question |
| 09:10 | todun | when I split the screen, I don't get the repl and I cannot switch between the split screens. |
| 09:10 | todun | you mentioned I use C-x b if I want to type a name |
| 09:10 | duck1123 | C-x [right] should allow you to cycle through the buffers |
| 09:11 | todun | I'm guessing that's the same as name space. |
| 09:11 | Fossi | todun: you want windmove |
| 09:11 | todun | I was not sure what a name space is in clojure |
| 09:11 | todun | right is the cursor? |
| 09:11 | duck1123 | each buffer has a name, if you know the buffer is "core.clj" you can start typing that to jump to it |
| 09:13 | duck1123 | by C-x C-b will bring up the list of buffers that you can choose from |
| 09:13 | todun | each buffer as in each file? |
| 09:14 | duck1123 | each open file (and some other things) each have a "tab" that emacs calls buffers |
| 09:14 | todun | Fossi: what is windmove? |
| 09:15 | todun | Fossi: where to download it from. |
| 09:15 | duck1123 | If you have the starter kit, you should be able to shift + arrow to move to other sides of the split |
| 09:15 | duck1123 | easier than C-x o |
| 09:15 | todun | Fossi: http://www.emacswiki.org/emacs/WindMove just describes. |
| 09:16 | todun | duck1123: you mean the app version? |
| 09:16 | duck1123 | are you using emacs in a terminal? |
| 09:16 | todun | yes |
| 09:17 | duck1123 | If so, shift + arrow might not work |
| 09:17 | duck1123 | C-x o it is then |
| 09:17 | Fossi | ah, okay |
| 09:19 | todun | I'm perfectly willing to try the app |
| 09:19 | todun | in fact I'm there now. shift arrow sets a mark |
| 09:20 | duck1123 | Ok, if you have windmove, that binds to windmove down. It's part of the v1 of starter kit, so I don't know where you get it |
| 09:21 | todun | duck1123: I did 24 nightly as suggested by raek |
| 09:21 | todun | will this give me windmove? |
| 09:22 | todun | also, the split is always between one name-space and another. |
| 09:22 | duck1123 | couldn't say. I'm still on 23.2.1 and starter-kit v1 |
| 09:22 | todun | so I do C-x 2 when I'm in clooj.clj. I get two windows of this |
| 09:23 | todun | duck1123: how do you do it with your version? |
| 09:23 | duck1123 | now you can take one of those sides an switch to a different buffer |
| 09:24 | todun | how do I switch between split screens? |
| 09:24 | duck1123 | todun: I just delete my existing ~/.emacs.d and then checkout the starter kit to that location. I believe things may have changed with the newer verson |
| 09:25 | duck1123 | M-x next-buffer or C-x <right> to cycle |
| 09:26 | raek | todun: with emacs-starter-kit, use Shift + arrow key |
| 09:26 | duck1123 | sorry, raek's right |
| 09:27 | duck1123 | C-x o if you don't have windmove or you're in a terminal |
| 09:27 | todun | shift arrow-key doesn't work for me. |
| 09:28 | todun | also, I only seem to be switching between scratch, GNU emacs, Completions, one.clj |
| 09:28 | todun | using C-x left/right arrow keys |
| 09:29 | duck1123 | Those are probably the only files you have open. C-x C-f to open a new file |
| 09:29 | todun | duck1123: but how do I switch to the repl? |
| 09:30 | duck1123 | Try M-x clojure-jack-in or start swank and M-x slime-connect |
| 09:31 | duck1123 | Personally, I prefer the latter because I always have a screen session running in Guake. |
| 09:32 | todun | duck1123: had to remove slime because it was messign with jack-in |
| 09:32 | todun | *messing |
| 09:32 | raek | todun: actually, you can have slime installed. it's just that you must have the right version |
| 09:32 | raek | which can be tricky |
| 09:33 | todun | raek: ok. at this point I just want to understand all this so I can begin developing like a clojurian! |
| 09:33 | duck1123 | I have only slime and slime-repl installed. Some of the other slime* packages cause me problems |
| 09:34 | todun | so I have it such that there are two screens. one with the repl, the other with the .clj |
| 09:34 | todun | now what? |
| 09:35 | duck1123 | code in the clj file. C-c C-k to load it, C-c M-p to set the namespace of the repl, run the function |
| 09:37 | todun | raek: doing C-c C-k to load the file. C-c M-p to make the repl be in the namespace of the file doesn't make the repl in my namespace...or am i missing something? |
| 09:39 | duck1123 | if your point is in the file, C-c M-p should populate the namespace, otherwise you might need to type it. This assumes you're connected, of course |
| 09:40 | duck1123 | And if you haven't required the namespace in any way, C-c M-p won't work. C-c C-k in that file first and you'll be all set |
| 09:40 | raek | todun: what duck1123 said. When you press C-c M-p it will diplay the namespace of the file in the minibuffer. press return to accept it. |
| 09:40 | todun | duck1123: what is a point ? |
| 09:41 | duck1123 | your cursor |
| 09:41 | todun | ok. yes I'm connected. |
| 09:41 | duck1123 | A lot of emacs stuff uses it's own names for things. |
| 09:41 | todun | required the namespace? |
| 09:42 | todun | C-c C-k === Cntrl + c Cntrl + k ? |
| 09:42 | duck1123 | yes, do that in the file |
| 09:42 | todun | C-c M-p == Cntrl + c Meta + p ? |
| 09:43 | duck1123 | Meta is either alt+p or esc p. |
| 09:44 | todun | duck1123: how to make alt the meta? |
| 09:44 | todun | Cntrl + c doesn't work for me. it instead puts in the character c and does nothing. |
| 09:45 | raek | todun: "meta" is the name emacs uses for the key that is called "alt" on PCs |
| 09:45 | todun | ok. can you change the meta ? |
| 09:45 | todun | or you're stuck with esc? |
| 09:46 | duck1123 | If emacs accepted the C-c, you should see "C - c -" at the bottom left |
| 09:46 | raek | todun: you can't use the alt key? |
| 09:46 | lucian | what's the standard for clojure package management (like python's pip, or ruby's gems) |
| 09:46 | todun | raek: yes. my meta is esc |
| 09:46 | raek | todun: you can use both |
| 09:47 | duck1123 | most terminals won't send your alt commands, so you're stuck with esc. |
| 09:47 | tdrgabi | lucian: leiningen |
| 09:47 | todun | raek: just tried |
| 09:47 | todun | didn't work |
| 09:47 | raek | lucian: packages = maven artifacts. build tools to make packages: Leiningen, Cake or Maven: repository: Clojars and Maven central |
| 09:48 | duck1123 | I've gotten to the habit of always using esc w for kill-ring-save. I've been bitten by OSX to many times. Want to copy text and end up closing the window |
| 09:48 | raek | well, you use the build tools to "consume" packages too |
| 09:48 | todun | C-c doesn't seem to be working for me. |
| 09:49 | raek | lucian: https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md |
| 09:49 | duck1123 | C-c doesn't do anything on it's own, It's a prefix for multiple key commands |
| 09:50 | lucian | raek: hmm. is there a way to install things system-wide? |
| 09:50 | lucian | thanks raek tdrgabi |
| 09:51 | duck1123 | lucian: it's really not encouraged |
| 09:51 | raek | lucian: cake has a "global project" which kind of works like that |
| 09:51 | lucian | duck1123: i know, but i want to do it anyway |
| 09:51 | lucian | i'd rather not make a project just for playing around with things |
| 09:51 | raek | with lein you need to make a "scratch project" |
| 09:52 | raek | there's also Cljr |
| 09:52 | lucian | right, i'll have a look |
| 09:53 | raek | lucian: https://github.com/liebke/cljr |
| 09:53 | lucian | raek: ah, awesome. precisely what i want |
| 09:53 | todun | got C-c M-p to work. it displays: Package: first-project.one |
| 09:53 | raek | todun: press return |
| 09:54 | todun | raek: I see a bunch of files. |
| 09:57 | todun | perhaps I should get cljr? |
| 09:58 | todun | will this help a newbie? |
| 09:58 | clgv | todun: you could try eclipse with ccw or similar plugin for netbeans ;) |
| 09:58 | duck1123 | perhaps in the short term, but if you're serious about clojure, you're going to need to know lein/maven/cake anyway |
| 09:59 | todun | clgv: ok. try that. but sine I've gone down this wabbit hole, might as well finish.. |
| 09:59 | xkb | hi #clojure |
| 10:00 | xkb | I am trying to get the first 100 entries from a stream. I get the stream trough async-http: (string stream-seq client ....) and I'd like to just do (take 100 stream) |
| 10:01 | xkb | however this doesnt work (looks like it blocks) |
| 10:01 | xkb | any idea how I should handle this? |
| 10:01 | clgv | xkb: then you might have not enough data in there ;) |
| 10:01 | xkb | I can continually print the seq by using doseq |
| 10:01 | xkb | (its a twitter stream) |
| 10:01 | andrewclegg | I keep running into little things that would be easier in clojure but not worth starting a separate project for |
| 10:02 | clgv | and remember take is lazy and wont do anything unless you access does elements |
| 10:02 | xkb | is take allowed/working on a stream-seq? |
| 10:02 | xkb | hmm |
| 10:02 | clgv | *those |
| 10:02 | andrewclegg | is there a best-practice/least-friction way to do that? |
| 10:02 | mikera | @andrewclegg works fine for me with Eclipse / Maven in a Java project |
| 10:02 | andrewclegg | mikera: just have a separate src/main/clojure dir and add the clojure nature? |
| 10:03 | mikera | yep. also I use Maven for the clojure dependency but you don't have to |
| 10:03 | andrewclegg | do you have to do anything funky to make sure the clojure stuff gets compiled before the java code that references it? |
| 10:03 | andrewclegg | I think I stumbled on that last time I tried |
| 10:03 | mikera | No - the clojure files get compiled on demand |
| 10:03 | andrewclegg | cool thanks, will try again and see how I get on |
| 10:04 | cemerick | andrewclegg: Do you need to distinctly compile the clojure stuff? Unless you're referring to types defined in Clojure, you can just ship the source .clj |
| 10:04 | andrewclegg | cemerick: I'm generally making jars to deploy to a repo for use by other java projects |
| 10:05 | andrewclegg | can you just bundle the source .clj in the jar? |
| 10:05 | cemerick | andrewclegg: absolutely |
| 10:05 | andrewclegg | and that gets compiled when the clojure rt first needs it? |
| 10:05 | cemerick | If your clients only touch the Java API, then there's no need to AOT-compile the clojure sources. |
| 10:05 | andrewclegg | this is sounding better all the time :-) |
| 10:06 | cemerick | In that scenario, you do need to load the Clojure sources at runtime (in a static init block, or somesuch), but you're otherwise golden. |
| 10:06 | cemerick | Again, this is the case if you're not referring to Clojure-defined types from Java. |
| 10:06 | mikera | I never used AOT compilation either, just bundles the .clj files in the jar |
| 10:07 | cemerick | You can just put your .clj files in src/main/resources (if you're using maven), and they'll get rolled into the jar automatically. |
| 10:08 | todun | raek: so to develop in emacs, what steps should I take from M-x, clojure-jack-in...? thanks. |
| 10:08 | andrewclegg | what I'm thinking is: I provide a library jar which has interfaces defined in java, that my consumers speak to. the implementation classes in my jar delegate some of their work to clojure functions. my consumers never speak to the clojure functions directly |
| 10:08 | andrewclegg | so my impl. classes have to do something in static blocks to bring up clojure? |
| 10:09 | andrewclegg | I don't suppose anyone knows of a blog post with an example :-) |
| 10:09 | cemerick | andrewclegg: Sounds beautiful; yes, just require the relevant namespaces from Java, and invoke the functions you want. |
| 10:09 | andrewclegg | nice -- I'll try and see where that gets me |
| 10:09 | andrewclegg | thx |
| 10:10 | xkb | is there someway to "disconnect" from a stream? |
| 10:10 | cemerick | andrewclegg: There's extensive examples in my book (sorry for the self-promotion). In short: |
| 10:10 | cemerick | private static IFn requireFn = RT.var("clojure.core", "require").fn() |
| 10:11 | cemerick | requireFn.invoke(Symbol.intern("your.namespace")); |
| 10:11 | cemerick | Then use RT.var to get access to the functions you defined in your namespace. |
| 10:12 | andrewclegg | sweet, thanks for summarizing |
| 10:14 | rafl | so i implemented a library that provides a bunch of java classes and interfaces and i'd like to hand that off to the java people to write applications with |
| 10:14 | rafl | for that, i'd like to provide them with documentation for the java api |
| 10:14 | rafl | should i be looking at any tools to generate docs targetted at java people from doc strings or whatever? |
| 10:14 | andrewclegg | rafl: sounds like you just volunteered to write such a tool :-) |
| 10:15 | clgv | I want to implement a custom serializer for kryo in clojure. unfortunately "Serializer" is an abstract class and not an interface. is the only clojure way to use a genclass or what other options do I have? |
| 10:15 | clgv | I cant use a deftype, can I? |
| 10:16 | rafl | andrewclegg: fair enough. i might as well :) |
| 10:17 | raek | clgv: you can only use proxy or gen-class in that case |
| 10:17 | clgv | ok deftype does not work |
| 10:17 | clgv | raek: well then it's genclass since I do not need to proxy any of the methods |
| 10:17 | cemerick | rafl: I looked at generating javadoc from Clojure sources a long time ago. |
| 10:17 | cemerick | javadoc is *not* easy or simple to extend |
| 10:18 | raek | or make a adapter class in java that delegates to something more clojure-friendly |
| 10:18 | rafl | cemerick: actually, that's the route i was going to try first. did it turn out to be particularly impossible? |
| 10:18 | cemerick | The general consensus we reached then was that generating dummy Java source files from Clojure-defined types and running Javadoc over that was the most reasonable path. |
| 10:19 | raek | yuck |
| 10:19 | cemerick | rafl: Yeah, it's *really* gnarly. |
| 10:19 | rafl | *nod* |
| 10:19 | cemerick | raek: That's what I thought at first. Then I looked at javadoc. |
| 10:20 | clgv | raek: hm right I could make a wrapper class that uses an interface |
| 10:20 | rafl | cemerick: any chance of finding your clojure types -> fake java code stuff somewhere public? |
| 10:20 | raek | how about the other way? is it simple to extract javadoc data from java source? |
| 10:20 | cemerick | rafl: Oh, I never actually implemented that! :-P |
| 10:20 | rafl | marvellous! |
| 10:20 | cemerick | Wouldn't be super-difficult, but never hit the top of my priority list. |
| 10:21 | cemerick | raek: No. I don't recall the details. |
| 10:21 | rafl | it seems quite doable, really. just a little unsure about how many yaks i want to shave today. |
| 10:33 | emil` | does anyone know why the clojurescript repl sample doesn't respond after the second post is sent to the server? |
| 10:33 | mikera | @andrewclegg - you're not the Andrew Clegg from RGS Guildford by any chance? |
| 10:37 | andrewclegg | mikera: yeah, from like 20 years ago! |
| 10:46 | wjlroe | How do I check if an atom is defined? |
| 10:46 | jingguo | Hi, All. Is tools.logging is a replacement of clojure.contrib.logging? |
| 10:47 | pyr | wjlroe: (if @atom) ? |
| 10:48 | wjlroe | pyr: just says Unable to resolve symbol |
| 10:49 | pyr | wjlroe: well then that's something else entirely |
| 10:49 | pyr | wjlroe: it's not specific to an atom, you just have a symbol that's not declared |
| 10:49 | wjlroe | pyr: I want to define an atom if it hasn't already been defined |
| 10:50 | pyr | i'm not sure you're doing it right |
| 10:50 | pyr | (def foo (atom nil)) |
| 10:50 | pyr | (when-not @foo (reset! foo some-val)) |
| 10:50 | wjlroe | pyr: ok, I'll try that |
| 10:51 | pyr | or you can use memoize |
| 10:51 | raek | pyr: there is a race condition in that piece of code |
| 10:52 | pyr | raek: how so |
| 10:52 | zoldar | (swap! foo #(when-not % some-val)) ? |
| 10:52 | clgv | zoldar: thats it |
| 10:53 | raek | pyr: the atom can change between the deref and the reset!. swap! should be used here |
| 10:53 | pyr | ah, of course |
| 10:57 | wjlroe | raek: thanks! I wouldn't have spotted that. makes the code much better implementing that |
| 10:57 | wjlroe | pyr: thanks for your help |
| 11:11 | ljos | Hi - If i want to do this in clojure how would I do it? frame.getContentPane().add(comp) I'm pretty new to clojure... |
| 11:11 | jcromartie | (.. frame (.getContentPane) (.add comp)) |
| 11:11 | jcromartie | I think |
| 11:11 | jcromartie | (is ".." deprecated?) |
| 11:12 | jcromartie | http://clojure.org/java_interop |
| 11:12 | ljos | wait.. I wrote the wrong thing. It should be frame.getContentPane().add(comp, BorderLayout.CENTER) |
| 11:12 | clgv | jcromartie: idk, but you can also use (-> frame .getContentPane (.add comp)) |
| 11:13 | ljos | Can I do it in a doto.. I have some other things I need to do to the frame as well.. |
| 11:14 | jcromartie | clgv: ah yes, -> is more idiomatic |
| 11:14 | jcromartie | I am dipping into interop right now too |
| 11:14 | jcromartie | using doto at the moment |
| 11:16 | duck1123 | ljos: If you're using Swing, I'm pretty sure there's one or more libs that abstract away most of the nastiness |
| 11:18 | ljos | duck1132: probably, but there is very little swing I need to do. I just wanted the frame up and running. |
| 11:19 | clgv | ljos: yes you can |
| 11:19 | ljos | Most of the swing stuff is in java. I just needed to start it properly. |
| 11:19 | ljos | clgv: Ty for your help, I just managed to make it work. This is sweet! |
| 11:20 | ljos | Thanks to everyone who answers as well :D |
| 11:21 | todun | what's the difference between def, defn, clojure ? |
| 11:22 | duck1123 | defn is a function, def is any var. |
| 11:22 | duck1123 | (defn foo [x] x) vs (def foo (fn [x] x)) |
| 11:23 | jcromartie | and defn supports a bit more than def, too |
| 11:23 | jcromartie | like comments |
| 11:23 | jcromartie | and pre/post-condition maps |
| 11:24 | clgv | duck1123: defn is a macro ;) |
| 11:25 | duck1123 | Yes, there are more differences than what I showed, but that's the imortant part he needs to know |
| 11:26 | duck1123 | if you're ever in the situation where you're trying to take the value of defn, you're probably doing something wrong anyway |
| 11:30 | chrido | hi, i want to insert a joda-datetime thing with clojure.java.jdbc into the database, which format string do i have to use? |
| 11:31 | chrido | YYYY-MM-DD HH:MM:SS behaves quite funny, i get Incorrect datetime value: '2011-10-285 15:10:54' for column 'lastUpdate' at row 1 |
| 11:32 | duck1123 | chrido: I believe sending the time as a number works |
| 11:33 | andrewclegg | ljos: are you doing swing? would this help? https://github.com/stathissideris/clarity |
| 11:33 | duck1123 | 285 days in October? |
| 11:35 | chrido | duck1123: do you know mean as timestamp? |
| 11:35 | chrido | yyyymmddhhmmss also doesn't work |
| 11:37 | duck1123 | chrido: right, if you can get it as a timestamp, this should eliminate parsing issues |
| 11:38 | duck1123 | but your real issue is your date is malformed |
| 11:38 | duck1123 | '2011-10-285' |
| 11:41 | chrido | duck1123: this is what bothers me most, this is the code which prints "2011-10-285 17:10:14" |
| 11:41 | chrido | (. (org.joda.time.format.DateTimeFormat/forPattern "YYYY-MM-DD HH:MM:SS") print (new org.joda.time.DateTime)) |
| 11:42 | duck1123 | I don't know if it's the same as the java string, but try "yyyy-MM-dd hh:mm:ss" |
| 11:42 | todun | duck1123: ok. so def is like 'var ? |
| 11:43 | duck1123 | todun: def defines a var, yes |
| 11:44 | chrido | duck1123: with "yyyy-MM-dd hh:mm:ss" i get "2011-10-12 05:43:16", |
| 11:46 | chrido | duck1123: "yyyy-MM-dd HH:mm:ss" is OK, gives 24hours |
| 11:46 | todun | duck1123: when I do this (def var 12) => 12, ('v 12) => nil, 'v => v |
| 11:46 | chrido | duck1123: thanks a lot! but will try to convert it to timestamp |
| 11:47 | duck1123 | todun: v => 12 |
| 11:49 | duck1123 | 'v gives you the quoted symbol. #'v gives you #'user/v (or whatever ns you're in) v gives the value pointed at by #'v |
| 11:50 | clgv | &#'v |
| 11:50 | lazybot | java.lang.Exception: Unable to resolve var: v in this context |
| 11:50 | clgv | &#'map |
| 11:50 | lazybot | ⇒ #'clojure.core/map |
| 12:01 | llasram | OOC, why are their multiple evaluation bots hanging out here, and are their interfaces documented anywhere? |
| 12:01 | llasram | s,their,there, |
| 12:02 | jcromartie | what's a good way to get a lazy seq of forms from a file |
| 12:02 | jcromartie | I'm trying to whip it up myself |
| 12:02 | jcromartie | but if there's an example |
| 12:02 | duck1123 | bots become smug when there's no cometition. It keeps them honest |
| 12:03 | ejackson | duck1123: they're lispbots, its in their nature. |
| 12:19 | galderz1 | hi all |
| 12:19 | galderz1 | have a question about the move of contrib to separate git repos |
| 12:19 | galderz1 | does anyone know where http://richhickey.github.com/clojure-contrib/string-api.html lives now? |
| 12:20 | galderz1 | it's not clear from looking at http://dev.clojure.org/display/doc/Clojure+Contrib |
| 12:23 | galderz1 | seems like i'm not the only one asking: http://groups.google.com/group/clojure/browse_thread/thread/973fae166ba4121d?pli=1 |
| 12:24 | duck1123 | clojure.string |
| 12:25 | duck1123 | most of the string stuff come with clojure now |
| 12:25 | galderz1 | duck1123 but grep is not there for example |
| 12:25 | galderz1 | ^^ |
| 12:25 | galderz1 | in particular, i wanted to grep a pattern in a file |
| 12:25 | galderz1 | there might be easier ways to do it of course |
| 12:35 | srid | (apply merge (for [] ...)) <- the for returns a list of maps that needs to be merged. is there a better way? |
| 12:37 | jkkramer | srid: you could use reduce to work with one map from start to finish |
| 12:37 | srid | reduce seems conceptually over-complicated for implemented 'set comprehensions' though |
| 12:38 | todun | duck1123: ok. I'll have to read up some more. thanks. |
| 12:39 | duck1123 | srid: looks like merge uses reduce1, so you're probably better off with apply |
| 12:40 | srid | seems so. {for [] ...} would have been better ;-) |
| 12:40 | duck1123 | since there's no special case for different # of args |
| 12:40 | jkkramer | srid: (into {} (for [] ...)) may also work, depending on what you produce with for |
| 12:41 | duck1123 | if you can produce only the sets of keys you want, you could (into {}) |
| 12:41 | srid | ,(into {} (for [x (range 5)] {x (* x x)})) |
| 12:41 | clojurebot | {0 0, 1 1, 2 4, 3 9, 4 16} |
| 12:41 | srid | ok |
| 12:42 | jkkramer | ,(into {} (for [x (range 5)] [x (* x x)])) ;also common |
| 12:42 | clojurebot | {0 0, 1 1, 2 4, 3 9, 4 16} |
| 12:43 | todun | how to quit out of a clojure repl |
| 12:45 | trptcolin | todun: ctrl-d will do it |
| 12:45 | todun | trptcolin: ok. no special "quit" or other? |
| 12:45 | trptcolin | nope |
| 12:46 | todun | trptcolin: thanks. |
| 12:46 | jcromartie | please critique my lazy form sequence function: https://gist.github.com/1281781 |
| 12:46 | jcromartie | I'm a lazy-seq noob |
| 12:46 | trptcolin | sure thing. lein repl has a fancy command: (exit), but nothing built-in |
| 12:47 | todun | trptcolin: that didn't work for me though, |
| 12:47 | trptcolin | using which version of lein? |
| 12:47 | todun | 'lein repl' user=> exit |
| 12:47 | todun | #<core$exit leiningen.core$exit@4b17b450> |
| 12:47 | trptcolin | (exit) |
| 12:47 | trptcolin | it's a function call |
| 12:47 | todun | ha. like all of closure :) |
| 12:47 | todun | *clojure |
| 12:49 | jcromartie | seems to work well enough |
| 12:49 | srid | lamina question: i defined a second filtered/mapped channel like this: (defonce event-queue (->> sink-queue (map* foo) (filter* identity))) ... but this would run in module load. what if I wanted to define this only when a function (eg: "initialize") is called? |
| 12:51 | duck1123 | srid: [shameless plug] you could try definitializer in Ciste. https://github.com/duck1123/ciste |
| 12:51 | srid | which file? |
| 12:51 | srid | \ |
| 12:51 | duck1123 | But that also hooks into the config and environment system |
| 12:52 | duck1123 | it's in ciste.config |
| 12:55 | todun | I'm about to write my first clojure in emacs now. but I'm a bit hazy as to some of the details. First I have to create a project(still not sure if I have to do this all the time like eclipse workspace). Then I know I have to open emacs in /src. Then connect to some swank server using M-x, clojure-jack-in. Then be in a name-space....etc. Does anyone know where I can find steps to do all this? thanks. |
| 13:01 | technomancy | todun: your patience is remarkable =) |
| 13:01 | dnolen | todun: if you just want to learn Clojure it seems like you're going thru a lot of trouble. |
| 13:01 | jcromartie | todun: might I recommend 4clojure? |
| 13:01 | technomancy | I signed off irc last night when you were figuring out clojure-mode and the first thing I see when I sign back on is that you're finally ready to code =) |
| 13:02 | jcromartie | http://www.4clojure.com/ |
| 13:02 | duck1123 | todun: have faith. It gets better. |
| 13:03 | cemerick | todun: I have to check: did you try the eclipse plugin, and find it not to your liking (I'm assuming here you are more familiar with eclipse…)? |
| 13:03 | technomancy | todun: the steps you've listed are correct. for starters it's simpler if you stay in one namespace/file |
| 13:04 | todun | thanks all. |
| 13:04 | todun | I'm interested in emacs so that I can know what to do whatever the platform. in other words, I want to be platform agnostic when learning clojure. |
| 13:05 | cemerick | carry on, then :-) |
| 13:05 | todun | cemerick: sure. |
| 13:05 | todun | technomancy: so the steps are correct. |
| 13:06 | todun | technomancy: should I have to create a project each time I start? |
| 13:06 | technomancy | todun: no need; if you're doing experimentation you can re-use a scratch project |
| 13:06 | todun | can I just have one folder which has /src in it. then from there have all my .clj in /src ? |
| 13:07 | todun | technomancy: scracth project? |
| 13:07 | todun | technomancy: will this let me save the work into a file? |
| 13:08 | technomancy | right; just do "lein new scratch" and work in the src/ dir of that project; that's probably the simplest for just experimentation |
| 13:09 | technomancy | you can get standalone sessions outside a project, but for learning's sake it's quicker to just get accustomed to a project-centric approach |
| 13:09 | todun | ok. trying that now... |
| 13:10 | duck1123 | sooner or later you're going to want a library outside of clojure, and it's easiest if you can just add it to the project file |
| 13:10 | todun | I cd scratch |
| 13:10 | clojurebot | No entiendo |
| 13:11 | todun | duck1123: meaning? |
| 13:11 | todun | duck1123: as in which is the project file? |
| 13:11 | todun | duck1123: is there a main project file? |
| 13:11 | technomancy | todun: project.clj in scratch defines your project settings including dependencies |
| 13:11 | duck1123 | when you do "lein new scratch" it will create a "project.clj" file |
| 13:12 | todun | duck1123: I though scratch of anything I do with 'lein new project' is a project file |
| 13:12 | duck1123 | that's how lein knows what libraries you're using |
| 13:12 | technomancy | at some point you should read "lein help tutorial" though I hate to distract you from actually writing code. |
| 13:13 | todun | technomancy: this doesn't cover dev in emacs though : https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md |
| 13:14 | todun | duck1123: ok. |
| 13:15 | todun | after creating, opening a file first-project.clj(in /src), connecting to server, then what? |
| 13:15 | technomancy | todun: open the file in src/scratch/core.clj and do C-c C-k; that will compile it in the repl |
| 13:15 | technomancy | write some code in there, and then recompile to see its effects |
| 13:16 | technomancy | then C-c M-p to switch the namespace repl buffer to match the file you're currently in |
| 13:17 | todun | technomancy: so I should keep the name of core.clj? |
| 13:17 | technomancy | if it's just for experimentation it doesn't matter |
| 13:17 | duck1123 | for now, unless you have a better name |
| 13:18 | todun | oh I see. core.clj doesn't exist yet. |
| 13:18 | duck1123 | it should be in src/scratch/core.clj |
| 13:19 | duck1123 | in the scratch directory that lein new made |
| 13:19 | todun | actually it does at sractch/src/scratch/core.clj |
| 13:20 | duck1123 | cd into the scratch folder and work from there |
| 13:20 | duck1123 | then do a git init and make your initial commit |
| 13:20 | todun | ok. I have it open with (ns scratch.core) as its sole content |
| 13:20 | duck1123 | magit is an awesome git client |
| 13:21 | todun | so it allows me to make commits directly from emacs? |
| 13:21 | todun | I actually have an idea of a group of functions I want to write. |
| 13:21 | duck1123 | C-x g (assuming you're using starter kit) |
| 13:22 | todun | yes |
| 13:22 | technomancy | duck1123: in v2 it's actually C-c g if you're using the bindings module; M-x magit-status if not |
| 13:22 | todun | do I write my code before I connect to the swank server? |
| 13:23 | duck1123 | technomancy: Not sure how I feel about that. My fingers are too trained |
| 13:23 | technomancy | todun: doesn't really matter, but you can't try it out until you're connected |
| 13:23 | technomancy | duck1123: trying to be a little better about followin gconventions |
| 13:26 | todun | technomancy: ok. let me write something quick and test it. |
| 13:28 | todun | how to undo in emacs starter-kit? I've always used C - ? |
| 13:29 | duck1123 | C-_ |
| 13:29 | duck1123 | or C-/ or C-x u |
| 13:30 | TimMc | todun: M-x undo and then look at the hint that appears in the minibuffer. |
| 13:30 | TimMc | It should tell you a keybinding. |
| 13:30 | todun | TimMc: thanks. |
| 13:30 | duck1123 | C-h f undo <ret> |
| 13:31 | TimMc | :-) |
| 13:39 | todun | does anyone get a weird indent when using emacs starter kit? |
| 13:39 | todun | I get it whenever I comment out a line. |
| 13:39 | todun | and hit return. |
| 13:41 | todun | technomancy: duck1123 ok. I have my function written in scratch. what next? |
| 13:41 | todun | connect to swank? |
| 13:42 | duck1123 | connect to swank, switch to that ns, run the fn and make sure it works |
| 13:43 | duck1123 | then write a unit test for it. |
| 13:45 | todun | connecting to swank...switch to ns ? |
| 13:53 | dnolen | so any opinions on the ClojureScript string/keyword patch? http://dev.clojure.org/jira/secure/attachment/10382/84-str-on-symbol-keyword.patch |
| 13:55 | todun | my comments in emacs-starter-kit seem to be right-justified. is this normal? |
| 13:55 | duck1123 | if you do ;; then emacs will keep them in line with the code |
| 13:56 | todun | duck1123: ok. thanks. |
| 13:56 | todun | I had to go back to the cli. emacs app was acting funny |
| 13:56 | todun | so I'm connected. what did you mean by switch to the ns? |
| 13:56 | ibdknox | dnolen, what's the practical implication of that change? |
| 13:57 | todun | duck1123: I thought I was already in the ns |
| 13:57 | dnolen | ibdknox: (str :foo) -> ":foo" |
| 13:57 | dnolen | ibdknox: currently (str :foo) -> :foo |
| 13:57 | todun | duck1123: when I start in core.clj |
| 13:57 | dnolen | ibdknox: same for symbols |
| 13:57 | duck1123 | You start off in the user ns, the repl will show your current ns |
| 13:57 | jkndrkn | hey all. i'm working with a multi-threaded webservice. we want to collect timing information for a request. we'd like to avoid making ad-hoc changes to our existing code in order to pass in and pass out a map that will accumulate timing information. |
| 13:58 | ibdknox | dnolen, the same for symbols? |
| 13:58 | dnolen | (str 'foo) -> 'foo in CLJS |
| 13:58 | ibdknox | ,(str 't) |
| 13:58 | duck1123 | todun: if you C-c C-k the core.clj file, the C-c M-p it'll switch you to the right ns) |
| 13:58 | clojurebot | "t" |
| 13:58 | ibdknox | dnolen, why the difference? |
| 13:58 | dnolen | ibdknox: exactly, patch aligns CLJS w/ Clojure |
| 13:59 | ibdknox | gotcha |
| 13:59 | duck1123 | todun: alternately (do (require 'scratch.core) (in-ns 'scratch.core)) |
| 13:59 | jkndrkn | however, if we were to create some kind of global state (a map) that could instead be passed timing information from within arbitrary parts of our system, we would still need to pass around some kind of request-id in order to assign timing data to the global map in a way that it uniquely identifies timing information for a given request |
| 14:00 | jkndrkn | unfortunately, we don't already pass the same data structure to all corners of our request, otherwise we would simply accumulate performance data on that data structure via metadata. |
| 14:00 | jkndrkn | have any ideas? |
| 14:00 | ibdknox | dnolen, looks fine to me |
| 14:01 | jkndrkn | we're using compojure (jetty), if that helps |
| 14:01 | todun | C-c C-k then C-c M-p ==== (do (require 'scratch.core) (in-ns 'scratch.core)) |
| 14:02 | ibdknox | jkndrkn, middleware + an atom + thread binding |
| 14:02 | todun | duck1123: where do I put (do (require 'scratch.core) (in-ns 'scratch.core)), before (ns scratch.core) ? |
| 14:02 | duck1123 | essentially. C-c C-k reloads the current file, C-c M-p switches the repl's ns |
| 14:03 | duck1123 | todun: in your repl |
| 14:03 | duck1123 | You could do it as two commands, the do is so it's a single command in your history |
| 14:04 | todun | duck1123: so they're equivalent at least in action? |
| 14:05 | duck1123 | todun: right. You can't switch to the namespace until it's loaded. That's what require does. The in-ns changes the repl's ns |
| 14:06 | jkndrkn | ibdknox: we've considered an atom and thread binding. could you clarify as to how you would use middleware? |
| 14:07 | todun | duck1123: this is what my emacs stuff looks like: http://pastebin.com/AxVUq9Cg |
| 14:07 | ibdknox | jkndrkn, you need your atom to be specific to each request. if you bind at the level of middleware, it will be. Take a look at the session implentation in ring or noir |
| 14:08 | ibdknox | jkndrkn, https://github.com/ibdknox/noir/blob/master/src/noir/session.clj#L49 |
| 14:09 | ibdknox | jkndrkn, then you just need to make sure other threads that are spawned from that request use bound-fn |
| 14:09 | ibdknox | ,(doc bound-fn) |
| 14:09 | clojurebot | "([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place." |
| 14:09 | todun | duck1123: after putting the line of code, what next? did I put the line of code in correctly? |
| 14:09 | ibdknox | actually.. there was talk at some point of having threads automatically pick up the bindings of whatever called them, did that ever happen? |
| 14:10 | jkndrkn | thanks, i'll look into that |
| 14:10 | duck1123 | ibdknox: that's cool, didn't know that one. Have some code to simplify |
| 14:10 | mabes | ibdknox: in 13 the bound-fn would not be needed |
| 14:10 | mabes | ibdknox: er.. 1.3 |
| 14:10 | ibdknox | mabes, k, so it does it by default in 1.3 then? |
| 14:11 | ibdknox | that would be the desired behavior in my mind |
| 14:11 | mabes | ibdknox: that is my understanding yes, you need to declare the var as dynamic though |
| 14:11 | ibdknox | yep yep |
| 14:11 | duck1123 | todun: try calling your function. Does it work? |
| 14:11 | todun | duck1123: so I just call it from the repl? |
| 14:13 | todun | duck1123: I get the following error: http://pastebin.com/iWj6BNuU |
| 14:14 | duck1123 | todun: what does your repl prompt say? If it still says "user>" then you didn't change the ns correctly |
| 14:14 | duck1123 | mabes: So I had to do something like https://github.com/duck1123/ciste/blob/master/src/ciste/triggers.clj#L33 are you saying that's no longer required? |
| 14:16 | mabes | duck1123: that is what I'm saying, but I haven't actually updated my apps to 1.3 yet.. so I may be incorrect, but that is what I remember from Rich's keynote at the last conj and other readings |
| 14:16 | mabes | somone with actual 1.3 experience may want to confirm the thread local bindings queustion... |
| 14:17 | duck1123 | I vaguely remember hearing that, but I wrote this well before that feature would've been put in |
| 14:17 | todun | duck1123: this is what it says. ; SLIME 20100404 |
| 14:17 | todun | user> greeting |
| 14:18 | duck1123 | todun: you're still in the default user ns. Try switching the ns again |
| 14:18 | todun | duck1123: I changed to it and pressed enter. It then changed to this: http://pastebin.com/TXXAygzp |
| 14:19 | todun | duck1123: I thought that the line of code I put in my app did that on my behalf, no? |
| 14:19 | duck1123 | put it in the repl, not the code |
| 14:19 | amalloy | ,(future (println "1")) |
| 14:19 | clojurebot | #<core$future_call$reify__5733@1d4e606: :pending> |
| 14:19 | amalloy | ,@(future (println "1")) |
| 14:19 | clojurebot | 1 |
| 14:20 | mabes | ,*clojure-version* |
| 14:20 | clojurebot | {:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"} |
| 14:20 | amalloy | duck1123, mabes: this works only because clojurebot is on 1.3. lazybot, on 1.2, should behave differently: ##@(future (println "1")) |
| 14:20 | lazybot | ⇒ nil |
| 14:20 | todun | duck1123: ok.. |
| 14:21 | duck1123 | amalloy: good to know. I use a bound var to represent some things and I needed those things to still be bound in my triggers |
| 14:24 | todun | duck1123: ok. I think that worked. is that all I do? |
| 14:25 | duck1123 | yep, code some more, C-c C-k in that file, then run it again from the repl |
| 14:29 | todun | duck1123: anytime I try to load a new function, the old one persists. |
| 14:29 | todun | do I have to restart eclipse over again ? |
| 14:30 | duck1123 | todun: Oh, you're on eclipse now? I think there's an option to reload the repl |
| 14:50 | daniel___ | https://github.com/danielstockton/evolve/blob/master/src/evolve/core.clj can anyone point out a method to println each generation? |
| 14:51 | daniel___ | i've seen you can use do to execute side effects, but the problem is the important statement is the return statement |
| 14:51 | daniel___ | i can't println until it's been evaluated |
| 14:52 | daniel___ | line 26 is the one i need to modify, so for each iteration i can log whats going on |
| 14:56 | amalloy | &(doto (inc 5) println) |
| 14:56 | lazybot | ⇒ 6 6 |
| 14:56 | ipostelnik | daniel___, look at clojure.contrib.trace |
| 14:57 | ipostelnik | daniel___, returned value of a do is the last form executed |
| 14:57 | ipostelnik | amalloy, that's a clever trick |
| 14:58 | duck1123 | daniel___: Here's the macro I use https://github.com/duck1123/ciste/blob/master/src/ciste/debug.clj#L5 |
| 15:03 | Raynes | dakrone: Ping. |
| 15:03 | TimMc | amalloy: Huh, kind of acts like a begin0 |
| 15:06 | ibdknox | or just use a let? |
| 15:13 | amalloy | TimMc: i think you mean a prog1, you crazy schemer |
| 15:14 | daniel___ | doto does the reverse order of do? |
| 15:14 | daniel___ | so the first is returned |
| 15:14 | Raynes | Do does something completely different, but sure, the first is returned. |
| 15:15 | Raynes | &(doto "hi" println) |
| 15:15 | lazybot | ⇒ hi "hi" |
| 15:15 | daniel___ | ah ok |
| 15:15 | llasram | daniel___: doto evalutes it's first argument, and embeds the evaluated value as the first argument in the subsequent forms. Check the macroexpansion |
| 15:15 | Raynes | &(macroexpand '(doto "hi" println)) |
| 15:15 | lazybot | ⇒ (let* [G__15133 "hi"] (println G__15133) G__15133) |
| 15:15 | daniel___ | ok, will do...it's jsut what i wanted |
| 15:19 | daniel___ | one more thing, with vimclojure when i launch the repl \s....should the file be loaded so i can call functions in it's namespace? or do i have to explicitly load it? because at the moment it cannot resolve symbols i've defined |
| 15:23 | dakrone | Raynes: pong |
| 15:24 | Raynes | dakrone: How much trouble would it be to release some sort of alpha or something of clj-http? I'd like to have something non-snapshot and running on 1.3 to depend on. |
| 15:24 | Raynes | Assuming that it isn't currently broken or something. |
| 15:25 | dakrone | Raynes: the current release "0.2.1" runs completely fine on 1.3, or did you need some feature in master that hasn't been released? |
| 15:25 | Raynes | Oh, it does? Awesome. In that case, nevermind. |
| 15:26 | dakrone | I've been testing with 1.2.1 and 1.3 since I took it over to make sure it's always compatible with both |
| 15:31 | TimMc | amalloy: More of a Racketteer, really. |
| 15:32 | zakwilson | ,(format "%x" (- (BigInteger. "4e95d6b5975a97db24369193", 16) (to-long (now)))) ; is there an easy way to do this? |
| 15:32 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: to-long in this context, compiling:(NO_SOURCE_PATH:0)> |
| 15:32 | zakwilson | Oh, right. |
| 15:32 | zakwilson | ,(format "%x" (- (BigInteger. "4e95d6b5975a97db24369193", 16) 1318447929255)) |
| 15:32 | clojurebot | #<IllegalFormatConversionException java.util.IllegalFormatConversionException: x != clojure.lang.BigInt> |
| 15:33 | technomancy | TimMc: not a raconteur? |
| 15:33 | TimMc | hmm |
| 15:34 | zakwilson | ,(format "%x" 10000000000000000000000000000000) ; reduced to the simplest version |
| 15:34 | clojurebot | #<IllegalFormatConversionException java.util.IllegalFormatConversionException: x != clojure.lang.BigInt> |
| 15:34 | TimMc | mouseketeer |
| 15:34 | technomancy | TimMc: http://www.penny-arcade.com/comic/2007/03/23 |
| 15:35 | daniel___ | is there anything i can call within an iterate to give me the number of the iteration? |
| 15:35 | llasram | zakwilson: clojure.core/format is thin wrapper around java String.format(), which doesn't know about the Clojure 1.3 BigInt type |
| 15:37 | llasram | zakwilson: http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics |
| 15:47 | wiseen | ClojureScript doesn't seem to support docstring in ns macro ? Is this true/intentional or a bug ? |
| 15:49 | wiseen | (ns test "DocString?") -> java.lang.AssertionError: Assert failed: Only :refer-clojure, :require, :require-macros, :use and :use-macros libspecs supported |
| 15:50 | duck1123 | we need a clojurescript bot in here |
| 15:51 | wiseen | duck1123: Think it's my install ? I'll pull the latest but I think I'm only a few days behind ... and it works otherwise |
| 15:54 | wiseen | nope, same thing ... will submit a bug report then |
| 15:56 | zakwilson | Ok, maybe I'm just dumb, but I'm not seeing a simple way to format a BigInt as a hex string without going Bigint -> String -> BigInteger -> String. |
| 16:02 | alpheus` | Heh. I needed to look at some vectors of maps so I'm emitting orgtbl-mode format for easy viewing in Emacs. |
| 16:20 | todun_ | duck1123: just got your message. not on eclipse I mis-typed(was obviously nodding off). still emacs. |
| 16:20 | todun_ | duck1123: if I make a change, do I reload the namespace somehow? |
| 16:21 | duck1123 | C-c C-k in the changed file will reload it in the current vm |
| 16:22 | todun_ | duck1123: after I use those commands, I get this Compilation finished. (No warnings) [0.01 secs] |
| 16:22 | todun_ | duck1123: then I switch wondows. |
| 16:22 | duck1123 | todun_: that means it's working :) |
| 16:22 | todun_ | then I get an exception when I call the function with args. |
| 16:23 | todun_ | duck1123: I call the function like so: (greeting "work") |
| 16:24 | duck1123 | What does the exception say? If it compiles but does not run, there's probably some logic error |
| 16:24 | todun_ | duck1123: (defn greeting "'Hello, username.' This is tough, but fun." [username] (str "hello, " username)) |
| 16:25 | todun_ | duck1123: that's the function. |
| 16:25 | todun_ | duck1123: I already suspected it didn't compile because it doesn't let me tab complete. |
| 16:26 | todun_ | duck1123: exception is http://pastebin.com/RtJGp3Av |
| 16:27 | duck1123 | todun_: you're in the user ns again |
| 16:29 | todun_ | duck1123: phew. I think I'm certifiably confused. |
| 16:29 | todun_ | duck1123: shouldn't have that line of code in repl be equivalent to compiling it like we did using C-c C-k? |
| 16:30 | duck1123 | C-c C-k compiles the line, but it does not change your repl's namespace |
| 16:31 | duck1123 | that's what C-c M-p is for or in-ns |
| 16:31 | duck1123 | The prompt in the repl shows your current ns, so if you see "user>" then you need to change |
| 16:32 | todun_ | duck1123: so that changes it to a name space called scratch.code, right? |
| 16:33 | todun_ | duck1123: thanks! it now works. it all does makes sense now, finally. |
| 16:33 | duck1123 | C-c M-p will auto populate the ns associated with the current file. (whereever your pointer is) |
| 16:34 | todun_ | duck1123: C-c C-k to compile ; C-c M-p to switch namespace. Then, like a script, call functions. |
| 16:35 | todun_ | if I were using lein as 'lein repl', will I have to do all this? |
| 16:35 | duck1123 | If you're using lein repl, then you don't have the fancy emacs commands |
| 16:35 | todun_ | could I just emacs my thing then open a new repl in the same folder and do my testing? |
| 16:35 | todun_ | duck1123: yeah, but I'll have another window. |
| 16:36 | todun_ | duck1123: and perhaps achieve the same results, no? |
| 16:37 | zerokarmaleft | lein repl isn't quite as nice as slime/swank |
| 16:37 | raek | todun_: in lein repl you type (require 'scratch.code :reload) instead of C-c C-k and (in-ns 'scratch.code) instead of C-c M-p |
| 16:37 | duck1123 | it's all the same in the end, you just won't have any of the features that slime provides. (ie. you can't C-c C-k to reload the file) |
| 16:37 | todun_ | duck1123: if I wanted to use this scheme, how will I load my core.clj into the lein namespace which seems to be eternally 'user' |
| 16:37 | todun_ | ? |
| 16:38 | zerokarmaleft | todun_: what raek said |
| 16:38 | raek | todun_: for future reference http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html |
| 16:38 | todun_ | raek: should I have it like so (do require 'scratch.code :reload) (do in-ns 'scratch.code) |
| 16:39 | raek | todun_: no. why the "do"? |
| 16:39 | todun_ | zerokarmaleft: sorry was typing out of sync with them. got it. |
| 16:39 | duck1123 | raek: I posted an example with do earlier |
| 16:39 | todun_ | raek: didn't work the first time. I thought I saw duck1123 do that earlier. |
| 16:39 | raek | todun_: (do a b c) is not the same as (a b c). |
| 16:40 | duck1123 | The do was only so both commands were the same command so you can pull it up from your history |
| 16:40 | ibdknox | oo |
| 16:40 | ibdknox | I wonder if that's a 1.0 of ring |
| 16:40 | raek | todun_: another neat trick is (doto 'scratch.code (require :reload) (in-ns)) |
| 16:41 | todun_ | duck1123: I see. |
| 16:41 | raek | that's the same as calling (let [x 'scratch.code] (require x :reload) (in-ns x) nil) |
| 16:41 | raek | ...or (let [x 'scratch.code] (do (require x :reload) (in-ns x) nil)) |
| 16:41 | duck1123 | raek: should return x actually |
| 16:41 | raek | but let has an "implicit do" so you don't need to write it |
| 16:41 | raek | duck1123: correct. my bad. |
| 16:42 | ibdknox | lol |
| 16:42 | todun_ | raek: do I run them on the same line like so (require 'scratch.code :reload) (in-ns 'scratch.code) |
| 16:42 | ibdknox | doto twice in one day |
| 16:42 | todun_ | raek: or line by line? |
| 16:42 | raek | todun_: doesn |
| 16:42 | raek | todun_: doesn't matter |
| 16:42 | amalloy | raek: the nil at the end of your doto/let/do doesn't make any sense |
| 16:42 | raek | amalloy: yes, I know. I meant (let [x 'scratch.code] (require x :reload) (in-ns x) x) |
| 16:43 | todun_ | raek: this is the output I get. |
| 16:43 | todun_ | http://pastebin.com/ZEd69Fm4 |
| 16:43 | ibdknox | lol |
| 16:43 | ibdknox | todun_, it has to be the name of your namespace |
| 16:44 | raek | todun_: I think you called in-ns by accident before you called require |
| 16:44 | raek | todun_: that way you are now in an empty namespace with nothing in it. not even 'require'. |
| 16:44 | duck1123 | todun_: isn't is 'scratch.core or did you rename? |
| 16:44 | raek | todun_: enter (in-ns 'user) to get back, and then call (doto 'scratch.code (require :reload) (in-ns)) again |
| 16:45 | cgray | it seems like my -main function is not exiting immediately when it's done running code... is there anything i can do to make it exit? |
| 16:45 | ibdknox | ,(= 'scratch.code 'scratch.core) |
| 16:45 | raek | (I think in-ns is hard-coded into the repl) |
| 16:45 | clojurebot | false |
| 16:45 | amalloy | yes, in-ns and several other things |
| 16:45 | raek | cgray: sometimes you need to run (shutdown-agents) |
| 16:47 | cgray | raek: thanks, that worked |
| 16:47 | todun_ | duck1123: I didn't rename it. |
| 16:47 | amalloy | raek: fwiw you don't have to get back to the user ns to do this; you could instead (clojure.core/require ...) from inside the "broken" ns |
| 16:47 | todun_ | ibdknox: should I space out in-ns to in - ns ? |
| 16:47 | todun_ | raek: ok. let me try that. |
| 16:48 | ibdknox | I think there are too many people telling you what to do :) |
| 16:48 | duck1123 | todun_: unlike most languages, - is legal in variable names. The proper name is "in-ns" |
| 16:49 | todun_ | raek: I get this error. http://pastebin.com/FpKqSk4V |
| 16:49 | ibdknox | amalloy, what triggers injecting clojure.core into a namespace? |
| 16:49 | todun_ | duck1123: oh ok. thanks. |
| 16:50 | amalloy | ibdknox: nothing does. you can reference anything that's been loaded by fully-qualifying it |
| 16:50 | amalloy | or do you mean, in the non-broken case? like (ns foo)? |
| 16:50 | ibdknox | amalloy, yes |
| 16:50 | duck1123 | todun_: you still have the namespace wrong. 'scratch.core |
| 16:50 | todun_ | duck1123: I cd like so : http://pastebin.com/NEAY7T7C |
| 16:51 | amalloy | the ns macro has an implicit (refer 'clojure.core), whose parameters you can modify with the :refer-clojure directive |
| 16:51 | todun_ | duck1123: yes. .core NOT .code! thanks |
| 16:51 | ibdknox | I see |
| 16:51 | amalloy | ,(macroexpand '(ns test)) |
| 16:51 | clojurebot | (do (clojure.core/in-ns (quote test)) (clojure.core/with-loading-context (clojure.core/refer (quote clojure.core)))) |
| 16:52 | todun_ | duck1123: raek thanks all! |
| 16:52 | amalloy | ,(macroexpand '(ns test (:refer-clojure :only [inc]))) |
| 16:52 | clojurebot | (do (clojure.core/in-ns (quote test)) (clojure.core/with-loading-context (clojure.core/refer-clojure (quote :only) (quote [inc])))) |
| 16:52 | amalloy | i think |
| 16:52 | todun_ | duck1123: is this all I need to know to begin developing using emacs and 'lein repl' ? |
| 16:52 | ibdknox | haha I like the quote of a keyword |
| 16:52 | ibdknox | ,(= :test ':test) |
| 16:52 | clojurebot | true |
| 16:53 | amalloy | ibdknox: just in case some future version of clojure makes keywords not self-evaluating, i'm sure... |
| 16:54 | ibdknox | amalloy, Planning for the future is important ;) |
| 16:54 | zerokarmaleft | todun_: that's a good start |
| 16:54 | duck1123 | todun_: keep in mind, the emacs stuff isn't going to work if you're using lein repl |
| 16:54 | zerokarmaleft | todun_: you may find the cycle of reloading source files after you've changed them so you can test in your REPL to be a PITA |
| 16:55 | zerokarmaleft | hence the keybinding in slime/swank for that sort of thing |
| 16:55 | amalloy | ibdknox: macros write all kinds of silly code that programmers never would, of course |
| 16:55 | amalloy | (do (do (do (inc 1)))) :P |
| 16:55 | ibdknox | haha |
| 16:55 | ibdknox | yeah |
| 16:56 | ibdknox | I still love dnolen's first impl of match and the code it spit out |
| 16:56 | ibdknox | it was like 18 nested fn's |
| 16:56 | todun_ | zerokarmaleft: oh ok. I wanted to know of the option just in case I needed to work without need of a text editor. |
| 16:56 | todun_ | duck1123: emacs wont work if in lein repl, meaning? |
| 16:57 | technomancy | todun_: you can use it with lein repl, but it's kind of dumbed-down compared to swank |
| 16:57 | duck1123 | C-c C-k and C-c M-p are swank commands |
| 16:57 | todun_ | technomancy: use what with 'lein repl'? |
| 16:58 | amalloy | ibdknox: really? if you nest too many fns you actually get something that won't AOT-compile because the classfile's name is too long to write to disk |
| 16:58 | ibdknox | haha |
| 16:58 | ibdknox | amalloy, it is *much* better now |
| 16:58 | amalloy | &(class (for [_ [1] _ [1] _ [1] _ [1] _ [1] _ [1] ] (fn []))) |
| 16:58 | lazybot | ⇒ clojure.lang.LazySeq |
| 16:59 | amalloy | &(class (first (for [_ [1] _ [1] _ [1] _ [1] _ [1] _ [1] ] (fn [])))) |
| 16:59 | ibdknox | last I saw it generated some very reasonable code |
| 16:59 | lazybot | ⇒ sandbox12208$eval15263$iter__15244__15264$fn__15265$iter__15246__15266$fn__15267$iter__15248__15268$fn__15269$iter__15250__15270$fn__15271$iter__15252__15272$fn__15273$iter__15254__15274$fn__15275$fn__15276$fn__15286 |
| 16:59 | raek | whoa |
| 16:59 | technomancy | todun_: there's rudimentary emacs integration that works with lein repl |
| 17:00 | technomancy | (setq inferior-lisp-program "lein repl") ; in Emacs lisp, followed by M-x run-lisp |
| 17:00 | amalloy | and even that filename is less than 256 characters, i guess. but you can see how if you nested things too deep you could run into trouble |
| 17:00 | technomancy | that should probably be set by default |
| 17:01 | todun_ | technomancy: oh ok. interesting. that way I wouldnt have to connect to a server. |
| 17:01 | todun_ | right? |
| 17:02 | clojurebot | to be fair I dunno that I've ever had code out right rejected, it just sits in jira or assembla or where ever, or if I ask if there is any interest (before writing any code) I get told to go write alioth benchmarks |
| 17:02 | zerokarmaleft | haha |
| 17:02 | amalloy | clojurebot: i officially reject your code |
| 17:02 | clojurebot | code-review is <rhickey> yikes |
| 17:02 | technomancy | todun_: right. it's not as fancy, but it's easier to set up |
| 17:02 | ibdknox | lol |
| 17:02 | ibdknox | feisty little bastard |
| 17:02 | todun_ | technomancy: ok. thanks for that. |
| 17:03 | amalloy | clojurebot: someone oughta teach you to respect your betters |
| 17:03 | clojurebot | Hello, wiseen |
| 17:03 | ibdknox | rofl |
| 17:03 | duck1123 | todun_: really though, stick with swank until you get the hang of the basics |
| 17:03 | todun_ | duck1123: how do I use the labrepl now that I have all this setup? |
| 17:04 | duck1123 | It's good to know how to drive a stick shift, but when you're just learning to drive, an automatic is easier |
| 17:05 | ibdknox | &(println "clojurebot is annoying") |
| 17:05 | lazybot | ⇒ clojurebot is annoying nil |
| 17:06 | ibdknox | I was hoping he might respond |
| 17:06 | ibdknox | it's not clear to me what gets clojurebot to say things |
| 17:06 | ibdknox | I guess I should look at the code sometime |
| 17:06 | amalloy | haha good luck with that |
| 17:07 | Raynes | I'm still trying to figure out what makes lazybot say things. |
| 17:07 | amalloy | from experience, though: (1) messages starting with ~ or clojurebot: (2) messages ending with ? (3) occasionally just for fun |
| 17:07 | todun_ | duck1123: ok will do. thanks again. |
| 17:07 | todun_ | thanks all. |
| 17:07 | technomancy | ibdknox: there's like a 1% chance he'll interpret any given line as being addressed to him |
| 17:07 | ibdknox | ~hey |
| 17:07 | clojurebot | what's up |
| 17:07 | technomancy | (sorry to spoil the magic) |
| 17:08 | ibdknox | lol |
| 17:08 | ibdknox | aw |
| 17:08 | amalloy | though he's obviously pickier about (2) since he diesn't answer all questions |
| 17:08 | zerokarmaleft | only the questions where the answers are snarky |
| 17:08 | amalloy | haha |
| 17:08 | amalloy | clojurebot: are you a snark bot? |
| 17:08 | clojurebot | Thanks! Can I have chocolate next time |
| 17:08 | ibdknox | lol |
| 17:08 | amalloy | wow, really? snark<=>snack? |
| 17:08 | ibdknox | snark != snack |
| 17:09 | ibdknox | I wonder if it just matches first and last or something haha |
| 17:09 | Raynes | That's strange. |
| 17:09 | ibdknox | clojurebot, sna |
| 17:09 | clojurebot | Thanks! Can I have chocolate next time |
| 17:09 | ibdknox | clojurebot, s |
| 17:09 | clojurebot | lisp is the red pill |
| 17:09 | ibdknox | clojurebot, sn |
| 17:09 | clojurebot | I don't understand. |
| 17:09 | ibdknox | clojurebot, snalfgd |
| 17:09 | clojurebot | I don't understand. |
| 17:09 | ibdknox | hm |
| 17:10 | amalloy | clojurebot: ibdknox doesn't understand |
| 17:10 | clojurebot | Titim gan éirí ort. |
| 17:10 | ibdknox | haha |
| 17:11 | amalloy | clojurebot: you're not helping |
| 17:11 | clojurebot | Huh? |
| 17:12 | ibdknox | clojurebot, snamp |
| 17:12 | clojurebot | Pardon? |
| 17:12 | ibdknox | clojurebot, snam |
| 17:12 | clojurebot | Pardon? |
| 17:12 | ibdknox | wpw |
| 17:12 | ibdknox | wow* |
| 17:12 | ibdknox | wtf is the code that matches that |
| 17:12 | amalloy | ibdknox: in fairness you don't make any sense to me either |
| 17:12 | ibdknox | haha |
| 17:13 | ibdknox | amalloy, I'm talking gibberish most of the time, so that's fair |
| 17:40 | alpheus` | does vals return things in the same order as keys does or is the order undefined for both keys and vals |
| 17:40 | TimMc | ,(doc vals) |
| 17:40 | technomancy | alpheus`: order is guaranteed to be the same if called on the same map. |
| 17:40 | clojurebot | "([map]); Returns a sequence of the map's values." |
| 17:40 | TimMc | ,(doc keys) |
| 17:40 | clojurebot | "([map]); Returns a sequence of the map's keys." |
| 17:41 | TimMc | Should be doc'd, really. |
| 17:41 | technomancy | I think there's an open issue for it? |
| 17:42 | TimMc | Oh yeah, and how long does it usually take for a CA to get entered? |
| 17:42 | brehaut | TimMc: its not a short process |
| 17:42 | TimMc | :-/ |
| 17:43 | alpheus` | technomancy: same map means *identical* map? or a map with the same keys? |
| 17:43 | amalloy | alpheus`: i think it has to mean identical |
| 17:43 | brehaut | TimMc: i think if you send one in, and then have some work you'd like to contribute and say you've sent one in, it'll get done as sooner |
| 17:43 | alpheus` | that's what I would have guessed. |
| 17:44 | brehaut | TimMc: call by need ;) |
| 17:44 | amalloy | since a given impl of IPersistent map can do whatever it wants for keys/vals, and can return a different impl of IPersistentMap for any call |
| 17:44 | amalloy | &(class (dissoc (hash-map :x 1) :x)) |
| 17:44 | lazybot | ⇒ clojure.lang.PersistentHashMap |
| 17:45 | TimMc | brehaut: Lazy loading? :-P |
| 17:49 | bsod1 | I can't run example in this page of clojurescript https://github.com/clojure/clojurescript/wiki/Quick-Start , I'm getting `cljs is not defined` error in chromium, any ideas? |
| 17:49 | amalloy | &(zipmap (keys {:a 1 :b 2}) (vals {:b 2 :a 1})) ;; alpheus` |
| 17:49 | lazybot | ⇒ {:b 1, :a 2} |
| 17:49 | amalloy | i guess is the easiest proof that it doesn't hold for arbitrary maps |
| 18:15 | hiredman | "Using it as a library from Clojure apps is likely a minority case." <-- does this seem ridiculous to anyone else? |
| 18:16 | brehaut | hiredman: context? |
| 18:16 | ibdknox | hiredman, yes |
| 18:17 | ibdknox | that thread made me sad |
| 18:17 | hiredman | brehaut: rich talking about clojurescript |
| 18:19 | brehaut | its curious given that clojure itself is a library as much as it is a language tool |
| 18:25 | technomancy | rich criticizing imprecise use of the term "language tool" without actually defining it himself was kind of irritating |
| 18:26 | hiredman | rich … is kind of irritating |
| 18:37 | amalloy | i wonder what the majority case is supposed to be |
| 18:39 | hiredman | how dare anyone assume you can use clojure and clojurescript together |
| 18:40 | ibdknox | well, I think we're missing what matters |
| 18:40 | ibdknox | there won't be a majority case if it's not easy to use lol |
| 18:41 | technomancy | people are going to use maven releases of clojurescript; it's just a question of whether there will be an official one or if it'll be community-driven |
| 18:41 | brehaut | i would rather not return to that |
| 18:41 | technomancy | much like the entire CLI experience, actually |
| 18:41 | technomancy | deja vu |
| 18:42 | ibdknox | technomancy, yeah, and I'd rather it be official just to prevent us from having 30 cljs jars around |
| 18:43 | technomancy | ibdknox: as long as there's a strong community consensus I think that can be avoided |
| 18:43 | ibdknox | technomancy, fair enough |
| 18:44 | ibdknox | lol |
| 18:44 | hiredman | technomancy: https://twitter.com/#!/aemoncannon/status/124252083477155841 so when can we get this from slime? |
| 18:45 | technomancy | hiredman: heh; vals vs vars? so like ... clojure.lang.IRefs are all blue? =) |
| 18:46 | hiredman | lexical vs. global bindings |
| 18:46 | technomancy | ah! now there's a thought. |
| 18:46 | technomancy | M-. working on locals would be 100% badass |
| 18:46 | hiredman | uh, I don't care about that |
| 18:47 | hiredman | just make them different colors |
| 18:47 | technomancy | well, if you can tell the difference, you might as well offer nav aid too |
| 18:47 | technomancy | but yeah, both would be rad |
| 18:47 | hiredman | I guess |
| 18:47 | technomancy | I guess if you need M-. on locals you probably have functions bodies that are way too long for your own good |
| 18:48 | ibdknox | waaaaay too long |
| 18:49 | brehaut | ie core :P |
| 18:49 | todun | how to quit out of emacs nicely when using swank? |
| 18:50 | technomancy | todun: C-x C-c |
| 18:51 | todun | technomancy: but that doesn't work cleanly in that swank is still running. |
| 18:52 | technomancy | just tell it yes |
| 18:52 | hiredman | technomancy: depends how he is running swank |
| 18:53 | todun | hiredman: I'm running it with split window |
| 18:53 | brehaut | todun: the question is are you starting it from emacs (e.g. clojure-jack-in) or from lein |
| 18:53 | hiredman | using lein swank? clojure-jack-in? other? |
| 18:54 | technomancy | either way exiting emacs will not be harmful |
| 18:55 | duck1123 | I've found that if I run swank in a terminal, when I kill emacs I get an exception in the terminal window, but it doesn't harm the app |
| 18:55 | todun | hiredman: clojure-jack-in |
| 18:55 | clojurebot | http://paste.lisp.org/display/74305 |
| 18:55 | todun | technomancy: ok. |
| 18:55 | todun | duck1123: uhm. ok |
| 18:56 | hiredman | duck1123: right, it's just swanking complaining |
| 18:57 | todun | hiredman: ok. thanks. |
| 18:57 | todun | how do I get back to using labrepl? |
| 18:57 | hiredman | ugh |
| 18:58 | todun | I want to do its exercises but my local host can't connect t o it anymore |
| 18:58 | hiredman | does anyone maintain that? |
| 18:58 | todun | *clojure labs |
| 18:58 | todun | hiredman: clojure labs. sorry about that. |
| 18:59 | duck1123 | hiredman: last activity 25 days ago |
| 19:01 | todun | actually I was right. it is called labrepl http://foognostic.net/labrepl-summary/ |
| 19:01 | todun | it shows up in your local host as Clojure labs |
| 19:04 | ibdknox | the koans might be more interesting |
| 19:04 | todun | ibdknox: referring to me? |
| 19:05 | ibdknox | todun, yeah |
| 19:05 | ibdknox | easier to start with too |
| 19:05 | ibdknox | though the easiest is still try-clojure |
| 19:05 | ibdknox | or just messing around in clooj |
| 19:06 | todun | ibdknox: this https://github.com/functional-koans/clojure-koans ? |
| 19:06 | ibdknox | yep |
| 19:06 | todun | ok. thanks. |
| 19:34 | mabes | where does -?> live? I can never remember.. or is it ->? |
| 19:34 | brehaut | -?> is clojure.contrib.core i think |
| 19:35 | mabes | brehaut: thats it, thanks! |
| 19:45 | Viluin | hey guys |
| 19:45 | Viluin | could anyone help me out with a small problem? |
| 19:46 | TimMc | Viluin: Just go ahead and ask your question; if someone can help they will answer. |
| 19:46 | Viluin | clojure is really weird to me |
| 19:47 | amalloy | i don't think that's a question yet |
| 19:47 | Viluin | getting there :P |
| 19:47 | Viluin | http://pastebin.com/SfS1yRMy I was hoping this would return true if integer n was larger than the amount of characters in string s |
| 19:47 | Viluin | but it doesn't compile at all |
| 19:47 | Viluin | ;x |
| 19:48 | TimMc | needs [] around the args |
| 19:48 | amalloy | prefix functions |
| 19:48 | amalloy | (< x y), not (x < y) |
| 19:48 | Viluin | oooh |
| 19:48 | TimMc | that too |
| 19:48 | Viluin | forgot about that |
| 19:49 | TimMc | I sometimes do that still. >_< |
| 19:50 | Viluin | (defn big [s n] ( < (count s) n)) just seems to return n, not a boolean |
| 19:50 | Viluin | err |
| 19:50 | Viluin | sorry, that wasnt true |
| 19:51 | Viluin | that was me failing to run it correctly |
| 19:51 | TimMc | ,((fn [s n] (< (count s) n) "1234" 12) |
| 19:51 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 19:51 | TimMc | ,((fn [s n] (< (count s) n)) "1234" 12) forgot a paren |
| 19:51 | clojurebot | true |
| 19:51 | Viluin | it seems to work |
| 19:52 | TimMc | Viluin: While we're on the topic, ##(< 1 2 3 4) is a way to check if a series of numbers is in increasing order. |
| 19:52 | lazybot | ⇒ true |
| 19:52 | TimMc | (## is the bot trigger) |
| 19:53 | Viluin | I'm using ClojureBox on Windows, this is really cumbersome to work with |
| 19:53 | TimMc | and Clojure predicates don't always use true and false -- they may return logical false (nil or false) or logical true (everything else.) |
| 19:53 | Viluin | the REPL doesn't seem to support trivial things like copy-paste and pressing uparrow for the previous command |
| 19:54 | Viluin | hmm |
| 19:54 | TimMc | ,(or nil 5 false) |
| 19:54 | clojurebot | 5 |
| 19:55 | Viluin | if there's only 1 arg does it still need [] around it? |
| 19:55 | amalloy | isn't clojurebox basically emacs? it supports all of those things, but in less-crazy ways than you might expect |
| 19:55 | Viluin | emacs, yes |
| 19:55 | Viluin | never used it before |
| 19:55 | TimMc | Viluin: Yes, it needs the []/ |
| 19:55 | TimMc | . |
| 19:55 | amalloy | M-p and M-n do the actions you expect from the up/down arrows |
| 19:56 | Viluin | I have no idea what that means :| |
| 19:56 | amalloy | alt-p/n |
| 19:56 | TimMc | M-p = Alt+p |
| 19:56 | TimMc | blah |
| 19:56 | Viluin | oh |
| 19:57 | Viluin | sometimes I wonder.. why?! |
| 19:57 | Viluin | uparrow works. |
| 19:57 | Viluin | why make it alt+p |
| 19:57 | duck1123 | up arrow moves up, which is more what people expect |
| 19:57 | hiredman | because it's a text buffer like anyother, so you can use up/down to scroll around |
| 19:57 | TimMc | Viluin: For hysterical raisins. |
| 19:58 | TimMc | (historical reasons) |
| 19:58 | hiredman | find some old output, copy and paste it, etc |
| 19:58 | TimMc | Arrow keys and such do not always transmit well in terminals. |
| 19:58 | amalloy | TimMc: that is not true at all |
| 19:58 | TimMc | amalloy: Really? |
| 19:58 | amalloy | i mean, yes, they often don't transmit well in terminals |
| 19:58 | amalloy | but your claim that it's historical is nonsense |
| 19:59 | amalloy | it's because, as hiredman says, you want to be able to edit text in the buffer |
| 20:00 | Viluin | if I have a collection, how do I check to see if it's a map, list or vector? |
| 20:00 | TimMc | Viluin: You usually don't care. |
| 20:00 | Viluin | I really don't, just doing some practice assignments to get to know this thing |
| 20:01 | duck1123 | ,((juxt map? list? vector?) {}) |
| 20:01 | clojurebot | [true false false] |
| 20:03 | Viluin | it's unclear to me what juxt does |
| 20:03 | amalloy | &(doc juxt) |
| 20:03 | lazybot | ⇒ "([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to t... https://gist.github.com/1282995 |
| 20:04 | amalloy | &((juxt inc dec) 1) |
| 20:04 | lazybot | ⇒ [2 0] |
| 20:04 | Viluin | so it applies all the functions to the arg and returns all the results? |
| 20:05 | amalloy | well, it returns a function which, when called, will do that |
| 20:05 | clojurebot | anonymous functions are functions with no names |
| 20:05 | amalloy | good call, clojurebot |
| 20:05 | amalloy | &(let [do-math (juxt + - * /)] (do-math 10 20)) |
| 20:05 | lazybot | ⇒ [30 -10 200 1/2] |
| 20:07 | Viluin | hmm |
| 20:07 | Viluin | so if I want to write a function that determines the type of a collection |
| 20:07 | Viluin | can I just make three if statements that go like if (map? collection) "map" etc? |
| 20:08 | TimMc | You might look at cond or condp. |
| 20:10 | Viluin | what's the difference? |
| 20:10 | Viluin | wouldn't if statements work? |
| 20:10 | TimMc | Sure. |
| 20:10 | Viluin | coljure compiler errors are really good at providing absolutely no info about the error |
| 20:10 | Viluin | lol |
| 20:23 | amalloy | clojurebot: juxt is usually the right answer |
| 20:23 | clojurebot | Ok. |
| 20:24 | ibdknox | amalloy, what does that enable you to do? |
| 20:24 | amalloy | ibdknox: hm? |
| 20:25 | ibdknox | does telling clojurebot let you trigger him somehow? |
| 20:25 | amalloy | *nod* |
| 20:25 | ibdknox | ~juxt |
| 20:25 | clojurebot | juxt is usually the right answer |
| 20:25 | ibdknox | I see |
| 20:25 | amalloy | amalloy: what's a good way to perform two functions on the same input? |
| 20:25 | amalloy | juxt? |
| 20:25 | clojurebot | juxt is usually the right answer |
| 20:25 | ibdknox | lol |
| 20:25 | ibdknox | fun |
| 20:26 | amalloy | ibdknox: this one's just for fun, of course, but in general it's a useful way to create canned replies |
| 20:26 | amalloy | clojurebot: where can i find zipWith? |
| 20:26 | clojurebot | It's greek to me. |
| 20:26 | amalloy | damn |
| 20:26 | ibdknox | haha |
| 20:26 | amalloy | clojurebot: zip? |
| 20:26 | clojurebot | zip is not necessary in clojure, because map can walk over multiple sequences, acting as a zipWith. For example, (map list '(1 2 3) '(a b c)) yields ((1 a) (2 b) (3 c)) |
| 20:26 | brehaut | amalloy: why sporks? |
| 20:26 | ibdknox | ~contrib |
| 20:26 | clojurebot | contrib is http://github.com/richhickey/clojure-contrib/tree/master |
| 20:26 | amalloy | brehaut: because you said it yesterday and i thought it was funny |
| 20:27 | Viluin | well I've had enough for tonight, heading off to bed, thanks for the help guys! |
| 20:27 | brehaut | fair enough |
| 20:27 | amalloy | clojurebot: forget contrib |is| http://github.com/richhickey/clojure-contrib/tree/master |
| 20:27 | clojurebot | I forgot that contrib is http://github.com/richhickey/clojure-contrib/tree/master |
| 20:28 | brehaut | clojurebot: tell me about contrib |
| 20:28 | clojurebot | contribute is http://clojure.org/contributing |
| 20:30 | ibdknox | contrib? |
| 20:30 | clojurebot | contribute is http://clojure.org/contributing |
| 20:30 | amalloy | clojurebot: where did contrib go? |
| 20:30 | clojurebot | well... it's a long story: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 20:31 | ibdknox | ah |
| 20:31 | ibdknox | that's the one |
| 20:31 | duck1123 | clojurebot: where's contrib? |
| 20:31 | clojurebot | http://clojure.org/contributing |
| 20:31 | ibdknox | I assume it's just a string match |
| 20:32 | amalloy | i think there is some fairy dust involved |
| 20:32 | duck1123 | One of these days I want to try getting an Alicebot working in Clojure |
| 20:32 | amalloy | specifically he has some kind of database of "things", with a full-text index of all "things" |
| 20:32 | amalloy | and i don't understand full-text indexes, but i understand that he can look for "whatever is close to X" |
| 20:33 | amalloy | duck1123: is that different from eliza? |
| 20:34 | duck1123 | amalloy: quite a bit more advanced, but same idea. A chat bot |
| 20:34 | duck1123 | it used a XML language to define the bot's knowledge. Perfect job for a Clojure DSL |
| 20:35 | brehaut | duck1123: port it to core.logic |
| 20:37 | amalloy | mehhhhhh. the LA clojure usergroup made some desultory collaborative effort in this direction at https://github.com/Factual/eliza but it never really went anywhere. i think having a canonical way to represent the bot's knowledge isn't as interesting/flexible as having a ring-wrapper sort of architecture for it to make it more pluggable |
| 22:08 | zakwilson | A potential client just asked for examples of sites built with Clojure. While I think the question is stupid, I have to humor him. Any good examples I can use? |
| 22:11 | @chouser | zakwilson: I'm sure there are many. 4clojure.com is one |
| 22:12 | zakwilson | chouser: I'm aware there are likely hundreds. I just want a couple I can point at and say "See? These are nice and professional-looking.". |
| 22:23 | jkkramer | zakwilson: http://dev.clojure.org/display/community/Clojure+Success+Stories might help |
| 22:23 | zakwilson | jkkramer: thanks |
| 22:40 | darevay | For those that have been frustrated by vimclojure, here's my attempt at a "base" configuration that people can build from or sanity check: https://github.com/daveray/vimclojure-easy |
| 23:06 | srid | zakwilson: heroku uses clojure. checkout github.com/heroku/pulse which is their internal real-time operations dashboard |
| 23:07 | zakwilson | srid: thanks. |
| 23:08 | srid | dell uses clojure http://groups.google.com/group/clojure/browse_thread/thread/d1b77050260340f6 |
| 23:53 | brehaut | amalloy: how are passwords stored on 4clojure? |
| 23:53 | amalloy | $google jasypt |
| 23:53 | lazybot | [Jasypt: Java simplified encryption - Main] http://www.jasypt.org/ |
| 23:54 | amalloy | brehaut: that is, we one-way hash them and store the hash. we don't do any salting afaict, so a replay attack would probably work? i'm not an expert in the area |
| 23:55 | brehaut | amalloy: cool, thats all i really wanted to know :) |
| 23:55 | amalloy | sweet |
| 23:55 | technomancy | clojurebot: how do you safely store passwords? |
| 23:55 | clojurebot | Gabh mo leithscéal? |
| 23:56 | technomancy | clojurebot: how do you safely store passwords is <reply>bcrypt. http://codahale.com/how-to-safely-store-a-password/ |
| 23:56 | clojurebot | Ok. |
| 23:56 | technomancy | but to be fair jasypt probably gives you a better deal than sha1 |
| 23:56 | brehaut | that article must have insane google juice by now |
| 23:58 | technomancy | googlebot crawls our logs, right? =) |
| 23:58 | brehaut | its the primary source |
| 23:59 | technomancy | jkkramer: did you get my privmsgs? |
| 23:59 | dsantiago | This is probably a really dumb question, but why does (type '(+ 1 2)) return a PersistentList and (type `(+ 1 2)) return a Cons? |
| 23:59 | duck1123 | ~passwords |
| 23:59 | clojurebot | bcrypt. http://codahale.com/how-to-safely-store-a-password/ |
| 23:59 | amalloy | dsantiago: ` does a lot of stuff |
| 23:59 | technomancy | dsantiago: basically you're never supposed to know there's a difference between the two classes |
| 23:59 | amalloy | &''(+ 1 2) |
| 23:59 | lazybot | ⇒ (quote (+ 1 2)) |
| 23:59 | technomancy | whatever you do, don't use the list? predicate |
| 23:59 | amalloy | &'`(+ 1 2) |
| 23:59 | lazybot | ⇒ (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/+)) (clojure.core/list 1) (clojure.core/list 2))) |