#clojure logs

2008-02-23

07:55bagglesoh :D this is a nice suprise, i was expecting to find noone here.
07:55bgeron:)
07:56bagglesi was just wondering how i might make an applet, so i go looking for how to make a class. i see the implement macro, but ... defjavaclass (java/awt/Applet) .... ??
07:56bagglesalso... maybe those of you who haven't seen this before will find it interesting: http://parleys.com/display/PARLEYS/The+future+will+be+about+programming+languages?showComments=true
07:59baggleshm. maybe i'm barking up the wrong tree with the applet thing, or it's simply not implemented yet.
08:09bgeronrhickey: thoughts about applets? :)
08:10baggleswell, i guess a better questions is: can i create a .class file that has a public class compatible the rest of the java world ...
08:13bagglesi did have a search through the mailing list, but there was only one passing mention to an applet.
08:13rhickeyRight now you can't implement named classes in Clojure, nor can you store compiled Clojure code. But it is easy enough to write a stub in Java, then call Clojure.
08:14bagglesok that's doable.
08:15rhickeySee also Repl.java
08:16rhickeyHosting Clojure isn't documented yet.
08:17bagglesok
08:19baggleshm. is the idea of providing some class-definition mechanism at all on the cards though?
08:22rhickeyThere will be a way to extend concrete classes anonymously and dynamically, a la implement, but probably not a way to define Java classes in Clojure syntax - by the time you add everything needed to specify field types, access levels, super et al, plus the new semantics of methods vs true fns, and what you get is Java w/parens, and a lot more complexity in the language.
08:24rhickeyI could see auto-generating the Java stubs from Clojure, maybe.
08:24baggleshm. so basically, when it comes to this applet stuff, i'm looking at a stub applet with something like public void init() { Compiler.... load something? } public void start() { Compiler.eval("(start)") }
08:24bagglesauto-generating the .java source files?
08:24rhickeyafter the compiler has loaded code, you can call it by:
08:25rhickeycreating a var, say clojureFn, in Java with the same ns/name as a Clojure fn you want to call...
08:26rhickeyclojureFn.invoke(args)
08:26rhickeyno eval
08:26bagglesok
08:27baggleshm cool. that was easy enough
08:27rhickeyThere will eventually be JavaDoc for the Clojure Java API
08:28bagglesbut still it's good enough to give an idea...
08:29rhickeyYes, just no way right now to know what's ok to use and what's implementation details - try to stick to RT, Var, and the (many) interfaces
08:30rhickeythe thing to know is that when you intern a var with the same ns/name, it is the _same_ var object, everywhere
08:30baggleshm. ok
08:31baggleswell
08:31bagglesi'll have a play with it and see how it goes
08:36baggleswell actually, i'm just going to see if i can make a generic applet to start a clojure runtime, then load a file given as a parameter into it in init, then find symbols for start, stop and paint in ... (or (a namespace named by another param) 'applet') .... and invoke them then.
08:37bagglesdoes this sound sensible?
08:37bagglesi'll put it on the mailing list if it works
08:37rhickeydefinitely possible. make sure you call RT.init once, early
08:37bagglesyes. i'll put it as the first thing in the init method
08:38bagglescool. this is quite exciting really. :)
08:39rhickeydefinitely post your progress on the group, I'm sure many would be interested.
09:07bagglesmaybe a stupid question. but clojure symbols case is preserved, right?
09:36baggleshm.
09:36bagglesCouldn't initialize Clojure runtime: Pop without matching push
09:37bagglesthat's on starting RT.init()... as the first thing inside the applet's init
09:52baggleshm
09:53bagglesok i think i can safely say that i'm stuck now
09:57rhickeyclojure symbols are case sensitive
09:58rhickeypop without matching push - stack trace?
10:00bagglesok. i'll include that with the mailing list post and all my code
10:02bagglesok sent
10:06bagglesmaybe all the clj and the java code is a bit wrong anyway... but I guess if i can't get the RT.init right....
10:16baggleshttp://groups.google.com/group/clojure/browse_thread/thread/7c65108c1d864e2b if anyone has any clues i'd be much obliged
10:16bagglesi'm going to try and implement the same thing in a frame now
10:24rhickeylooking at it now. I'm trying to create an applet from scratch in netbeans 6, got through RT.init(), in AppletViewer at least
10:24bagglescool
10:25bagglesyeah i was using appletviewer too
10:25bagglesmight updating to latest svn help ?
10:25rhickeyIt might help with the stacktrace - those line #s don't correspond to my source
10:26bagglesok i have an up to ate source
10:26bagglesis ant the best way to build?
10:27rhickeydoesn't matter much
10:27rhickeyant and maven scripts are there
10:27baggleswell, i barely remember ant and i've never heard of maven
10:28bagglesoh well
10:28bagglesthat was quick. 6 seconds
10:28bagglesjava.lang.IllegalStateException: Pop without matching push at clojure.lang.Var.popThreadBindings(Var.java:224) at clojure.lang.RT.init(RT.java:240) at ClojureAppletTest1.init(ClojureAppletTest1.java:22)
10:29bagglesoh. it's looking for boot.clj and i've moved the jar
10:30baggleswhoops
10:30bagglesi see now
10:30bagglesi was just trying to be convenient for myself really
10:30bagglesso that boot.clj is fairly fundamental
10:30rhickeyyeah most of Clojure is defined in itself, in that file
10:31bagglesok
10:31bagglesi mean in that applet, i've just included clojure.jar in with that applet's tags... how is boot.clj going to fit in?
10:32baggleswell, as it appears to only load boot.clj i guess i'll just load it through my own means then.
10:32rhickeyboot.clj is in clojure.jar
10:32bagglesoh
10:32bagglesso it SHOULD be ok really...
10:32rhickeyRT.init() loads it from the jar
10:33bagglesso it's just not working with this setup then
10:34rhickeydon't know - the error you are getting is not the one you get when there is a problem loading boot.clj
10:35bagglesok
10:36baggleswhat does your applet look like then?
10:37rhickeyjust the boilerplate spewed by NB for a JApplet
10:37baggleshm
10:38rhickeywhat platform are you on?
10:38bagglesLinux bill-desktop 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008 i686 GNU/Linux
10:38rhickeyand JVM?
10:38bagglesjava version "1.6.0_03"
10:38bagglesJava(TM) SE Runtime Environment (build 1.6.0_03-b05)
10:38bagglesJava HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
10:39rhickeyIt almost looks like ThreadLocal initialValue isn't working there
10:40rhickeythe Var pushThreadBindings and popThreadBindings are matched up where you get the error
10:40rhickeybut pop restores the prior frame...
10:41baggleshm. maybe i should initialize the runtime in start instead of init?
10:41rhickeywhich is setup by ThreadLocal.initialValue
10:42rhickeyyou could try that, but it shouldn't matter
10:43bagglesok
10:43bagglesoh well
10:43bagglesmaking it in a Frame it runs
10:43bagglesi think its' that i have loaded the clojure.jar and not had it in the classpath somehow
11:32bagglesaha
11:32baggleswell. using eclipse i got it working
11:33bagglesi must have just set up the classpath incorrectly or something
11:44baggleshm
12:02rhickeyworks in NB, after I figured out how to get the clojure script into the jar...
12:02baggleserm
12:02baggleswhat do you mean? boot.clj?
12:02rhickeyno, the app script
12:02bagglesoh.
12:03rhickeyI added a helper to RT - var(ns,name), both strings
12:03baggleshm. yeah. i guess that would help. well, i was trying with eclipse and using its method of running the applet (by using some java invocation with the AppletViewer class) it works
12:03bagglesbut just trying to get the HTML to make it appear in the standalone appletviewer program
12:03bagglescomes up with those "pop without push" errors
12:04bagglesmy latest attempt involves trying to make a jar with clojure.jar as part of the classpath as described in a manifest per these instructions: http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
12:10baggles http://java.pastebin.com/m220e4856 anyway that's where my java is at at the moment if you're interested.
12:15baggleshm. svn update is a bit broken at the moment it seems.
12:15rhickeyyeah, I can't commit either
12:15bagglesbah
12:16bagglesi think... i've been thinking about this for too many hours
12:16baggleswell, i'd be interested to see your applet anyway.
12:16bagglesif it was working in appletviewer and a browser.
12:23bagglesoh cool about the RT.var aswell
12:24bagglesoh well
12:24bagglesi think it must be time for runescape now :P
13:15hoeckhi