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

db.cljc doesn't compile on clojure-1.9.0-alpha12 ecause of __hash #176

Closed
lvh opened this issue Sep 8, 2016 · 7 comments
Closed

db.cljc doesn't compile on clojure-1.9.0-alpha12 ecause of __hash #176

lvh opened this issue Sep 8, 2016 · 7 comments

Comments

@lvh
Copy link

lvh commented Sep 8, 2016

Exception in thread "main" java.lang.AssertionError: The names in #{__hash __meta __hasheq __extmap} cannot be used as field names for types or records., compiling:(datascript/db.cljc:369:1)

This is used in

(defrecord-updatable DB [schema eavt aevt avet max-eid max-tx rschema #?(:clj __hash)]
and a handful of other places. This is a consequence of CLJ-1224.

It's not entirely clear what the best resolution here is; if I understand correctly; the Clojure change just makes all records behave how this record already behaved anyway.

@lvh
Copy link
Author

lvh commented Sep 8, 2016

There is also a deftype that does this (bitset), but that shouldn't matter for now; @puredanger has suggested on Clojure Slack shouldn't do that either, though.

I have filed an issue with Clojure as well, since I'm not entirely sure who eventually resolves this and how: http://dev.clojure.org/jira/browse/CLJ-2020

@puredanger
Copy link

__meta and __extmap have always been off limits and marked in the docstring - I would take the __ prefix there to imply that this is a naming convention for internal stuff and suggest that datascript's use of __hash and __hasheq was treading on the obvious future field names for a record caching its hash values. I would certainly prefer datascript to switch to a different convention (or maybe remove it entirely if the new behavior satisfies the same need).

@lvh
Copy link
Author

lvh commented Sep 8, 2016

Removing it entirely would be a performance regression on <1.9.0, right? What would be the impact of just renaming it?

@puredanger
Copy link

puredanger commented Sep 8, 2016

I have declined the Clojure ticket - I do not believe it should have been considered valid to modify a record's hash semantics - those are controlled by the language (and should match those of a map).

If you want control over hashing, you should use a deftype, where it's perfectly ok to extend IHashEq. I would say even there that using a __-prefixed field name is inadvisable, but is ok.

I cannot answer the question of performance if this code is modified. It may be necessary to use a deftype for those records prior to 1.9.

@levand
Copy link
Contributor

levand commented Sep 12, 2016

This issue is a blocker for my work on Arachne; I am using spec heavily and will have to temporarily disable DataScript support until it works with Clojure 1.9.

@tonsky tonsky closed this as completed in 0f942b9 Sep 14, 2016
@lvh
Copy link
Author

lvh commented Sep 14, 2016

Whoa, awesome! thanks @tonsky!

@levand
Copy link
Contributor

levand commented Sep 14, 2016

Badass, thanks!

theronic added a commit to theronic/datsync that referenced this issue Jan 30, 2018
…sky/datascript#176

Suspected incompatibility of Datascript with newer version of Clojure. Boot compiles everything against current version.
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

3 participants