#clojure logs

2008-07-29

00:54ChouserI just added gen-interface to clojure-contrib.
00:54ChouserIt's undocumented, weakly tested, and the API will probably change. But I believe it is functionally complete.
00:55ChouserThe filename and namespace may not even be correct -- I haven't quite figured out the new contrib layout.
00:57Chouserperhaps make-array could take either an integer or a seq. integer would be current behavior, seq would use the given member type, but populate it with the contents of the seq like into-array does.
01:11jykrdI don't see why this should be so hard. I'm trying to add clojure support to scite, right? But I'm using the plain lisp lexer that comes with scite.. I just want scite to associate all my *.clj files with the clj shell script (which runs clojure). But I can't get it to work.
01:12jykrdfile.patterns.clj=*.clj
01:12jykrdfilter.clj=clj (clj)|*.clj|
01:12jykrdlexer.$(file.patterns.clj)=lisp
01:12jykrdcommand.go.$(file.pattern.clj)=/home/john/bin/clj $(FilePath)
01:13jykrdthose four lines, in the lisp.properties file, should do the trick, as far as I can tell
01:14jykrdthat, and I added clj to a few places in the SciTEGlobal.properties file
01:24jykrdoh, wait, I think I did it
01:26jykrdum, yes.. frick ya
01:30jykrdno to build a keyword list.
01:32jykrdWhich basically means any reserved word?
01:32jykrdie, don't use the Clojure sense: Keywords are like symbols, except: They can and must begin with a colon, e.g. :fred. They cannot contain '.' or name classes.
01:54jykrdomg the keyword list is long.. I'm just putting in the entire api
02:12jykrddude, that was a lot of typing
02:16mebaran151well jykrd those aren't really keywords per se
02:16mebaran151much closer to a stdlib
02:21jykrdright, and I guess "Special forms" would be closer to keywords?
02:21jykrdbut where do I draw the line?
02:21jykrdwell, I suppose some can be over-riden and others not, right?
02:26jykrdbut what's better, "def" and "first" show up as different colors or both as blue?
02:27jykrdor def and map
02:30hoeckjykrd: are you talking about editor highliting?
02:30jykrdyea, scite, the editor
02:31hoeckjykrd: ahh, i see
02:31jykrdIt's working pretty well actually
02:31jykrdit's using the lisp lexer
02:32jykrdI've added all the clojure words in there
02:32jykrdI go to tools -> go, and it executes into a second window pane
02:33jykrdgot the pretty highlights going and everything.
02:33jykrdnow, here's the really interesting part:
02:33hoeckemacs lisp modes are highlighting every symbol matching ^\(def.*
02:34jykrddoes that not cover everything in the api?
02:35jykrdoh well, the keyword list can be tweaked... here's the interesting thing:
02:36hoeckactually not, only standard "if", "let", ":keywords" and strings
02:36jykrdI'm looking at a tutorial right now to integrate java ide features into scite: java classes highlighting, calltips, and auto completion
02:37jykrdso, what I'm going to do is work through this tutorial, but use it on my clj extensions to scite, rather than java
02:37jykrdand see what kind of java integration I can mingle in with the clojure
02:38jykrdhttp://www.burgaud.com/scite-java-api/
02:39jykrdstart typing StringB.. and it lists options for StringBuffer, StringBufferInputString, StringBuilder, etc
02:39jykrddoes emacs do that?
02:39jykrd;)
02:39jykrdwell, you could probably make it do that
02:41hoeckyeah, there is some kind of keyword-completion
02:41jykrdyea, but can you hook in the entire java api?
02:41jykrdplus, java help docs?
02:42hoeckiirc you have to generate tags from the source files
02:44hoeckbut i prefer the dynamic abbreviation mode, where the editor tries to complete a given string by searching the open files for matches
02:51hoecki actually would like to have a kind of a hybrid environment, where you use the editor for code input and some self-hosting clojure-routines for browsing, inspection, profiling ..
02:52jykrdpart if this tutorial provides 'tooltips' which give pop up tips showing you what types of parameters a give method accepts. Like, type buffer.append( and a tooltip pops up saying "append(String)". You configure that functionality in a scite config file with this:
02:52jykrdcalltip.java.word.characters=._$(word.chars.cxx) calltip.java.parameters.start=( calltip.java.parameters.start=) calltip.java.parameters.separators=.
02:52jykrdHow could I translate that into clojure?
02:53jykrdcalltip.java.parameters.start=.*
02:53jykrd(with a space at the end)
02:55hoeckthe problem is, in clojure you (normally) type the method before the class
02:55hoeckas in (.method class)
02:55jykrdI thought it was (.method param)
02:55hoecki mean object
02:56jykrdright, param could be object, right?
02:56jykrdbut it's the parameter
02:56hoeck(.method object params...)
02:56jykrdoh
02:57jykrdyea
02:57hoeckyes, so the 'intellisense' doesn't know the methods to complete
02:57jykrdlooking at that now...
02:58hoeckcompleting ctors would work
02:58jykrdso maybe (02:52:35 AM) jykrd: calltip.java.parameters.start=.word word
02:59hoeckat least for java interop
03:00jykrdif scite is using some kind of regex resolution there, and it has some way to express "dot word word $"
05:46Lau_of_DKChouser : You here?
06:01Lau_of_DKAnybody here comfortable working with XML in Clojure ?
06:06Lau_of_DKuser=> (class (first (xml-> x :problem)))
06:07Lau_of_DKclass clojure.lang.LazilyPersistentVector
06:07Lau_of_DKuser=> (class (xml-> x :problem [:title "Broken room"]))
06:07Lau_of_DKclass clojure.lang.PersistentList
06:07Lau_of_DKWhy arent these the same class-type, anybody know?
06:16hoeckLau_of_DK: you are using "first" in the first example
06:17hoeckwhere can i find the "xml->" function?
06:27Lau_of_DKin xml.clj in clojure.jar
06:28Lau_of_DKsorry Im mistaken, its in Chousers' zip-filter in user-contrib
06:28Lau_of_DKhttp://clojure-contrib.svn.sourceforge.net/viewvc/clojure-contrib/trunk/zip-filter.clj?revision=90&view=markup
06:31Lau_of_DKBut hoeck, you actually clued me in already, I just wrapped the second statement in (first ..) and then it was cast to a LPV - Thanks a lot! :)
06:47hoeckLau_of_DK: np :)
06:48Lau_of_DKBut hoeck, do you know why (first) casts as it does? It seems weird that the output type is unpredictable (to me anyway) when it can cause meltdowns later in the program
06:51rhickeyLau_of_DK: what do you mean?
06:54Lau_of_DKuser=> (class (first (xml-> x :problem)))
06:54Lau_of_DKclass clojure.lang.LazilyPersistentVector
06:54Lau_of_DKuser=> (class (xml-> x :problem [:title "Broken room"]))
06:54Lau_of_DKclass clojure.lang.PersistentList
06:55Lau_of_DKrhickey : this to me was a bit unpredictable behavior. It wasnt clear to me (it isnt) why it picked list for 1, and vector for another, and why zip/root and all those related functions crashed it it was not all done as a vector
06:55rhickeywhat does xml-> return?
06:58rhickeyIn any case, a collection and the items in a collection need not be the same type. In one case you call first, getting the first item, in the other you don't:
06:58rhickeyuser=> (def x [1 2 3])
06:58rhickey#'user/x
06:58rhickeyuser=> (class x)
06:58rhickeyclass clojure.lang.PersistentVector
06:58rhickeyuser=> (class (first x))
06:58rhickeyclass java.lang.Integer
06:59Lau_of_DKIn this case, it was (def x (zip/xml-zip (xml/parse "xmlfile.xml"))))
07:16Lau_of_DKMeaning, (xml-> x :problem [:title "First problem"]) should be the same as (first (xml-> :problem)) right ?
07:16Lau_of_DKI mean the content is completely identical, only one is wrapped in () and the other in []
07:17rhickeyx and (first x) are 2 different things, for any x
07:17rhickeyexcept nil
07:26Lau_of_DKOk, then thats the thing thats confusing me, I imaged that (first '(1 2)) was the same as {:first 1 :second 2} and then taking the first value.
09:05ChouserLau_of_DK: xml-> generally returns a seq of zip nodes (unless your final expression is "node" or "text")
09:06Chouserso the class of that will be a PersistentList or perhaps some kind of lazy list.
09:07Chousercalling first on it will get you a single zip node. Zip nodes are currently implemented as a PersistentVector of 2 items, but you really don't want to deal with them at that level, you just want to use the zip.clj API to manipulate them.
09:38Lau_of_DKChouser, thanks alot - that made perfect sense :)
09:38Chouserheh, great.
10:19bstephenson#enclojure
12:40scgilardirhickey: hi Rich. The new clj directory in svn 972 is empty.
12:48Chouserhe speaks the truth
12:48rhickeytry now
12:54Chouserlooks good
12:54rhickeysorry about that, IntelliJ made it look like the dirs were version controlled
12:57Chousersvn has particular problems with moving and deleting directories
12:58Chouserstoring metadata inside each subdirectoy turns out to be a Poor Choice.
14:25ericthorsenjust pulled the latest down from svn and I'm getting an exception running the Repl: Exception in thread "main" java.lang.ExceptionInInitializerError
14:25ericthorsen at clojure.lang.Repl.<clinit>(Repl.java:22)
14:25ericthorsenCaused by: java.lang.RuntimeException: java.lang.IllegalStateException: Var refer is unbound.
14:25ericthorsen at clojure.lang.RT.<clinit>(RT.java:312)
14:30ChouserI'm not. Did you try a clean and rebuild?
14:30ChouserThat's just the REPL, no .clj file?
14:31ericthorsenChouser: yes...clean build
14:33ericthorsenchouser: You are running the latest clojure.lang.Repl no problems?
14:33Chouseryes I am. SVN 973
14:34ericthorsenchouser: ok, let me try again. thx
14:34ChouserI've not done much with it, but a repl prompt comes up ok.
14:41shooverericthorsen: Do you have anything in user.clj that calls in-ns and tries to refer?
14:42ericthorsenshoover: no, I just pulled the latest source using IntelliJ to build, ran the Repl and I'm getting an error....let me try a fresh pull again. Thx
15:58meredyddGrr.
15:59meredydd(and I want a pony. One that flies.)
15:59Chouserreally? why?
15:59meredyddEmbedded platforms suck.
16:00ChouserI mean, I know why you want a pony. But why class files?
16:00meredyddChouser: Oh, I'm starting out with Android.
16:00meredyddIt translates to a different VM, so you can't compile stuff dynamically
16:00albinoahh dalvik IIRC
16:00meredyddyep
16:01Chouseryeah, clojure would be fundamentally incompatible, wouldn't it?
16:01albinoI was going to use the jython compiler with that, the jython project has deprecated their compiler though
16:01Chouseroh, does it traslate java bytecode to android bytecode or something?
16:01meredyddWell, not so much "fundamentally" - there's a mechanised JVM bytecode --> Dalvik conversion
16:02meredyddalbino: They have a compiler?!
16:02Chouserah, ok. I assumed android used Java source and had its own compiler.
16:02albinomeredydd: they did for version 2.1, but like I said it's deprecated
16:02meredydd(hmm...wonder what the overheads are)
16:02meredyddalbino: Bugger.
16:02meredyddso I'm back to sodding Java.
16:02albinomeredydd: if you're willing to write 7 year old python code :)
16:02meredyddalbino: Well, if it's that or Java...
16:03albinoNutter was saying jruby would get one, wonder if they have made much progress on that front
16:03Chouserheh, you could try emulating the asm API and generate Dalvik instead.
16:03meredyddI guess I'm just feeling ranty. I just looked at the easy, gentle introduction to JUnit
16:03cemerickI'd love to have a compile-to-classfile path; fasl-esque output will do well enough, though.
16:03albinomeredydd: well yeah, between java and python I choose python, but interestingly enough the last two weeks I've met a few who would choose the opposite
16:03meredyddand it's TWENTY-SIX BLOODY LINES LONG.
16:04meredyddThis to test a single method call. Heaven help you if you need a mock object.
16:04cemerickmeredydd: clojure-contrib/test-is is the answer to your prayers :-)
16:04Chousermeredydd: heh. The gen-interface I checked in last night is itself not even 26 lines.
16:05meredyddcemerick: I know. Well, actually, I use my own, cause I started before that was released.
16:05meredyddcemerick: Hey, it was only 100 lines :)
16:05cemerickChouser: I'm so behind the ball. gen-interface, checked in, like, where? :-P
16:05meredyddChouser: Suddenly, it's so much more painful to go back :D
16:06Chousercemerick: clojure-contrib. I didn't make a big announcement 'cuz it's probably not ready for prime-time. But it pretty much just works.
16:06albinomeredydd: doesn't scala compile down to .class files
16:06albinoacutally I'm sure of it
16:07meredyddalbino: It does - it's on my shortlist. Dunno how terse it gets, though.
16:07cemerickChouser: Fantastic.
16:07albinomeredydd: I wasn't happy with a lot of the syntax
16:07meredydd(that, and their type system scares me.)
16:07Chousercemerick: do you have a use for it? If so, please let me know if it looks like it's headed in the rigth direction.
16:07cemerickI'm actually thinking about writing a gen-interface that dumps java source, simply so that I have something to run javadoc over.
16:07meredydd(Oh, yeah, the half-a-ton of syntax, too. But that's gettable-used-to.)
16:08albinoheh, gettable-used-to
16:08cemerickChouser: Yes, I do. I'll have to figure out how easy (or not) it would be to hook up javadoc so that :doc metadata on interface definitions can be integrated into its output, though.
16:08Chousercemerick: I'm thinking the -and-save function should actually to a load as well, so that later gen calls can have param types etc. from earlier gens.
16:09Chouserah, interesting.
16:09cemerickChouser: yeah, we do that as a matter of course now
16:11Chouseroh, you do that with gen-and-save-class?
16:13cemerickYes, we have a save-gen-class macro that loads a stub of the same name and then saves the full definition. That way the gen-class spec can be colocated with code that references the generated type (as opposed to siting the specs in a -gen.clj file or something).
16:13cemerickI posted that macro as part of my genbean post on the google group.
16:14Chouseryeah, I saw it, but I didn't understand your use case well enough to make sense of it.
16:14cemerickIn our case, we use type hints that refer to the generated class.
16:14cemerick...in the same file, which is the point. Makes the build process a lot simpler.
16:17Chouserso during build you load all your .clj files?
16:17cemerickYup, with *warn-on-reflection* on.
16:18Chouserand some other flag so your app doesn't try to start up?
16:19cemerickwe put all of our app entry points within (if *command-line-args* ...) forms, and bind *command-line-args* to nil while we load all of the .clj files.
16:19Chouserthat's really interesting. So you catch whatever syntax errors you can at build time, as well as generating .class files where needed.
16:20abrooksHm. That is interesting.
16:20cemerickYup.
16:21cemerickI might bundle it up into an ant plugin eventually, once clojure's core settles down some.
16:21Chouserall without sacrificing the ability to have a repl and hot-swap code as needed later.
16:21cemerickThere's really no other way to do it, AFAIC. There's a compiler there, one should use it. :-)
16:29ChouserIt makes a lot of sense if you already have a build step that you run through regularly anyway. But I expect a lot of apps will need either no build step at all, or something pretty minimal to generate a .class file once in a blue moon.
16:30cemerickyeah, maybe. I'm pretty far away from a development environment like that, though.
17:38cemerickChouser: a quick run through the javadoc sources makes me think that coercing it to emit javadoc based on anything other than .java files is folly
17:40cemericka java-source-emitting gen-interface-src may be the only option, at least in my situation; your gen-interface would still be necessary during the build process though (yeesh, all this to avoid specifying method names more than once!)
17:52Chousercemerick: you don't have a similar javadoc requirement for gen-class?
17:53cemerickChouser: In general, no. I've not yet had occasion to introduce new :methods in a gen-class form.
17:53Chouserah, I see.
17:55cemerickwhat I'm aiming for is to use a genbean-like form to emit an interface (that is javadoc-able) along with a default impl in one fell swoop. I might give gen-interface-src a try shortly...
18:01Chouserwow. ok.
18:02cemerickChouser: either you're amazed or horrified or both :-P
18:03Chouseryou need it to be real javadoc so your API consumers won't know you're not using Java?
18:04cemerickChouser: roughly, yes. Some of them would absolutely freak out.
18:04cemerickThat, and it's a mixed project anyway -- the other code's docs are in javadoc, and there's really no good reason to have things split up.
18:08Chouserdinner. bbl.
18:12albinoheh
18:12albinoI would love to see the freak out when they find out
18:13albinowhat the f*** are all these .clj files
18:13albinooh no....LISP!
18:13cemerickalbino: they won't see any .clj files anyway ;-)
18:14albinocemerick: well you should do that to them at some point just for fun, have an ambulance standing by
18:15albinoSometimes when i go to language groups I hear people mention lisp and the reactions are kind of funny
18:15albinosome people can't believe it still exists
18:15albinoothers feel pure horror for some reason
18:16cemerickwell, that makes for a competitive advantage for us :-)
18:16albinocemerick: who are you competing with?
18:17albinocemerick: I should buy some of your stock so I can profit from this competitive advantage
18:17cemerickvarious other companies
19:35jykrdit irks me that no one is in the #scite channel
20:17Hooke(hi :)
20:24jykrdhello
20:42Hookehello jykrd, how are you
20:44Hooke(instance? jykrd FeelingGoodPerson)
20:56Chousergoes the other way 'round. ;-)
21:01Hookefalse
21:01Hooke(instance FeelingGoodPerson jykrd)
21:01Hooketrue
21:02Hooke(doto Chouser thank)
21:02Hooke:)
21:21Chouser:-)
21:36Hookereading http://clojure-log.n01se.net/date/2008-06-29.html
21:37jykrd(.person wake (/me))
21:37jykrdI'm good
21:38jykrdis there a freenode room to talk about stocks and markets? I'm looking for advice
21:41jykrdoh, theres a command for that
21:41Hookefor what?
21:41jykrdfor searching for rooms by keyword
21:42jykrd /search
21:42jykrdor something
21:42Hookeaha
21:42Hookedunno
21:43Hookesorry :D
21:43jykrdit's cool
21:47HookeI was wondering whether there is/will be a functional reactive programming framework (like frtime) in clojure
21:47Hookeare "reactive agents" something like that?
22:27Hookegtg, byee
23:25pjb3I'm wondering how to call a Clojure function from Java, is that possible?
23:28Chousersure. Repl.java calls a couple
23:29pjb3Chouser: I'm trying to figure out how to do the most basic hello world type thing
23:29pjb3some how in clojure (defn foo [] "foo)
23:30pjb3and then from Java call the foo function
23:30pjb3Compiler.eval ?
23:30Chouserstatic final Var foo = RT.var("user", "foo");
23:31Chouserfoo.invoke()
23:31ChouserI think. Tell me how that goes. :-)
23:32Chouseroh, yeah, you've got to load your .clj first.
23:33ChouserCompiler.loadFile("foo.clj")
23:36pjb3there is no Compiler.loadFile, I tried RT.loadResourceScript("foo.clj");
23:36pjb3and foo.clj is in the class path
23:36pjb3but I get Var foo is unbound
23:45Chouserhm, not sure. I'm just going off of Repl.java -- I don't have my own example.
23:45Chousermaybe make sure that foo.clj is getting loaded? print something?
23:46Chouserand make sure that function foo is defined in the "user" namespace?
23:46Chouserthat's all I've got. I'm off to bed. Hope you figure it out!
23:54shoover1pjb3: I got it working; my foo.clj has (clojure/in-ns 'user) at the top to make sure (defn foo ...) happens in the user namespace, as Chouser mentioned.
23:55shoover1Also a (clojure/refer 'clojure) to make sure defn is available.