Hi--another example, another failed attempt to do something that looks
quite basic (grumble, grumble) ...

I'm continuing on my path to learning how to use Clojure with the
graphics library Piccolo2D (http://www.piccolo2d.org) by re-
implementing some of Piccolo2D's sample programs. Now I'm working on
the "Graph Editor" program described at 
http://www.piccolo2d.org/learn/grapheditor.html
.

In this sample program (which you don't really need to look at) I need
to subclass a Piccolo2D class to create a class named GraphEditor ,
but unlike the last time (see "Java interop question: proxy or gen-
class?" in this group), I can't subclass using proxy because *this*
subclass, GraphEditor, adds a new method. This means I have to use gen-
class.

Not unexpectedly, GraphEditor wants to execute a number of Java
statements when a new instance is instantiated. Pretty simple, eh?
Well, nothing I tried worked. So my next step was to try to debug the
simplest possible gen-class example I could come up with, which
follows:

-----
(ns genclassInteger
 (:gen-class
   :extends [java.lang.Integer])
 ;(:import (java.lang   Integer))   ; <<<<< unnecessary, right?
 )

(defn -genclassInteger [this number]
  (println "It worked!")
  number)

(defn -main []
  (println (new genclassInteger 666)))
-----

This returns the error:

     Exception in thread "main" java.lang.ClassNotFoundException:
[java/lang/Integer] (genclassInteger.clj:1)

Now, turn your attention to the line marked with "<<<<<". After I got
the above error, I added this line (minus the leading semincolon), and
I got the same error.

My goal with GraphEditor is to add some behavior to its constructor
(when compared with its superclass). Apart from whatever caused the
error in the toy program above, is the creation of a function whose
name is "-" followed by the name of the subclass (e.g., -GraphEditor, -
genclassInteger) the right way to do so?

As always, I appreciate any suggestions/pointers/etc.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to