Martin Geisler <[EMAIL PROTECTED]> writes: Hi Janus -- I'm CCing you since I you might be able to comment on the use of Java in my example. This is a followup to this post in which I created a minimal implementation of the Twisted Deferred class:
http://article.gmane.org/gmane.comp.cryptography.viff.devel/26 > At a SIMAP meeting yesterday, it was discussed if Python was a > requirement for Twisted of if it could be done in any language > (Java). >From my example implementation of a Share, it should be apparent that one needs a language where it is possible to pass around functions (or pointers to functions) for this style of programming to be pleasant. Python allows this directly and so does C and C++. Of course the functional languages (Haskell, ML, etc...) allows you to do this too. In Java I think you'll have to do something different -- there are no function pointers in that language as far as I know. Instead I believe people normally define an interface like this: interface Callback { public Object execute(Object); } and then define callbacks that implement the interface: class AddByTwo implements Callback { public Object execute(Object i) { return (Integer)i + 2; } } (I haven't tested that code, but I think that recent versions of Java allows implicit boxing and unboxing of ints.) If there is a better way to do callbacks in Java, then I would of course be interested to see it! Or maybe one would implement this completely different in Java... instead of building up the execution tree implicitly, one would probably represent it as a concrete data structure and then evaluate this, starting with the leaf nodes. -- Martin Geisler _______________________________________________ viff-devel mailing list (http://viff.dk/) [email protected] http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk
