Clojure

Allow :require to support a :refer clause

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

There's been discussion previously about the complexity of the ns
macro. In particular the fact that :use causes all vars to be referred
by default is widely seen as unfortunate, and the distinction between
use and require is a source of conceptual overhead for people new to
the language.

We can't change the fact that :use refers everything by default
without breaking lots of existing code. But it would be possible to
enhance :require to support referring specified vars, leaving us free
to deprecate or otherwise discourage the use of :use.

Clojure-dev thread discussing this: http://groups.google.com/group/clojure-dev/browse_thread/thread/91b708ddb909affd

Activity

Hide
Stuart Sierra added a comment -

Patch applied.

Show
Stuart Sierra added a comment - Patch applied.
Hide
Stuart Sierra added a comment -

Not "Test." Screened. The patch is Screened. I hate this.

Show
Stuart Sierra added a comment - Not "Test." Screened. The patch is Screened. I hate this.
Hide
Stuart Sierra added a comment - - edited

My mistake. The docstring is included in 'require', but not in 'refer', which also changed. But the public API of 'refer' did not change. So this patch is good.

Show
Stuart Sierra added a comment - - edited My mistake. The docstring is included in 'require', but not in 'refer', which also changed. But the public API of 'refer' did not change. So this patch is good.
Hide
Stuart Sierra added a comment -

Not Vetted. I can't remember what the names mean. Ready for Rich. That's "Test" right?

Show
Stuart Sierra added a comment - Not Vetted. I can't remember what the names mean. Ready for Rich. That's "Test" right?
Hide
Stuart Sierra added a comment -

Vetted. Patch is good, although it needs docstring updates in 'require'

Show
Stuart Sierra added a comment - Vetted. Patch is good, although it needs docstring updates in 'require'
Hide
Kevin Downey added a comment -

patch still applies cleanly to master, tests pass

there is a warning when you run the tests though:

[java] Testing clojure.test-clojure.keywords
[java]
[java] Testing clojure.test-clojure.load
[java] WARNING: with-bindings already refers to: #'clojure.core/with-bindings in namespace: clojure.test-clojure.require-scratch, being replaced by: #'clojure.main/with-bindings
[java]
[java] Testing clojure.test-clojure.logic
[java]
[java] Testing clojure.test-clojure.macros

Show
Kevin Downey added a comment - patch still applies cleanly to master, tests pass there is a warning when you run the tests though: [java] Testing clojure.test-clojure.keywords [java] [java] Testing clojure.test-clojure.load [java] WARNING: with-bindings already refers to: #'clojure.core/with-bindings in namespace: clojure.test-clojure.require-scratch, being replaced by: #'clojure.main/with-bindings [java] [java] Testing clojure.test-clojure.logic [java] [java] Testing clojure.test-clojure.macros
Hide
Phil Hagelberg added a comment -

So... how about it? Thoughts?

Show
Phil Hagelberg added a comment - So... how about it? Thoughts?
Hide
Devin Torres added a comment -

I'd love to see this discussed.

Show
Devin Torres added a comment - I'd love to see this discussed.
Hide
Phil Hagelberg added a comment -

Any chance we could get some discussion going on this?

Show
Phil Hagelberg added a comment - Any chance we could get some discussion going on this?
Hide
Phil Hagelberg added a comment -

Patch containing implementation, test, and documentation.

Show
Phil Hagelberg added a comment - Patch containing implementation, test, and documentation.

People

Vote (9)
Watch (7)

Dates

  • Created:
    Updated:
    Resolved: