2011-08-27
| 00:06 | joshnz | Hi all. I'm trying to learn clojure and my heads going round in circles trying to get emacs/slime/clojure setup. Does anyone here have time to please provide some guidance? |
| 00:09 | srid | another clojure web framework - http://ringfinger.floatboth.com/ |
| 00:12 | amalloy | dnolen: i don't understand how much happens at compile time vs runtime. could the method bodies at line 37 be typehinted? |
| 00:12 | talios | srid: looks interesting - yours? |
| 00:12 | amac | joshnz: http://www.dreamux.com/community/getting-started-with-clojure-setup.php |
| 00:12 | srid | talios: nope, just found that by browsing reddit |
| 00:12 | amac | this is pretty much up-to-date |
| 00:12 | hiredman | ugh |
| 00:12 | hiredman | no |
| 00:12 | hiredman | amac: not |
| 00:13 | hiredman | blog posts are horrible, and always out of date |
| 00:13 | hiredman | read the swank-clojure readme, and follow the 3 steps listed there |
| 00:13 | dnolen | amalloy: why would method bodies need typehints? |
| 00:13 | joshnz | I've just been looking at swank-clojure latest readme |
| 00:13 | amac | hiredman: fair enough, though I tried to write this one comprehensively and somewhat recently |
| 00:14 | talios | I'd go so far as to say for a newbie - stay away from emacs/slime and use clooj - http://dev.clojure.org/display/doc/getting+started+with+Clooj - so much easier for a newbie |
| 00:14 | amac | though it only covers setup on osx |
| 00:14 | hiredman | amac: well, you should have read the swank-clojure readme |
| 00:14 | amalloy | dnolen: even better question. i guess i don't even know if extend-type automatically hints stuff. i suppose it should |
| 00:14 | dnolen | amalloy: it does. |
| 00:14 | amac | true. |
| 00:14 | amalloy | well then |
| 00:14 | hiredman | amac: lein-swank hasn't been required for a long time now |
| 00:14 | amalloy | carry on being clever, i'll just keep making bad suggestions |
| 00:15 | hiredman | https://github.com/technomancy/swank-clojure <-- 3 steps under usage, all you need to do |
| 00:15 | amac | gah, you're right. |
| 00:15 | hiredman | you can run into issues with osx, because it doesn't give cocoa emacs the right path, it might be able to find lein unless you manually set your path |
| 00:15 | hiredman | might not |
| 00:16 | joshnz | emacs 23.3. clojure-mode 1.10.0 installed via emacs-starter-kit from marmalade. |
| 00:16 | joshnz | lein plugin install swank-clojure 1.3.2. done |
| 00:16 | joshnz | From inside a project, invoke M-x clojure-jack-in |
| 00:17 | amac | joshnz: working? |
| 00:17 | joshnz | It just says "starting swank server...." but nothing else |
| 00:17 | amac | you need a project.clj |
| 00:17 | talios | joshnz: another kiwi clojurian? nice :) |
| 00:17 | hiredman | it can take some time, you should have a *swank* buffer start to op up |
| 00:17 | amac | go to a directory and type lein new |
| 00:18 | joshnz | yeah, I created a lein project. I've open the project.clj file in emacs |
| 00:18 | amac | then open src/project/core.clj and do mx clojure-jack-in again |
| 00:18 | amac | and it can take a while |
| 00:18 | hiredman | if clojure-jack-in doesn't work, and you don't want to try and debug it, you can run `lein swank` in a shell, use M-x slime-connect |
| 00:19 | amac | hiredman: clj-jack-in doesn't really give much feedback for debugging |
| 00:19 | hiredman | depends |
| 00:20 | hiredman | *shrug* |
| 00:20 | joshnz | does clojure-jack-in just use clojure-mode's own logic to talk to the swank server? Does it bypass slime totally? |
| 00:20 | amac | it starts the swank server and then fires up the slime connection |
| 00:21 | amac | basically it starts both sides of the conversation for you |
| 00:21 | hiredman | clojure-jack-in pulls a copy of slime that is known to work with swank-clojure out of the swank-clojure jar and loads it into emacs |
| 00:21 | amac | doin lein swank from your project will start the server manually, and mx slime-connect starts slime manually |
| 00:21 | joshnz | ah...I've found the swank buffer: /bin/bash: lein: command not found... hmm... |
| 00:21 | hiredman | right |
| 00:21 | hiredman | joshnz: osx right? |
| 00:21 | joshnz | yup |
| 00:21 | hiredman | this is the exact issue I mentioned |
| 00:21 | joshnz | it's on the path for terminal |
| 00:22 | hiredman | sure, but osx doesn't read your dotfiles when launch gui apps |
| 00:22 | talios | joshnz: what part of nz are you in? |
| 00:22 | hiredman | launching |
| 00:22 | joshnz | hamilton |
| 00:22 | duck1123 | I never have had much luck getting path working right for osx emacs |
| 00:22 | hiredman | (setenv "PATH" "...:whereverleinis:...") |
| 00:22 | talios | joshnz: ahh- bit to far to often a inhouse clojure tutorial pair session then :) Auckland here |
| 00:24 | hiredman | if you want your env variables to be populated to gui apps, I believe you need to load them into launchd somehow, or write them up in some xml file |
| 00:24 | joshnz | no prob ;) At least I've got a bit more a lead on what the issue is. The problem following blog posts and video tuts as mentioned earlier is that all have a different way and none of them are correct any more ;) |
| 00:25 | talios | joshnz: that being said, I've been thinking of reasons for a road-trip weekend to hamilton. been too long since I've visitied folk down there. |
| 00:26 | duck1123 | http://www.astro.washington.edu/users/rowen/AquaEnvVar.html |
| 00:26 | joshnz | how is it that clojure-mode knows where to find swank-clojure? Does it depend on lein? |
| 00:27 | hiredman | it uses lein's plugin system |
| 00:27 | joshnz | (I should probably just read the clojure-jack-in code ;) |
| 00:27 | hiredman | lein plugin install makes swank-clojure available for all projects as a user level plugin |
| 00:29 | joshnz | thanks for the link duck1123. |
| 00:31 | hiredman | launchctl also has a setenv cmd |
| 00:37 | joshnz | Possibly the easiest thing right now without mucking around with the system is to simply append my lein path to the PATH var in emacs. Something like (setenv (append "/usr/local/bin" (getenv "PATH"))) but that's not quite working.. |
| 00:37 | joshnz | Not crash hot on my elisp either.. but it's only been a few days ;) |
| 00:38 | hiredman | PATH is a string |
| 00:38 | hiredman | so you need to use stringconcat or something |
| 00:38 | hiredman | just (concat ...) |
| 00:38 | hiredman | and you'll need a : |
| 00:39 | joshnz | ah so that's what's happening :) I |
| 00:39 | joshnz | It's outputting my new path as a vector of char bytes |
| 00:39 | joshnz | lol. Makes sense |
| 00:40 | joshnz | google's good: (setenv "PATH" (concat "your-lein-dir:" (getenv "PATH"))) |
| 00:43 | hiredman | you could actually have emacs fork your shell and echo $PATH |
| 00:45 | joshnz | Now I get an error in the process filter: Symbol's value as variable is void: Process [2 times]. This is while loading slime from the jar it appears. |
| 00:46 | joshnz | I'll restart emacs. I'm assuming the swank server is shut down when I do this? |
| 00:46 | hiredman | if you kill the *swank* buffer it will die |
| 00:47 | hiredman | but yes, closing emacs with do that |
| 00:47 | joshnz | yup, that would have been the active process I just told emacs to kill :) |
| 00:48 | hiredman | (setenv "PATH" (shell-command-to-string "echo $PATH")) ; works pretty nicely |
| 00:48 | hiredman | hmmm, maybe not, I should try it on a clean emacs |
| 00:49 | joshnz | yeah, I've got some other similar suggestions from google groups... there's env-var-from-shell |
| 00:50 | joshnz | But I'm connect to swank now. Probably had a few stuck processes before which was stuffing things up |
| 00:59 | joshnz | Thanks heaps to all. It appears I have it working. I should probably go and add to the clojure wiki. |
| 01:00 | paul__ | hey, I'm trying to make a seq of vectors into just one seq, what is the function to do this called? |
| 01:01 | amalloy | paul__: (apply concat vecs) |
| 01:01 | paul__ | thanks |
| 01:01 | amalloy | but also see if you can not produce the seq of vectors to begin with, by using eg mapcat |
| 01:01 | amalloy | joshnz: that'd make you a better citizen than most of us |
| 01:09 | joshnz | How does emacs know that I'm in a clojure project? Does clojure-jack-in need to be called from core.clj, or does it do something clever and traverse folders looking for something? That be seem hard to implement a stop condition on..... |
| 01:10 | joshnz | oh, it probably doesn't care. clojure-jack-in will just connect to swank regardless... |
| 01:13 | amalloy | it has to start the swank server too. i suspect it walks up the tree looking for project.clj |
| 01:19 | amalloy | joshnz: i was wrong. it just calls "lein swank" in the cwd, and lein does the filesystem walking |
| 01:19 | amalloy | or i guess it calls "lein jack-in"; whatever, same thing |
| 01:20 | joshnz | really? So it will walk all the way to root if you're in say a rails project? lol |
| 01:20 | semperos | trying to tinker with the Clojure repl, intercepting the read process, making some adjustements to what's in *in* and then letting it resume per usual, but I'm not sure how to work with the LineNumberedPushbackReader that is *in* |
| 01:20 | amalloy | probably. i've never looked at the lein source |
| 01:20 | joshnz | I guess it's not too bad, since you're not checking sibling folders, only the parent or current |
| 01:21 | amalloy | right |
| 01:21 | semperos | as an arbitrary example, say I just wanted to make a single case where if "1 + 1" is typed at the repl, I can parse that, and then replace that with "(+ 1 1)" and send the repl on its normal path |
| 01:21 | semperos | I see how to replace the standard read fn for clojure.main/repl, but as I mentioned, at this point I'm not sure how to work with PushbackReaders |
| 01:22 | semperos | any thoughts/guidance/good resources to look at? |
| 01:22 | amalloy | semperos: you could rebind *in* to a proxy of LNPBR |
| 01:23 | amalloy | that wraps the original *in* and delegates to it |
| 01:24 | semperos | right |
| 01:24 | semperos | that it needs a PushbackReader or derivation thereof I understand, I suppose my question is more on the Java side of actually using that class to look at the contents and then constructing a new one |
| 01:25 | semperos | some of the code samples I found were less than helpful... |
| 01:30 | amalloy | semperos: i'll gist something up in a few minutes |
| 01:30 | semperos | amalloy: didn't mean to ask for too much hand-holding, but I appreciate any help, thanks |
| 01:36 | amalloy | semperos: hm. it's more complicated than i thought because the reader reads stuff one character at a time, not line at a time. but i'll gist what i have and you can take what you like |
| 01:37 | amalloy | https://gist.github.com/1175034 |
| 01:37 | semperos | yeah, I noticed that |
| 01:37 | semperos | thanks for putting that together, I'll take a look |
| 01:38 | amalloy | $javadoc java.io.PushbackReader |
| 01:38 | lazybot | http://download.oracle.com/javase/6/docs/api/java/io/PushbackReader.html |
| 01:38 | semperos | yep, I looked at those |
| 01:38 | amalloy | yeah, that was for me |
| 01:38 | semperos | gotcha |
| 01:39 | semperos | haven't been on in a while, nice to see continued bot helpfulness |
| 01:39 | amalloy | you probably want to proxy BufferedReader, which does all its input line-at-a-time, and then wrap a LNPBR around your proxy |
| 01:39 | amalloy | ugh, but i bet it doesn't do *all* its input line at a time :P |
| 01:39 | semperos | heh |
| 01:40 | semperos | that makes sense, though |
| 01:42 | amalloy | semperos: i always have a hell of a time finding the java stdlib sources. i'm curious now; you don't happen to know where i can see buffered-reader's impl? |
| 01:42 | semperos | no, I don't |
| 01:43 | semperos | for download: http://download.java.net/jdk6/source/ |
| 01:45 | amalloy | ah, lovely |
| 01:49 | joshnz | ok, added a comment to the dev page. If there's anything horrible incorrect, let me know and i'll update it |
| 01:49 | joshnz | http://dev.clojure.org/display/doc/Getting+Started+with+Emacs?focusedCommentId=2687001&#comment-2687001 |
| 01:50 | semperos | my other question would be in actually getting a running repl; I've tried to mimic the appropriate parts of clojure.main/main to run a repl with my updated read fn |
| 01:51 | semperos | but whenever I run the code, it just prints the "user=>" prompt and then immediately exits |
| 01:51 | ivan__ | joshnz: hi fellow NZ person :) |
| 01:51 | joshnz | howdy ivan_ |
| 01:53 | amalloy | semperos: are you running it from swank? |
| 01:53 | semperos | tried that |
| 01:54 | hiredman | semperos: using lein run? |
| 01:54 | semperos | currently using the code from lein repl and tweaking there, as I got that working |
| 01:54 | amalloy | i wouldn't be surprised if that didn't work |
| 01:54 | semperos | amalloy: now that you mention it, I'm not either |
| 01:54 | amalloy | repl and/or run probably would |
| 01:54 | cheier | semperos: make sure you setq slime-net-coding-system 'utf-8-unix |
| 01:54 | semperos | hiredman: yes, in my own code, was trying lein run |
| 01:54 | hiredman | semperos: I've seen that behaviour before, your repl will run fine outside of lein run |
| 01:54 | semperos | rather, with my own code, was putting the code to run the repl in -main and using `lein run` from cmd line |
| 01:55 | hiredman | e.g. if you uberjar it |
| 01:55 | semperos | ah |
| 01:55 | semperos | shouldn't taken that one more step, I'll git it a try |
| 01:55 | amalloy | joshnz: "You will still need to the :. "? |
| 01:55 | hiredman | lein run and clojure.main/repl have issues |
| 01:57 | joshnz | I assumed so. Because you're appending to the head of PATH, so it still needs to be separated with a colon. I'll tweak that a bit |
| 01:57 | amalloy | joshnz: i'm not saying you're wrong, i'm saying i don't understand the sentence |
| 01:57 | joshnz | yeah, that's how I understood your question |
| 01:57 | amalloy | especially, do i need ":", and your sentence ends with ".", or do i need ":."? |
| 01:58 | amalloy | since :. is a pretty common thing to have in your PATH |
| 01:58 | joshnz | I'm not sure if you need the : if PATH is empty string. I assume it won't break anything if you end your PATH var with a colon |
| 01:59 | hiredman | amalloy: only if you like being insecure |
| 01:59 | amalloy | or...maybe "." isn't actually common, and i just thought it was when i was a DOS junkie |
| 01:59 | joshnz | I agree that I thought it was a bit weird typing :. but i'm not one for long docs ;) |
| 02:00 | amalloy | hiredman: i remember learning it was insecure (and perhaps forbidden) as root, but i never re-evaluated the assumption that it's good for general users. now that i say it aloud it's clearly wrong |
| 02:00 | amalloy | (and indeed it hasn't been on my path for years) |
| 02:02 | semperos | hiredman: yep, uberjar worked, good call |
| 02:02 | joshnz | update to make :. a bit more descriptiive |
| 02:02 | joshnz | updateD that should be |
| 02:03 | hiredman | semperos: I was playing with my own repo recently |
| 02:03 | hiredman | repl |
| 02:04 | semperos | that'd help |
| 02:12 | joshnz | @ivan_: You're not Ivan from Mindscape by chance? |
| 03:50 | zoldar | Hello, I'm trying to use an object instance from compiled record in java code. Minimal example here: http://pastebin.com/P4C3FxXM . Is it at all possible to refer to the vars outside record's namespace? Or is gen-class the only way in such situation? |
| 03:51 | hiredman | as I said last time you asked, you have to load the namespace |
| 03:52 | zoldar | hiredman, sorry, had to miss your answer then |
| 03:52 | hiredman | loading the record doesn't load the namespace, and the record tries to use the values of vars that are not setup until you load the namespace |
| 03:53 | zoldar | how would I accomplish this? in such case ? |
| 03:54 | hiredman | RT.load maybe work |
| 03:54 | zoldar | should I explicitly put require/use inside method body? |
| 03:54 | hiredman | no |
| 03:54 | zoldar | ah |
| 03:54 | hiredman | (clojure.lang.RT/load "foo/core") or whatever |
| 03:54 | hiredman | (but as java) |
| 03:57 | zoldar | that worked |
| 03:58 | zoldar | but it'll require writing wrappers |
| 04:03 | zoldar | thanks for pointers anyway, and sorry for reposting the same question |
| 06:07 | kzar | What d'ya reckon to this attempt at filtering every nth item in a sequence? http://paste.lisp.org/display/124299 - sure it's a bit clunky |
| 06:25 | thorwil | kzar: seems a bit brutal to index the items |
| 06:28 | kzar | thorwil: Hmm can't think of how else to approach it though |
| 06:33 | thorwil | kzar: i'd consider the use of partition or somehow looping with an internal counter |
| 06:36 | thorwil | ,(flatten (map butlast (partition 4 [:a :b :c :d :e :f]))) |
| 06:37 | clojurebot | (:a :b :c) |
| 06:37 | thorwil | kzar: ^ |
| 06:37 | mrBliss | ,(mapcat butlast (partition 4 [:a :b :c :d :e :f])) |
| 06:37 | clojurebot | (:a :b :c) |
| 06:38 | thorwil | nice :) |
| 06:55 | thorwil | is there any potential use in using one name more than once in a function signature? |
| 07:00 | kzar | mrBliss: Hey I did the same approach, one problem though is that partition leaves off the |
| 07:00 | kzar | end of the list if there's not enough for the partition |
| 07:00 | kzar | ,(partition 3 [1 2 3 4 5]) |
| 07:00 | clojurebot | ((1 2 3)) |
| 07:01 | mrBliss | use partition-all instead (btw thorwill came up with the function, I only tweaked it a bit) |
| 07:01 | mrBliss | *thorwil |
| 07:02 | kzar | gold stars all round |
| 07:03 | thorwil | ah, well, butlast will not be the right thing is the last partition is shorter ... |
| 07:04 | kzar | Yea just noticed that, (take (dec nth) col) instead maybe |
| 07:06 | peteriserins | I'm following the cljs QuickStart, getting this error when launching script/repljs java.lang.ClassNotFoundException: sun.org.mozilla.javascript.internal.Context |
| 07:07 | peteriserins | is it because I am running openjdk? |
| 07:07 | morphling | peteriserins: yes |
| 07:08 | kzar | (defn skip-nth [col nth] (apply concat (partition-all (dec nth) nth col))) |
| 07:48 | peteriserins | would one use vim-clojure with clojurescript? |
| 07:58 | fliebel | What became of the indexed vs map-indexed discussion? I keep wanting the index of an item in different places. |
| 08:00 | fliebel | I suppose amalloy-utils has it... |
| 08:05 | fliebel | kzar: What became of your drop-nth? |
| 08:06 | kzar | fliebel: Shortest I did was this: #(apply concat (partition-all (dec %2) %2 %)) which is as above but with #() instead of (fn .. |
| 08:07 | kzar | fliebel: I think there's an indexed function in seq-utils |
| 08:07 | fliebel | kzar: I was playing with the modulus of the index in filter. |
| 08:08 | kzar | fliebel: Yea I thought about that, didn't try it that way in the end though |
| 08:09 | fliebel | kzar: It *might* be faster, because you create less temp objects that way. |
| 08:10 | kzar | fliebel: Something like (map second (filter #(not (zero? (mod (first %) (dec nth)))) (clojure.contrib.seq-utils/indexed col))) |
| 08:10 | kzar | fliebel: Tpyed that straight into IRC without trying it, probably wont work |
| 08:10 | fliebel | I did this: (map peek (remove #(zero? (mod (first %) 3)) (indexed (range 10 0 -1)))) |
| 08:12 | kzar | fliebel: Is there a shorter way of writing (apply concat ...) ? |
| 08:13 | fliebel | mapcat comes to mind |
| 08:13 | kzar | fliebel: But without mapping a function voer first |
| 08:13 | fliebel | yea... dunno |
| 08:14 | kzar | What's bamboozling me now is this one http://4clojure.com/problem/31 |
| 08:15 | fliebel | flatten, maybe, but that's not very nice I think. |
| 08:16 | fliebel | kzar: let me tell you ther's a function in core that almost solves that. |
| 08:16 | kzar | aha that's got me down into shortest solution |
| 08:16 | kzar | fliebel: Cool OK, well don't tell me I'll try and find it heh |
| 08:17 | fliebel | Maybe a synonym to 'pack' might help... well, not really a synonym, but the sultuion reads like the problem description. |
| 08:18 | kzar | ah got to run anyway |
| 08:38 | semperos | I'm playing with clojure.main/repl, I've written my own read function that does some things with *in* and then calls Clojure's default clojure.core/read function |
| 08:38 | semperos | I can successfully "intercept" it and call it, but in the running REPL, I have to hit enter twice for the result to be returned |
| 08:39 | semperos | so if I write (+ 1 1), I can see it running through my read code, but then it hangs after the call to clojure's default read function, at which point if I press enter again, it continues and returns 2 |
| 08:41 | semperos | I've tried adding \newline to the end of the content I pass to read, but that doesn't seem to help |
| 08:50 | lobotomy_ | hm, is there something special about testing multimethods that (invoke functions that) throw exceptions? |
| 08:51 | lobotomy_ | i'm trying to verify that the exception is thrown. with (make-piece [-1 20 6 6] "" "" "") i get the exception as i should; with (is (thrown? java.lang.IllegalArgumentException (make-piece [-1 20 6 6] "" "" ""))) the test fails, saying "actual: nil", which apparently means nothing was thrown |
| 08:53 | lobotomy_ | make-piece is a multimethod that switches on the type of the first of the first argument, and in the Integer case does a (map verify-edge first-arg), where verify-edge throws IllegalArgumentException for illegal values such as < 0 |
| 11:08 | technomancy | hiredman: would something like (shell-command "echo \"lein jack-in 92424\" | sh") solve the macosecks path issue? |
| 11:32 | scode | What's the idiomatic way to do (byte 200) in clojure? That won't work due to overflow protection. I want to do the equivalent of "byte b = (byte)myInt;" in Java, preferably without doing (byte (- x 128)). |
| 11:33 | coopernurse | scode: try (.byteValue 20) |
| 11:33 | coopernurse | ,(.byteValue 20) |
| 11:33 | clojurebot | 20 |
| 11:34 | coopernurse | (class (.byteValue 20)) |
| 11:34 | coopernurse | ,(class (.byteValue 20)) |
| 11:34 | clojurebot | java.lang.Byte |
| 11:34 | scode | Thanks! |
| 11:34 | coopernurse | &(class (.byteValue 30)) |
| 11:34 | lazybot | ⇒ java.lang.Byte |
| 11:34 | coopernurse | looks like it works in 1.3 also.. |
| 11:35 | coopernurse | not sure if there's a more idiomatic way, but that should work |
| 13:25 | solussd | question- why when I add the clojure.data.json library to my dependencies list in my project.clj (leiningen) do I prefix it with org.clojure/ ? the json library is in the clojure.data.json namespace, what's with the / and org. ? |
| 13:25 | solussd | in other words what's the difference between that usage and the name.space/package usage in clojure? |
| 13:26 | coopernurse | solussd: in project.clj you're specifying a (maven style) library dependency |
| 13:26 | Chousuke | solussd: someone else might offer a modified version of the same package |
| 13:26 | Chousuke | so you have organisation/package |
| 13:26 | coopernurse | which is a JAR that contains many packages |
| 13:27 | coopernurse | sorry, namespaces (not packages) in clojure parlance |
| 13:27 | coopernurse | does that help? |
| 13:27 | solussd | ok, so there isn't necessarily a relationship between the package namespace and the organization/package in my project.clj |
| 13:27 | coopernurse | right |
| 13:27 | solussd | that does. thanks! |
| 13:28 | coopernurse | if you look in your ~/.m2/repository dir |
| 13:28 | coopernurse | you'll see the local cache of JARs you've specified in project.clj across all projects on your box |
| 13:28 | coopernurse | and that dir structure will match project.clj's naming conventions |
| 13:28 | solussd | cool. Sure is a lot in there. :D |
| 13:28 | coopernurse | if you "jar tvf [filename]" one of the jars in lib |
| 13:29 | coopernurse | you'll see the layout of files in the library |
| 13:29 | coopernurse | and that layout will match your namespaces for the files you use/require |
| 13:30 | coopernurse | heh, yeah, maven (which lein uses) has been described as a "DSL for downloading the internet" |
| 13:30 | solussd | haha |
| 13:30 | coopernurse | good thing there's a local cache |
| 13:55 | rdbcci | is it just me or does the repl hang alot? |
| 13:56 | coopernurse | rdbcci: how are you starting the repl? |
| 13:56 | rdbcci | java -cp .;jline-0_9_5.jar;clojure.jar jline.ConsoleRunner clojure.main |
| 13:57 | coopernurse | and you're interacting with it directly, or are you talking to it from an editor like emacs? |
| 13:58 | rdbcci | directly windows vista |
| 13:58 | jkkramer | rdbcci: does it just hang out of the blue or in reaction to certain input (e.g., infinite sequences)? |
| 14:01 | rdbcci | input, maybe infinite seq - but since im fiddling about... |
| 14:02 | jkkramer | if you find yourself accidentally realizing infinite seqs a lot, the *print-length* and *print-depth* vars may help |
| 14:02 | fliebel | Those guys at Geni are like 6 hours behind GMT, right? I'm having trouble figuring out the right time to try to reach them. |
| 14:02 | jkkramer | er, *print-level*, not *print-depth* |
| 14:05 | rdbcci | not giving any output though, just hanging |
| 14:07 | jkkramer | rdbcci: it tends to hang if you attempt to print an infinite seq |
| 14:07 | jkkramer | ,(binding [*print-length* 10] (prn (iterate inc 1))) |
| 14:07 | clojurebot | (1 2 3 4 5 6 7 8 9 10 ...) |
| 14:07 | jkkramer | in the repl, (set! *print-length* 10) |
| 14:07 | raek | rdbcci: are there certain expressions that hangs, or is the hanging random? |
| 14:09 | rdbcci | certain expressions im pretty sure |
| 14:12 | rdbcci | i know i may be abusing it, but it seems a little less than robust |
| 14:13 | raek | rdbcci: can you show an example of an expression that hangs? |
| 14:13 | arohner | fliebel: they're in california, so that's -8 I believe |
| 14:14 | fliebel | arohner: Hm, okay, so I'm GMT+2 ATM, I believe, so they should at least be awake now, right? |
| 14:14 | arohner | yes, 11AM there |
| 14:16 | rdbcci | sure, happens while exploring function for url data fetching |
| 14:20 | rdbcci | mainly coll returned from url .getHeaderFields |
| 14:31 | semperos | playing clojure.main/repl, I've put together a custom read function that does a few things, then builds a new LineNumberingPushbackReader and passes it to the default clojure.core/read function |
| 14:32 | semperos | however, whenever I create this LNPBR and pass it to the default read, the prompt just sits there |
| 14:32 | semperos | either waiting for me to press enter twice |
| 14:32 | semperos | I've tried appending newlines to the content of the LNPBR before sending it to read, but that doesn't make any difference |
| 14:33 | semperos | when I spit to file what is in *in* by default, e.g. if I enter foo at the repl, it's foo plus three newlines (char code 10) |
| 15:11 | michaelr525 | Hey! |
| 15:21 | jblomo | anyone using lein-beanstalk? trying to get my app working on aws |
| 15:47 | Netpilgrim | Hi. I’m reading The Joy of Clojure, and the authors say (p. 91): “Also, the order of values returned by seq on a list is backward compared to seq on a vector …” Am I missing something, or is this just not true? |
| 15:47 | Netpilgrim | ,(seq '(1 2 3)) |
| 15:47 | clojurebot | (1 2 3) |
| 15:47 | Netpilgrim | ,(seq [1 2 3]) |
| 15:47 | clojurebot | (1 2 3) |
| 15:51 | jblomo | Netpilgrim: I don't have the book, but yea that seems wrong the way i'm reading it. the order in which things are *added* is reversed |
| 15:53 | Netpilgrim | jblomo: I know, and I'm thinking about how this could be they meant somehow but I don't think the sentence as written can be misinterpreted. |
| 15:53 | Netpilgrim | s/they meant/what they meant/ |
| 15:53 | lazybot | <Netpilgrim> jblomo: I know, and I'm thinking about how this could be what they meant somehow but I don't think the sentence as written can be misinterpreted. |
| 15:54 | jblomo | yea, strange. maybe they have an eratta on the website |
| 15:55 | Netpilgrim | jblomo: They have, but it's not in there. |
| 15:56 | jkkramer | the context is stacks and peek/pop. maybe they meant peek/pop work on opposite ends for list/vector |
| 15:56 | jkkramer | ,(peek '(1 2 3)) |
| 15:56 | clojurebot | 1 |
| 15:56 | jkkramer | ,(peek [1 2 3]) |
| 15:56 | clojurebot | 3 |
| 15:56 | jkkramer | it does appear to be incorrect as worded, though |
| 15:57 | jblomo | defonce doesn't work with Vars from other namespaces? |
| 15:58 | jblomo | i'd like to (:use settings.custom) then have (ns settings) set defaults |
| 16:01 | Netpilgrim | jkkramer: That's probably what they were thinking about. It's still more than just a type. I'll add it to the errata thread in the Manning forum. |
| 16:01 | Netpilgrim | s/type/typo/ |
| 16:02 | lazybot | <Netpilgrim> jkkramer: That's probably what they were thinking about. It's still more than just a typo. I'll add it to the errata thread in the Manning forum. |
| 16:11 | stuartsierra | jblomo: The full name of a Var includes the namespace in which it was defined. |
| 16:12 | stuartsierra | All the `def` forms create a new Var in the current namespace. |
| 16:13 | jblomo | is there a better way to conditionally load custom settings? |
| 16:14 | stuartsierra | Lots. |
| 16:14 | stuartsierra | You could merge a map of defaults with a map of overrides. |
| 16:16 | jblomo | (try (require 'custom) (merge settings custom/settings) (catch FileNotFound e settings)) |
| 16:16 | jblomo | kind of like that? |
| 16:35 | stuartsierra | jblomo: preferably without the try/catch, but yes |
| 16:35 | stuartsierra | You could even put the custom/default settings in a file, as a map, and `read` it in. |
| 16:38 | stuartsierra | Good luck, see you later. |
| 16:39 | Netpilgrim | Since (some #{:x} coll) seems to be idiomatic, am I right in assuming that it's more efficient than ((set coll) :x)? |
| 16:43 | scottj | Netpilgrim: not sure, but (set coll) turns the entire coll into a set even if :x is the first thing |
| 16:45 | Netpilgrim | scottj: Good point. And (set coll) is probably not very fast because of all the equality tests needed. |
| 16:47 | amalloy | Netpilgrim: well, (set coll) can mostly just do hash comparisons; it only needs equality tests on hash collisions |
| 16:47 | amalloy | but (set coll) is necessarily O(n*logn), when you only want to do an O(n) "compare everything with :x" operation |
| 16:50 | Netpilgrim | amalloy: I wish the doc strings of functions had more information on their run time. |
| 16:51 | amalloy | well, it...i mean, it has to be. conjing onto a set is logn, and you're doing it n times |
| 16:52 | amalloy | and many functions don't even have a meaningful runtime. what is the runtime of concat? or of conj? |
| 16:52 | Netpilgrim | amalloy: I'm not doubting your assessment, just saying it would be nice if (doc f) would give me that information. |
| 16:53 | Netpilgrim | amalloy: Not sure about concat but shouldn't the run time for conj be O(1) for every data structure? |
| 16:55 | amalloy | no. it's logn for sorted data structures, at least. i asserted a moment ago that it's logn for hashsets too, but i'm not actually sure of that now i come to think of it |
| 16:56 | amalloy | and because clojure's data family of data structures is extensible, you can write your own data type that has O(n^2) insertion. surely nobody would want to rewrite conj's docstring then! |
| 16:56 | Netpilgrim | amalloy: Yes, I hadn't thought of sorted structures. |
| 17:01 | lobotomy_ | wait, why is (set coll) O(n log n)? |
| 17:07 | amalloy | lobotomy_: well, i said that because i thought insertions were logn. but as remarked above i'm no longer sure of that |
| 17:07 | amalloy | i mean, certainly they're at least log32(n) |
| 17:07 | amalloy | but that's basically constant |
| 17:20 | michaelr525 | oudeis: hey there |
| 17:22 | Netpilgrim | michaelr525: Hi. |
| 17:22 | Netpilgrim | michaelr525: Didn't realize you were talking to oudeis. |
| 17:25 | michaelr525 | hehe |
| 17:25 | michaelr525 | don't worry about it |
| 17:28 | semperos | amalloy: so on the topic of the repl read function from last night, I tried reading through *in* and saving that off to a string; I then do my processing with the string, and create a new LNPBR with (LineNumberingPushbackReader. (StringReader. my-string)) and pass that to the default (read) function, but then the repl just hangs and waits for me to press enter or C-d before it even starts reading my LBPBR |
| 17:28 | semperos | s/LBPBR/LNPBR |
| 17:28 | lazybot | <semperos> amalloy: so on the topic of the repl read function from last night, I tried reading through *in* and saving that off to a string; I then do my processing with the string, and create a new LNPBR with (LineNumberingPushbackReader. (StringReader. my-string)) and pass that to the default (read) function, but then the repl just hangs and waits for me to press enter or C-d before it even starts reading my LNPBR |
| 17:29 | semperos | not saying it's an optimal way to deal with the *in* at this point, but just trying to get something simple working |
| 17:30 | amalloy | Netpilgrim: i think JoC was referring to ##(seq (conj [] 1 2 3)) vs ##(seq (conj () 1 2 3)) |
| 17:30 | lazybot | (seq (conj [] 1 2 3)) ⇒ (1 2 3) |
| 17:30 | lazybot | (seq (conj () 1 2 3)) ⇒ (3 2 1) |
| 17:30 | currentB | if I have a vector of maps, how do I access the first map with destructuring? |
| 17:31 | amalloy | because if you've been conjing into the structure as a stack, and you then call seq, it matters which structure you were using |
| 17:31 | amalloy | currentB: uhm, the same way you access the first of any seq with destructuring, no? |
| 17:32 | amalloy | &(let [maps [{:a 1 :b 2}, {:x 5 :y 6}], [{:keys [a b]}] m] [a b]) |
| 17:32 | lazybot | java.lang.Exception: Unable to resolve symbol: m in this context |
| 17:32 | amalloy | &(let [maps [{:a 1 :b 2}, {:x 5 :y 6}], [{:keys [a b]}] maps] [a b]) |
| 17:32 | lazybot | ⇒ [1 2] |
| 17:33 | amalloy | semperos: no useful advice from me, i'm afraid |
| 17:33 | semperos | okie doke, wasn't sure if something would spring to mind |
| 17:33 | currentB | actually sorry, it's actually a map of vectors of maps. {:thinga [{:a1 "x" :a2 "y"]} |
| 17:33 | Netpilgrim | amalloy: Might be, but it's still conj creating a different order, not seq. |
| 17:34 | amalloy | so...currentB, what is it you actually want to do? "access" is pretty vague |
| 17:36 | currentB | I have a map of info about a product, containing a vector of image info of that product (ie, path, dimensions, whatever). I'd like to be able to refer to the first image as first-img in a function that handles these products |
| 17:36 | amalloy | &(let [m {:thinga [{:a1 "x" :a2 "y"}]}, {[{a :a1}] :thinga} m] a) ;might work? |
| 17:36 | lazybot | ⇒ "x" |
| 17:37 | amalloy | &(let [m {:thinga [{:a1 "x" :a2 "y"}]}, {[first-img] :thinga} m] first-img) ; if you want the whole map |
| 17:37 | lazybot | ⇒ {:a1 "x", :a2 "y"} |
| 17:37 | currentB | awesome, thanks! eventually my brain will start to catch up with this stuff and I'll stop asking dumb things here. Thanks again! |
| 17:38 | michaelr525 | ERC is great |
| 17:38 | michaelr525 | it's C-l's every once in a while |
| 17:50 | mbac | how do I get to the UNIX API in clojure? |
| 17:50 | mbac | getuid and the like |
| 17:50 | amalloy | java doesn't really expose most posix stuff |
| 17:51 | mbac | right |
| 17:54 | mbac | am I screwed unless I write native bindings |
| 17:54 | mbac | ? |
| 17:55 | amalloy | more or less. i think there are some unofficial native libraries out there already, but i don't know if they're any good |
| 17:55 | raek | mbac: there should be libraries for accessing the posix stuff. it's just not included in Java |
| 17:56 | amalloy | and of course that would hurt your portability and distribution. if you want to run it anywhere other than your own machines, people may worry about the unsandboxed native code |
| 17:56 | mbac | is everything in clojure-contrib intended to be built on standard J2SE? |
| 17:56 | mbac | oh, Linux is the only platform that matters to me :) |
| 17:59 | raek | mbac: I think so |
| 18:03 | amalloy | mbac: sure. but are your *own* linux machines the only platform that matter? if so, have a blast, of course. just pointing out that native libraries make it harder for anyone to use your stuff, even on the same arch |
| 18:03 | zakwilson | The Gaka docs suggest compiling the code to a static stylesheet and serving that. Why not just memoize the css function instead? |
| 18:04 | mbac | amalloy, 90% of software is written for a single buyer, so that's not a big deal to me |
| 18:04 | mbac | and it shouldn't be for most people, I gather |
| 18:05 | amalloy | fair enough. i assume that statistic is completely made up, either by you or whoever you got it from, though :P |
| 18:05 | mbac | it's my statistic, i got it from looking at ads for software developers |
| 18:06 | scottj | zakwilson: seems that would be fine, I basically do that with slice |
| 18:06 | mbac | most software developers work on projects that never leave one company's walls |
| 18:06 | amalloy | that's probably related to the fact that google, microsoft, etc., don't advertise on stackoverflow-jobs |
| 18:07 | amalloy | but whatever. your product is for one buyer, and that's what counts |
| 18:07 | scottj | zakwilson: I mark slices that are impure and everything else is memoized |
| 18:08 | amalloy | zakwilson: if you compile to a static stylesheet you can do http-level caching, no? |
| 18:09 | mbac | so, i take it there's no clojure->C interface :) |
| 18:09 | zakwilson | amalloy: well, yes, but you could probably come up with a way to do that with memoization too. Granted, with a static sytlesheet you can leave the caching up to an external server or a CDN. |
| 18:10 | amalloy | sure |
| 18:11 | arohner | mbac: there's jna |
| 18:11 | mbac | right |
| 18:13 | arohner | other than clj-native, I'd look at e.g. jtux |
| 18:26 | bulters | hi. If I add a dependency in a leiningen project.clj; is it possible to have the new dependency available in a running swank session? |
| 18:27 | amalloy | no |
| 18:30 | srid | i have a function that returns a list of two elements [a, b] - and the caller of this function needs to assign it within the map with other elements {:a <> :b <.> :c 3 :d 5 ....} |
| 18:30 | srid | can I destructure the return value like that? or is there a better way? |
| 18:31 | srid | the function exists only to not pollute the caller with its functionality; technically it is not required. |
| 18:31 | bulters | amalloy: thanks. all i needed to know ;-) |
| 18:32 | srid | real world case - in this map https://github.com/srid/notaskinnerbox/blob/master/src/notaskinnerbox/stackexchange.clj#L42 - I want to add a ":todate" key, and extract calculation of :fromdate and :todate to a different function that accepts a single argument 'N' |
| 18:32 | amalloy | srid: just conj the two maps together |
| 18:33 | amalloy | &(conj {:a 1 :b 2 :c 3} {:from 'x :to 'y}) |
| 18:33 | lazybot | ⇒ {:to y, :from x, :a 1, :b 2, :c 3} |
| 18:33 | srid | right, i still think imperatively :) |
| 18:34 | Netpilgrim | What is the most idiomatic way to get the first element in a seq, for which a predicate is true? I've come up with (some #(if (pred %) %) s) and (first (drop-while (not (pred %)) s)). |
| 18:35 | amalloy | Netpilgrim: those are both reasonable, though most people use filter rather than drop-while there |
| 18:36 | Netpilgrim | amalloy: Oh, I knew I had overlooked a more common function. :) |
| 18:36 | amalloy | you can also write a HOF for #(if (pred %) %), which IMO makes it nicer |
| 18:36 | amalloy | (some (validator pred) s) |
| 18:36 | Netpilgrim | amalloy: HOF? |
| 18:37 | amalloy | given (defn validator [pred] (fn [x] (when (pred x) x))) |
| 18:37 | amalloy | higher order function |
| 18:37 | amalloy | or call it "satisfying" instead of "validator", whatever |
| 18:38 | Netpilgrim | amalloy: I like it. |
| 18:39 | srid | amalloy: i ended up not writing a function, but still using conj - https://github.com/srid/notaskinnerbox/commit/8bbda3758f82b322d35199cba1d52356179c41cd#L0L42 |
| 18:40 | amalloy | srid: ##(doc pos?) |
| 18:40 | lazybot | ⇒ "([x]); Returns true if num is greater than zero, else false" |
| 18:40 | srid | ah, good to know. |
| 18:42 | Netpilgrim | I'm picking up on how to use the bots here, but is there a manual or help function? |
| 18:43 | amalloy | none that are comprehensive |
| 18:43 | amalloy | Netpilgrim: the important ones to know are that if the first character is , or & then clojurebot or lazybot (respectively) will eval it as clojure code |
| 18:44 | amalloy | lazybot also snags things like ##(inc 1) in mid-message |
| 18:44 | lazybot | ⇒ 2 |
| 18:44 | Netpilgrim | amalloy: What's the difference between the bots? |
| 18:45 | amalloy | for other commands, lazybot takes $command and clojurebot takes ~command |
| 18:45 | amalloy | *chuckle* just about everything. they don't have any common code that i know of these days |
| 18:46 | Netpilgrim | amalloy: So if I want something evaluated I can take either one? |
| 18:46 | amalloy | yeah |
| 18:46 | Netpilgrim | amalloy: OK, thanks. |
| 18:46 | amalloy | lazybot: do you guys also respond to PMs??? |
| 18:46 | lazybot | amalloy: Oh, absolutely. |
| 18:47 | Netpilgrim | Cool. |
| 18:50 | shellox | hi |
| 18:50 | Netpilgrim | shellox: Hi. |
| 18:53 | shellox | can you help me, i dont understand why i get the error in the paste: http://dpaste.com/603789/ |
| 18:53 | amalloy | too many parens in foo |
| 18:54 | amalloy | and also no parameter declaration |
| 18:54 | amalloy | ie, square has [n], but where are the args to the function foo? |
| 18:55 | Netpilgrim | amalloy: You're fast. My browser tab hadn't loaded yet. |
| 18:55 | amalloy | quickest gun in the west, that's me |
| 18:56 | shellox | amalloy: i just want to calculate it in foo without giving an argument, and then do (println foo) or so |
| 18:56 | amalloy | then you don't want defn, which defines a function |
| 18:56 | shellox | just fn then? |
| 18:56 | amalloy | you could just write (+ (square 5) (square 5)) and the repl would print it for you |
| 18:57 | amalloy | if you want to give it a name, you can (def foo (+ ...)) |
| 19:02 | shellox | amalloy: ok i got it now, but if i want to print the result it put - before, but the calculation is correct |
| 19:02 | shellox | http://dpaste.com/603791/ |
| 19:03 | shellox | its 2640, but it shows -2640 then, why? |
| 19:03 | shellox | i thought it calculate and print the result then |
| 19:04 | amalloy | &(- 385 3025) |
| 19:04 | lazybot | ⇒ -2640 |
| 19:04 | amalloy | &(- 3025 385) |
| 19:04 | lazybot | ⇒ 2640 |
| 19:06 | shellox | ah, you are right of course, my mistake :/ |
| 19:07 | shellox | i first tried it with plus, so it wasnt important whats first, but it is with - of corse ;) |
| 19:07 | shellox | course* |
| 19:18 | dgreensp | can I use Ring with Clojure 1.3? Is anything packaged to work with 1.3? I'm trying to run the ClojureScript compiler on my web server |
| 19:23 | dgreensp | is there a website for clojure-contrib 1.3? it seems like things were moved around, but I can't find any information on it |
| 19:34 | mudge | could ring-serve be used for a production server? |
| 19:35 | mudge | anybody here use ring? |
| 19:38 | Netpilgrim | dgreensp: If I understand it correctly, there will be no clojure-contrib 1.3 because all further development will be done in separate smaller projects. The only information I could find about these: http://dev.clojure.org/display/doc/Clojure+Contrib |
| 19:40 | shellox | mhh, how to calculate the crossfoot of a number |
| 19:42 | mudge | Netpilgrim: yes, that's right |
| 19:44 | dgreensp | Netpilgrim: thanks, that's a new link to me. I saw something about it being broken up as a practical matter. I was expecting to change a few lines in project.clj and move on, but I have no idea where to find "split-line", "pprint", etc. now... |
| 19:46 | dgreensp | it doesn't seem like anyone is really using 1.3, though, except Rich :P |
| 19:47 | Netpilgrim | dgreensp: I hope, someone will update the clojure-contrib page on clojure.org to show where all the functions can be found now. |
| 19:47 | amalloy | (1) what/where is split-line? (2) pprint was never in contrib, it's in core, so i would be a little surprised if it moved |
| 19:51 | shellox | how to split "foo" in a list ['f', 'o', 'o']? |
| 19:53 | dgreensp | sorry, clojure.contrib.string/split-lines, and clojure.contrib.pprint -- I guess there is a clojure.pprint too, but for whatever reason I got an error message in my fiddling around from something using the contrib pprint |
| 19:54 | amalloy | &(seq "foo") |
| 19:54 | lazybot | ⇒ (\f \o \o) |
| 19:57 | dgreensp | oh, there's clojure.string/split-lines too -- maybe clojure.contrib.string is completely obsolete |
| 20:03 | mudge | anybody here use ring? |
| 20:07 | tomoj | ask? |
| 20:07 | tomoj | clojurebot: ask? |
| 20:07 | clojurebot | No entiendo |
| 20:07 | amalloy | tomoj: that's his real question, actually |
| 20:07 | mudge | any reason not to use ring serve for production? |
| 20:07 | tomoj | ah |
| 20:08 | amalloy | mudge: ring is eminently suitable for production. i suspect [almost] every real-life clojure webserver uses ring |
| 20:08 | tomoj | heh |
| 20:08 | amalloy | certainly 4clojure.com and geni.com do |
| 20:08 | amalloy | and clojars |
| 20:08 | mudge | amalloy: my question is, can ring-serve be suitable for production as the production server |
| 20:10 | tomoj | I think only you can decide that |
| 20:18 | mudge | does anybody emed jetty into their clojure web application for production? |
| 20:18 | mudge | or is this only used for development? |
| 20:18 | mudge | embed* |
| 20:21 | amalloy | i think embedding jetty is fairly common, but often you put another webserver in between (possibly another jetty) to proxy to jetty |
| 20:22 | mudge | amalloy: is this proxying done so that you can have multiple embeded jetties for multiple websites on the same machine? |
| 20:22 | amalloy | that's why i do it. others probably have better reasons |
| 20:23 | mudge | amalloy: cool beans, I think I will do something similar |
| 20:28 | amalloy | mudge: nginx has been pretty good for my needs, if you're looking for recommendations |
| 20:28 | mudge | amalloy: yes looking for recommendations, thanks |
| 20:28 | mudge | i see using nginx as the proxy server |
| 20:30 | amalloy | yes |
| 20:32 | amalloy | mudge: the server at 4clojure.com is serving about a dozen other websites via nginx |
| 20:33 | mudge | amalloy: cool, is 4clojure.com yours? |
| 20:33 | amalloy | mostly |
| 20:33 | mudge | awesome |
| 20:33 | mudge | how do you go about embedding jetty for those websites? |
| 20:33 | amalloy | i don't understand the question. the other websites? |
| 20:34 | mudge | i am just curious how you embed jetty for your clojure websites |
| 20:34 | mudge | in the typical way with ring/ring-jetty-adapter |
| 20:34 | mudge | ? |
| 20:35 | amalloy | https://github.com/dbyrne/4clojure/blob/develop/src/foreclojure/core.clj#L14 |
| 20:35 | mudge | amalloy: ah, thanks! |
| 20:36 | amalloy | and then nginx is told to forward 4clojure.com:80 to localhost:8080 |
| 20:36 | mudge | amalloy: yea, make sense |
| 20:37 | mudge | I am currently using lein ring uberwar to create a war file out of my clojure app and then dropping the war app into a tomcat container, but I think I am going to change it so that it is similar to how you are doing it |
| 20:37 | mudge | with jetty embedded |
| 20:40 | mudge | amalloy: do you ever connect a repl to one of your remote websites? |
| 20:40 | mudge | or use a repl somehow with 4clojure as it is running? |
| 20:41 | amalloy | no |
| 20:41 | mudge | for development? |
| 20:41 | amalloy | local copy |
| 20:41 | mudge | i see |
| 20:42 | st3fan | what is 4clojure? |
| 20:42 | mudge | 4Clojure is a resource to help fledgling clojurians learn the language through interactive problems. |
| 20:42 | mudge | http://4clojure.com/ |
| 20:42 | st3fan | oh fun |
| 20:43 | mudge | the website is also written in clojure: https://github.com/dbyrne/4clojure |
| 20:43 | st3fan | cool |
| 20:43 | st3fan | i wrote a little web app with noir |
| 20:43 | mudge | st3fan: cool, what's it do? |
| 20:44 | st3fan | basically a hackernews clone :) |
| 20:44 | mudge | ah, cool |
| 20:44 | st3fan | yeah was a good exercise |
| 20:44 | st3fan | i am not sure about generating *all* html in code though |
| 20:44 | mudge | why not? |
| 20:45 | mudge | using hiccup? |
| 20:45 | st3fan | yeah |
| 20:45 | st3fan | i would like to combine hiccup with more traditional templates i think |
| 20:45 | mudge | there's enlive |
| 20:45 | mudge | have you used enlive? |
| 20:45 | st3fan | nope, checking! |
| 20:46 | mudge | not a templating system, you write raw html and enlive allows you to hook and combine things together awesomely |
| 20:47 | amalloy | i'm not sure i'd say enlive is *not* a templating system |
| 20:47 | mudge | i take it back |
| 20:47 | amalloy | it's a DOM transformer |
| 20:47 | amalloy | well. that's not true. it transforms...trees. html, xml, whatever |
| 20:48 | st3fan | yeah nice |
| 20:48 | st3fan | i'll give it a try |
| 20:48 | mudge | i was thinking that it would be nice to have something that transforms hiccup vectors, like how enlive transforms html |
| 20:49 | mudge | it would be nice to be able to write hiccup vectors and have something like enlive work on that |
| 20:49 | tomoj | bah |
| 20:49 | tomoj | just use hiccup to generate static html? |
| 20:49 | tomoj | ..if you must |
| 20:50 | st3fan | tomoj: the problem is that our amazing web people know html and css very well |
| 20:50 | st3fan | well it is not a problem |
| 20:50 | tomoj | not suggesting that |
| 20:50 | st3fan | but i don't want them to get into clojure |
| 20:50 | tomoj | my web people know html and css too |
| 20:50 | amalloy | st3fan: tomoj doesn't mind writing html and transforming it with enlive |
| 20:50 | tomoj | so I want them to write pure html and css |
| 20:50 | amalloy | byt writing hiccup and transforming that with enlive? you lose most of the benefits of both enlive and hiccup |
| 20:51 | tomoj | I don't think you lose any enlive benefits unless your hiccup pieces are dynamic |
| 20:51 | tomoj | well, yeah |
| 20:52 | st3fan | do you all use Emacs? |
| 20:52 | tomoj | you lose the benefit that it's actually written in html :) |
| 20:52 | amalloy | st3fan: a majority |
| 20:52 | mudge | you only lose the enlive benefit of having raw html, if that is a benefit for you, for me it is not because i don't have html design people |
| 20:52 | mudge | st3fan: of course, who doesn't use Emacs? |
| 20:58 | danenania | hey all, i'm trying to get started with both clojure and emacs on osx 10.6. no experience with either. i am to the point of having swank-clojure installed, and 'lein swank' inside a project opens a connection on 4005. but when i open core.clj with emacs and do 'M-x clojure-jack-in', i get 'No Match' |
| 20:58 | danenania | any ideas? |
| 20:58 | amalloy | if you've started the swank server yourself, just run M-x slime-connect |
| 20:59 | danenania | ok.. that is equivalent? |
| 20:59 | mudge | clojure-jack-in starts up swank, so you don't need to |
| 20:59 | st3fan | neo, jack in |
| 21:00 | danenania | i see.. guess i will go with slime-connect then, but i wonder why jack-in isn't working... |
| 21:01 | mudge | try clojure-jack-in without a swank process already running |
| 21:02 | danenania | haven't had the process running when i've tried |
| 21:02 | mudge | ah, i see, i guess emacs doesn't find clojure-jack-in |
| 21:03 | danenania | yeah.. well i'll just use connect to get going and maybe figure this out when i understand things better |
| 21:03 | danenania | thanks for the help |
| 21:04 | mudge | amalloy: have you thought of writing a clojure book? |
| 21:04 | amalloy | not really interested |
| 21:04 | mudge | ah |
| 21:05 | amalloy | interactive teaching in #clojure is more fun |
| 21:05 | mudge | yea, that's fun |
| 21:15 | mudge | when is #clojure businest? |
| 21:15 | mudge | *busiest |
| 21:25 | mdeboard | mudge: Seems like it's always very close to the mean |
| 21:26 | mdeboard | probably overnights USA would be slowest |
| 21:27 | mudge | thanks |
| 21:41 | mudge | amalloy: why do you use (var app) in (run-jetty (var app) {join false :port 8080})) ? |
| 21:42 | amalloy | it's a pretty standard compojure trick, basically giving jetty a pointer to a function instead of a function itself, so that you can re-def stuff and the running jetty instance will see the new code |
| 21:43 | st3fan | hm 4clojure is awesome |
| 21:43 | mudge | amalloy: i see |
| 21:44 | coopernurse | st3fan: agreed.. working on a problem now myself |
| 21:45 | st3fan | coopernurse: i'm at the beginning .. implementing count nth last in terms of loop/rest/recur .. learning a lot |
| 21:45 | coopernurse | st3fan: nice. do you have a FP background? or is clojure your first |
| 21:46 | st3fan | more hobby than a background .. did some common-lisp stuff (practical common lisp) |
| 21:46 | clojurebot | lisp is the red pill |
| 21:46 | st3fan | but i intend to actually do some useful things with clojure |
| 21:46 | mudge | st3fan: like what? |
| 21:46 | coopernurse | excellent. clojuredocs is very good too if you haven't seen it yet http://clojuredocs.org/ |
| 21:47 | st3fan | hm that is ncie |
| 21:49 | mudge | amalloy: in this namespace declaration why are some of the namespaces in a vector and some not: (ns foreclojure.core |
| 21:49 | mudge | (:use compojure.core |
| 21:49 | mudge | [foreclojure static problems login register golf ring |
| 21:49 | mudge | users config social version graphs mongo utils] |
| 21:49 | mudge | ring.adapter.jetty |
| 21:50 | amalloy | shorthand for forclojure.static foreclojure.problems... |
| 21:50 | mudge | amalloy: oh right, thanks |
| 22:32 | technomancy | danenania: your clojure-mode is too old; need to get it from either marmalade or my git repo |
| 22:33 | wastrel | what do they pay you for this technomancy |
| 22:33 | technomancy | hehe |
| 22:33 | danenania | ah thank you, it was actually much dumber than that... i just didn't edit my .emacs file correctly |
| 22:34 | danenania | all set now |
| 22:34 | technomancy | cool |
| 22:58 | klutometis | It doesn't look like there's a `defmacro-' analog to `defn-'; and I take it adding `:private true' metadata is meaningless. |
| 22:58 | hiredman | why do you take that? |
| 23:01 | fbru02 | hi ! what's the usual way to embed some server variables in the javascript (using cljs but the question is more general also) , is it templating the javascript and generating the js with the server? |
| 23:07 | klutometis | hiredman: It works, but not quite in the way `defn-' works: whereas public functons can call ones defined with `defn-', public macros cannot invoke macros with `:private true' outside the namespace. |
| 23:24 | dgreensp | klutometis: there's a clojure.contrib.def/defmacro- |
| 23:27 | dgreensp | fbru02: for basic stuff, I usually put (str "clientVars=" (json-str client-vars)) in a script tag |
| 23:28 | fbru02 | dgreensp: makes sense |
| 23:28 | dgreensp | or it should be called serverVars depending on how you look at it :) |
| 23:28 | fbru02 | :P |
| 23:43 | amalloy | i try, where possible, to avoid :private metadata by using closures instead. i guess i don't have a lot of company in this, but you might consider writing your private macro as a macrolet instead, with tools.macro |
| 23:45 | amalloy | (or by just making things public and not worrying about "hiding" them) |