From: Ben H. <be...@in...> - 2001-01-30 00:18:08
|
Finn Bock wrote: > [Will] > >I have run into some surprising behavior of Java Integer objects while using > >jython: > <example snipped> > >What am I doing wrong? How can I keep Integer and Double objects from being > >converted to Java primitives? > > You can't. The eagerness with which Jython converts the java.lang.* > wrapper classes to instances of native python classes have been > discussed previousely: > > http://mail.python.org/pipermail/jpython-interest/1999-December/002590.html My main concern is: will this obstruct the use of Java APIs which require Boolean parameters? In the example William gives the expected method is not invoked. Will developers using Jython to script or integrate existing Java systems encounter problems; either hard to find bugs, or method signatures that cant be invoked? > It is basicly the same problem you have re-discovered. I'm still not > convinved that it is a net win to reduce this eagerness. > > http://mail.python.org/pipermail/jpython-interest/1999-December/002596.html From the above article, Finn Bock wrote: One of the downsides of this patch, is that the simple if statement below will no longer work. I am afraid to think about the incompabilities this change will introduce in existing jpython programs. if not lang.Boolean.FALSE: print "FALSE" Equivalently, the statement below is not legal Java. Is there need to support semantics that arent in Java? I cant imagine many developers using expressions similar to above, since they couldnt in Java anyway. if (! Boolean.FALSE) {} As I understand the issues, I *think* I prefer a less eager conversion policy, but would be happy to hear more counter-arguments. Regards Ben -- Ben Hutchison Software Engineer-Market Predictor Webmind Australia http://www.webmind.com/productspredictor.html |