#clojure log - Jul 17 2008

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

7:00 StartsWithK: hi

7:01 rhickey_: hey

7:01 StartsWithK: did any one created osgi bundle that can use clojure?

7:01 i have no luck with creating one

7:01 what i did is

7:02 i created regular bundle (with scala, but its sam as java version)

7:02 and in manifest file included Bundle-ClassPath: clojure.jar

7:02 and included clojure.jar with my bundle

7:03 i think RT class would be global to all bundles if it was registered as separate bundle

7:03 bun when i try to call some method on RT i get..

7:04 java.lang.ExceptionInitilizerError

7:05 this happens in my Activator inside start method..

7:07 rhickey_: I don't know osgi, but it could be that RT can't find boot.clj etc in the classpath

7:08 StartsWithK: i even tryed to call something like RT.nextID ..

7:08 is there a way for clojure to dump me some kind of log of what it is doing?

7:09 hmm.. maybe it is that

7:09 should i maybe copy all of clojure.jar files directly to my bundle?

8:08 rhickey_: I've changed eval so the stack traces should be much shorter and more relevant

8:35 cemerick: rhickey_: That's *very* exciting.

10:00 * meredydd prods Chouser

10:00 meredydd: http://pastebin.com/m4be0b624

10:01 Ooo. And I look at scrollback, and see rhickey has addressed that issue too

10:28 Chouser: I've got rhickey's changes built, but I haven't tried them out yet.

10:29 rhickey_: try (+ "a" 2) before and after the change

10:36 Chouser: Anyone looked at Google's protocol buffers? "Order of magnitude faster than xml" sounds interesting.

10:36 http://code.google.com/apis/protocolbuffers/docs/overview.html

10:37 rhickey_: ugh, IDL

10:40 Many people wish they had Google's problems, but they don't

10:40 Chouser: heh. good point.

10:41 rhickey_: I'm no fan of XML, but I would prefer optimizations oriented around - "here's the first set of tags, all the children will have the same set so I'll leave them out", which would still be dynamic

10:42 and XML closing tags are an abomination

10:43 * rhickey_ - scarred for life by DCOM

10:43 Chouser: I guess I'm an XML fan if not a fan-boy. It's better than anything else I've heard of that acheived such broad acceptance.

10:44 abrooks: I continue to share some level of Brett's annoyance at the inconsistency between attributes and sub-tags.

10:44 Chouser: ASN.1 is no good. I've only heard bad things about DIF. etc.

10:46 sure, there's plenty of things wrong with XML. But what's right: dynamic, namespaced, heirarchical, char-encoding-aware, widely used.

10:47 I like JSON too for a lot of applications, but it's missing at least 2 of those.

10:47 albino: How is xml dynamic?

10:47 rhickey_: read/print

10:48 abrooks: Chouser: Have you presented the alternate Clojure XML representation?

10:48 Chouser: nope. It's not very different from a couple of formats people are knocking around, though.

10:49 abrooks: No, it's fairly similar but I think the difference is big enough that it should be considered.

10:49 rhickey_: [tag {attrs} children ...]

10:49 ?

10:49 Chouser: rhickey_: yes

10:49 * abrooks realizes he was the one who was supposed to write it up...

10:49 Chouser: I think we had some namespace ideas too

10:49 rhickey_: attrs optional?

10:49 abrooks: Yeah, I now need to disinter those dead brain cells to remember that.

10:50 Yes, attrs optional.

10:50 I think.

10:50 Is that what we said?

10:50 Chouser: rhickey_: I want parse, zip, and emit support for that format. (and was planning to write it if nobody else did)

10:51 * abrooks is in the middle of a release cycle and has done /no/ Clojuring recently.

10:51 Chouser: abrooks: yes, optional attrs for input only

10:51 abrooks: ^middle^end

10:51 Chouser: Ah, that's right.

10:53 Chouser: rhickey_: compared to xml.clj, that's one less hash-map per xml element, and less verbose when printed.

10:54 rhickey_: Chouser: an early version (prior to checkin) used that format. It was one of the things that inspired subvec

10:54 I think it is ideal for human entry

10:54 abrooks: Why the change?

10:54 Chouser: rhickey_: does it have a drawback I'm missing?

10:54 rhickey_: programming with it, I found it a bit precarious, as it was easy to get the wrong bits of the data structure accidentally

10:55 you'd have to use access functions always

10:55 abrooks: Because of the need to conditionalize for the posibly absent attributes?

10:55 Chouser: xml.clj already provides accessors for tag, attrs, and content. I figured providing those would make it seamless.

10:55 abrooks: Off by one or two for the name and attribute slots?

10:57 I think those issues are not so significant with the current set of tools. There's really not a need to touch the structure directly.

10:57 rhickey_: you get into a nested context and forget (content x) and use x, it's the same data structure

10:58 I'm not arguing against it, but that was my experience

11:00 abrooks: Chouser: Did we discuss [name {attrs} [content]]?

11:00 rhickey_: switching back was on my todo list, but I wanted to think about those issues

11:00 abrooks: I have pages and pages of variants, including that

11:00 abrooks: Less nesting is still probably better.

11:00 rhickey_: right

11:00 Chouser: abrooks: not that I recall. wouldn't really help rhickey's specific example.

11:01 rhickey_: Chouser: I don't think optional attrs for input only works

11:01 Chouser: oh?

11:02 rhickey_: turning [a b] into [a {} b] on people will be confusing

11:02 Chouser: I guess input only would have to be defined -- probably by requiring use of a normalize function or something.

11:03 rhickey_: plus you might read a huge structure which will need translation

11:03 Chouser: hm. if the accessors still work correctly? I would just rather not type [:p {} "This is " [:b {} "bold"]]

11:05 rhickey_: I'm arguing for the opposite, leave out empty {}s, attrs and content accessors have to test the type of (element 1)

11:06 Chouser: oh, arguing against the "input only" part. ok.

11:07 I guess if you're already requiring the use of accessors, that's not a huge deal.

11:07 rhickey_: right, whatever data structure is acceptable input has to work without transformation

11:08 and will discourage (drop 2 element) to get at content

11:08 Chouser: another detail is that [[:tag ...] [:tag ...]] would be spliced in

11:09 rhickey_: ?

11:11 Chouser: because I don't know how else to nicely splice in generated content

11:11 * rhickey_ is still confused

11:11 Chouser: [:table [:tr "heading row"] (for [r rows] [:tr r])]

11:13 rhickey_: user=> `[a b ~@(range 3)]

11:13 [user/a user/b 0 1 2]

11:13 Chouser: yeah. that's what webjure does

11:13 rhickey_: if you are a macro

11:16 Chouser: stiull not sure I get what you meant by [[:tag ...] [:tag ...]]

11:18 Chouser: [:p [:c1] [:c2] [[:c3] [:c4]] [:c5]] ... all the c's are siblings, :p is their parent

11:18 rhickey_: oh

11:21 Chouser: I don't love it, but so far I think I like it better than any alternative I've tried.

11:21 rhickey_: indefinitely nested?

11:22 abrooks: Chouser: I think that plays with my head and would lead to several easy-to-commit errors.

11:23 Chouser: rhickey_: hm. presumably, though I haven't needed more than one level yet.

11:23 abrooks: It does make merging easier.

11:24 How about sequences? [:p [:c1] [:c2] ([:c3] [:c4]) [:c5]] ?

11:24 Chouser: abrooks: so suggest an alternative. webjure uses a backtick at the root of the s-expr, and then ~ or ~@ before every non-literla value.

11:24 abrooks: sure, seq or vector. but not written like that.

11:25 abrooks: Oh, heh.

11:25 Chouser: [:p [:c1] [:c2] (list [:c3] [:c4]) [:c5]]

11:25 abrooks: [:p [:c1] [:c2] '([:c3] [:c4]) [:c5]] ?

11:25 Hm. Not the same.

11:26 Chouser: that's good enough

11:26 in this case

11:27 the point is, vector hash-map and keyword syntax allow beautiful self-representation without quoting using ` or '

11:27 rhickey_: seqs/vecs don't matter, what matters is that the entry format be directly useful as data, so (content element) would have to call some sort of flatten

11:28 also, if you are looking for easy read/modify/emit, both seqs and vecs have bad insert-in-middle perf

11:28 abrooks: We can't really do this without macros...

11:28 Or adding flattening functions which I think we agree are yucky.

11:28 Chouser: but as soon as you quote or use a macro, you lose all that and have to convert stuff in and out of the format.

11:29 rhickey_: we need to clarify what we are talking about here - templating systems are another level, first thing is how is xml represented as data

11:29 * abrooks senses the ghost of Goedel hovering over his shoulder...

11:29 Chouser: you might as well then use symbols and lists instead: `(html (body ~this ~that ~@(stuff ...)))

11:33 of course everyone's specific use cases are different, but when one situation I'm frequently in is one where I now reach for xslt/xpath.

11:33 abrooks: ... and a bucket.

11:33 Chouser: xpath is ok, but xslt is annoying. I think I have a reasonable replacement for xpath in clojure, so I'd like to do my full round trip xml->parse->modify->xml in clojure

11:34 right now, xml.clj -> zip.clj -> zip-filter.clj work nicely for the parsing and selecting.

11:35 But in order to insert new sub-trees into my zip-tree, I need to generate xml.clj's structure.

11:36 doing that with raw s-expr is verbose and error-prone (I set the :contnet of the element, why can't I see it?)

11:36 abrooks: All of these nits aside, I must say that Clojure's ability to reasonably represent and process XML in a native but isomorphically structured format is amazing. Every other language you hit places where you hold your breath, unpack the XML into something usable, process and, only at the end, restructure everything for output.

11:36 rhickey_: Chouser: ?

11:36 Chouser: I've suggest to poor Lau that he provide the new content as an string and run it through xml/parse. This works but is slow and has other caviats.

11:37 abrooks: isn't that what we're doing in clojure?

11:38 rhickey_: Chouser: when you have (content e) -> [a b d e] and you want to make it [a b c d e] what do you want to do/say?

11:39 abrooks: Chouser: I don't mean on the bits level, I mean on the data structure level (or even above) -- how you relate and interact with the data.

11:39 Chouser: hm. well now that I've spewed all that, perhaps all I really want is something that consumes [:a {:href ...}] and produces {:tag :a, :attrs {:href ...}, ...}

11:39 rhickey_: heh

11:40 Chouser: then I can make up all the fancy input semantics I want (optional {}, nested seq content, etc.)

11:40 I'm pretty bad at thining unless I'm talking. *sigh*

11:41 thinking

11:41 abrooks: We don't have an (xml<- ...) yet do we? (We have (xml->) IIRC).

11:42 Chouser: abrooks: xml-> is from zip-filter, and it's -> in the sense of the builtin ->, not like C++ >> stream io or anything.

11:42 abrooks: xml.clj provides parse and emit

11:43 abrooks: Richt. I was thining of (<- xml [:tag])

11:43 Drat. There's that thining again. We must not be doing enough thinking.

11:45 Chouser: well, if I write a tmpl function as described above, you could say (xml/emit (tmpl [:tag]))

11:45 abrooks: Is Clojure SVN still sad? I'm not getting any response.

11:45 Chouser: and get <tag /> ...so much better. :-/

11:45 abrooks: Ah, no, wait... it's just horribly slow.

11:46 * rhickey_ wonders if tag/attrs/content couldn't be made polymorphic on element type...

11:48 Chouser: I want to think more about xml namespaces too. They're powerful, but a lot of the APIs out there make them pretty painful to deal with.

11:49 abrooks: Isn't that what we were doing with optional attrs.

11:49 ?

11:49 rhickey_: abrooks: no, I mean supporting both vector (new) and map (as is today) elements

11:50 abrooks: Ah, I see. Multiple formats simultaneously based on object types.

11:50 rhickey_: Chouser: at least nested : is ok now

11:50 Chouser: rhickey_: yep, I look forward to taking advantage of that. :-)

11:52 the problem is that you want a map of prefixes to namespace uris somewhere so that all your query and literal xml expressions can use the prefixes.

11:52 so where do you put the namespace map without getting all stateful?

11:52 rhickey_: Chouser: I don't think the flatten required by your nested child seqs is too bad, since most reading is sequential

11:53 Chouser: rhickey_: I was just about to say that -- lazy-xml generates a seq instead of a vector for the content anyway, and zip and zip-filter still work great

11:56 rhickey_: an advantage to the canonic (current) xml data representation is that 'setting' the content is easier

11:56 so transformations of vector elements might yield map elements, but using accessors on wouldn't care

11:56 one wouldn't

11:57 Chouser: where do they go in xml?

11:57 namespaces

11:58 attrs?

11:58 Chouser: you can declare a namespace prefix association in any element, and it applies for that element and all descendants.

11:59 they look like attributes

11:59 rhickey_: are they not?

11:59 in a DOM?

12:00 Chouser: <ns1:foo xmlns:ns1="namespace1">...</ns1:foo>

12:00 um... good question.

12:01 rhickey_: also most DOMs will present the tags as qualified names for programmatic use

12:01 or at least make the ns available

12:02 so a ns aware parser could ns-qualify while keywordizing...

12:03 and an emitter could elide anything namespaces declared along the way...

12:03 setting aside read/print veracity

12:03 Chouser: SAX lists namespace declarations as attrs, though other parsers do other things.

12:05 xpath and xslt associate the real namespace with each tag and attr

12:05 I'm not sure what the w3 DOM does

12:06 rhickey_: applying the namespaces on read seems to be the right thing

12:07 getting rid of them on the way out is the trick

12:08 Chouser: sure. but even "apply the namespace" isn't obvious to me.

12:08 Or I guess what I mean is, what's the canonical format?

12:08 rhickey_: :ns:name

12:09 Chouser: except an ns looks like http://www.w3.org/1999/xhtml

12:09 you don't want {:tag :http://www.w3.org/1999/xhtml:img ...}

12:10 I guess you could do {:tag :img, :nsmap {nil "http://www.w3.org/1999/xhtml"} ...}

12:10 ...and then have the nsmaps apply to children, just like raw xml does. But then those children lose meaning when taken out of context.

12:10 (this is what I meant by "where to put the ns map")

12:11 rhickey_: if you don't end up with the ns on the tag somehow, everyone will have to track the namespaces, there isn't one map as it can change in nested contexts

12:12 if I see :img in the middle of the document, how do I know which :img?

12:12 Chouser: right. the same question applies to :xhtml:img -- which xhtml?

12:13 in practice, most documents don't stack their nsmaps very much. you tend to declare them in the root element and leave them alone.

12:13 rhickey_: but programmatically you can ask img for its ns and get http://www.w3.org/1999/xhtml

12:13 anywhere, with no lookup table

12:13 Chouser: how? I don't follow.

12:14 I mean, we need to provide a way to do that, but I don't see how to best store that information.

12:14 rhickey_: when you load that into a dom and ask the element for its ns you get the whole gnarly thing

12:14 metadata, except none for keywords...

12:14 Chouser: :-)

12:15 right, because remember each attr has a namespace as well

12:15 rhickey_: yes, all names

12:16 Chouser: it's also beneficial to store the prefixes used on input somewhere. there are a lot of almost-correct xml tools that panic when you use an unexpected prefix

12:17 they want <rss:entry xmlns:rss="...rss..."> not <n1:entry xmlns:n1="...rss...">

12:18 rhickey_: I don't think we'd be making up prefixes

12:18 Chouser: maybe it would work for every element to have an :nsmap, and mostly they would all be the same hash-map

12:18 rhickey_: maybe swapping in full qualifiers

12:19 Chouser: if you hit a stacking case on input, the subtree of elements will all be pointing to a second hash-map

12:19 rhickey_: something does that... some Scheme thing?

12:19 cemerick: I'm totally lurking here, and a long way from the days when I swam in XML, but it seems that conforming to XML Infoset would be a #1 priority. Syntax and such are definitely important, but the data model needs to be right...otherwise, impedance ramps up quickly when serializing, etc.

12:26 rhickey_: http://okmij.org/ftp/Scheme/SXML.html

12:29 emulated here: http://groups.google.com/group/clojure/browse_frm/thread/ce8131bd1ae59bfc/437c0119d2c91628?#437c0119d2c91628

12:32 cemerick: yeah, SXML looks like a good starting point.

12:33 I only brought up infoset because it was what led me to sanity after running into some very hairy technicalities w.r.t. namespace handling in various contexts. There be dragons.

12:34 (or, some degree of sanity; IIRC, there are some edge cases where some key XML specs are in conflict and/or ambiguous w.r.t. namespace handling)

12:37 Chouser: ok, so sxml attempts to handle namespaces though that clojure version doesn't?

12:38 cemerick: Chouser: yeah, that's listed as one of the to-do's in the code

12:38 Chouser: ah, indeed.

12:39 I don't really understand what sxml is doing, though.

12:39 "If an application told the parser how to map http://www.cars.com/xml, the application can keep this mapping in its mind and will not need additional reminders."

12:41 it seems to list details in an element's (@ ...) list, but it's not clear to me if that's actuallying being returned or not

12:41 huh. http://www.cars.com/xml:part is a valid scheme symbol.

12:47 cemerick: Rich's sxml link was the first I've heard of it, but it seems that he's talking about application-registered namespaces.

12:48 Which can be handy in situations where you need to combine documents that have conflicting namespace aliases.

13:53 rhickey_: user=> (namespace 'http://www.cars.com/xml/part)

13:53 "http://www.cars.com/xml"

13:55 user=> (name :http://www.cars.com/xml/part)

13:55 "part"

14:15 cemerick: rhickey_: shouldn't that be :http://www.cars.com/xml:part?

14:16 rhickey_: not in Clojure, namespace is everything before last /

14:16 this way you can get at the parts with namespace and name

14:17 on emit can be changed to :

14:20 cemerick: oh, I figured you were using some functions in some xml ns you were working on. Clever bit, reusing the built-ins.

14:21 rhickey_: still trying to encode xml in native data structures, here symbols or keywords for identifiers

14:23 when working with xml esp rdf, it is a huge pain when systems create a composite identifier with no ability to split ns and name

14:24 cemerick: yes, definitely

14:43 Chouser: rhickey_: do you think the whole universal name should be used for every tag and attr name in the internal structure?

14:44 rhickey_: Chouser: I don't know, but it's now an option

14:44 Chouser: :-) ok.

14:45 rhickey_: other options are to use symbols, with namespaces in the metadata (:ns ^(tag e))

14:46 Chouser: symbols are interned, but their metadata wouldn't be, is that correct?

14:47 rhickey_: one problem is that 'by hand' xml data would still need to be 'parsed' to get the qualification

14:47 cemerick: semantically, namespaces are definitely *not* metadata (at least how clojure conceives of metadata)

14:47 rhickey_: Chouser: if the names are symbols or keywords, the strings are interned, ns meta maps can be shared as you described before

14:47 cemerick: true

14:48 attrs could be considered metadata, but xml really leaves the semantics open

14:49 cemerick: I mean, clojure metadata is a thoroughly convenient mechanism for name metadata. FWIW, I often wish there were parallel metadata tracks in clojure -- one for the current notion of metadata, and one that *is* considered part of a value.

14:50 (not that I don't abuse that mechanism for my own purposes, anyway ;-) )

14:51 rhickey_: cemerick: is considered for equality or something more?

14:56 cemerick: equality for sure, but other things too, I'm sure. Having that other metadata print (with pr, etc) would be super-handy.

14:57 rhickey_: *print-meta* controls meta printing

14:57 cemerick: I've got a prn-with-meta fn that gets the job done with the current metadata, so it's not a big deal.

14:57 Hah!

14:58 * cemerick walks away, muttering :-)

15:22 StartsWithK: hi

15:22 so i was trying to create this osgi bundle with clojure

15:22 and i have no luck

15:23 whatever i do i get that java.lang.ExceptionInitilizerError

15:24 did any one created osgi bundle with clojure?

15:25 it seams that clojure can't find boot.clj, it throws same error if i remove boot.clj from clojure.jar and try to run in

15:26 i don't know is this important but i use Knopflerfish as osgi container

15:27 cemerick: sounds like a classloader issue

15:28 StartsWithK: yes it looks like it is

15:28 so ill just dump all experiments i did so far

15:29 included clojure.jar in my bundle.jar and used Bundle-ClassPath: clojure.jar

15:29 included files from clojure.jar in my .jar

15:29 added Bundle-ClassPath: .

15:29 and copied all .clj files from clojure.jar to directory where my .jar is located

15:30 cemerick: well, I don't know how Bundle-Classpath works, but if you want to merge Clojure in with your jar, you need to put everything from clojure.jar into your jar

15:30 the .clj files, too

15:30 StartsWithK: i did that too

15:30 same thing

15:31 cemerick: OK, so your jar's top level has the clojure classfile dir, yes?

15:31 StartsWithK: yes

15:31 cemerick: the .clj files should be at that top level as well

15:32 StartsWithK: ther are

15:32 they*

15:32 cemerick: Well, it *should* work. :-) boot.clj is loaded using the same classloader that loaded clojure's core runtime class(es)

15:32 StartsWithK: hmm

15:32 i wish it worked :)

15:33 cemerick: hrm, try putting the clj files in clojure/lang in your jar

15:34 StartsWithK: ok

15:43 same thing happens

15:44 at this point i have .clj in my jar, inside clojure/lang in my jar, clojure.jar in my jar and all .clj files in directory where my jar is located

15:44 its not picking up on any of them

15:45 also, this code work outside of osgi container.. i can run it as standalone just fine

15:45 cemerick: well, the last thing you mentioned wouldn't ever work. The 2nd and 3rd things should definitely work (modulo the operation of Bundle-Classpath

15:47 StartsWithK: ill create minimal example, using java instead of scala.. but there should not be any difference there

15:51 cemerick: Nevermind, the first option should be the one that works (I just re-noticed that '/' is prepended to all paths being loaded at init).

16:22 StartsWithK: hmm.. same thing

16:25 if i run it again, without reintalling the bundle

16:25 i get

16:26 java.lang.NoClassDefFoundError: Colud not initialize class cljure.lang.RT

16:46 For the OSGi import/export mechanism to work,

16:46 the bundle must use the Bundle classloader.

16:46 o! However, many libraries uses the system

16:46 classloader or the thread's classloader

16:46 o! Works great in standalone apps

16:46 o! Does not work at all in typical OSGi settings

16:47 from knopflerfish presentation about bundling existing applications as osgi bundles

16:47 and i see that DynamicClassLoader is using thread's

16:51 cemerick: StartsWithK: well, NoClassDefFoundError is much different than the initializer exception you mentioned earlier

16:56 StartsWithK: cemerick, yes it is, but that is from second call to bundle's start(), so if RT's static {} field faild to execute first time that could be why i see that message second time i try to start the bundle

17:08 cemerick: StartsWithK: could you paste a full stack trace?

17:08 StartsWithK: cemerick, here is no stack trace at all

17:09 just that one message that is shown inside knopflerfish admin gui

17:09 i mean, there is stack trace but it starts with kf gui and only last entry is for my bundle

17:09 cemerick: have you checked your log files? The stack trace must be printed out somewhere.

17:10 You might have to turn on osgi debugging, etc., in order to get the original stack trace

17:10 That is, if clojure.lang.RT is being found, but is causing an error during initialization.

17:13 StartsWithK: oh.. i didn't turn all debug options inside kf.. ill try with all of them on

17:24 meredydd: Hmm..any suggestions for:

17:24 java.lang.Exception: Unable to resolve symbol: in this context

17:24 Didn't think you could *have* an empty symbol :)

17:25 (Just to be helpful, it's giving me no line numbers at all)

17:25 (or even a file)

17:25 Chouser: meredydd: is this with the new easier-to-understand stack traces?

17:26 rhickey_: any more stack trace than that?

17:26 meredydd: Chouser: Yep. It's a compiler thing, though, so it's probably not part of the rejig.

17:26 rhickey_: Sure, one sec

17:27 http://pastebin.com/m7b2cc513

17:27 * rhickey_ is having fun with 10-line IM repl

17:28 meredydd: Nice. Is this that XMPP library you're playing with?

17:28 rhickey_: yeah

17:28 I have a repl going through gtalk and jabber.org

17:28 * meredydd is currently condensing a server-side IM gateway from Java to Clojure.

17:29 meredydd: Much less elegant, and less XMPP.

17:29 Any enlightenment on the compiler error?

17:31 rhickey_: meredydd: sure looks like you have a blank symbol somewhere

17:31 meredydd: The mind boggles. How *does* one write a blank symbol?

17:31 rhickey_: any symbol-creating macros in there?

17:32 meredydd: Uhh...doing what?

17:32 I have one or two that use #

17:32 Chouser: meredydd: You have to delete the line where you do: (symbol "")

17:32 meredydd: and I think the odd (gensym), before I found out about #

17:32 rhickey_: (symbol "") or equivalent

17:32 Chouser: ;-)

17:32 meredydd: Oh. No.

17:33 Hmm. I *am*, however, using 'lib

17:33 which probably does do some interesting symbol-bending behind the scenes

17:36 ...and it appears to have gone away again. Which is odd.

17:37 I was *sure* I'd restarted the REPL after the update to svn HEAD. Perhaps my mind is playing tricks on me.

17:38 rhickey_: meredydd: I put up a patch which wraps the body of analyze, so you should get a line next time

17:38 meredydd: Thank-you.

17:38 Do I get a filename as well?

17:38 rhickey_: yup

17:38 meredydd: ta

17:41 rhickey_: now I can write a coy "Little Clojurer" book with the code in iChat bubbles

17:41 meredydd: Someone's having fun :)

17:43 StartsWithK: cemerick, http://pastebin.com/m560b7301

17:43 this is with copy of clojure inside my jar, .clj files are both in root of my jar and in clojure/lang

17:45 thats it, no error message inisde debug log, only in kfish popup window

17:45 meredydd: rhickey_: Would it be possible, when method invocations go via reflections, to wrap the method call in a try-catch block for InvocationTargetException and re-throw the original (causal) exception?

17:46 rhickey_: no, but it could be peeled off in the repl

17:46 meredydd: The causal exception has the full backtrace any Clojure programmer is looking for - from our PoV, the InvocationTargetException amounts to an implementation detail

17:47 Is there a particular reason you're not willing to peel off InvocationTargetExceptions in all cases? (I'm guessing it's going to be a performance thing)

17:48 rhickey_: and code gen size

17:50 meredydd: Hmm...theoretically, one might move reflected calls into RT, but I guess that's an extra-stack-frame penalty you don't want either

17:50 I have no intuitive feel for how slow reflection is, so I don't really know how much it would cost in relative terms.

17:52 rhickey_: I take all that back, the calls go through Reflector so I can just change that rather than each gen point...

18:02 meredydd: done - so no error reporting complaining for 1 week :)

18:03 meredydd: Yay!

18:03 * meredydd is a Happy Man,.

18:03 meredydd: (although if you want me to stop yelping when I stub my toe on something in the language, I fear a +b might be the only effective approach.)

18:04 rhickey_: just kidding, I like improving Clojure

18:04 meredydd: In all seriousness, though, from what I've seen, your stack-tidying, and now this together, look like the silver bullet.

18:05 My stack traces actually tell me where in my code I was when I screwed up, and do so fairly concisely.

18:06 rhickey_: I'll grant completely that my first priority was making correct code work correctly, error handling will improve with time, but dynamic langs always have some more room for errors

18:08 meredydd: Absolutely, I agree with the emphasis. But I was having to grovel through three-deep stacks of InvocationTargetExceptions, checking the trace at each level to see whether my filename was there at all

18:08 which got a bit wearing after a while.

18:08 But no longer!

18:08 * meredydd toddles off

18:37 mebaran151: I'm playing with Clojure and I was wondering if there was an easy way to declare a main method so I could easily launch my app from the Netbeans idea

18:39 also are there any good ideas as to how write servlets with clojure: should I just define one generic servlet and route everything through it, hitting associated functions?

18:47 eerie silence ...

19:17 cemerick: mebaran151: There's no main methods per se -- use clojure.lang.Script to bootstrap a .clj file whose top-level forms do what you'd want from a "main method"

19:18 StartsWithK: I don't see any errors there -- looks like the BundleClassLoader (whatever that is) is finding everything, including .clj files

19:18 StartsWithK: cemerick, yes, it looks like that

19:19 but i am not even trying to execute any code from my test

19:19 only call RT.nextID()

19:19 cemerick: And the UI shows an exception?

19:19 StartsWithK: yes

19:20 maybe i should try with alternative osgi container

19:20 cemerick: I don't know. Try deploying a java-only (no clojure) app to knopflerfish, where all it does is try to load a file from the jar you deploy (i.e. using class.getResourceAsStream)

19:20 or, yes, try another container

19:21 I know people are using clojure within eclipse, which I think uses osgi pretty pervasively

19:21 StartsWithK: using clojure to write eclipse plugins?

19:22 cemerick: that I'm not aware of, but I'm pretty sure eclipse uses osgi "stuff" to bootstrap apps when debugging, etc

19:22 StartsWithK: my other option is equinox

19:22 cemerick: (so as to support "hot" code reloading, etc)

19:22 StartsWithK: yes, they have equinox as there osgi implementation

19:22 cemerick: otherwise, try to find out from the knopflerfish folks how to get the details of that stack trace, because it's not showing anywhere in the logs

19:23 StartsWithK: its second day i am trying to use kfish.. and not impressed in general

19:24 cemerick: well, if eclipse is using equinox, then it seems like a safe choice

19:24 StartsWithK: gui starts in 2-3 mnues before i can even see bundles..

19:24 well, thats it for today

19:25 thanks for help.. ill continut this tomorow

19:25 cemerick: StartsWithK: np

19:29 mebaran151: cemerick: is that a Java class or something?

19:33 cemerick: mebaran151: Yes, clojure.lang.Script is a Java class

19:33 mebaran151: for example, java -cp clojure.jar clojure.lang.Script yourfile.clj will load yourfile.clj and exit

19:34 mebaran151: ah so it should just be in the startup script

19:35 I'm trying to figure out how to get Clojure integrated into my servlet workflow too, so any pointers on that would be appreciated. Right now, I'm thinking of building a generic routing servlet that would dispatch to function matched in a hashmap. Is this the cleanest way to work with servlets in clojure?

19:36 the only problem with it being scripted that way is that I can't set netbeans just to run my app...

19:40 cemerick: mebaran151: that certainly sounds like the simplest way to do it. I'm not really a web programmer, though.

19:41 well, you'll want to gen-class your actual servlet, and then put the implementation of the servlet in clojure, and deploy the whole thing to tomcat, etc. Netbeans should be able to load that up without a problem.

19:42 you'll want to read this: http://clojure.org/api#gen-and-save-class

19:42 g'night all

20:32 mebaran151: how do I set up the path in which closure searches for other namespaces

20:32 to import functions from

20:41 anyway to setup some sort of env file for a project so that aquamacs automagically picks up the libs I dump in lib and the cljs I keep in src

20:44 Chouser: You can use load-file to load a .clj file, and then refer so you don't have to use a full namespace each time you call a function from that .clj

20:44 rhickey: mebaran151: there might be something in contrib, right now Clojure proper just has explicit load-file. user.clj will get auto-loaded, and you could put some logic in there to load all the cljs from a directory. As far as 'libs', are you talking about jars?

20:45 mebaran151: I need to use a couple jars from jetty

20:45 so load-file is probably somewhat similar to ruby's require semantics?

20:46 rhickey: mebaran151: no, but there is require in the lib.clj from contrib

20:47 jars are subject to Java classpath, which unfortunately doesn't let you put a dir in the classpath and jars in the dir - each jar must be in the classpath

20:49 Clojure has add-classpath, but that should only be used temporarily to grab a jar you forgot - there are limits to the visibility of classes loaded that way

20:49 mebaran151: ah I see

20:49 what's contrib

20:49 I just started playing with Clojure today when I got sick of Scala's oh so mutable data structures

20:51 rhickey: contrib is an incubation project for extensions to Clojure, some nice things there: https://sourceforge.net/projects/clojure-contrib/

20:56 mebaran151: what does the clojure/refer clojure mean?

20:57 thanks for all your help by the way: doc on closure is much to scattered....

20:57 rhickey: mebaran151: everything is covered on the API page in one place if you haven't seen that yet

21:00 refer is the way you pull names into your namespace. A new namespace doesn't even have Clojure's public vars yet, so the use of refer itself has to be namespace qualified. (clojure/refer 'clojure) pulls in the core clojure names, after which refer, e.g., can be used without qualifier

21:00 mebaran151: oh I see

21:02 arbscht: speaking of the api, have you considered hyperlinking each entry in the api to the reference page it is also described in?

21:02 koneill: mebaran151: if git is your poison there is a clone of the contrib project available from git://github.com/kevinoneill/clojure-contrib.git

21:03 mebaran151: so how would I include it? just dump it in lib and set up my user.clj to figure it out?

21:05 rhickey: arbscht: at some point the redundancy between the two will be removed, so there won't necessarily be a place in the reference for each fn. There aren't already for many. I will try to go the other way as fns are referenced.

21:06 mebaran151: btw, does anybody here work with the Netbeans plugin? Can it reference the code in the buffer I'm working on?

21:07 rhickey: mebaran151: I haven't used the lib stuff, but I imagine if you have user.clj explicitly load lib.clj, then you can use its require to get classpath-based logical-name loading from there

Logging service provided by n01se.net