On Dec 11, 3:31 pm, ataggart <alex.tagg...@gmail.com> wrote:
> On Dec 11, 12:27 pm, Keith Irwin <keith.ir...@gmail.com> wrote:

> > Folks--
>
> > I've got a class I can't change which has an abstract method I'd like
> > to override using the proxy macro in Clojure.
>
> > The class looks something like:
>
> > public abstract class Foo {
>
> >    private Map stuff;
>
> >    private void initStuff() {
>
> >        stuff = new HashMap();
> >        stuff.put("a", new Object());
> >        addStuff(stuff);
> >    }
>
> >    protected void abstract addStuff(Map stuff);
> >  }
>
> > Normally, you extend the above and implement the addStuff method.
> > Works in Groovy as long as I explicitly state the void return type and
> > the type of the parameters.
>
> > In Clojure, I construct:
>
> >    (proxy [Foo] []
> >       (addStuff [stuff] (println "yay!")))
>
> > But get an AbstractMethodError when I attempt to use the Foo class
> > (calling a method which eventually calls addStuff).
>
> > The docs suggest I can override a protected method class, but can't
> > call other protected methods, which I think is fine, here.
>
> > Is there something I'm missing?
>
> > Keith

> Given what you have written, the proxy function will return an
> instance that extends Foo, implementing the addStuff method; it
> doesn't modify the Foo class, nor provide you with a derived class.
> If you want to create a derived class that's accessible from java,
> you'll need to use something related to gen-class.

I was under the impression that :gen-class only works for AOT
compilation, rather than running in a scripting context. Maybe the
solution is to add a little Java to the mix. The unfortunate part of
all this is that I HAVE to use the something like the above class due
to Politics.

Thanks!

Keith

-- 
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