On Wed, 29 Mar 2006, Nick Sieger defenestrated me: > Any more comments on this thread?
Yep. Sorry I should have responded to this thread. I sort of committed half of this patch, but not exactly since I put that half ito a different function in a different class. Here is what we have right now: Any Time instances passed to a Java method will get implicitly converted to a Java.util.Date. This happens in Java.ruby_to_java (or one of its subordinates). I could not commit the other direction right away because it brought up some questions (which is great since it made me realize some stuff). Consider the following example: --- include_class 'java.util.Calendar' java_date = Calendar.getInstance.getDate java_date.getTime --- With the original patch the above would not work since java_date would have already been converted to Time (which has no 'getTime' method). This would have made an inconsistent use if you compare Date to most other included Java objects. This made me start thinking....Things in Ruby are largely so powerful because of duck-typing. Perhaps a large part of the solution space is to make Java.util.Date objects quack like Time with no need for conversion. Seems like a good start in the Java playing nice with Ruby area. After talking to Charlie about this a bit he thinks that making the 'java_date' act like it is a 'kind_of? Time' would fix problems when people write code which does type checks (e.g. we ran into a check like this involving IO in the pure ruby yaml module). This is the other part of this. We cannot just 'extends(Time)' in the proxy since none of those functions would be hooked up to java.util.Dates internal state, but we could override kind_of? in proxies to return in a special way... like say it is a type it may be emulating. Adding a function to the proxy like 'impersonate(class)'. The methods for the class we are impersonating would need to all be created, but they would anyways. -Tom -- + http://www.tc.umn.edu/~enebo +---- mailto:[EMAIL PROTECTED] ----+ | Thomas E Enebo, Protagonist | "Luck favors the prepared | | | mind." -Louis Pasteur | ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Jruby-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jruby-devel
