Fork me on GitHub

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


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 takes ObjExpr as an argument to emit method.