#clojure logs

2008-08-14

04:27blackdogin a macro when a ~@body is being processed what is the reason for the @ ?
04:29blackdogis the body automtically a ref?
04:40Chouserno, it has nothing to do with refs
04:41Chouser~ inserts a value, ~@ splices in a list
04:42Chouseruser=> `[1 ~[2 3] 4]
04:42Chouser[1 [2 3] 4]
04:42Chouseruser=> `[1 ~@[2 3] 4]
04:42Chouser[1 2 3 4]
04:42blackdogok that helps
04:44blackdogthx
04:44Chousersure. It's documented on the Reader page on the site, but that's a pretty dense section.
04:46blackdogi have a pretty dense section between my ears too :)
04:47Chouserheh. if you got anything at all out of my first answer, then I highly doubt it.
04:50blackdogso if i'm supplying a macro body (using) and I notice that the macro is using ~@ I should return a list, cos right now i get a compilation error when the last value is a map
04:52ChouserIf the thing to the right of ~@ isn't a collection, you'll get: java.lang.IllegalArgumentException: Don't know how to create ISeq from: X
04:53blackdogok, making more sense
05:04blackdogso to get a value out of macro the way is (let [x# ~@body]
05:04blackdog (.commit ~con)
05:04blackdog x#)
05:04blackdognever mind the commit
05:04blackdogso i return the x#
05:05blackdogis that ok to do?
05:11lisppaste8blackdog pasted "returning the body value of a macro?" at http://paste.lisp.org/display/65307
05:12roblallyI'm not an expert, so this me joining in to the speculation, but wouldn't the value of the let be the value of ~@body, so it kind of becomes unnecessary?
05:12blackdogbut i need to do the commit which is the last step
05:12blackdogso don't ignore the commit :)
05:13roblallyI have removed the filter now, and can see the statement again.
05:13blackdogin that paste you can see i'm getting stuff from the db, processing it and then i want to return something different
05:14roblallySo, if you splice the body into the let list, you'll get the unrolled list of expressions in the let statement. So that doesn't look right.
05:16roblallyWould (let [x# (do ~@body)] ... ) make sense?
05:16blackdog:) i have no idea but i'll try it
05:17roblallyIf I understand it properly do would evaluate all the statements and return the last value.
05:17blackdogok i see
05:19blackdogcrikey I'm in your deby
05:19blackdogcrikey I'm in your debt
05:19blackdogthat works
05:20roblallyNeat! I was exaggerating when I said I wasn't an expert. I'm not even competent.
07:05StartsWithK_hi
07:06StartsWithK_i now have osgi bundle with clojure
07:06StartsWithK_using equinox
07:06Chousercool!
07:07ChouserI don't know what any of that means, but it sounds cool!
07:07StartsWithK_it works but, i had to merge clojure.jar with mine bundle and jar of every library that will interact with clojure
07:08StartsWithK_Chouser: http://www.osgi.org/About/Technology
07:09StartsWithK_equinox is eclipse implementation of osgi container
07:10Chouseryeah, I've been looking at that page. Too much Java for my poor little head.
07:10StartsWithK_second implementation (or first) is knopflerfish, but i had no luck with it
07:10ChouserBut I'm sure there are people who will show up and say "does Clojure support OSGi? We only do OSGi."
07:10Chouserand because of you, they will be happy. :-)
07:10StartsWithK_its like plugin system for your application, but much more generic
07:11StartsWithK_now :) there are problems :)
07:11StartsWithK_i extended clojure manifest so it can be registered in osgi container
07:11StartsWithK_that works if you never have to (import) anything
07:12StartsWithK_problem is, clojure bundle will have it's own class loader and your bundle will have it's
07:12Chouserah.
07:12StartsWithK_and your file.clj is in your bundle
07:13StartsWithK_that could work maybe, but each bundle has to have Import-Package directive that list all packages this bundle will require
07:13StartsWithK_so clojure needs only org.xml.sax and org.xml.sax.helpers (xml.clj)
07:13Chouserhm, so OSGi is expecting a more static world than Clojure is.
07:13StartsWithK_yes
07:14StartsWithK_too much if you ask me
07:14StartsWithK_there is Dynamic-ImportPackage directive, you can use wildcards in it
07:14StartsWithK_but you can't use '*' as standalone, that could maybe solve importing problem
07:15StartsWithK_so i merged clojure with my bundle (each bundle will have to merge cojure.jar with itself)
07:15StartsWithK_this soled only one part of the problem
07:16StartsWithK_second one is when you create proxy (i don't know will it happend is some other situation)
07:17StartsWithK_library that is using proxy will be in another bundle, and i woulg get errors that clojure (?) can't find classes from clojure.lang package
07:17StartsWithK_so.. to solve this, i had to pack all libraries that will interact with clojure inside my own bundle
07:18StartsWithK_that kind of defeats the purpose of osgi :)
07:18roblallyYou probably want to look at a bundle fragment rather than merging the jar in. You could also use buddy loading, but that would restrict you to Equinox
07:18StartsWithK_knopflerfish didn't work anyway so i have no problem with using only equinox
07:19StartsWithK_i was thinking of using that, but then i would have to have for every lib a clojure bundle fragment that will provide new Import-Package directives
07:20StartsWithK_and i don't think that will solve second problem, when other bundle will use proxy
07:21roblallyYeah, you're probably right. Dynamic behaviour is always a problem in an OSGi environment. Personally I'd rather gnaw off my own foot than use OSGi where I didn't have to.
07:22StartsWithK_i would say biggest problem here is RT and how it handles class loaders
07:23StartsWithK_but i don't know that much about clojure or java
07:23roblallyIt'll start to get even uglier when if you want to use the parallel/fork-join framework and the jars from there.
07:24roblallyAnd I can't even begin to guess what you'd have to do to get gen-class running in a sane way.
07:24StartsWithK_why? :) don't scare me :)
07:25roblallyThat's another jar that you'll need to declare as a dependency from each bundle that uses it, and if there's call-backs, you'll end up merging that into the same library.
07:25roblallyPretty soon you end up with one giant OSGi bundle containing the whole world.
07:27roblallyThe problems aren't intractable, apparently, but they're not easy to solve in a manner that's easy for normal humans to comprehend.
07:28roblally(I've had experts trying to explain this stuff to me for years and I've never been able to keep it in my head for more than a few minutes at a time.)
07:29StartsWithK_it that happens, i will try to split them up by implementing services in scala (other part of each bundle) and scala actors uses fork/join lib too
07:29StartsWithK_so maybe i will avoid most of the probles
07:31roblallyGood luck.
07:31StartsWithK_but this should be resolved inside clojure, so i can do rt = new RT, there is no need for one static runtime
07:31StartsWithK_or is there?
07:36albinoStartsWithK_: May I ask why you are using osgi? Is there a big benefit you're after?
07:37StartsWithK_albino: loading and unloading of plugins at runtime
07:38albinoDoes a plugin just have to meet the osgi spec to be loadable?
07:40StartsWithK_i theory yes, in practice there are some class loader problems, its not just clojure, there are others that have similar problems
07:42StartsWithK_but in some slides from knopflerfish, they state that it is not osgi problem, that libs use class loaders incorrectly and that it shows when you use them inside osgi container
07:43StartsWithK_i don't know is that true or not
12:32roblallyIf I have a method with a var-args parameter [& more] and I have a list that I want to pass it, is there a way to unroll the list so that 'more' is assigned to the contents of the list rather than the list?
12:32kotarakroblally: (apply your-func the-list)
12:32Chouserapply
12:32roblallyAhh, thanks guys. Much appreciated.
13:31vixeyhow does the compiler work?
13:31drewrRich addresses that very well in one of the videos.
13:31slavait compiles, i guess :)
13:32drewrIf you know anything about Lisp readers/compilers in general, it's fairly similar.
13:33slavathe difference being that the JVM does most of the hard work
13:33vixeyI don't know how you compile a dynamic language to the static jvm
13:33slava'dynamic' and 'static' are pretty meaningless terms
13:33slavathe jvm supports runtime method dispatch and so on
13:37slavamain problem with compiling clojure to the jvm is that the jvm doesn't support tail calls or closures, but rich has some workarounds for those that seem pretty satisfactory for the mostpart
13:37vixeywhat are they ?
13:37slavai implementd a jvm language once with full continuations and tail calls, by managing my own call stack, but the gains are not really worth the extra overhead
13:38slavaso if i did it again i'd take the clojure approach
13:39vixeyIt looks like everything it emitted as boxed by the compiler unless it's possible to unbox
13:40vixeyand I guess boxed just means that you've got type information in the value (maybe that's not quite it though)
13:40slavaall java objects have runtime type information
13:40slavaprimitives don't
13:40slavaso a compiler can only emit code using primitives if it can prove it is monomorphic
13:53vixeydoes he talk about it in one of these http://clojure.blip.tv/ ?
14:04drewrvixey: Yes. I *think* it's in Clojure for Java Programmers Part 1.
14:05vixeythanks
16:15ericthorjure
18:40arohnerlisppaste8: url
18:40lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
18:41arohnerrhickey: I have a really tiny diff for you that helped me find a bug in my program
18:41lisppaste8arohner pasted "diff" at http://paste.lisp.org/display/65342
18:47rhickeyarohner: I look at it tomorrow, thanks
18:47arohnerok
19:17wwmorganI'm trying to write a function or macro that takes a list containing some symbols not bound in the current namespace, and returns a function that takes a map and evals the list using the key-val pairs as symbol-value pairs. http://paste.lisp.org/display/65343
19:17wwmorganany ideas?
19:18Chouserhm, sounds like fun...
19:22Chousercan create-template be given the list of symbols it will need to bind, or does it have to discover them somehow?
19:25wwmorganit's fine to assume that it knows what symbols it needs to bind
19:25wwmorganI've adopted a convention of making them begin with upper-case letters a la Prolog
19:28Chouseruser=> (defmacro create-template [s & b] `(fn [{:keys ~s}] ~@b))
19:28Chousernil
19:28Chouseruser=> (def template (create-template [a b] (+ a b)))
19:28Chouser#'user/template
19:28Chouseruser=> (template {:a 4, :b 6})
19:28Chouser10
19:29Chouserhope that helps, even if it's not exactly what you want.
19:30Chouseranyway, I'm off to bed.
19:30wwmorganthanks good night
20:33arohnerwhat is the clojure equivalent to import java.io.*?
20:33arohnerI tried (import '(java.io *)) but that didn't work
20:33arohner(import '(java.io.*)) works, but then the symbols aren't in the same namespace