Skip to content
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

changing deftype during session produces caching errors #65

Closed
genmeblog opened this issue Jan 28, 2022 · 2 comments
Closed

changing deftype during session produces caching errors #65

genmeblog opened this issue Jan 28, 2022 · 2 comments

Comments

@genmeblog
Copy link

When starting with simple type definition and progressively adding some interfaces casues caching errors and some exceptions.

Step 1 - create notebook with the following

(deftype MyType [a b])
(MyType. 1 2)
;; => #object[sometest.MyType 0x57c6a598 "sometest.MyType@57c6a598"]

Step 2 - add toString

(deftype MyType [a b]
  Object
  (toString [_] (str "#MyType " [a b])))

(MyType. 1 2)
;; => #object[sometest.MyType 0x1987e9b3 "#MyType [1 2]"]

Which causes nippy problems

image

Step 3 - add Seqable interface

(deftype MyType [a b]
  Object
  (toString [_] (str "#MyType " [a b]))
  clojure.lang.Sequential
  clojure.lang.Seqable
  (seq [_] (seq [a b])))

(MyType. 1 2)
;; => #object[sometest.MyType 0x6fd2252 "#MyType [1 2]"]

An exception is thrown:

1. Unhandled java.lang.AbstractMethodError
   Receiver class sometest.MyType does not define or inherit an
   implementation of the resolved method 'abstract clojure.lang.ISeq
   seq()' of interface clojure.lang.Seqable.

                   RT.java:  543  clojure.lang.RT/seqFrom
                   RT.java:  537  clojure.lang.RT/seq
                  core.clj:  139  clojure.core/seq
                  core.clj: 7392  clojure.core/bounded-count
                  core.clj: 7386  clojure.core/bounded-count
               viewer.cljc:  320  nextjournal.clerk.viewer$bounded_count_opts$fn__18923/invoke
               viewer.cljc:  320  nextjournal.clerk.viewer$bounded_count_opts/invokeStatic
               viewer.cljc:  317  nextjournal.clerk.viewer$bounded_count_opts/invoke
               viewer.cljc:  418  nextjournal.clerk.viewer$describe/invokeStatic
               viewer.cljc:  366  nextjournal.clerk.viewer$describe/invoke
               viewer.cljc:  372  nextjournal.clerk.viewer$describe/invokeStatic
               viewer.cljc:  366  nextjournal.clerk.viewer$describe/invoke
                  view.clj:  110  nextjournal.clerk.view/->result
                  view.clj:  109  nextjournal.clerk.view/->result
                  view.clj:  164  nextjournal.clerk.view/describe-block
                  view.clj:  151  nextjournal.clerk.view/describe-block
                  core.clj: 2635  clojure.core/partial/fn
                  core.clj: 2746  clojure.core/map/fn/fn
     PersistentVector.java:  343  clojure.lang.PersistentVector/reduce
                  core.clj: 6885  clojure.core/transduce
                  core.clj: 6901  clojure.core/into
                  core.clj: 6889  clojure.core/into
                  view.clj:  171  nextjournal.clerk.view/doc->viewer/fn
                  core.clj: 6185  clojure.core/update
                  core.clj: 6177  clojure.core/update
                  view.clj:  171  nextjournal.clerk.view/doc->viewer
                  view.clj:  167  nextjournal.clerk.view/doc->viewer
                 clerk.clj:  274  nextjournal.clerk/file->viewer
                 clerk.clj:  271  nextjournal.clerk/file->viewer
                 clerk.clj:  273  nextjournal.clerk/file->viewer
                 clerk.clj:  271  nextjournal.clerk/file->viewer
                  core.clj: 2598  clojure.core/juxt/fn
                  core.clj: 2746  clojure.core/map/fn/fn
     PersistentVector.java:  343  clojure.lang.PersistentVector/reduce
                  core.clj: 6885  clojure.core/transduce
                  core.clj: 6901  clojure.core/into
                  core.clj: 6889  clojure.core/into
                 clerk.clj:  380  nextjournal.clerk/build-static-app!
                 clerk.clj:  366  nextjournal.clerk/build-static-app!
                      REPL:   15  sometest/eval25870
@genmeblog
Copy link
Author

Adding ^:nextjournal.clerk/no-cache to the namespace fixes above

@mk
Copy link
Member

mk commented Feb 10, 2023

I believe this has been fixed with e5c00bb, at least I just tried running through the steps and it worked mostly fine.

Mostly means that Clerk does cache (MyType. 1 2) and not invalidate that expression when extending the deftype but I'm not sure we can or want that (the current caching behavior is simple and predicable). I'll let folks open up a new issue for this if there's a need for it.

@mk mk closed this as completed Feb 10, 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

No branches or pull requests

2 participants