On Jan 17, 3:17 pm, Jason Wolfe <ja...@w01fe.com> wrote: > I think you can. Let me elaborate on my simplistic example. Compile > the code for a function twice -- once where everything works within > primitives, and once where everything works with Objects -- and > concatenate the bytecode together. Start by running the primitive > version. On overflow, jump into the corresponding spot in the object > version (after some patching up / boxing) -- rather than throwing an > exception. If no overflow happens, you run *exactly* the same > bytecode as the current unprimed ops. (I'm not sure how this would > interact with JIT compared to exceptions, though). As soon as > overflow happens, you run code as if all of the operations were > primed, until function call exit. I'm not sure the JVM allows methods to do that; it might be possible though.
This doesn't address the issue that a method has to decide up front whether it is going to return a primitive or an object. I suppose you could compile two versions of each function, but brings up two issues: First, there would be massive code bloat, which might hurt the ability of the code to be JITed well. Second, if a function is hinted to return a primitive, it would almost certainly be an error to return something that isn't a primitive. -- 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