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

Close #305: Qualify @ ~ ~@ sexpr's under clojure.core #306

Merged

Conversation

frenchy64
Copy link
Contributor

@frenchy64 frenchy64 commented Aug 14, 2024

@frenchy64 frenchy64 force-pushed the issue-305-sexpr-differs-from-read-string branch 2 times, most recently from ea99838 to 56dcbe5 Compare August 14, 2024 16:32
@frenchy64 frenchy64 marked this pull request as ready for review August 14, 2024 16:33
@frenchy64 frenchy64 force-pushed the issue-305-sexpr-differs-from-read-string branch 3 times, most recently from 03e847f to 548773b Compare August 14, 2024 16:51
z/sexpr should return the same value as clojure.core/read-string
as per the documentation. The tests were moved from
  clojure.tools.reader.edn/read-string
to
  clojure.tools.reader/read-string
because the latter implements Clojure's reader.

After this commit, the only special forms that return different
values are ` and #=.
@frenchy64 frenchy64 force-pushed the issue-305-sexpr-differs-from-read-string branch from 548773b to 37b75f0 Compare August 14, 2024 16:55
[clojure.test :refer [deftest is]]
[clojure.tools.reader.edn :refer [read-string]]
[clojure.test :refer [deftest is testing]]
[clojure.tools.reader :as rdr]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to use clojure.tools.reader instead of clojure.tools.reader.edn for your tests to be valid?

Copy link
Contributor Author

@frenchy64 frenchy64 Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My initial motivation to tweak this was to automatically test this statement in the docs: "Within reason, Clojure’s read-string and rewrite-clj’s sexpr functions should return equivalent Clojure forms".

So that meant using clojure.core/read-string instead of clojure.tools.reader.edn/read-string. This is because:

  1. I interpreted "Clojure’s read-string" to mean clojure.core/read-string
  2. Things like '@~ are not valid edn, so the tests would not make sense.

Since CLJS doesn't have read-string, I replaced c.t.n with c.t.n.edn for reason number 2.

The main downside is *read-eval* can be dangerous, so I tried to be as conservative as possible in setting that.

I think perhaps the test in t-parsing-seqs could also test against clojure.core/read-string in the :default case for reason number 1.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok, thanks for explaining, @frenchy64.

The thing is sci tests are currently failing.
Sci tests are a bit involved, would you like me to have a look-see?

@frenchy64
Copy link
Contributor Author

frenchy64 commented Sep 7, 2024 via email

lread added a commit to lread/sci-test that referenced this pull request Sep 7, 2024
For compatibility with new tests in
clj-commons/rewrite-clj#306, add
`clojure.tools-reader`:
- `read-string`
- `*read-eval*`
…fers-from-read-string

* upstream/main:
  dev & ci: bump deps (clj-commons#312)
  maint: bump tools.reader (clj-commons#310)
  dev & ci: bump deps (clj-commons#309)
  publish: apply version 1.1.48
  doc: maint - contributors and used by (clj-commons#308)
  dev & ci: bump deps (clj-commons#307)
@lread
Copy link
Collaborator

lread commented Sep 7, 2024

Ok @frenchy64, I've resolved the failing sci test by exposing clojure.tools.reader's read-string and *read-eval* from my skunkworks sci-test repo.

But now I've just noticed that this PR breaks a zprint test expectation (we run tests of all popular libs using rewrite-clj against rewrite-clj changes). So we'll have to look into why that is so.

@lread
Copy link
Collaborator

lread commented Sep 7, 2024

Hmm... the zprint test is failing due to differences only in line wrapping and formatting.
So it must be making formatting decisions based on something included in this change.
Which seems strange.

@lread
Copy link
Collaborator

lread commented Sep 7, 2024

I've taken a peek a zprint and see some evidence of it basing formatting decisions on sexpred nodes. Which seems like not a great idea. I'll raise an issue at zprint to try to get confirmation.

@lread
Copy link
Collaborator

lread commented Sep 8, 2024

@frenchy64, I'm going to go ahead and finally merge this puppy.

@lread lread merged commit 7ddab96 into clj-commons:main Sep 8, 2024
81 checks passed
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.

2 participants