--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
What's problematic about it is that it's slightly easier to do the wrong thing. It seems insignificant, but 98% of times you use use, it's going to be wrong. Also, 'use only' means I have to change my calling NS twice in different parts of the emacs buffer any time I change a function name in the called namespace.On Tue, Jul 23, 2013 at 3:08 PM, Cedric Greevey <cgre...@gmail.com> wrote:
:use...:only doesn't strike me as especially problematic, since it documents the specific symbols it's importing and from where.
-Lee
One of the main issues I have faced with :use is, understanding a non-trivial codebase becomes very difficult and almost always requires Emacs Meta-dot.
I'd vote for deprecating :use.
It complects require and refer ;-)
On Tue, Jul 23, 2013 at 1:53 PM, Ben Wolfson <wol...@gmail.com> wrote:Because use = require + refer (essentially).
> On Tue, Jul 23, 2013 at 1:50 PM, Stefan Kamphausen <ska...@gmail.com>
> wrote:
>> It complects require and refer ;-)
> How so?
On Tue, Jul 23, 2013 at 1:55 PM, Sean Corfield <seanco...@gmail.com> wrote:
On Tue, Jul 23, 2013 at 1:53 PM, Ben Wolfson <wol...@gmail.com> wrote:Because use = require + refer (essentially).
> On Tue, Jul 23, 2013 at 1:50 PM, Stefan Kamphausen <ska...@gmail.com>
> wrote:
>> It complects require and refer ;-)
> How so?
If that's all that's required for one thing to complect two others, clojure's rife with the stuff. if-let complects if and let. Destructuring assignment complects assignment and getting values from a data structure (as the macroexpansion of (let [[a b] x]) demonstrates. split-with complects take-while and drop-while. let complects lambda abstraction and function application. Etc. I had assumed that "a complects b and c" on the one hand meant more than "a can be expressed using b and c" and on the other was a criticism.
I think I read somewhere that :use is no longer encouraged, but I could be mistaken.
From what I've read, it seems like most people agree that Clojure has too many ways of including/importing/referencing/requiring/using things:
http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
The above gives a very nice explanation of all the various difference, but it also acknowledges their complexity.
Since :use uses :require, and since :require can do everything that :use can, can we simplify Clojure programming a bit for newcomers by deprecating the use of :use? The situation in ClojureScript is even worse because it adds :require-macros on top of all the other ways of including files.
Ideally, it would be awesome if there was just a single directive for everything, but perhaps there's some complicated low-level reason why that's not possible. :-\
Thoughts?
I think I read somewhere that :use is no longer encouraged, but I could be mistaken.
From what I've read, it seems like most people agree that Clojure has too many ways of including/importing/referencing/requiring/using things:
http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
The above gives a very nice explanation of all the various difference, but it also acknowledges their complexity.
Since :use uses :require, and since :require can do everything that :use can, can we simplify Clojure programming a bit for newcomers by deprecating the use of :use? The situation in ClojureScript is even worse because it adds :require-macros on top of all the other ways of including files.
Ideally, it would be awesome if there was just a single directive for everything, but perhaps there's some complicated low-level reason why that's not possible. :-\
Thoughts?
Well, obviously :use can't be replaced by (require :refer).
According to DRY, I strongly agree the deprecation of :use. But that doesn't mean interpreter shouldn't support it right now since we have legacy code base. However, we could come to an agreement to less use of :use.
Sorry, It's a typo. What I mean is it can be replaced. But you can't force people not to use :use without :only, and the tool I mentioned will replace that kind of misuses.
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/i2VzAlT6oqM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
But you can't force people not to use :use without :only, and the tool I mentioned will replace that kind of misuses.
We should scour clojuresphere for uses of 'use' and automatically post github issues to the projects of interest, and redefine the ns macro to issue a warning with use.
Does anyone actually like 'use'?
Require is always more evident.
On Tue, Jul 23, 2013 at 2:17 PM, Jozef Wagner <jozef....@gmail.com> wrote:
+1, :use is IMO an antipattern.
I hate it mainly in blogs, where they explain some new API. They :use like 3 namespaces and you have to guess which fn is from which ns :)
JW
On Tuesday, July 23, 2013 5:50:50 PM UTC+2, Greg Slepak wrote:I think I read somewhere that :use is no longer encouraged, but I could be mistaken.
From what I've read, it seems like most people agree that Clojure has too many ways of including/importing/referencing/requiring/using things:
http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
The above gives a very nice explanation of all the various difference, but it also acknowledges their complexity.
Since :use uses :require, and since :require can do everything that :use can, can we simplify Clojure programming a bit for newcomers by deprecating the use of :use? The situation in ClojureScript is even worse because it adds :require-macros on top of all the other ways of including files.
Ideally, it would be awesome if there was just a single directive for everything, but perhaps there's some complicated low-level reason why that's not possible. :-\
Thoughts?
Thanks,
Greg
P.S. If this has already been brought up you have my sincere apologies.
--
Please do not email me anything that you are not comfortable also sharing with the NSA.
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
+1, :use is IMO an antipattern.
I hate it mainly in blogs, where they explain some new API. They :use like 3 namespaces and you have to guess which fn is from which ns :)
JW
On Tuesday, July 23, 2013 5:50:50 PM UTC+2, Greg Slepak wrote:
I think I read somewhere that :use is no longer encouraged, but I could be mistaken.
From what I've read, it seems like most people agree that Clojure has too many ways of including/importing/referencing/requiring/using things:
My assumption from our discussion would be that a warning would be added in a near release when :use was detected in the ns macro, and that it would be removed for Clojure 2.0 when backwards-incompatible changes are OK.
(?<- (stdout) [?a ?b] (generator :> ?a ?b))
Without a use, or (:require :refer :all), this would become very cumbersome to read :
(cascalog/?<- (cascalog/stdout) [?a ?b] (generator :> ?a ?b))
The same applies to SQL DSLs like korma.
So, IMHO there are cases where (:use) simplifies things.
--
Philippe Guillebert
On Tue, Jul 23, 2013 at 1:53 PM, Ben Wolfson <wol...@gmail.com> wrote:
> On Tue, Jul 23, 2013 at 1:50 PM, Stefan Kamphausen <ska...@gmail.com>
> wrote:
>> It complects require and refer ;-)
> How so?
Because use = require + refer (essentially).
I think I read somewhere that :use is no longer encouraged, but I could be mistaken.
From what I've read, it seems like most people agree that Clojure has too many ways of including/importing/referencing/requiring/using things:
http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
The above gives a very nice explanation of all the various difference, but it also acknowledges their complexity.
Since :use uses :require, and since :require can do everything that :use can, can we simplify Clojure programming a bit for newcomers by deprecating the use of :use? The situation in ClojureScript is even worse because it adds :require-macros on top of all the other ways of including files.
Ideally, it would be awesome if there was just a single directive for everything, but perhaps there's some complicated low-level reason why that's not possible. :-\
Thoughts?
Thanks,
Greg
+1, :use is IMO an antipattern.I hate it mainly in blogs, where they explain some new API. They :use like 3 namespaces and you have to guess which fn is from which ns :)
I think I read somewhere that :use is no longer encouraged, but I could be mistaken.
From what I've read, it seems like most people agree that Clojure has too many ways of including/importing/referencing/requiring/using things:
http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
The above gives a very nice explanation of all the various difference, but it also acknowledges their complexity.
Since :use uses :require, and since :require can do everything that :use can, can we simplify Clojure programming a bit for newcomers by deprecating the use of :use? The situation in ClojureScript is even worse because it adds :require-macros on top of all the other ways of including files.
Ideally, it would be awesome if there was just a single directive for everything, but perhaps there's some complicated low-level reason why that's not possible. :-\
Thoughts?
Thanks,
Greg
First, I think I’m seeing an entirely legitimate concern being expressed by some developers that :use complicates life in their shops. Contrariwise, there’s clearly a set of developers who are in environments where :use feels very natural, and is of considerable convenience.
As someone who is generally in the latter situation, I have a hard time with notion of getting rid of :use, but I can equally well picture myself doing Clojure environments where the restriction was pertinent. So, how about if there was a compiler option that caused :use to be flagged with a warning or error? I’d say that was entirely acceptable solution that kept everyone happy.
In general: if you’re talking about expanding the existing functionality to help solve people’s problems, I’m all for it. If you’re talking about restricting existing functionality to require conformity with your particular vision, that’s a problem.
BTW, if you insist on making the :use functionality substantially less convenient, well, I know how I respond to such things. I recall a saying from long ago in the Lisp community that “if you don’t like the syntax, write your own!”---and so I do. I’ve already dealt with several perceived nuisances in existing Clojure by writing and using my own macros. Coming up with a custom replacement for the ns macro feels a little challenging, but I dare say I’d rise to the occasion if need be. If that becomes common practice, I’d say you’ve won the conformity battle but lost the war. (Hey, maybe we should get rid of macros to prevent such heinous acts, eh? It worked for Java…)
Next, there's an "I can't tell where identifiers come from" thought. Yeah, I've felt that pain, and as I've indicated, I'm situationally sympathetic. But here's a thought: how is this different from any programming language where one file/class/module/whatever can be included by another? Might there already be technology for dealing with it---even technology that doesn't involve manually qualifying every non-local identifier?
Finally, with
respect to the “it’s too hard for newcomers” line of argumentation, my reaction
is: this is silly. Do you really want to optimize Clojure for use
by newcomers? Assuming you managed such
a thing, would the result still be useful to experienced programmers---who are,
after all, are the main constituency for Clojure? Newcomers don’t tend to stay
newcomers for very long, right?
Similarly, with respect to the “ns is too complex” meme, my response is: gimme a break. It really isn’t all that complicated, and reducing its set of options by one isn’t going to change that very much. In the overall scheme of things involving functional programming in general and Clojure in particular, this tiny spec of complexity hardly signifies.
Now, what is a problem is one of explanation---like, how to make newcomers aware of a good-enough set of recipes to get them going, or a lucid description of what the options actually are, and where they should be applied.
So, here's a
suggestion: improve the documentation!! Have you looked at the docstring
associated with ns? Yeeesh! It’s all
proper and correct, and about as profoundly uninformative as can be. (I’ve been
doing Clojure intensively for about three years now, and just now I had a hard
time even parsing it.)
In fact, I think I’d generalize on this, as a lot of the
docstrings in core Clojure are, um, terse… so I’d suggest that if Clojure 2.0
is afoot, improving the documentation would be an excellent goal.
FWIW...
Howard
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/i2VzAlT6oqM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
Agree that :use should be deprecated, mostly as it's quite a barrier to folks new to the language that you need to know 3 different parts of the ns macro before you start.
However "objectively bad" is strong language indeed. ":refer :all" is vital anywhere you want a DSL - if using something like Korma, for example, you have 3 options :
1. Use :as and fill your code with ugly things like "(k/select user (k/where {:name [k/like " fred"]})
2. Use ":refer [select where like..." and almost every other symbol in Korma - might be ok if you have a perfect IDE, but still needlessly verbose
3. Use ":refer :all". It's perfectly fine, IMHO, when used responsibly.
- Korny
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
Agree that :use should be deprecated, mostly as it's quite a barrier to folks new to the language that you need to know 3 different parts of the ns macro before you start.
However "objectively bad" is strong language indeed. ":refer :all" is vital anywhere you want a DSL - if using something like Korma, for example, you have 3 options :
1. Use :as and fill your code with ugly things like "(k/select user (k/where {:name [k/like " fred"]})
2. Use ":refer [select where like..." and almost every other symbol in Korma - might be ok if you have a perfect IDE, but still needlessly verbose
3. Use ":refer :all". It's perfectly fine, IMHO, when used responsibly.
The only time I've seen :as lead to ugly code was when it was in a DSL that would probably have been nicer to use if it was a data-based DSL like Hiccup rather than code-based.
To me the things that make Clojure namespace handling a nightmare for beginners are:- Bad error messages (no.1 problem!)- Confusion with keywords vs. symbols (why ":use" in ns declarations vs "use" at the repl?)- Confusion about quoting and when / where it is needed (again compared with "use" at the REPL)- Confusion about when you should use lists vs. vectors vs symbols etc., and how this interacts with the extra magic syntax like ":as"- Problems with circular loading of namespaces (and how this affects your code structure)
It's pretty ugly to use aliases for numerical code, e.g. with core.matrix, e.g.
It's pretty ugly to use aliases for numerical code, e.g. with core.matrix, e.g.Agreed. It's nice that :require :refer :all is available for such instances, isn't it?
The namespace declaration is too complex. The existence of ":use" is not
what causes this.
can you please therefore explain why you think a breaking change
to ns is a good thing to remove something that we are still going to be
able to do, but in a more verbose way.
user=> (doc ns)-------------------------clojure.core/ns([name docstring? attr-map? references*])MacroSets *ns* to the namespace named by name (unevaluated), creating itif needed. references can be zero or more of: (:refer-clojure ...)(:require ...) (:use ...) (:import ...) (:load ...) (:gen-class)with the syntax of refer-clojure/require/use/import/load/gen-classrespectively, except the arguments are unevaluated and need not bequoted. (:gen-class ...), when supplied, defaults to :namecorresponding to the ns name, :main true, :impl-ns same as ns, and:init-impl-ns true. All options of gen-class aresupported. The :gen-class directive is ignored when notcompiling. If :gen-class is not supplied, when compiled only annsname__init.class will be generated. If :refer-clojure is not used, adefault (refer 'clojure) is used. Use of ns is preferred toindividual calls to in-ns/require/use/import:(ns foo.bar(:refer-clojure :exclude [ancestors printf])(:require (clojure.contrib sql combinatorics))(:use (my.lib this that))(:import (java.util Date Timer Random)(java.sql Connection Statement)))
(ns one.fresh-server(:refer-clojure :exclude [ancestors printf])(:use core.matrix[ring.adapter.jetty :only (run-jetty)][ring.middleware.file :only (wrap-file)][ring.middleware.file-info :only (wrap-file-info)][ring.middleware.stacktrace :only (wrap-stacktrace)][ring.util.response :only (file-response)])(:require [one.reload :as reload][one.middleware :as middleware][net.cgrand.enlive-html :as html])(:import (org.apache.maven.artifact.resolver ArtifactResolver)(java.io File))))
(ns one.fresh-server
(:require [clojure.core :refer [ancestors printf]]
[core.matrix :refer :all]
[ring.adapter.jetty :refer [run-jetty]]
[ring.middleware.file :refer [wrap-file]]
[ring.middleware.file-info :refer [wrap-file-info]]
[ring.middleware.stacktrace :refer [wrap-stacktrace]]
[ring.util.response :refer [file-response]]
[one.reload :as-ns]
[one.middleware :as-ns]
[net.cgrand.enlive-html :as html]
[org.apache.maven.artifact.resolver.ArtifactResolver :as-class]
[java.io.File :as-class]))
Please also explain at the same time, why (use 'core.matrix) remains
clear and why this should not change to "(require 'core.matrix :refer
:all)".
(:require [clojure.core :refer [ancestors printf]]
(:require [clojure.core :refer-except [ancestors printf]]
(ns one.fresh-server"optional doc string goes here"[clojure.core :refer-except [ancestors printf]]
[core.matrix :refer :all][ring.adapter.jetty :refer [run-jetty]][ring.middleware.file :refer [wrap-file]][ring.middleware.file-info :refer [wrap-file-info]][ring.middleware.stacktrace :refer [wrap-stacktrace]][ring.util.response :refer [file-response]][one.reload :as-ns][one.middleware :as-ns][net.cgrand.enlive-html :as html][org.apache.maven.artifact.resolver.ArtifactResolver :as-class][java.io.File :as-class])