2009-07-03
| 00:46 | CoreyWhite | Does anyone know of a syntax highlighter with Clojure support? Or with generic Lisp support that would be fairly easy to adapt to Clojure? (For the web, preferably javascript/jQuery, although I could live with something server-side in PHP.) |
| 00:47 | CoreyWhite | I'm aware of the Clojure plugin for SyntaxHighlighter (here: http://travis-whitton.blogspot.com/2009/06/syntaxhighlighter-for-clojure.html), which is quite good . . . but unfortunately SyntaxHighlighter messes with my markup in very unpleasant ways. |
| 00:53 | gstamp | http://kai.myownsiteonline.com/clojure/html.clj.html |
| 00:55 | CoreyWhite | that seems pretty excellent! Is that your site? |
| 01:04 | gstamp | No not mine. There was a recent thread in the mailing list. I plucked the URL from that. |
| 01:05 | gstamp | Thread was titled "Displaying Clojure code on a Website" if you'd like to look it up |
| 01:12 | Knekk | anyone here use vimclojure? |
| 01:28 | Chouser | gah. why can't I have a reader hook!? |
| 03:00 | mrpika | t |
| 03:00 | mrpika | oops |
| 03:06 | Knekk | for a large(ish) multi-dimensional array of mutable data should I use vectors of refs? or Java arrays? |
| 03:08 | parthm | Knekk: If you want java interop + performance you can use java arrays |
| 03:09 | parthm | are there multiple threads in your program operating on the data? |
| 03:09 | Knekk | Would only need performance for the array. I can define the data itself without java interop |
| 03:09 | Knekk | yeah, multiple threads will manipulate the data |
| 03:10 | parthm | refs of vectors can be a start. if you feel performance is bad you can switch to arrays |
| 03:10 | parthm | vectors have a lot of functions to work on them |
| 03:11 | Knekk | that's what I am seeing, yeah |
| 03:11 | parthm | for most cases vector performance is fine |
| 03:11 | Knekk | I am blowing the heap space trying to create the vectors. Need to get my head around the implications here |
| 03:12 | parthm | hmm ... do you need all the initialization up front or maybe it can be lazy |
| 03:14 | Knekk | even if it's lazy I'll be iterating across all the array elements a number of times to do transformation on the data pretty fast, so all elements will be accessed |
| 03:19 | parthm | I probably don't get the use case but even the computation should be delayed and only the relevant values should be generated/computed. |
| 03:19 | parthm | user=> (time (def y (map (partial + 1) (range 10000000)))) |
| 03:19 | parthm | "Elapsed time: 0.904514 msecs" |
| 03:19 | parthm | #'user/y |
| 03:19 | parthm | user=> (take 5 y) |
| 03:19 | parthm | (1 2 3 4 5) |
| 03:19 | parthm | user=> (take 5 (drop 1000000 y)) |
| 03:19 | parthm | (1000001 1000002 1000003 1000004 1000005) |
| 03:19 | parthm | user=> |
| 03:20 | parthm | sometime I have seen the stack blow when we hold on to the head somewhere. |
| 03:21 | Knekk | I am probably not using the proper methods then. I am a n00b. Using (apply vector (map (fn [_] (ref (struct my-struct))) (range large-number)) |
| 03:21 | Knekk | )) |
| 03:22 | Knekk | to create one dimension of the array |
| 03:23 | Lau_of_DK | apply forces evaluation, thats not the same as parthm's example above |
| 03:24 | Knekk | I was basing mine on a different example, and that'd explain why I am blowing the heap |
| 04:46 | Knekk | ok, so now I have a better lazy approach to creating a multi-dimensional array of refs |
| 04:52 | Knekk | night |
| 05:22 | Knekk | laggy tonight |
| 06:46 | Chousuke | Chouser: are you handling the clojure-1.0 compatible contrib branch? |
| 08:01 | AWizzArd | Is there an efficient built-in function that removes an element from a vector at position n? |
| 08:20 | rhickey | AWizzArd: can't be |
| 08:26 | AWizzArd | rhickey: is it planned to add new immutable data structures to Clojure, such as doubly linked lists or skiplists? |
| 08:27 | rhickey | AWizzArd: finger trees would be welcome |
| 08:27 | rhickey | http://en.wikipedia.org/wiki/Finger_tree |
| 08:30 | AWizzArd | Finger trees or skiplists ( http://en.wikipedia.org/wiki/Skiplist ) would have to be implemented in Java for performance reasons yes? |
| 08:32 | rhickey | no |
| 08:34 | rhickey | any data structures need to be persistent |
| 08:34 | AWizzArd | yes |
| 08:34 | rhickey | so, doubly linked lists not possible |
| 08:34 | qra | hi clojure group, this is first time I entered this channel. |
| 08:35 | rhickey | qra: hi |
| 08:36 | AWizzArd | I see, didn't think about that yet. Anyway, what would you do if you wish to conj up a vector V of structs over which (V) you then run a unification and pattern matching algorithm that wants to remove at (possibly random) positions elements and add new ones? |
| 08:37 | rhickey | AWizzArd: what's the significance of the positions? |
| 08:37 | qra | how to force 'for' to run through all items in a lazy list? |
| 08:38 | durka421 | qra: doall |
| 08:38 | durka421 | or you may be looking for doseq instead of for |
| 08:38 | qra | ok |
| 08:38 | rhickey | qra: if your 'for' is only for side effects, use doseq instead, otherwise you can call doall on the result of for |
| 08:39 | rhickey | or vec |
| 08:41 | AWizzArd | rhickey: if the positions won't be important then maybe a set would be right. But if the order must stay the same it is not so easy anymore. |
| 08:43 | rhickey | AWizzArd: for splicing we need finger trees |
| 08:43 | AWizzArd | I see |
| 08:49 | qra | (for [i last-list] (doall (println i)) wont work? |
| 08:50 | durka42 | for produces a lazy seq, so you want to wrap doall around the entire thing |
| 08:50 | durka42 | (doall (for ...)) |
| 08:51 | qra | ok, but i cant understand what's going on |
| 08:51 | rhickey | qra: for is designed to return a sequence of values |
| 08:51 | rhickey | but yoiu just want to perform a sequence of side effects, so use doseq |
| 08:52 | rhickey | (doseq [i last-list] (println i)) |
| 08:52 | qra | doseq throws some error it expects vector, but I have only lazy-list |
| 08:53 | rhickey | for produces the values lazily, so if you never use them, it never produces them |
| 08:54 | rhickey | qra: try: (doseq [i (range 3)] (println i)) |
| 08:54 | rhickey | at the repl |
| 08:55 | qra | thank u, it works. |
| 09:02 | tashafa | hello all |
| 09:02 | danlarkin__ | salut! |
| 09:02 | tashafa | whats up danlarkin |
| 09:02 | danlarkin__ | it's finally sunny! |
| 09:03 | tashafa | not in mass :( |
| 09:03 | danlarkin__ | maybe... just maybe it can last all day |
| 09:03 | tashafa | massachusetts |
| 09:03 | tashafa | i dont think ive seen the sun in a month |
| 09:04 | danlarkin__ | I was in Boston last weekend, and driving home was hilarious. I left boston in a hazy cloud cover and like 30 minutes west it turned into a beauuuutiful day |
| 09:05 | tashafa | thats new england weather for you |
| 09:06 | sgtarr_ | england weather is worse. |
| 09:06 | tashafa | clojure ques. |
| 09:06 | sgtarr_ | ques? |
| 09:07 | tashafa | it escapes me but how do you extend a java class again and override a method |
| 09:07 | tashafa | ? |
| 09:07 | tashafa | in clojure ofcourse |
| 09:07 | tashafa | :) |
| 09:08 | sgtarr_ | i can tell you how to do it in java.. :) |
| 09:08 | danlarkin__ | proxy |
| 09:09 | danlarkin__ | unless proxy is gone now |
| 09:09 | danlarkin__ | it's been a few weeks since I've used clojure :( |
| 09:09 | tashafa | same here |
| 09:09 | sgtarr_ | haha |
| 09:09 | sgtarr_ | clojure changes that quickly? |
| 09:09 | tashafa | i've been in python world |
| 09:09 | sgtarr_ | the cutting edge! |
| 09:09 | sgtarr_ | tashafa: welcome back to civilization... |
| 09:10 | sgtarr_ | naw, I shouldn't talk like that about Python. I use it often and i've used it for many projects since approx 2002 |
| 09:10 | sgtarr_ | But there are some things that bug me... |
| 09:10 | sgtarr_ | and java is just much better for Enterprise |
| 09:10 | tashafa | yup... procedural programming is just mind numbing |
| 09:12 | tashafa | after messing with clojure that is |
| 09:13 | sgtarr_ | yea |
| 09:13 | sgtarr_ | tashafa: how did you get involved with clojure? |
| 09:14 | sgtarr_ | interest in lisp from before? |
| 09:14 | tashafa | by way of paul graham |
| 09:14 | tashafa | but common lisp was just hard to get started with |
| 09:16 | sgtarr_ | yea |
| 09:16 | sgtarr_ | I was always fascinated by Lisp |
| 09:16 | sgtarr_ | and there is a finance company that I was familiar with that used Lisp exclusively, still do, but they used LispWorks afaik |
| 09:17 | tashafa | cool |
| 09:21 | sgtarr_ | I remember that asteroid probe Deep Space 1 also ran Lisp |
| 09:21 | durka42 | really? |
| 09:22 | sgtarr_ | It still does actually, even though its ion thrusters have been off since 2001 |
| 09:22 | sgtarr_ | Lisp up there in space, still running silently :) |
| 09:22 | durka42 | the first google result for "deep space 1 lisp" is that rant about how JPL lost faith in lisp |
| 09:23 | sgtarr_ | really? weird |
| 09:23 | sgtarr_ | check out http://en.wikipedia.org/wiki/Deep_Space_1#Remote_Agent |
| 09:23 | sgtarr_ | the RAX software was lisp |
| 09:23 | sgtarr_ | and the mission was a huge success |
| 09:24 | sgtarr_ | from your article: |
| 09:24 | sgtarr_ | "Based on this experience I think it's safe to say that if not for Lisp the Remote Agent would have failed." |
| 09:25 | sgtarr_ | "Debugging a program running on a $100M piece of hardware that is 100 million miles away is an interesting experience. Having a read-eval-print loop running on the spacecraft proved invaluable in finding and fixing the problem." |
| 09:25 | sgtarr_ | Nice. REPL 100 million miles away |
| 09:38 | tashafa | hmm |
| 09:39 | tashafa | how do you call methods on the parnet class (super) in proxy? |
| 09:43 | tashafa | proxy-super |
| 09:45 | Chousuke | hm, is that even possible? |
| 09:51 | AWizzArd | Is there (maybe in contrib) a foo for doing (foo [1 2 3 4 :x 5 6 7 8 :x 9 10 :x 11]) ==> ((1 2 3 4) (:x) (5 6 7 8) (:x) (9 10) (:x) (11)) ? |
| 09:52 | AWizzArd | split-at, split-with, take-while, partition-by, group-by and others don't work |
| 09:55 | AWizzArd | my foo call was not complete, it misses something like #(= % :x) or #(not= % :x) |
| 10:02 | tashafa | Chousuke: I have no idea |
| 10:02 | tashafa | but shouldnt it be? |
| 10:29 | tashafa | Chousuke: http://dishevelled.net/Tricky-uses-of-Clojure-gen-class-and-AOT-compilation.html |
| 10:32 | Chousuke | interesting |
| 11:31 | lisppaste8 | AWizzArd pasted "How to group/split contents of a collection into groups?" at http://paste.lisp.org/display/82957 |
| 11:32 | rzoom | is there a github issue? |
| 11:33 | rzoom | rob@eniac:~$ git clone http://github.com/richhickey/clojure |
| 11:33 | rzoom | Initialized empty Git repository in /home/rob/clojure/.git/ |
| 11:33 | rzoom | fatal: http://github.com/richhickey/clojure/info/refs not found: did you run git update-server-info on the server? |
| 11:42 | rzoom | nevermind |
| 11:43 | rzoom | in the future, use the github specified Clone URL, for .... you know ... cloning |
| 11:43 | rzoom | e.g. git clone git://github.com/richhickey/clojure.git |
| 11:52 | cgrand | AWizzArd: (s/partition-by #{:x} [1 2 3 4 :x 5 6 7 8 :x 9 10 :x 11]) |
| 11:52 | cgrand | where s is seq-utils |
| 11:53 | AWizzArd | cgrand: ah good, that is much better |
| 12:23 | jackdempsey | rzoom: yea, .git on the end :) |
| 12:49 | lisppaste8 | codyK pasted "already in zip libraries?" at http://paste.lisp.org/display/82962 |
| 13:38 | Lau_of_DK | Good evening gents |
| 13:39 | dysinger | sup |
| 13:50 | jackdempsey | evenin |
| 15:31 | jackdempsey | anyone familiar with compojure round these parts? |
| 15:39 | jackdempsey | is there an idiomatic approach for getting the current time in clojure? |
| 15:39 | jackdempsey | reading a variety of ways to ask java, and prety much all end with |
| 15:39 | jackdempsey | "i hate the Calendar class" :-) |
| 15:42 | Lau_of_DK | I use Joda time for that stuff |
| 15:42 | Lau_of_DK | And yea, Compojure is hot |
| 15:42 | Lau_of_DK | *sizzle* |
| 15:43 | jackdempsey | k, saw Joda mentioned before as well, gotta check it out it seems |
| 15:44 | jackdempsey | sigh |
| 15:44 | jackdempsey | This page is unavailable at the moment. Please try again shortly. Sorry for the inconvenience. |
| 15:44 | jackdempsey | oh the yak shaving :-) |
| 15:46 | technomancy | the JDK calendar is horrible, but if all you want is the current time, it's not bad |
| 15:46 | technomancy | (java.util.Date.) |
| 15:48 | jackdempsey | hey technomancy , yeah, thanks man, i'm ultimately looking for just the current time in a unix style timestamp |
| 15:48 | jackdempsey | i thought it'd be fun to rewrite this in clojure/compojure: http://github.com/jcapote/watercoolr/blob/125707e211b0a3cb6462ea405bb77aefb1618f8b/watercoolr.rb |
| 15:48 | jackdempsey | good exercise to learn more, etc |
| 15:48 | lisppaste8 | Lau_of_DK pasted "Macro this!" at http://paste.lisp.org/display/82973 |
| 15:48 | Lau_of_DK | Boys - Can somebody shed some macrobiotic light on the question I asked in that lisp-paste ? |
| 15:50 | Chouser | macfoo always uses a function named 'foo' exactly twice? |
| 15:52 | Lau_of_DK | Yep |
| 15:52 | Lau_of_DK | On the first assumption |
| 15:52 | Lau_of_DK | But it will use it x number of times, depending on the length of your list, ie "mister" "#clojure" "bar" "baz" etc |
| 15:53 | Lau_of_DK | @ Chouser |
| 15:54 | Chouser | Lau_of_DK: did you want to pass in the initial string too? |
| 15:54 | Lau_of_DK | That would be ideal |
| 15:55 | technomancy | jackdempsey: my first project was porting a web app to compojure too, but I found I learned more from writing Mire; I kind of fizzled out on the web app. |
| 15:55 | jackdempsey | heh gotcha |
| 15:56 | jackdempsey | yeah its kinda painful so far |
| 15:56 | technomancy | web apps just have too much incidental stuff to worry about |
| 15:56 | jackdempsey | especially coming from rails |
| 15:56 | technomancy | might be better to tackle that domain once you've got a grasp on the core language |
| 15:56 | jackdempsey | ah |
| 15:56 | jackdempsey | i see what you mean |
| 15:56 | jackdempsey | not a bad point |
| 15:56 | Chouser | (defmacro macfoo [string & subs] `(-> ~string ~@(for [sub subs] `(foo ~sub)))) |
| 15:56 | jackdempsey | my eyes are starting to glaze over |
| 15:57 | jackdempsey | hmm |
| 15:57 | jackdempsey | this isn't too bad tho |
| 15:57 | jackdempsey | (/ (. System currentTimeMillis) 1000.0) |
| 15:57 | Lau_of_DK | Chouser: Man thats nasty :) |
| 15:58 | Lau_of_DK | It was the ~@(for...) I couldnt work out, but it makes perfect sense |
| 15:58 | Chouser | :-) |
| 16:00 | krumholt_ | why is it every? but some without "?" |
| 16:01 | Lau_of_DK | Chouser, mind if I annote it so that others can benefit? |
| 16:01 | Chouser | Lau_of_DK: by all means. |
| 16:01 | lisppaste8 | Chouser annotated #82973 "Macroed" at http://paste.lisp.org/display/82973#1 |
| 16:02 | Chouser | krumholt_: the "?" suggests it'll return true or false |
| 16:02 | achim | Lau_of_DK: umm, why a macro? that's "reduce" ... |
| 16:02 | achim | (reduce #(foo %1 %2) "hi!" ["mister" "#clojure"]) |
| 16:02 | krumholt_ | Chouser, ok thanks |
| 16:02 | Chouser | krumholt_: 'some' returns the value returned by the predicate -- could be something other than boolean |
| 16:03 | Chouser | achim is absolutely right. |
| 16:03 | jackdempsey | heh |
| 16:04 | Chouser | I violated the first rule of writing macros. |
| 16:04 | Lau_of_DK | Achim... ehm.... I was just setting Chouser up of course, I had it figured out hours ago :) |
| 16:04 | jackdempsey | lol |
| 16:05 | Lau_of_DK | Chouser you should paste your user.clj .... (defmacro println) etc... :) |
| 16:18 | achim | did anybody here have a look at Qi? |
| 16:22 | technomancy | can you start nailgun from an already-launched clojure instance? |
| 16:22 | technomancy | i'm using (com.martiansoftware.nailgun.NGServer/main (make-array String 0)) to no effect |
| 16:23 | rhickey | achim: Qi is definitely interesting |
| 16:29 | jackdempsey | ah cool |
| 16:29 | jackdempsey | hadn't heard of Qi |
| 16:29 | foox | i have three sub-expr in a 'let'. the third gets evaluated before the second; how can i prevent this |
| 16:30 | foox | the second sub-expr is a doseq |
| 16:32 | drewr | technomancy: I haven't tried nailgun yet. Like it? |
| 16:32 | technomancy | drewr: works like a charm |
| 16:32 | krumholt_ | how can i remove an item from a map? |
| 16:32 | technomancy | except for starting the server in an already-running instance; I can't figure that out |
| 16:32 | technomancy | krumholt_: dissoc |
| 16:33 | krumholt_ | thanks |
| 16:33 | technomancy | drewr: on the whole it's very simple and obvious |
| 16:33 | drewr | krumholt_: Also look at select-keys if you have a bunch to remove. |
| 16:34 | drewr | technomancy: Looked like it. I'll give it a shot. |
| 16:34 | krumholt_ | thanks |
| 16:44 | technomancy | if the nailgun server is runnable, can I pass it to a new thread and have the thread run it for me? |
| 16:44 | technomancy | how does that interface work? |
| 16:45 | technomancy | oh, looks like that works. |
| 17:51 | dysinger_ | thank goodness for #clojure's active irc channel |
| 17:53 | Chouser | hm. a joke? |
| 17:53 | Chousuke | :P |
| 17:55 | technomancy | I think he means relative to Java IRC channels |
| 17:55 | technomancy | #hadoop is like a tomb |
| 17:55 | Chouser | ah |
| 17:55 | technomancy | and dysinger_ is dancing among the gravestones |
| 17:56 | dysinger_ | y Chouser - seems like often Java dudes ( I am on ex-10-yr one myself ) just hang out on IRC and don't actually participate in discussion. |
| 17:56 | Chouser | ah. |
| 17:56 | dysinger_ | I've tried to ask a question on #hadoop 4 times - every time there's like 60 people in there but all I get is crickets |
| 17:56 | Chousuke | Can you do the moonwalk? Maybe it'd activate the channel. |
| 17:57 | dysinger_ | I ran naked through the channel |
| 17:57 | technomancy | as long as it's not the Thriller zombies... |
| 17:57 | dysinger_ | but nobody said anything :) |
| 17:57 | Chouser | normally I would have assumed you were making a straight statement, but since your comment was the first in over an hour I just wasn't sure. |
| 17:57 | dysinger_ | seriously :) "dysinger_ runs by naked and nobody notices [2:52pm] •" |
| 17:57 | Chouser | heh |
| 18:03 | jackdempsey | man |
| 18:03 | jackdempsey | this is really interesting, but i feel like i'm starting to walk again |
| 18:03 | jackdempsey | except i have arthritis from OO land |
| 18:03 | jackdempsey | i'm staring at (let [id gen-id]....) for a while and wondering why i get the function back |
| 18:04 | jackdempsey | maybe because thats exactly what i asked it to set id to |
| 18:04 | jackdempsey | [id gen-id] will just st id to be the function referred to by gen-id, correct? if i actually want it to be the result i have to do (let [id (gen-id).....) right? |
| 18:04 | Chousuke | yes. |
| 18:05 | jackdempsey | cool |
| 18:05 | Chousuke | first-class functions are fun little things :) |
| 18:05 | jackdempsey | technomancy: that little web port is coming along ok....so far the hardest part has been trying to figure out what i can borrow from java......and of course some basic clojure stuff. |
| 18:05 | jackdempsey | haha, yep |
| 18:05 | jackdempsey | going to take a while to unlearn some bad habits |
| 18:06 | jackdempsey | i can't wait to see what this does to my ruby.... |
| 18:06 | Chousuke | jackdempsey: you'll be using code blocks a lot more I guess. |
| 18:07 | jackdempsey | yeah, blocks are already kinda ubiquitous, but i think the way i use them and approach certain problems will certainly be different |
| 18:07 | Chousuke | or then you do an assignment and go "wtf, why is the old reference changing too?" |
| 18:07 | jackdempsey | i saw somethhing in couchdb earlier and thoguth" but but but, thats a side effect, oh god no!.......oh wait........ahem" |
| 18:07 | jackdempsey | lol |
| 18:08 | jackdempsey | user=> (def foo #{}) |
| 18:08 | jackdempsey | #'user/foo |
| 18:08 | jackdempsey | user=> (conj foo 1) |
| 18:08 | jackdempsey | #{1} |
| 18:08 | jackdempsey | user=> (conj foo 2) |
| 18:08 | jackdempsey | #{2} |
| 18:08 | jackdempsey | that still cracks me up....not used to it at all :-) |
| 18:08 | Chousuke | yeah. |
| 18:08 | jackdempsey | "where'd the 1 go.........oh......ha" |
| 18:09 | jackdempsey | its definitely easier to think about things in the more pure functional sense...appeals to my math side for sure |
| 18:09 | Chousuke | I find it easier because functions become true black boxes. |
| 18:09 | Chousuke | once they work, you *only* need to know what they do, not how |
| 18:09 | jackdempsey | yep |
| 18:09 | jackdempsey | exactly |
| 18:10 | jackdempsey | "does that still set that random thing or not......have to go look" |
| 18:10 | jackdempsey | man, i really really want to reply with something about refs and STM: http://stackoverflow.com/questions/1080993/pure-ruby-concurrent-hash :-) |
| 18:11 | arohner | Clojure makes me more irritated by ruby |
| 18:11 | arohner | I get annoyed by things like not being able to pass multiple blocks to a function |
| 18:11 | technomancy | yes. |
| 18:12 | arohner | and blocks are not a replacement for first class functions |
| 18:12 | technomancy | I find myself writing classes for pure IO and keeping them totally separate from the bulk of the logic. |
| 18:12 | technomancy | but I've only written like two pages of Ruby since learning Clojure. =) |
| 18:13 | Chousuke | arohner: what, you can only pass one? :/ |
| 18:13 | slashus2 | technomancy: Was it your main language before? |
| 18:13 | jackdempsey | heh |
| 18:13 | arohner | Chousuke: yes, one "normal" block. After that, you have to start passing procs around, which use a different syntax |
| 18:13 | jackdempsey | yeah, if you do def (foo, &bar) |
| 18:13 | arohner | that, and there are 6 or 7 different kinds of blocks |
| 18:14 | jackdempsey | can pass that one normal block, otherwise as arohner says you have to use lambdas |
| 18:14 | jackdempsey | hehe |
| 18:14 | Chouser | though in a mutable language, first class functions are not a replacement for blocks |
| 18:14 | arohner | Chouser: how so? |
| 18:16 | arohner | http://innig.net/software/ruby/closures-in-ruby.rb |
| 18:16 | arohner | that is a great example of how Ruby is insane |
| 18:16 | jackdempsey | oh man |
| 18:16 | jackdempsey | lol |
| 18:16 | jackdempsey | really exposing the skeletons in the closet now :-D |
| 18:16 | Chouser | ruby blocks can use 'break' and such to control the loop they're in |
| 18:16 | arohner | ewww |
| 18:16 | jackdempsey | lambas can return as well....but procs return differently......and well......yea |
| 18:17 | jackdempsey | ruby's an excellent language for some things.....but for others, not so much, and like anything, has its warts |
| 18:17 | jackdempsey | k, workout time, later gents |
| 18:28 | codyK | is there an existing pretty-printer for xml-zip ? |
| 18:31 | Chouser | codyK: you can zip back up to the root and use 'emit' to print it as xml again. |
| 18:35 | codyK | good enough, thanks |
| 19:11 | _hrrld | Is there a function to tell me if a Var is "bound"? |
| 19:16 | Chousuke | _hrrld: (when-let [v (resolve sym)] (.isBound v)) perhaps |
| 19:21 | _hrrld | Comically, I can't seem to call resolve on an unbound symbol. |
| 19:22 | _hrrld | (declare x)(resolve x) ; Var user/x is unbound. |
| 19:24 | achim | _hrrld: (.isBound #'x) seems to do the trick |
| 19:25 | achim | resolve is a function, it doesn't even see the x, the compiler tries to substitute it before calling resolve |
| 19:28 | _hrrld | That makes sense, and the hash quote does work. Thanks. |
| 19:28 | Chouser | That assumes the var exists |
| 19:29 | Chouser | which is why Chousuke use 'resolve' first to see if there's even a var named by that symbol |
| 19:37 | unlink | hi |
| 20:47 | something | if I know the name of the function, is there a way to get the fn definition back during runtime? |
| 20:59 | Chouser | something: have you tried clojure.contrib.repl-utils/source ? |
| 21:00 | something | Chouser: no I didn't yet. let me take a look at that. |
| 21:01 | Chouser | it actually uses the var name not the fn, and it needs to be able to find the original .clj file in the classpath |
| 21:01 | something | Chouser: I want to figure out # of arguments a particular fn takes before I invoke it. Is there an easy way to do that? |
| 21:02 | Chouser | something: not perfectly, but you could get an 80%-type solution if you have access to the var |
| 21:02 | Chouser | if the var has been resolved to an actual fn, or if the fn was never in a var, you're pretty much out of luck. |
| 21:03 | Chouser | the var has :arglists metadata you can try to use |
| 21:03 | something | Chouser: awesome! let me check that out. |
| 21:05 | Chouser | the thing is even if you have the var, it's possible for the var's arglists to have been left out or changed |
| 21:07 | something | in what scenario can the arglists be left out? |
| 21:08 | Chouser | (def foo (fn [a b c] ...)) |
| 21:09 | something | Chouser: right, |
| 21:10 | something | Chouser: I'm going after the defn case, so I should be ok, but I understand what you are saying. |
| 21:23 | something | Chouser: I guess the question is how to get a hold of the var when I only know the string representation of it |
| 21:36 | Chouser | something: (resolve sym) |
| 21:46 | something | Chouser: ah, thanks |
| 21:49 | Raynes | Joining #Concatenative after making less-than-nice remarks on reddit - Awkward. |
| 23:33 | Knekk | does clojure provide data/object serialization functionality (for writing to a stream, for instance) or does one need Java interop? |
| 23:34 | Chouser | Most Clojure collections can be printed as ascii that can then be read again. |
| 23:35 | Chouser | There's also a *print-dup* var that can be set to make sure you get identical object types when read as when printed. |
| 23:37 | Knekk | thank you. I have too much data to keep in memory and need to find an efficient way to offline to disk |