#clojure log - Feb 23 2008

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

7:55 baggles: oh :D this is a nice suprise, i was expecting to find noone here.

7:55 bgeron: :)

7:56 baggles: i 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) .... ??

7:56 also... 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

7:59 hm. maybe i'm barking up the wrong tree with the applet thing, or it's simply not implemented yet.

8:09 bgeron: rhickey: thoughts about applets? :)

8:10 baggles: well, i guess a better questions is: can i create a .class file that has a public class compatible the rest of the java world ...

8:13 i did have a search through the mailing list, but there was only one passing mention to an applet.

8:13 rhickey: Right 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.

8:14 baggles: ok that's doable.

8:14 * baggles wonders how

8:14 * baggles reads java interop again

8:15 rhickey: See also Repl.java

8:16 Hosting Clojure isn't documented yet.

8:17 baggles: ok

8:19 hm. is the idea of providing some class-definition mechanism at all on the cards though?

8:22 rhickey: There 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.

8:24 I could see auto-generating the Java stubs from Clojure, maybe.

8:24 baggles: hm. 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)") }

8:24 auto-generating the .java source files?

8:24 rhickey: after the compiler has loaded code, you can call it by:

8:25 creating a var, say clojureFn, in Java with the same ns/name as a Clojure fn you want to call...

8:26 clojureFn.invoke(args)

8:26 no eval

8:26 baggles: ok

8:26 * baggles looks at running javadoc over clojure/src .... hmmmm

8:27 baggles: hm cool. that was easy enough

8:27 rhickey: There will eventually be JavaDoc for the Clojure Java API

8:28 baggles: but still it's good enough to give an idea...

8:29 rhickey: Yes, 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

8:30 the thing to know is that when you intern a var with the same ns/name, it is the _same_ var object, everywhere

8:30 baggles: hm. ok

8:31 well

8:31 i'll have a play with it and see how it goes

8:36 well 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.

8:37 does this sound sensible?

8:37 i'll put it on the mailing list if it works

8:37 rhickey: definitely possible. make sure you call RT.init once, early

8:37 baggles: yes. i'll put it as the first thing in the init method

8:38 cool. this is quite exciting really. :)

8:39 rhickey: definitely post your progress on the group, I'm sure many would be interested.

9:07 baggles: maybe a stupid question. but clojure symbols case is preserved, right?

9:36 hm.

9:36 Couldn't initialize Clojure runtime: Pop without matching push

9:37 that's on starting RT.init()... as the first thing inside the applet's init

9:52 hm

9:53 ok i think i can safely say that i'm stuck now

9:57 rhickey: clojure symbols are case sensitive

9:58 pop without matching push - stack trace?

10:00 baggles: ok. i'll include that with the mailing list post and all my code

10:02 ok sent

10:06 maybe 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:16 http://groups.google.com/group/clojure/browse_thread/thread/7c65108c1d864e2b if anyone has any clues i'd be much obliged

10:16 i'm going to try and implement the same thing in a frame now

10:24 rhickey: looking at it now. I'm trying to create an applet from scratch in netbeans 6, got through RT.init(), in AppletViewer at least

10:24 baggles: cool

10:25 yeah i was using appletviewer too

10:25 might updating to latest svn help ?

10:25 rhickey: It might help with the stacktrace - those line #s don't correspond to my source

10:26 baggles: ok i have an up to ate source

10:26 is ant the best way to build?

10:27 rhickey: doesn't matter much

10:27 ant and maven scripts are there

10:27 baggles: well, i barely remember ant and i've never heard of maven

10:28 oh well

10:28 that was quick. 6 seconds

10:28 java.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:29 oh. it's looking for boot.clj and i've moved the jar

10:30 whoops

10:30 i see now

10:30 i was just trying to be convenient for myself really

10:30 so that boot.clj is fairly fundamental

10:30 rhickey: yeah most of Clojure is defined in itself, in that file

10:31 baggles: ok

10:31 * baggles wonders how to attack this problem

10:31 baggles: i 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:32 well, as it appears to only load boot.clj i guess i'll just load it through my own means then.

10:32 rhickey: boot.clj is in clojure.jar

10:32 baggles: oh

10:32 so it SHOULD be ok really...

10:32 rhickey: RT.init() loads it from the jar

10:33 baggles: so it's just not working with this setup then

10:34 rhickey: don't know - the error you are getting is not the one you get when there is a problem loading boot.clj

10:35 baggles: ok

10:36 what does your applet look like then?

10:37 rhickey: just the boilerplate spewed by NB for a JApplet

10:37 baggles: hm

10:38 rhickey: what platform are you on?

10:38 baggles: Linux bill-desktop 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008 i686 GNU/Linux

10:38 rhickey: and JVM?

10:38 baggles: java version "1.6.0_03"

10:38 Java(TM) SE Runtime Environment (build 1.6.0_03-b05)

10:38 Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)

10:39 rhickey: It almost looks like ThreadLocal initialValue isn't working there

10:40 the Var pushThreadBindings and popThreadBindings are matched up where you get the error

10:40 but pop restores the prior frame...

10:41 baggles: hm. maybe i should initialize the runtime in start instead of init?

10:41 rhickey: which is setup by ThreadLocal.initialValue

10:42 you could try that, but it shouldn't matter

10:43 baggles: ok

10:43 oh well

10:43 making it in a Frame it runs

10:43 i think its' that i have loaded the clojure.jar and not had it in the classpath somehow

11:32 aha

11:32 well. using eclipse i got it working

11:33 i must have just set up the classpath incorrectly or something

11:44 hm

12:02 rhickey: works in NB, after I figured out how to get the clojure script into the jar...

12:02 baggles: erm

12:02 what do you mean? boot.clj?

12:02 rhickey: no, the app script

12:02 baggles: oh.

12:03 rhickey: I added a helper to RT - var(ns,name), both strings

12:03 baggles: hm. 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:03 but just trying to get the HTML to make it appear in the standalone appletviewer program

12:03 comes up with those "pop without push" errors

12:04 my 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:10 http://java.pastebin.com/m220e4856 anyway that's where my java is at at the moment if you're interested.

12:15 hm. svn update is a bit broken at the moment it seems.

12:15 rhickey: yeah, I can't commit either

12:15 baggles: bah

12:16 i think... i've been thinking about this for too many hours

12:16 well, i'd be interested to see your applet anyway.

12:16 if it was working in appletviewer and a browser.

12:23 oh cool about the RT.var aswell

12:24 oh well

12:24 i think it must be time for runescape now :P

13:15 hoeck: hi

Logging service provided by n01se.net