From: Ken A. <kan...@bb...> - 2002-09-09 18:18:18
|
If you need to make inner classes with behavior specialized with scheme, do it by writing a wrapper class that takes the scheme behavior you want in the constructor. Here's your example: (define-class (package foo) (public class MyFoo) (private Procedure action) (public MyFoo (Procedure action) (.action$# this action)) (public void bar () ((.action$# this))) ) Here's a sample use: > (.bar (foo.MyFoo. (lambda () (print 'hi)))) hi #null > At 01:17 PM 9/9/2002, Kyle R . Burton wrote: > > There are several ways to do this. see > > http://jscheme.sourceforge.net/jscheme/src/dclass/dclass.html > > > > The closest thing to what Jython does is > > (define-class). This requires you to declare types for all your methods, > > so it isn't as nice as Jython's way. > > > > I'd like to do it Jython's way at some point. > >Thanks for the quick reply. I have been able to create a Scheme class that >sub-classes a Java class. > >I do have another question though. Is it possible to create anonymous clases? >Java supports a syntax for declaring anonymous classes: > > Foo foo = new Foo() { > public void bar () { > System.out.println("in bar()"); > } > }; > >Is there a corresponding construct in JScheme? > > >Thank you, >Kyle R. Burton > >-- > >------------------------------------------------------------------------------ >Wisdom and Compassion are inseparable. > -- Christmas Humphreys >mo...@vo... http://www.voicenet.com/~mortis >------------------------------------------------------------------------------ > > >------------------------------------------------------- >This sf.net email is sponsored by: OSDN - Tired of that same old >cell phone? Get a new here for FREE! >https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 >_______________________________________________ >Jscheme-user mailing list >Jsc...@li... >https://lists.sourceforge.net/lists/listinfo/jscheme-user |