Yesterday, a bug was filed against Suchwow under 1.9alpha11. It turns out to 
have been a use of `ns …(require…` instead of `(ns …(:require`. Not in Suchwow, 
but in Midje. Unfortunately, the Suchwow file the bug report pointed at *also* 
had that typo - apparently I am prone to it - so adding the colon to the 
require there didn’t make the problem go away. 

That caused me to lose my temper and make a fool of myself, which is neither 
here nor there, except that I apologize to @puredanger. 

I have two suggestions, though:

1. It has long been the case that Clojure allowed `(ns (require…)` even though 
that’s strictly incorrect. I suggest that, for backwards compatibility, it be 
allowed going forward. That is, I think it does no harm for a correct `ns` 
statement to allow symbols as well as keywords. That wrong code in Midje has 
been there since Clojure 1.2. 

2. The following is not a good error message:

Exception in thread "main" java.lang.IllegalArgumentException: Call to 
clojure.core/ns did not conform to spec:
In: [2] val: ((require [such.vars :as var] [such.immigration :as immigrate]) 
(require midje.checking.checkers.defining midje.checking.checkers.chatty 
midje.checking.checkers.simple midje.checking.checkers.combining 
midje.checking.checkers.collection)) fails at: [:args] predicate: (cat 
:attr-map (? map?) :clauses :clojure.core.specs/ns-clauses),  Extra input

- It would be better to say “`require` should be a keyword, not a symbol” than 
"fails at: [:args] predicate: (cat :attr-map (? map?) :clauses 
:clojure.core.specs/ns-clauses),  Extra input”

- Suggest Clojure.spec error messages follow the “inverted pyramid” structure 
of news reports: https://en.wikipedia.org/wiki/Inverted_pyramid 
<https://en.wikipedia.org/wiki/Inverted_pyramid> That would mean the text 
message about the error would come first, the spec second, and the wrong 
expression last. 

- It would be better to name the namespace that has the problem.

- The stack trace adds nothing to the error. If anything, it makes it less 
understandable, as the sheer amount of text is offputting.

My https://github.com/marick/structural-typing 
<https://github.com/marick/structural-typing> does (a small) part of what 
clojure.spec does. I went to a lot of effort to get it to produce good error 
messages, and it turned out OK. I doubt it would be applicable to clojure.spec, 
but I’d be happy to sign over any code that could be of use. 

It’s unfortunate that reporting errors is so much harder than detecting them. 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to