Skip to content

Directly linked protocols - #32

Draft
frenchy64 wants to merge 29 commits into
masterfrom
direct-linked-protocols
Draft

Directly linked protocols#32
frenchy64 wants to merge 29 commits into
masterfrom
direct-linked-protocols

Conversation

@frenchy64

@frenchy64 frenchy64 commented Jan 7, 2023

Copy link
Copy Markdown
Owner

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