Java 7 is adding dynamics
baptiste-wicht.com
baptiste-wicht.com
I mean, I can't see this sort of thing as being very enjoyable to write all the time.
JComboBox combo = new JComboBox();
MethodHandle handle = MethodHandles.lookup().findVirtual(JComboBox.class, "setModel", MethodType.make(void.class, ComboBoxModel.class));
handle.invoke(combo, new CustomComboModel());If they're exposed via the Java reflection API at all, it's incidental to their actual purpose.
I don't know much about Java, but it sounds like they're extending the bytecode to better support those alternate languages which currently are sort of hack-ish.
(defun find-nth-match (test from n)
(if (= n 0)
from
(martial-n test (1+ from) n)))
(defun martial-n (test from n)
(find-nth-match test
from
(if (funcall test from) (1- n) n)))
(find-nth-match #'evenp 1 5) => 10
The idea is that tail recursion is not just recursing into the exact same function you appear to be in. Is this available with current clojure? Can recur help me somehow?http://groups.google.com/group/clojure/browse_frm/thread/625...
http://openjdk.java.net/projects/mlvm/subprojects.html#TailC...
"There are three supported invocations modes :
invokestatic, invokespecial, invokeinterface or
invokevirtual."
So ... Are there four, or is one very much like another?static for static methods
special for constructors I think
virtual for class methods
interface for interface methods (since its harder to find where an interface method is defined, its different to virtual)
Currently the Method object in Java always does dynamic dispatch for instance methods and static invocation for static methods, and there's no way to do mimic invokespecial via it.