On Monday, 5 August 2013 09:40:04 UTC+1, Korny wrote:
> 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.
>
I really don't think :use was ever a significant problem for newcomers:
it's fairly obvious what it does if you come from another language that has
similar package-importing constructs. The majority of other languages
behave more like "use" than "require".
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)
I count myself as someone who was quite confused by all these things
initially, but I never had a problem understanding ":use" as a concept.
> 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.
>
Absolutely agreed: method 3 is a decent approach for DSL scenarios.
This is why I am in favour of keeping ":use" for such situations. There's
no value in making a breaking change that removes a helpful syntactical
feature (aside from wasting the time of people who like ":use", it will
just make namespaces even more verbose and it will invalidate a lot of
tutorials / example code which I don't think is very welcoming to newcomers
either).
For example, which is easier to explain to a newcomer:
(ns foo
(:use my.dsl)
(:require [some.library :as bar])
(:import baz.java.Class))
(ns foo
(:require [my.dsl :refer :all])
(:require [some.library :as bar])
(:import baz.java.Class))
The second version is more verbose, has more "magic keywords" (count
them!), and is IMHO somewhat confusing in the sense that you are using
":require" to do two very different things. ":use" is a simpler and more
concise syntax for what the ns declarations above are trying to express
(and has the advantage of consistency with "use" at the REPL).
Reductio ad absurdum: If we take the logic of deprecating ":use" and
overloading ":require" to its logical conclusion, surely we should also
deprecate ":import" and replace it with something like (:require
[:java-package baz.java :java-classes [Class]])? Replacing ":import" in
this way would also simplify ns declarations and make things easier for
newcomers, right? :-)
> - Korny
> On 5 Aug 2013 09:09, "Anthony Grimes" <[email protected] <javascript:>>
> wrote:
>
>> I can't think of a single good reason to not deprecate :use. :require can
>> do everything :use could do now.
>>
>> This isn't about whether or not (:use ..) without :only is bad. I'd go as
>> far as to say that outside of test files (and sometimes not even those) and
>> repl sessions, :use without :only is objectively bad. Not much
>> justification you can give me that'll make it unbad. But that isn't what
>> this is about. Deprecating :use doesn't make doing the aforementioned bad
>> thing impossible, and :refer :all was added to require for that specific
>> purpose. :require still lets you do bad things if you really want to. All
>> we're doing by deprecating :use is removing cruft and making things less
>> complicated for new people. We currently have two things, and one of them
>> does all the things the other one does and more, yet we still have both of
>> them.
>>
>> Just my $0.02.
>>
>> On Tuesday, July 23, 2013 8:50:50 AM UTC-7, Greg 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<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 [email protected]<javascript:>
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> 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 [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.