make use of deprecated namespaces/vars easier to spot

Description

From the mailing list http://groups.google.com/group/clojure/msg/c41d909bd58e4534. It is easy to use deprecated namespaces or vars without knowing you are doing so. The documentation warnings are small, and there is no compiler warning.

Proposed:

  • Add new warn-on-deprecated dynamic var, defaulted to false

  • Warn to stderr when {:deprecated true} namespace is loaded.

  • Warn to stderr when {:deprecated true} var is analyzed.

  • Warn to stderr when {:deprecated true} macro is expanded.

  • New system property clojure.compiler.warn-on-deprecated

  • Compile Clojure itself with clojure.compiler.warn-on-deprecated

  • Fix deprecation warnings inside Clojure (replicate, clear-agent-errors)

  • Mark clojure.parallel as deprecated with :deprecation tag

Examples:

Patch: 706-deprecated-ns-var-warnings-tested-3.diff

Questions: Should default for deprecation warnings be true instead? People upgrading are likely to see new warnings which might be surprising.

  • Should default be to warn or not warn on deprecated?

Environment

None

Attachments

9

Activity

Show:

import September 20, 2018 at 10:32 AM

Comment made by: simongray

What happened to this feature? Is it still coming?

Alex Miller March 11, 2016 at 7:49 PM

Marking pre-screened for Rich to look at.

Alex Miller March 11, 2016 at 2:53 PM

One more (hopefully final) round and then I think we're good:

  • The docstring for warn-on-deprecated should be updated now that we've expanded scope to cover ns too.

  • In the deprecated ns warning message, can we make it: "Deprecation warning: loading deprecated namespace `foo` from namespace `bar`."

  • In the macro and var warnings can we change "is tagged as deprecated" to just "is deprecated"?

  • Clean up the hanging parens in test/clojure/test_clojure/compilation/deprecated.clj

Thanks for the work on this!!

Cezary Kosko March 11, 2016 at 11:40 AM

Uploaded a new diff addressing the comments & added warning on macroexpansion.

As far as the namespace deprecation warning goes, though, the code's only printing the current namespace, did not know whether there was a decent way to get a file/line combo.

Alex Miller March 10, 2016 at 4:54 PM

  • The if in the first change in core.clj should be a when instead.

  • Can namespace deprecation warning include more about where this is occurring?

  • I'm having a hard time reproducing the deprecated ns warning in a manual test (see below). There seems to be something weird about the binding+printf as the conditions appear to be satisfied. I'm thinking it has something to do with flushing err? Seems like (println "Warning: loading deprecated ns" lib) would be better there.

  • src/jvm/clojure/lang/Compile.java needs added support for clojure.compile.warn-on-deprecated RT flag

  • I think we should turn on warn-on-deprecated in the Clojure build itself (in build.xml)

  • If you do that, the following deprecation warnings exist in the Clojure build itself and we should fix those:

[java] Deprecation warning, clojure/core_proxy.clj:112:75 : var #'clojure.core/replicate is tagged as deprecated
[java] Deprecation warning, clojure/genclass.clj:149:41 : var #'clojure.core/replicate is tagged as deprecated
[java] Deprecation warning, clojure/genclass.clj:235:65 : var #'clojure.core/replicate is tagged as deprecated
[java] Deprecation warning, clojure/test/junit.clj:118:22 : var #'clojure.test/file-position is tagged as deprecated

  • Mark clojure.parallel as deprecated in the ns meta

Details

Assignee

Reporter

Labels

Approval

Prescreened

Patch

Code and Test

Priority

Created January 6, 2011 at 2:39 AM
Updated October 1, 2019 at 2:04 PM