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

Deprecate clojure.core/use #112

Merged
merged 6 commits into from Mar 30, 2016

Conversation

Projects
None yet
2 participants
@arrdem
Collaborator

arrdem commented Mar 25, 2016

This patch deprecates use, doing a bunch of legwork to provide automatic refactor suggestions for replacing use with require and refer.

arrdem added some commits Mar 24, 2016

Deprecate clojure.core/use
Unrestricted referrals are difficult to reason about and should be
avoided in favor of qualified imports. Restricted and unrestricted
referrals can both be achieved via require, so use has no special value.
Add clojure.core/sift
Special case of group-by for predicates, nicer to destructure
@arrdem

This comment has been minimized.

Show comment
Hide comment
@arrdem

arrdem Mar 25, 2016

Collaborator

Quick demo:

2016-03-24-233013_548x154_scrot

Note that my demo is actually broken because :refer isn't a supported use parameter. That should be :only. No warning for this is provided yet.

Collaborator

arrdem commented Mar 25, 2016

Quick demo:

2016-03-24-233013_548x154_scrot

Note that my demo is actually broken because :refer isn't a supported use parameter. That should be :only. No warning for this is provided yet.

@arrdem

This comment has been minimized.

Show comment
Hide comment
@arrdem

arrdem Mar 25, 2016

Collaborator

Bug: refer does not actually support multiple body forms in the style of use or require. Consequently the generated :refer forms aren't actually correct.

Collaborator

arrdem commented Mar 25, 2016

Bug: refer does not actually support multiple body forms in the style of use or require. Consequently the generated :refer forms aren't actually correct.

@arrdem

This comment has been minimized.

Show comment
Hide comment
@arrdem

arrdem Mar 25, 2016

Collaborator

Bug fixed. :refer forms are now legal.

2016-03-25-020436_964x283_scrot

I still kinda object to this patch on the grounds that it's trying to do some amount code formatting in core, which really should either be whole-hog baked in (pls no) or avoided. The argument for doing so is primarily user convenience, as this changeset does attempt to enforce a somewhat significant and loudly complained of style change and whatever help can be provided to the user will mitigate this inconvenience.

A related concern is refer. It's pretty clearly an implementation detail, and really only needed for unrestricted referrals (which are a bad idea and the reason for this change) and rename (which is also arguably a bad idea since it makes it more difficult to understand code if the names are locally rebound). Rewriting use to require and refer is correct, but if we want refer to go away (which we may well) doing so is kinda silly.

Collaborator

arrdem commented Mar 25, 2016

Bug fixed. :refer forms are now legal.

2016-03-25-020436_964x283_scrot

I still kinda object to this patch on the grounds that it's trying to do some amount code formatting in core, which really should either be whole-hog baked in (pls no) or avoided. The argument for doing so is primarily user convenience, as this changeset does attempt to enforce a somewhat significant and loudly complained of style change and whatever help can be provided to the user will mitigate this inconvenience.

A related concern is refer. It's pretty clearly an implementation detail, and really only needed for unrestricted referrals (which are a bad idea and the reason for this change) and rename (which is also arguably a bad idea since it makes it more difficult to understand code if the names are locally rebound). Rewriting use to require and refer is correct, but if we want refer to go away (which we may well) doing so is kinda silly.

@arrdem

This comment has been minimized.

Show comment
Hide comment
@arrdem

arrdem Mar 25, 2016

Collaborator

Updated demo. (:refer) forms never need to be emitted both the original and emitted form are now formatted nicely, and a warning is emitted if the rewritten form makes use of :rename that it may be deprecated.

2016-03-25-183700_631x344_scrot

Collaborator

arrdem commented Mar 25, 2016

Updated demo. (:refer) forms never need to be emitted both the original and emitted form are now formatted nicely, and a warning is emitted if the rewritten form makes use of :rename that it may be deprecated.

2016-03-25-183700_631x344_scrot

Add use refactor suggestions
This patch causes use to emit a warning containing a rewrite of the use
form to a require form. Does a bunch of legwork to try and rewrite use
forms into a minimal requires. Multiple use forms reaching the same ns
are collapsed. A good effort is also made to format the resulting
warning nicely.

Also adds a warning if renaming is used that renaming is a Bad Idea and
support may be dropped.

@arrdem arrdem merged commit cce7bd8 into develop Mar 30, 2016

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@arrdem arrdem deleted the feature/deprecated-use branch Mar 30, 2016

@arrdem arrdem referenced this pull request Mar 30, 2016

Open

Strict ns #117

2 of 4 tasks complete
@@ -155,6 +155,16 @@
(. clojure.lang.RT (seq coll))))
(def
^{:arglists '(^clojure.lang.ISeq [coll])

This comment has been minimized.

@Bronsa

Bronsa Mar 30, 2016

Contributor

this doesn't look right

@Bronsa

Bronsa Mar 30, 2016

Contributor

this doesn't look right

This comment has been minimized.

@arrdem

arrdem Mar 30, 2016

Collaborator

Argh. You're right as usual.

@arrdem

arrdem Mar 30, 2016

Collaborator

Argh. You're right as usual.

@arrdem arrdem modified the milestone: 0.3.0 Apr 8, 2016

arrdem added a commit that referenced this pull request Apr 9, 2016

Merge tag 'v0.2.0' into develop
Vist 0.2.0 upon the world

This release focuses on fleshing Jaunt out as a separate platform atop
Clojure, adding support for the `.jnt` file extension and the `:jnt`
reader conditional directive. Other changes include the deprecation and
automatic refactoring hinting of `use` and `refer`, the addition of
`^:uses` metadata fo `AFn` instances in support of future static
analysis work and migration to JDK8 for the entire project although few
JDK8 features are used at this time.

- [#131](#131) Add support for `.jnt` files (@arrdem).
  - `load-file` now chooses the first file of `.class`, `.jnt`, `.clj`, `.cljc`.
- [#129](#129) Emit `^:uses` metadata on `Fn` instances (@arrdem).
- [#126](#126) Add reader support for `Infinity`, `NaN` (@arrdem).
- [#123](#123) Add support for `:jnt` in reader conditionals (@arrdem).
  - Update to Java 1.8
  - Implement `java.lang.Iterable` over `clojure.lang.Seqable` using a Java 8 interface default method
  - Add `clojure.lang.RT.union(set, seq):set`
- [#122](#122) Catch and print exceptions encountered loading `user.clj` (@arrdem).
- [#116](#116) Deprecate `clojure.core/refer` (@arrdem).
  - Deprecate `clojure.core/refer`
  - Refactor `clojure.core/refer` to emit a warning describing how to rewrite refer into require.
- [#117](#117) Fix typo in arglists (@arrdem).
- [#112](#112) Self-refactoring use (@arrdem).
  - Add `clojure.core/sift`.
  - Refactor `clojure.core/use` to emit a warning describing how to rewrite use into require/refer.
  - Refactor out uses of `use`.
- [#111](#111) Add a warning when expanding deprecated macros (@arrdem).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment