Skip to content

use vs require #1

Open
Open
@Raynes

Description

@Raynes

Howdy. Just wanted to suggest not promoting the use of :use.

As of Clojure 1.4, require serves both its original purpose and the purpose of use via the :refer modifier. For example

(ns foo.bar.baz
  (:require [plumbing.core :refer :all]))

If compatibility with pre-1.4 is not a requirement, this is generally a better way to go. It makes ns declarations far more consistent and uniform, and also means there is less code using use if it gets deprecated at some point in the future (which would not be entirely unsurprising).

My suggestion would be to replace the use uses (no pun intended) with require, but add a note about use for the unlikely event that the reader requires < 1.4 compatibility.

As a secondary thing, it isn't really great to promote these unqualified imports. In tests and such it is generally fine, but in actual code you almost always want to qualify things for readability and clarity. It seems to be trying to say this, but it doesn't feel clear enough. I'd be more aggressive in saying that it's almost always a bad idea to do unqualified imports. I don't know what plumbing.core is and whether or not it is a good example of an exception though.

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions