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

Implement protocols #279

Closed
10 of 11 tasks
borkdude opened this issue Feb 25, 2020 · 6 comments
Closed
10 of 11 tasks

Implement protocols #279

borkdude opened this issue Feb 25, 2020 · 6 comments

Comments

@borkdude
Copy link
Collaborator

borkdude commented Feb 25, 2020

Work in progress in the defprotocol branch.

Todo:

  • defprotocol
  • extend-protocol
  • defrecord + protocols
  • extend
  • extend-type
  • support docstring in defprotocol:
(defprotocol Fly
  "A simple protocol for flying"
  (fly [this] "Method to fly"))
  • extends?
  • fully qualify protocol symbols / test with different namespaces
  • instance? should work on protocol checks: (instance? clojure.spec.alpha.Spec x)
  • test more examples from clojuredocs
  • test libs: spec, hiccup
@cldwalker
Copy link

I think this would be valuable as I've tried using a couple libraries in bb scripts and found the lack of protocol prevented their usage. https://github.com/clj-commons/camel-snake-kebab was one I tried

@cldwalker
Copy link

cldwalker commented May 7, 2020

Three more namespaces/libraries that would be great to have if defprotocol is available:

@borkdude
Copy link
Collaborator Author

Another library with defprotocol: https://github.com/clojure/tools.namespace
See babashka/babashka#424

@borkdude borkdude changed the title Consider the (im)possibility of protocols Implement protocols Jun 6, 2020
@borkdude
Copy link
Collaborator Author

borkdude commented Jun 7, 2020

Made some progress in the defprotocol branches of babashka and sci.

  • The camel-snake-kebab library now fully works.
  • The loom.graph namespace works, but .alg doesn't because it depends on the priority-map library which uses deftype.
  • tools.namespace:
user=> (require '[clojure.tools.namespace.find :as f])
: Unable to resolve classname: java.net.URLClassLoader [at clojure/java/classpath.clj, line , column ]

This class isn't supported by GraalVM afaik.

test.check:

user=> (require '[clojure.test.check :as tc])
: Could not resolve symbol: *unchecked-math* [at clojure/test/check/random.clj, line 92, column 7]

After solving that problem, I hit deftype.

@cldwalker
Copy link

@borkdude Confirmed all the same behaviors in the above libraries with 0.1.1. Thanks! To get closer to test.check working, I could add the *unchecked-math* binding to main.clj if you'd like

@borkdude
Copy link
Collaborator Author

Sure, go ahead.

bbss pushed a commit to bbss/sci that referenced this issue Aug 18, 2020
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