Fork me on GitHub
#clojure-dev
<
2018-09-06
>
jetzajac00:09:04

Did anyone try to implement clojure’s closures with MethodHandle and invokeDynamic? in order to eliminate a huge number of classes

jetzajac00:09:33

My plan is: - implement IFn on top of MethodHandle (do that in java to handle invokeDynamic) - for each lambda: emit static method with “closes” and lambda args as params. emit MethodHandleFn constructor invocation with MethodHandle to that static method, fixing first n args for closure. Theoretically it should reduce number of classes dramatically - make some vars initialization lazy to reduce startup time further. Or maybe even eliminate vars at all in some cases (with special compiler option) The first problem I see is that every expression type in current Compiler.java takes ObjExpr as an argument to emit method.