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

Store multifn in atom instead var #29

Open
darkleaf opened this issue Sep 12, 2019 · 2 comments
Open

Store multifn in atom instead var #29

darkleaf opened this issue Sep 12, 2019 · 2 comments
Labels
clojurescript support Issues that we have to tackle in order to get ClojureScript support working. help wanted Extra attention is needed
Milestone

Comments

@darkleaf
Copy link
Contributor

darkleaf commented Sep 12, 2019

ClojureScript has a stripped-down implementation of vars and does not have the alter-var-root! function.

How to store multifn in atom like clojurescript does?
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/core.cljc#L2768

Or maybe just use mutable field?

For clojurescript support #20

@darkleaf darkleaf mentioned this issue Sep 21, 2019
@camsaul camsaul added help wanted Extra attention is needed clojurescript support Issues that we have to tackle in order to get ClojureScript support working. labels Jun 4, 2021
@camsaul
Copy link
Owner

camsaul commented Jun 4, 2021

Related: #52

@camsaul camsaul closed this as completed Jun 4, 2021
@camsaul camsaul reopened this Jun 4, 2021
@camsaul
Copy link
Owner

camsaul commented Sep 9, 2022

It looks like ClojureScript stores the individual bits of a multimethod in atoms rather than the entire multimethod itself

https://github.com/clojure/clojurescript/blob/e8643ab1cbaae9b01d3ed306711883f6473115aa/src/main/clojure/cljs/core.cljc#L2791-L2798

I need to think about how we could do something like this without affecting programmatic/functional multimethod manipulation -- if you do something like this:

(m/defmulti mf ...)

(let [mf2 (m/add-primary-method mf ...)]
  ...)

mf2 should not affect mf at all -- sort of like how assoc doesn't mutate the original map. If we used atom(s) everywhere it would bust things (unless add-primary-method copied the existing atom(s) into new atom(s)... maybe that would work).

I think either way we can get away with storing the entire impl in a single atom rather than having several atoms.

@camsaul camsaul added this to the 1.0.0 milestone Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clojurescript support Issues that we have to tackle in order to get ClojureScript support working. help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants