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 cljs version of ordered-map #59

Merged
merged 4 commits into from
Sep 21, 2021

Conversation

plexus
Copy link
Contributor

@plexus plexus commented Aug 24, 2021

In a case of parallel evolution we wrote this as a utility in a project we are working on with the Nextjournal folks, unaware of this project. We only wrote the cljs version, and it seems this project only has a clj version, so that works out well.

This only implements ordered-map at the moment, so no transient map or sets. Still I assume this may already be useful for some, and can help as a guide to implement the rest. We used Datascript's entity implementation as a guide for which protocols to implement.

Partially addresses #43 .

@borkdude
Copy link
Contributor

My 2 cts: I think having an incomplete implementation is OK, the map is the most used one anyway. I think it's good to merge this, perhaps add some unit tests?

@danielcompton
Copy link
Member

I think having an incomplete implementation is OK, the map is the most used one anyway

Yep, I don't see this as a blocker.

Could you see if the tests can run against both implementations as CLJC? If not, someone else can add them later and we could mark the map implementation as alpha for now?

@plexus
Copy link
Contributor Author

plexus commented Aug 26, 2021

I'll have a look at the tests, those comments at the end were meant to become tests anyway. For the existing tests I'll have to split them up a bit in the ones that are cljc and the ones that are still only clj.

Change the map-test namespace to `cljc`, several sections are still marked as
clj-only, because they rely on eval, hashCode, compact, or transient-map. I made
some adjustments to the cljs implementation in the process to make it better
match the clj version.
@plexus
Copy link
Contributor Author

plexus commented Aug 26, 2021

I made the map tests cljc to the extent possible, made the data reader cljc, and added kaocha setup for running the clj and cljs tests. I didn't add kaocha to the CI yet.

@borkdude
Copy link
Contributor

@plexus Just out of curiosity, is kaocha able to run tests in advanced compiled mode too nowadays? (That would help catching nasty advanced compiled bugs during testing).

@plexus
Copy link
Contributor Author

plexus commented Aug 26, 2021

Only with kaocha-cljs2, which is a lot more involved to set up, so I tend to stick to kaocha-cljs for simple libraries like this one.

@borkdude
Copy link
Contributor

It's slightly concerning to me that we're not testing with advanced. Perhaps we should also set up shadow or cljs-test-runner for this, in addition to kaocha, to run advanced in CI? Or is this unimportant for this library since it doesn't do a lot of interop in CLJS (I haven't checked).

@plexus
Copy link
Contributor Author

plexus commented Aug 26, 2021

Also something I should point out, the #ordered/map reader literal works in both clj and cljs, but I had to resort to a bit of a hack. It seems the official line is that cross platform reader conditionals are not supported.

https://clojurians.slack.com/archives/C03S1KBA2/p1629984675020400

@plexus
Copy link
Contributor Author

plexus commented Aug 26, 2021

It's slightly concerning to me that we're not testing with advanced.

This is a valid concern, but this is fairly straightforward ClojureScript code, and we've been using this implementation in an advanced build for some time already, so I think the payoff for setting up an advanced CI build for this is limited, given that this also isn't a trivial thing to set up.

@plexus plexus force-pushed the arne/add-cljs-map branch from 65f875e to 3879402 Compare August 26, 2021 15:00
@borkdude
Copy link
Contributor

Fair enough!

@plexus
Copy link
Contributor Author

plexus commented Sep 16, 2021

I also just became aware of linked, which is very similar in scope to ordered, and included cljs support.

@borkdude
Copy link
Contributor

I'm aware of the other library, but I think it's nice to have CLJS support for this library nonetheless.

I would say let's merge, but this is @danielcompton's call.

@slipset slipset requested a review from borkdude September 21, 2021 08:29
@slipset slipset merged commit caec8d9 into clj-commons:master Sep 21, 2021
@filipesilva
Copy link

Hey all, any chance of a release soon? Would love to use the cljs ordered map in a project I have right now.

@borkdude
Copy link
Contributor

borkdude commented Oct 1, 2021

Pinging @slipset: not sure if this project has been set up for deployment like the others?
@filipesilva Is it possible to use this project as a git dep?

@filipesilva
Copy link

@borkdude I think so, would have to refactor this lein project to use deps edn or some lein plugin to do that. Hadn't really thought about that option.

@borkdude
Copy link
Contributor

borkdude commented Oct 8, 2021

@filipesilva Released as 1.15.10

@filipesilva
Copy link

Thanks for letting me know!

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.

5 participants