Skip to content

Directly linked protocols #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft

Conversation

frenchy64
Copy link
Owner

@frenchy64 frenchy64 commented Jan 7, 2023

Is the emitArgs call still appropriate for invokeStatic?

This is broken, I think because of https://clojure.atlassian.net/browse/CLJ-1865 the recursive calls needed for a protocol to lookup its own cache are not directly linked. Can we stash the cache somewhere else?

(defprotocol Foo (pfoo [this]))
(defn libfn [x] (pfoo x))
(extend-protocol Foo String (pfoo [_] :dude))
(libfn "hello")
(alter-var-root #'user/pfoo (fn [old] (fn [this] (prn :this) (old this))))
(libfn "hello")
Execution error (NullPointerException) at user/pfoo (REPL:1).
Cannot invoke "clojure.lang.MethodImplCache.fnFor(java.lang.Class)" because "cache__8012__auto__2146" is null

Idea: start from scratch, this time try and broaden the Fn's that canBeDirect. For protocols, we need to:

  1. allow (.__methodImplCache this) without counting towards "this" usages, and
  2. allow functions to close over other directly linkable functions.

@frenchy64 frenchy64 changed the title Direct linked protocols Directly linked protocols Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant