> Hmm... If you didn't have to worry about Java <7 compatibility, for one > thing with invokedynamic you could remove a lot of code from Clojure. No > more IFn or AFn. You simply have a method handle. >
Actually, Clojure's solution is almost identical to a method handle. An instance of AFn is not much different from an instance of MethodHandle, from the JVM's standpoint. The problem MethodHandle solves for languages like JRuby is that they need *different classes* for each method handling, whereas Clojure gets away with instances. Where using MethodHandle becomes important is when you want to participate in the invokedynamic bootstrapping, which expects MethodHandle instances. If Clojure ever needs to do this, it would be a simple one-to-one translation from AFn. > Second, I think it would allow the JVM to have a better view into > optimization, and would allow the JVM to optimize something speculatively > and allow for Clojure tell the JVM when to deoptimize with a SwitchPoints > and MutableCallSites. > Except that there's no functional mutability in Clojure! I tried hard, but I could not come up with a case in which this could be used. What are you thinking of, specifically? > I don't think Phil's comparison is actually a fair one. If you're going to > use type hints or type inference, then you're basically moving more towards > static typing, which of course will be faster. > See my comments on the issue in my longer report: Clojure does use standard JVM invocations with static typing. In fact, it has no choice. :) It's also pretty smart about coercing types to the what the JVM method expects, and of course there is hinting to help it out. -- 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