<< Back to previous view

[CLJ-1211] Protocol call sites emit many unused fields and bytecodes Created: 25/May/13  Updated: 25/May/13  Resolved: 25/May/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Ghadi Shayban Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: File protocol-sites.diff    
Patch: Code

 Description   

Three unused instance member fields are emitted by emitProto() in the compiler - seems that at some point it was for inline caching of protocol implementations, but it looks like that's all handled by MethodImplCache now.

This patch eliminates it, and brings down protocol heavy classes like the new ManyToManyChannel in core.async from 120+ fields down to 23 fields, mostly Var caches.

There should be a lot less bytecode in such classes now, and less memory overhead.



 Comments   
Comment by Ghadi Shayban [ 25/May/13 10:49 AM ]

Needs work





[CLJ-1203] Fallback to hash-based comparison for non-Comparables in Util.compare() Created: 17/Apr/13  Updated: 29/Apr/13  Resolved: 29/Apr/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Tassilo Horn Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: enhancement, patch

Attachments: Text File 0001-Add-hasheq-based-fallback-to-Util.compare.patch    
Patch: Code

 Description   

I oftentimes use sorted collections, and my comparator functions usually look like that:

(fn [a b]
  (let [x (compare-according-to-my-use-case a b)]
    (if (zero? x)
       (compare a b)
       x)))

That is, I define the sorting order depending on the requirements of my use-case, and if that doesn't suffice to make a distinction, I simply fall back to the standard `compare` function in order to get a stable ordering anyhow. I think that's a widely used idiom, e.g., also used in "Clojure Programming" (for example page 109).

The problem with this approach is that several data structures don't implement Comparable, and thus aren't applicable to `compare` (you'll get a ClassCastException). Examples are maps, records, deftypes, and sequences.

The patch I'm going to attach extends `Util.compare()` with a fallback clause that performs a `hasheq()`-based comparison. This results in a meaningless but at least stable sorting order which suffices for use-cases like the one shown above.



 Comments   
Comment by Andy Fingerhut [ 18/Apr/13 9:01 PM ]

Patch 0001-Add-hasheq-based-fallback-to-Util.compare.patch dated Apr 17 2013 applies cleanly to latest master, but causes several unit tests in data_structures.clj to fail. These are the kinds of things you would expect to fail with the change made in the patch, because the failing tests expect an exception to be thrown when comparing objects that don't implement Comparable, and with this patch's changes they no longer do. If this patch's change is desired, those tests should probably be removed.

Comment by Tassilo Horn [ 19/Apr/13 2:34 AM ]

Thanks Andy, I can't believe I've forgotten to re-run the tests.

Anyway, I'm attaching a new version of the patch that deletes the few sorted-set and sorted-set-by invocations that check that an exception is thrown when creating sorted sets containing non-Comparables.

Comment by Tassilo Horn [ 19/Apr/13 2:35 AM ]

New version of the patch.

Comment by Andy Fingerhut [ 26/Apr/13 2:47 PM ]

Tassilo, you say that one of your use cases is sorted collections. Note that any compare function that returns 0 for two values will cause sorted sets and maps to treat the two compared values as equal, and at most one of them will get into the ordered set/map, the second treated as a duplicate, even though the values are not equal. See https://github.com/jafingerhut/thalia/blob/master/doc/other-topics/comparators.md#comparators-for-sorted-sets-and-maps-are-easy-to-get-wrong for an example (not based on your modified compare, but on a comparator that returns 0 for non-equal items).

With your proposed change to compare, this occurrence would become very dependent upon the hash function used. Probably quite rare, but it would crop up from time to time, and could potentially be very difficult to detect and track down the source.

Comment by Tassilo Horn [ 29/Apr/13 2:29 AM ]

Hi Andy, you are right. It's possible to add an explicit equals()-check in cases the hashcodes are the same, but I think there's nothing you can do in the hashcodes-equal-but-objects-are-not case. That is, there's no way to ensure the rule sgn(compare(x, y)) == -sgn(compare(y, x)), the transitivity rule, and the compare(x, y)==0 ==> sgn(compare(x, z))==sgn(compare(y, z)) for all z rule.

I'm closing that ticket.





[CLJ-1194] Typo in core.reducers Created: 08/Apr/13  Updated: 09/Apr/13  Resolved: 09/Apr/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.5
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Dmitry Groshev Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

As far as I can say, there is a typo in core.reducers (and therefore core.reducers/monoid is unusable in 1.5.1):

https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/reducers.clj#L321

(fn m <-- this
    ([] (ctor))
    ([a b] (op a b))))

Should I submit a patch to fix this?



 Comments   
Comment by Ghadi Shayban [ 08/Apr/13 3:09 PM ]

I guess you didn't try to actually use the function to see if it is actually broken...

m is not a argument vector, those are below in the function clauses.

Comment by Dmitry Groshev [ 08/Apr/13 3:26 PM ]

I did, but as it turns out the error was somewhere else and I can't reproduce it within a "clean" environment. Sorry for this hasty ticket.

Comment by Andy Fingerhut [ 08/Apr/13 11:31 PM ]

Dmitry, do you think it is OK to close this ticket as declined, meaning no change will be made in response to it? I can do that for you, if you wish.

Comment by Dmitry Groshev [ 09/Apr/13 4:49 AM ]

Andy, I'll close it myself if you don't mind. I would done it earlier, but didn't have sufficient rights in JIRA.





[CLJ-1179] distinct? does not accept zero arguments Created: 09/Mar/13  Updated: 12/Apr/13  Resolved: 12/Apr/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4, Release 1.5
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Jean Niklas L'orange Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: bug

Attachments: Text File clj-1179-distinct-zero-arguments.txt    
Patch: Code
Approval: Not Approved

 Description   

distinct? cannot be invoked with zero arguments. When using the pattern (apply distinct? x), this is bothersome as you have to check whether x is empty or not. It is also logical that distinct? should return true if no arguments are given, since there are no duplicates.

What (small set of) steps will reproduce the problem?

user=> (apply distinct? [])
ArityException Wrong number of args (0) passed to: core$distinct-QMARK-  clojure.lang.AFn.throwArity (AFn.java:437)

What is the expected output? What do you see instead?

I would expect distinct? to return true whenever given zero arguments.

What version are you using?

This was tested under Clojure 1.4 and Clojure 1.5.



 Comments   
Comment by Jean Niklas L'orange [ 09/Mar/13 6:08 AM ]

Attached the straightforward patch which solves this issue.





[CLJ-1178] Requiring the same ns doesn't throw an exception Created: 07/Mar/13  Updated: 29/Mar/13  Resolved: 29/Mar/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Trivial
Reporter: Michael Drogalis Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Approval: Not Approved

 Description   

The compiler will happily allow requiring the same ns twice. I can't see any reason you'd intentionally do this.

(ns program
  (:require [program.a :as a]
            [program.a :as b])

This caused some confusion for a while as to why b wasn't producing the expected functionality. Just a simple mistake that I think can be caught at compile time.



 Comments   
Comment by Stuart Halloway [ 29/Mar/13 5:57 AM ]

The example shows valid Clojure code.





[CLJ-1170] conj-ing x on equal values should produce equal results Created: 23/Feb/13  Updated: 01/Mar/13  Resolved: 01/Mar/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Irakli Gozalishvili Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

I've recently have run into a WHAT behavior here is an example:

```clojure
(def head 1)
(def tail [2 3])

(= tail (rest (cons head tail))) ; true

;; Types don't really match but close enough I guess
(type tail) ; clojure.lang.PersistentVector
(vector? tail) ; true
(type (rest (cons head tail))) ; clojure.lang.PersistentVector$ChunkedSeq
(vector? (rest (cons head tail))) ; false

;; Bet then it get's ugly (I would expect them to be equal)
(= (conj tail :x) (conj (rest (cons head tail)) :x)) ; false

;; Because
(conj tail :x) ; [2 3 :x]
(conj (rest (cons head tail)) :x) ;(:x 2 3)
```

This brings me to a pretty surprising behavior, which is conj-ing
equal values produce non-equal results:

```clojure
(= '(2 3) [2 3]) ; true
(= (conj '(2 3) 1) (conj [2 3] 1))
```

I think conj should either produce equal results or list and vectors with
same elements should not be equal. That would also resolve a previous
problem, although intuitively I would expect `(rest (cons x y))` to
return `y` back.



 Comments   
Comment by Andy Fingerhut [ 24/Feb/13 10:46 AM ]

Irakli, it is an explicitly documented feature that conj puts new items in different places for lists (at the beginning) and vectors (at the end). rest is explicitly documented to call seq on its argument. See their doc strings.

I don't know if it is explicitly documented, or just long-standing practice, that vectors and seqs with the the same sequence of values in them are equal. I think that a lot of existing code would break if Clojure changed so those were not equal.





[CLJ-1166] Range function accumulates minor errors when called on floating-point numbers Created: 19/Feb/13  Updated: 29/Mar/13  Resolved: 01/Mar/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.5
Fix Version/s: None

Type: Defect Priority: Trivial
Reporter: Stephen Nelson Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Due to range's incremental computation minor errors introduced by floating point arithmetic accumulate, becoming more noticeable in long ranges and causing unexpected behaviour.

Compare the output of the following:

=> (range 0.0 10.0 0.1)
(0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6 0.7 0.7999999999999999 0.8999999999999999 0.9999999999999999 1.0999999999999999 1.2 1.3 1.4000000000000001 1.5000000000000002 1.6000000000000003 1.7000000000000004 1.8000000000000005 1.9000000000000006 2.0000000000000004 2.1000000000000005 2.2000000000000006 2.3000000000000007 2.400000000000001 2.500000000000001 2.600000000000001 2.700000000000001 2.800000000000001 2.9000000000000012 3.0000000000000013 3.1000000000000014 3.2000000000000015 3.3000000000000016 3.4000000000000017 3.5000000000000018 3.600000000000002 3.700000000000002 3.800000000000002 3.900000000000002 4.000000000000002 4.100000000000001 4.200000000000001 4.300000000000001 4.4 4.5 4.6 4.699999999999999 4.799999999999999 4.899999999999999 4.999999999999998 5.099999999999998 5.1999999999999975 5.299999999999997 5.399999999999997 5.4999999999999964 5.599999999999996 5.699999999999996 5.799999999999995 5.899999999999995 5.999999999999995 6.099999999999994 6.199999999999994 6.299999999999994 6.399999999999993 6.499999999999993 6.5999999999999925 6.699999999999992 6.799999999999992 6.8999999999999915 6.999999999999991 7.099999999999991 7.19999999999999 7.29999999999999 7.39999999999999 7.499999999999989 7.599999999999989 7.699999999999989 7.799999999999988 7.899999999999988 7.999999999999988 8.099999999999987 8.199999999999987 8.299999999999986 8.399999999999986 8.499999999999986 8.599999999999985 8.699999999999985 8.799999999999985 8.899999999999984 8.999999999999984 9.099999999999984 9.199999999999983 9.299999999999983 9.399999999999983 9.499999999999982 9.599999999999982 9.699999999999982 9.799999999999981 9.89999999999998 9.99999999999998)

=> (defn range' [start end step] (map #(+ start (* % step)) (range 0 (/ (- end start) step) 1)))
=> (range' 0.0 10.0 0.1)
(0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 0.7000000000000001 0.8 0.9 1.0 1.1 1.2000000000000002 1.3 1.4000000000000001 1.5 1.6 1.7000000000000002 1.8 1.9000000000000001 2.0 2.1 2.2 2.3000000000000003 2.4000000000000004 2.5 2.6 2.7 2.8000000000000003 2.9000000000000004 3.0 3.1 3.2 3.3000000000000003 3.4000000000000004 3.5 3.6 3.7 3.8000000000000003 3.9000000000000004 4.0 4.1000000000000005 4.2 4.3 4.4 4.5 4.6000000000000005 4.7 4.800000000000001 4.9 5.0 5.1000000000000005 5.2 5.300000000000001 5.4 5.5 5.6000000000000005 5.7 5.800000000000001 5.9 6.0 6.1000000000000005 6.2 6.300000000000001 6.4 6.5 6.6000000000000005 6.7 6.800000000000001 6.9 7.0 7.1000000000000005 7.2 7.300000000000001 7.4 7.5 7.6000000000000005 7.7 7.800000000000001 7.9 8.0 8.1 8.200000000000001 8.3 8.4 8.5 8.6 8.700000000000001 8.8 8.9 9.0 9.1 9.200000000000001 9.3 9.4 9.5 9.600000000000001 9.700000000000001 9.8 9.9)



 Comments   
Comment by Stephen Nelson [ 19/Feb/13 3:06 PM ]

=> (last (range 0.0 10000000.0 0.1))
9999999.98112945
=> (last (range' 0.0 10000000.0 0.1))
9999999.9

Comment by Stuart Halloway [ 01/Mar/13 10:08 AM ]

Range is incremental by design, and that is how floats work. Something with the desired behavior would need to be a different fn with a different name.

Comment by Stephen Nelson [ 03/Mar/13 2:38 PM ]

"Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step"

What specifically about that wording specifically suggests that the implementation will use naive increment-and-recurse behaviour? My reading is that the function will return a lazy sequence of numbers from start to end separated by step, not separated by 'almost step'.

This implementation leads to unexpected behaviour with bounds:

=> (count (range 0 100 1))
100
=> (count (range 0 10 0.1))
101

http://www.ima.umn.edu/~arnold/455.f96/disasters.html

Comment by Timothy Pratley [ 29/Mar/13 5:09 PM ]

range could avoid this issue cleanly by converting floats to bigdecimals (let me know if you think this is a good idea?)

I ran into this problem recently, and have to say it was pretty ugly. This is how I avoided the issue:

(defn rangef
"Returns a sequence of n numbers from start to end inclusive."
[start end n]
(for [i (range 0 n)]
(+ start (* i (/ (- end start) (dec n))))))

Hope that helps any disillusioned float users out there, or just pass in BigDecimals to range instead of floats... I would go so far as to say using floats with range as it stands is almost always going to end in tears (or worse as Stephen describes ).

Comment by Timothy Pratley [ 29/Mar/13 5:10 PM ]

[and just to be clear if it is considered an error, it would be nice if range explicitly forbade it]





[CLJ-1156] clojure.walk/stringifiy-keys does not stringify non-keyword keys Created: 03/Feb/13  Updated: 01/Mar/13  Resolved: 04/Feb/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Joel Kuiper Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Patch: None

 Description   

The doc says "Recursively transforms all map keys from keywords to strings." however only those keys that pass keyword? get transformed to string. This leaves other keys such as java.Long as-is.

A simple fix would be

(defn stringify-keys*
"Recursively transforms all map keys from keywords to strings."
[m]
(let [f (fn [[k v]] (if (keyword? k) [(name k) v] [(str k) v]))]
;; only apply to maps
(postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))



 Comments   
Comment by Andy Fingerhut [ 03/Feb/13 11:20 PM ]

It appears from the doc string that this function does exactly what it claims it will do, without any changes.

Comment by Joel Kuiper [ 04/Feb/13 4:29 AM ]

You're right.
Somehow I parsed the doc string wrongly. My sincere apologies! Can be marked invalid.

Comment by Andy Fingerhut [ 04/Feb/13 9:30 AM ]

Closing as declined, since submitter agrees that code behavior and documentation match.





[CLJ-1155] Suppress tracebacks from clojure.core Created: 01/Feb/13  Updated: 29/Mar/13  Resolved: 29/Mar/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Wilfred Hughes Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: enhancement

Attachments: Text File suppress_tracebacks.patch    
Patch: Code

 Description   

It would be really nice if we could hide the Java traceback from the compiler when it's not relevant. When there's no Java interop, it's not useful. I can't see any case where we want the tracebacks from the compiler referencing clojure.core.

Here's how a syntax error traceback looks at the moment on trunk:

$ more dodgy-map.clj
(defn dodgy-map []
  {:1 :2 :3})
$ java -cp target/clojure-1.5.0-master-SNAPSHOT.jar clojure.main dodgy-map.clj
Exception in thread "main" java.lang.RuntimeException: Map literal must contain an even number of forms, compiling:(/home/wilfred/src/clojure/dodgy-map.clj:2:13)
	at clojure.lang.Compiler.load(Compiler.java:7070)
	at clojure.lang.Compiler.loadFile(Compiler.java:7020)
	at clojure.main$load_script.invoke(main.clj:286)
	at clojure.main$script_opt.invoke(main.clj:348)
	at clojure.main$main$fn__6682.invoke(main.clj:432)
	at clojure.main$main.doInvoke(main.clj:429)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.lang.Var.invoke(Var.java:415)
	at clojure.lang.AFn.applyToHelper(AFn.java:161)
	at clojure.lang.Var.applyTo(Var.java:532)
	at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Map literal must contain an even number of forms
	at clojure.lang.Util.runtimeException(Util.java:219)
	at clojure.lang.LispReader$MapReader.invoke(LispReader.java:1090)
	at clojure.lang.LispReader.readDelimitedList(LispReader.java:1145)
	at clojure.lang.LispReader$ListReader.invoke(LispReader.java:979)
	at clojure.lang.LispReader.read(LispReader.java:182)
	at clojure.lang.Compiler.load(Compiler.java:7058)
	... 10 more

With my patch, this is simplified to:

$ java -cp target/clojure-1.5.0-master-SNAPSHOT.jar clojure.main dodgy-map.clj
java.lang.RuntimeException: Map literal must contain an even number of forms, compiling:(/home/wilfred/src/clojure/dodgy-map.clj:2:13)

Another example: here's how name errors appear on trunk:

$ more i-dont-exist.clj
(defn no-such-variable []
  i-dont-exist)
$ java -cp target/clojure-1.5.0-master-SNAPSHOT.jar clojure.main i-dont-exist.clj
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: i-dont-exist in this context, compiling:(/home/wilfred/src/clojure/i-dont-exist.clj:1:1)
	at clojure.lang.Compiler.analyze(Compiler.java:6380)
	at clojure.lang.Compiler.analyze(Compiler.java:6322)
	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
	at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
	at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
	at clojure.lang.Compiler.analyze(Compiler.java:6361)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
	at clojure.lang.Compiler.analyze(Compiler.java:6361)
	at clojure.lang.Compiler.access$100(Compiler.java:37)
	at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:529)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
	at clojure.lang.Compiler.analyze(Compiler.java:6361)
	at clojure.lang.Compiler.analyze(Compiler.java:6322)
	at clojure.lang.Compiler.eval(Compiler.java:6623)
	at clojure.lang.Compiler.load(Compiler.java:7063)
	at clojure.lang.Compiler.loadFile(Compiler.java:7020)
	at clojure.main$load_script.invoke(main.clj:286)
	at clojure.main$script_opt.invoke(main.clj:348)
	at clojure.main$main$fn__6682.invoke(main.clj:432)
	at clojure.main$main.doInvoke(main.clj:429)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.lang.Var.invoke(Var.java:415)
	at clojure.lang.AFn.applyToHelper(AFn.java:161)
	at clojure.lang.Var.applyTo(Var.java:532)
	at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Unable to resolve symbol: i-dont-exist in this context
	at clojure.lang.Util.runtimeException(Util.java:219)
	at clojure.lang.Compiler.resolveIn(Compiler.java:6874)
	at clojure.lang.Compiler.resolve(Compiler.java:6818)
	at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6779)
	at clojure.lang.Compiler.analyze(Compiler.java:6343)
	... 25 more

With patch:

$ java -cp target/clojure-1.5.0-master-SNAPSHOT.jar clojure.main i-dont-exist.clj
java.lang.RuntimeException: Unable to resolve symbol: i-dont-exist in this context, compiling:(/home/wilfred/src/clojure/i-dont-exist.clj:1:1)

I'm not familiar with the compiler internals, but I've attached a tentative patch. Undoubtedly it isn't perfect. For one, it would be nicer to say 'Syntax error' rather than 'java.lang.RuntimeException'. All the tests pass with this change.

Relevant mailing list discussion: https://groups.google.com/forum/?fromgroups=#!searchin/clojure/wilfred/clojure/M5NlEW7HJ_c/joUY6mo6Rd8J

Please let me know what you think. This would make my life easier when developing.



 Comments   
Comment by Stuart Halloway [ 29/Mar/13 6:06 AM ]

It is easy for tools that consume Clojure to hide stack traces for those who do not want to see them. If Clojure itself eats stack traces, it is impossible for those of us who do want to see them to get them back.

Please do this kind of work in tool (if at all) and make it optional for users.





[CLJ-1153] Change *read-eval* default value to false Created: 30/Jan/13  Updated: 01/Mar/13  Resolved: 09/Feb/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3, Release 1.4, Release 1.5
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Andy Fingerhut Assignee: Unassigned
Resolution: Declined Votes: 33
Labels: None

Attachments: Text File clj-1153-patch-v2.txt     Text File CLJ-1185.patch    
Patch: Code
Approval: Not Approved

 Description   

Discussion on the security implications of read-eval defaulting to true here: https://groups.google.com/forum/?fromgroups=#!topic/clojure/qUk-bM0JSGc

I'm not sure whether the unit test that needs read-eval true in order to pass is a sign of lots of other code that would break if read-eval defaulted to false.



 Comments   
Comment by Phil Hagelberg [ 31/Jan/13 11:55 AM ]

It's worth noting that there was a breakin to rubygems.org over the weekend that was caused by what amounts to this same issue, but with YAML: https://news.ycombinator.com/item?id=5141138

The current default is both dangerous and undocumented; this needs to change.

Comment by Soren Macbeth [ 31/Jan/13 12:33 PM ]

Seconded!

Comment by Mike Anderson [ 01/Feb/13 12:52 AM ]

Thirded.

For what it's worth, on the topic of breaking changes I'd much rather my old code break than continue to work with an unnoticed security hole.

Comment by Stuart Halloway [ 01/Feb/13 7:21 AM ]

Fourthed. I hope folks will pitch in and help deal with any breakage.

Comment by Chas Emerick [ 01/Feb/13 12:57 PM ]

New patch attached, {{CLJ-1185.patch}}.

This patch eliminates the use of *print-dup* in the compiler entirely. read-string continues to be used to support values that can only be represented via tagged reader literals; I don't think there's any way around that, since the mapping between particular data readers and values' types are buried in individual print-method implementations.

All tests pass (including cases like (eval (list + 1 2 3)) as discussed in the ML thread referenced in the issue description), and a variety of sanity checks around evaluation and compilation tooling (e.g. AOT, nREPL, introspection utilities in Leiningen/Reply/Counterclockwise) all work as expected.

Of course, if this is applied, then any usage of read over trusted content containing #= forms will need to be done with *read-eval* bound to true.

To aid in testing, a Clojure build (1.5.0-RC4) + this patch is available here:

[com.cemerick/clojure "1.5.0-SNAPSHOT"]

Note that you'll have to exclude the standard Clojure dependency from your project in order for this one to take precedence; you can do this by adding

:exclusions [org.clojure/clojure]

to your project.clj.

Comment by Paul Stadig [ 01/Feb/13 2:49 PM ]

I ran the Sonian test base against this patch. I wouldn't say our test cases are comprehensive, but they're not trivial. We talk to databases through JDBC, and we deal with lots of different data types (BigInts, Strings, Dates, and such).

I had to make a few small changes to our code base, because we rely pretty heavily on print-dup to serialize non-user originated data. We have to add corresponding binding blocks when reading to set read-eval to true. Other than that, the tests all passed.

+1

Comment by Chas Emerick [ 01/Feb/13 4:28 PM ]

Thanks to all that have tested the patch! Looks like we've made some progress. I'm going to post to the main Clojure ML now and hopefully get more yay/nay votes.

Comment by Andy Fingerhut [ 02/Feb/13 11:05 AM ]

clj-1153-patch-v2.txt dated Feb 2 2013 is functionally identical to Chas Emerick's CLJ-1185.patch dated Feb 1 2013, and no retesting is needed by anyone because of it.

The only change I have made to his patch is: the doc string for read-eval now says its default value is false.

Comment by Andy Fingerhut [ 02/Feb/13 11:06 AM ]

Also removed my original didn't-fix-enough-things patch from Jan 30 2013.

Comment by Tim McCormack [ 02/Feb/13 3:22 PM ]

I'm bumping the Priority field from its default value to "Major" to reflect recent events. (I personally feel "blocker" would be more appropriate, or at least "critical", but I don't want to step on any toes.)

Comment by Rich Hickey [ 04/Feb/13 7:55 PM ]

https://github.com/clojure/clojure/commit/974a64c06917861b7557fd73154254195b2de548

Comment by Rich Hickey [ 09/Feb/13 9:17 AM ]

This ticket is an excellent example of a terrible ticket.

1) It does not lead with a problem statement. The title takes the form akin to "I want X". It proposes a tactic.

2) The description is woefully inadequate. Here too, no problem statement. Descriptions should point to any discussions, but discussions are long and rambling, and no substitute for a succinct problem statement in the description. Descriptions need to be maintained, with the current strategy and name of best patch.

3) No resolution strategy. Just patches attached. How is a reviewer supposed to assess your patch if you don't even bother stating what the problem is and what your approach will be in fixing it, how that approach does fix it, and what if any tradeoffs are being made?

4) The change being requested would be a breaking change. That should be made extremely clear in the description, and doubles the threshold for quality of motivation and implementation.

5) Any breaking change would have to carefully enumerate what would break and when, what the migration strategy would be etc.

6) The patch breaks the compiler. If you don't understand how the compiler works, and why features are there, you shouldn't submit patches that alter it. The only assessments made in comments are 'it works for me', which, while useful anecdotes, are insufficient.

While the ticket itself was bad, the uncritical rallying behind it was more troubling. This is not how Clojure was built, and will not be how it is maintained.

In the end, the ticket proposed a tactic, and that tactic has been rejected. Read safety has been addressed by other means.





[CLJ-1139] Compiler exception while compiling swank/commands/basic.clj Created: 23/Dec/12  Updated: 09/Feb/13  Resolved: 09/Feb/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.5
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Brian Rowe Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:
  • Clojure: 1.5.0-RC1
  • Java: Java 1.7.0_05 Java HotSpot(TM) 64-Bit Server VM
  • Leiningen: 2.0.0-preview10
  • lein-swank: 1.4.4
  • lein-ritz: 0.6.0

Attachments: Text File tmp.txt    

 Description   

Current Behavior:

When attempting to start a swank server, the clojure compiler throws a CompilerException, and the process terminates.

Expected Behavior:

A swank server is successfully started.

Steps to reproduce (terminal session attached):

1. lein new tmp
2. Edit the project.clj to require clojure version 1.5.0-RC1
4. cd tmp
3. lein swank



 Comments   
Comment by Brian Rowe [ 23/Dec/12 4:58 AM ]

I suppose I should add that I'm using Mac OS X 10.8.2

Comment by Andy Fingerhut [ 24/Dec/12 9:27 AM ]

Have you noticed that swank-clojure [1] is deprecated, i.e. no longer under active development, and the developer recommends that you use nrepl.el [2] instead?

[1] https://github.com/technomancy/swank-clojure
[2] https://github.com/kingtim/nrepl.el

Comment by Andy Fingerhut [ 26/Dec/12 8:55 AM ]

It also appears that someone has created an update to lein-swank (to version 1.4.5) that works with Clojure 1.5.0-RC1:

https://groups.google.com/forum/#!topic/clojure/CAiajyDWJJg

(in particular Toby Crawley's post on Dec 26 2012)

Comment by Brian Rowe [ 08/Feb/13 8:03 PM ]

Yes, this can be closed.

Comment by Andy Fingerhut [ 09/Feb/13 2:20 AM ]

Submitter agrees this issue was resolved by changes in other software outside of Clojure.





[CLJ-1089] clojure.java.io/copy interprets read count of 0 as eos Created: 22/Oct/12  Updated: 22/Oct/12  Resolved: 22/Oct/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Herwig Hochleitner Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File 0001-CLJ-1089-clojure.java.io-do-copy-methods-determine-e.patch    

 Description   

According to the interface http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#read()
InputStream.read() family of methods return -1 when the end of stream is reached.

do-copy methods currently use a test: (pos? size) to determine whether eos is reached. This mostly works, but the specification is pretty clear in that InputStream implementations are allowed to return reads of zero bytes before returning more bytes.

##EDIT changed title of ticket from "clojure.java.io/copy should test for -1 instead of 0 for end of stream"



 Comments   
Comment by Herwig Hochleitner [ 22/Oct/12 3:40 PM ]

Attached patch changes do-copy methods to test for -1

Comment by Andy Fingerhut [ 22/Oct/12 4:56 PM ]

Herwig, can you elaborate on "the specification is pretty clear in that InputStream implementations are allowed to return reads of zero bytes before returning more bytes"?

I ask because in the very InputStream documentation page you link to, it seems to explicitly say the opposite of what you claim: "If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b."

Comment by Herwig Hochleitner [ 22/Oct/12 4:57 PM ]

I reread the spec for InputStream.read and it clearly says

"If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b."

The reason I originally thought of this as an issue was a misbehaving ServletInputStream from Jetty.

I closed the issue as declined. Sorry for the noise!





[CLJ-1067] Fix error message inconsistencies in Symbol and Keyword Created: 14/Sep/12  Updated: 01/Mar/13  Resolved: 17/Sep/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Trivial
Reporter: Christoffer Sawicki Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File Make-Keyword-extend-AFn-just-like-Symbol.patch    
Approval: Not Approved

 Description   

1. There are some ugly and unnecessary – but harmless – inconsistencies between Symbol and Keyword:

(.run 'foo);    => ArityException Wrong number of args (0) passed to: Symbol  clojure.lang.AFn.throwArity (AFn.java:437)
(.run :foo);    => UnsupportedOperationException   clojure.lang.Keyword.run (Keyword.java:97)
(.call 'foo);   => ArityException Wrong number of args (0) passed to: Symbol  clojure.lang.AFn.throwArity (AFn.java:437)
(.call :foo);   => IllegalArgumentException Wrong number of args passed to keyword: :foo  clojure.lang.Keyword.throwArity (Keyword.java:88)
(.invoke 'foo); => ArityException Wrong number of args (0) passed to: Symbol  clojure.lang.AFn.throwArity (AFn.java:437)
(.invoke :foo); => IllegalArgumentException Wrong number of args passed to keyword: :foo  clojure.lang.Keyword.throwArity (Keyword.java:88)

2. Keyword.java contains a lot of code that has already been factored out to AFn.java.

I propose that Keyword is modified to extend AFn to resolve the above issues.



 Comments   
Comment by Stuart Halloway [ 17/Sep/12 7:03 AM ]

At first glance, it appears that there could be some code sharing here. But the attached patch changes the semantics of run, which is a non-starter.

Comment by Christoffer Sawicki [ 17/Sep/12 7:19 AM ]

The only thing that changes is the type of thrown exception.

Current call tree:

Keyword.run() -> throw new UnsupportedOperationException()

Call tree with patch applied:

Keyword.run() -> AFn.run() -> AFn.invoke() -> AFn.throwArity(0) -> throw new ArityException(...)

(I.e. Keyword.run() always throws an exception, with and without my patch.)





[CLJ-1054] Syntax quoted form produces a sequence, not a list Created: 31/Aug/12  Updated: 18/Sep/12  Resolved: 18/Sep/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Andrei Zhlobich Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Syntax quote returns clojure.lang.Cons instead of IPersistenList.
But simple quote always returns list.

(list? '(1))     => true
(list? '(1 2 3)) => true
(list? `(1))     => true
(list? `(1 2 3)) => false


 Comments   
Comment by Stuart Halloway [ 18/Sep/12 6:42 AM ]

It is unusual in Clojure to expect/rely on concrete list? checks, particularly given the prevalence of seq?

If the behavior documented here is causing problems, please discuss use case on mailing list, and then we can open a ticket.





[CLJ-1051] Recursive function raises "call unbound fn" exception Created: 27/Aug/12  Updated: 01/Mar/13  Resolved: 09/Nov/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Armando Blancas Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

OSX


Attachments: File expr.clj    

 Description   

I've tried to reduce the code to the minimum that will reproduce the problem. This is a parser combinator library that uses the "list of successes" method. The test is a simple expression for adding one-digit integers with support for parens; sample input might be "1+(2+3)+4".

Having declared the parsers (see attached file), the expression parser is this:

(declare expr)

(def factor
  (choice (between (match \() (match \)) expr)
	  integer))

(def expr
  (bind factor
       (fn [t]
	 (choice (bind (match \+) (fn [_] (bind expr (fn [e] (result (+ t e))))))
	         (result t)))))

With the above, I get this error:

Clojure 1.4.0
user=> (load-file "expr.clj")
#'user/expr
user=> (run expr "(3)")      
IllegalStateException Attempting to call unbound fn: #'user/expr  clojure.lang.Var$Unbound.throwArity (Var.java:43)

I can, however, avoid this error if I code the (factor) function by expanding the code of the parser (between):

(declare expr)

(def factor*
  (choice (bind (match \() (fn [_]
          (bind expr       (fn [e]
	  (bind (match \)) (fn [_] (result e)))))))
	  integer))

(def expr
  (bind factor*
       (fn [t]
	 (choice (bind (match \+) (fn [_] (bind expr (fn [e] (result (+ t e))))))
	         (result t)))))

And now I can do:

Clojure 1.4.0
user=> (load-file "expr.clj")
#'user/expr
user=> (run expr "(3)")      
3
user=> (run expr "1+(2+3)+(4+5)")
15

The ability to reuse parser and add conveniences like (between) is key for this style of parsing.



 Comments   
Comment by Kevin Downey [ 27/Aug/12 6:03 PM ]

this is not a bug in clojure.

declare creates an unbound var then your def tries to use the value of the var before you have given it a value.

declare does not let you use a value of a var before you have given it one (via def or whatever).

Comment by Kevin Downey [ 27/Aug/12 6:05 PM ]

meta comment:
I would close this as "Declined", but I am not sure if that is kosher for me to do.

Comment by Armando Blancas [ 27/Aug/12 10:28 PM ]

Thanks for looking into this.

Just want to point out that as far as the declare and the use of expr as a forward reference, the second scenario I've presented (with factor*) uses (declare) the same way, yet it works: the var "expr" in (factor*) ends up pointing to the root value set later, but before it runs.

Seems to me similar to this case, where f is defined in terms of itself and it works fine, having the var "f" obtained its root binding after the def form runs:

user=> (def f (fn [n] (if (< n 1) 1 (* n (f (- n 1))))))
#'user/f
user=> (f 6)
720

Given that I've got a usage that works, I would suspect that there's something about the first case that prevents the root binding to be visible to the declared var.

Comment by Kevin Downey [ 28/Aug/12 3:25 AM ]

the formatting of the second case makes it hard to read, but it looks like expr is referenced inside a function, so the var #'expr will not be derefed until the function is run.

Comment by Armando Blancas [ 28/Aug/12 12:32 PM ]

Though the difference isn't quite apparent to me, I kind of grasp the idea that the var may be in one case deref'ed earlier in one case than the other because calls to (bind) are eager and in the case of the additional call to (between) the var is inside the function. I'll ask the board for advice on this and this ticket can be closed. Thanks.

Comment by Stuart Sierra [ 09/Nov/12 8:51 AM ]

Closed based on discussion in comments.





[CLJ-1050] Remove a lock in the common case of deref of delay Created: 26/Aug/12  Updated: 18/Sep/12  Resolved: 18/Sep/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Enhancement Priority: Trivial
Reporter: Nicolas Oury Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: enhancement, patch, performance

Attachments: Text File 0001-No-lock-in-the-common-path-for-delays.patch    

 Description   

Currently, when deref is called in Delay.java, a lock on the Delay is always acquired.
This is wasteful as most of the time you just want to read the val.

The attached patch changes this behaviour to the following:

  • val is initialised to a known secret value. (During its constructor so it is visible from any thread).
  • When deref is called, val is checked to the known secret value.
  • If it is not the secret value, then it has to be the value computed by the function and we return it.
  • If it is the secret value, then we lock this object and revert to the current behaviour.

This is faster than what is done currently and can be very much faster if there is contention on the delay.



 Comments   
Comment by Nicolas Oury [ 27/Aug/12 2:37 AM ]

Please close and reject. The patch is not working if val has non final fields.





[CLJ-1042] [PATCH] Allow negative substring indices for (subs) Created: 14/Aug/12  Updated: 19/Sep/12  Resolved: 17/Sep/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.5
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Ian Eure Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: enhancement, patch

Attachments: Text File clj-1042-negative-indices-patch3.txt     Text File negative-subs.patch    
Patch: Code and Test

 Description   

This adds Python-style negative string indices for (subs), e.g.:

(subs "foo bar" -3) ;; -> "bar"



 Comments   
Comment by Andy Fingerhut [ 16/Aug/12 7:17 PM ]

Ian, thanks for the patch. It is Rich Hickey's policy only to consider applying patches to Clojure from those who have signed a Clojure contributor agreement: http://clojure.org/contributing

Were you interested in doing so, or perhaps it is already in progress?

Comment by Ian Eure [ 20/Aug/12 11:44 AM ]

I wasn't aware that this was necessary. I'm mailing the form in.

Comment by Andy Fingerhut [ 27/Aug/12 7:56 PM ]

Patch clj-1042-negative-subs-patch2.txt dated Aug 27 2012 is identical to Ian Eure's negative-subs.patch, except it is in the desired git format.

Ian, for future reference on creating patches in the desired format, see the instructions under the heading "Development" on this page: http://dev.clojure.org/display/design/JIRA+workflow

Comment by Ian Eure [ 28/Aug/12 11:47 AM ]

Thanks, will do.

Comment by Steve Miner [ 04/Sep/12 3:53 PM ]

If Clojure decides to support Python-style negative indices, you should also consider adding support to subvec.

Comment by Ian Eure [ 06/Sep/12 12:17 PM ]

Patch extended to support negative indices on (subvec) as well.

Comment by Adrian Bendel [ 07/Sep/12 8:01 AM ]

The arg to rindex should probably be tagged with ^clojure.lang.Counted instead of ^String now.

Comment by Steve Miner [ 07/Sep/12 1:31 PM ]

Regarding the previous comment, String is a Java class so it isn't a clojure.lang.Counted. Is the type hint necessary? Maybe it should be on the call rather than the defn.

Ignoring the type hinting, I'll suggest a slightly simpler way to implement the rindex logic:

(defn rindex [coll i]
(if (neg? i) (+ (count coll) i) i))

In any case, I'm not sure rindex should be public even if you want the subs and subvec enhancements. Someone needs to make the case for adding a new function to core.

The Pythonic negative index is a debatable feature since it's pretty easy to implement for yourself if you want it.

Comment by Adrian Bendel [ 07/Sep/12 11:05 PM ]

Sorry, the type hint on rindex args isn't necessary at all. Just looked up in the source, calling count should never be reflective, since (count ..) emits calls to clojure.lang.RT/count.

Your solution looks good.

Comment by Stuart Halloway [ 17/Sep/12 7:07 AM ]

Negative indices were considered and rejected a long time ago. (I am merely conveying information--I have no strong opinion on this one.)

Comment by Andy Fingerhut [ 17/Sep/12 12:07 PM ]

Note: If some people really like negative index behavior as in Perl or Python, it is straightforward to create a library of functions in a different namespace, perhaps with different names, that can do it. Perhaps a "pythonisms" library?

Comment by Ian Eure [ 18/Sep/12 12:31 PM ]

Would this be accepted as part of clojure.string instead? I considered putting it there, but thought it would be confusing to have multiple substring functions in different namespaces.

This is very helpful in practice, and I'd really like to see at least the (subs) stuff in Clojure.

Comment by Andy Fingerhut [ 18/Sep/12 2:52 PM ]

Disclaimer: I'm no Clojure/core member, so can't speak authoritatively on whether something would or would not be accepted into clojure.string.

However, given that clojure.string is distributed with clojure.core, my guess is it would not be accepted. You'd be able to get things like this out for you and others as a separate library distributed on Clojars. That would also make it easy to include other Python-like things that you don't find in Clojure already.

Comment by Ian Eure [ 18/Sep/12 4:02 PM ]

This isn't about "python-like things," this is about a useful feature. Lots of languages support this: Perl, PHP, Ruby, Python, JavaScript, to name a few. Are you really suggesting that I should create a whole package for a version of a function in clojure.core with slightly different semantics? That's insane.

Anyway, I'm done wasting my time trying to navigate this hopelessly broken process. Maybe it would have been accepted if I included yet another way to interoperate with Java types.

Comment by Michael Klishin [ 18/Sep/12 5:09 PM ]

Stuart, do you remember why specifically negative indexes were rejected? Developing a separate library for a minor improvement to an existing function sounds unreasonable.

Comment by Carlos [ 18/Sep/12 5:10 PM ]

some explanation about this topic was given by Rich Hickey himself here: http://news.ycombinator.com/item?id=2053908

citation:
"...Yes, there is a backlog from when it was just me, and it will take a while to whittle down. We have finite resources and have to prioritize. I can assure you we have more important things to concentrate on than your negative index substring enhancement, and are doing so. You'll just have to be patient. Or, if you insist, I'll just reject it now because a) IMO it's goofy, b) you can make your own function that works that way c) we don't get a free ride from j.l.String, d) it begs the question of negative indices elsewhere..."

i've been following this thread hoping this feature would be included. but whatever the reason was for the rejection, i'm sure it was thoughtful. great thanks for this wonderful language, and thanks Ian Eure for his effort.

Comment by Steve Miner [ 18/Sep/12 5:25 PM ]

That HN link eventually leads back to CLJ-688 which was rejected.

Comment by Stuart Halloway [ 19/Sep/12 12:03 PM ]

Michael: A proposal for negative indexes would need to be systematic in considering implications for all functions that have index arguments.

Ian: Clojure is driven by design, not incremental piling of features.

All: clojure.string is incomplete in more important and fundamental ways than negative indexes. This sucks now, and will suck worse as more code is written in different dialects. I find myself wishing string was a contrib, so we could iterate faster.

Comment by Andy Fingerhut [ 19/Sep/12 1:34 PM ]

Stuart: Any specific proposals for how you'd like to see clojure.string improve? If it can be made a contrib, that would be cool, but understood if that would be considered too breaking of a change. Even if it isn't made a contrib, having tickets for improvement ideas you are willing to see means patches might get written, and they'll get in some time.





[CLJ-1035] Remove the need to use ":import" of a record Created: 29/Jul/12  Updated: 10/Aug/12  Resolved: 10/Aug/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Warren Lynn Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Right now if I need to use a record defined in another name space, I need to do this:

(ns myproj.test.xyz
(:use [myproj.xyz])
(:import [myproj.xyz MyRecord])

Hope we can remove the need of ":import" clause.



 Comments   
Comment by Stuart Halloway [ 10/Aug/12 12:44 PM ]

Hi Warren,

Importing a Java class and using a record are two logically distinct ideas, hence two separate steps in your code. Note that using a namespace makes the defrecord constructor fns (e.g. >MyRecord and map>MyRecord) available without a second step.

Please discuss ideas on the mailing list before using JIRA to make suggestions.

Cheers

Comment by Warren Lynn [ 10/Aug/12 2:19 PM ]

Thanks for giving it a thought.

I think it is conceptually simple/consistent to say "if you use a namespace, then all the public symbols in that namespace is available without namespace qualification". It is unnecessary to remind people "Hey, record is an actually a Java class so the rules do not apply". I think it is the right choice for Clojure to integrate closely with the host language, but it is not the objective to expose the host details when not needed. If you say "this is a compromise due to some implementation consideration", then I can understand. But I disagree with the rationale you mentioned.





[CLJ-1028] (compile) crashes with NullPointerException if public function 'load' is defined Created: 20/Jul/12  Updated: 20/Jul/12  Resolved: 20/Jul/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Ben Kelly Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: Compiler, bug
Environment:

Linux, OpenJDK 1.6.0 64bit


Attachments: File stack-trace    

 Description   

When performing AOT compilation, if the namespace being compiled or one of the namespaces :required by it defines a public function named 'load', the compiler will crash with a NullPointerException.

The following code demonstrates this:

(ns ca.ancilla.kessler.core (:gen-class)) (defn load [x] x) (defn -main [& args] 0)

When run directly, with 'clojure -m ca.ancilla.kessler.core' or 'clojure ca/ancilla/kessler/core.clj', it runs as expected. When loaded with 'clojure -i' and (compile)d, however, or when automatically compiled by 'lein run', it results in a NullPointerException (the complete stack trace is attached).

This occurs whether or not 'load' or actually called. It does not, however, occur if 'load' is private.



 Comments   
Comment by Ben Kelly [ 20/Jul/12 12:43 PM ]

If you add (:refer-clojure :exclude [load]) to the (ns), it works fine:

(ns ca.ancilla.kessler.core (:refer-clojure :exclude [load]) (:gen-class))
(defn load [x] x)
(defn -main [& args] 0)

Thanks to llasram on IRC for discovering this.

Comment by Stuart Halloway [ 20/Jul/12 4:35 PM ]

You should not replace functions in clojure.core. This is left legal (with a loud CONSOLE warning) for compatibility, but programs that do it are in error.

Comment by Ben Kelly [ 20/Jul/12 10:06 PM ]

So, just to make sure that I have this right, then...

If I want to create a namespace with a public function that shares a name with a function in clojure.core, the only supported way of doing this is to (:refer-clojure :exclude [list of all such functions])?

If so, it would be nice if the warning were replaced with an error, rather than having the compiler emit an error and then crash.





[CLJ-1025] Enable support for \x.. escaped characters. Created: 13/Jul/12  Updated: 19/Oct/12  Resolved: 19/Oct/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Dave Sann Assignee: Unassigned
Resolution: Declined Votes: 1
Labels: None
Environment:

All


Attachments: Text File 0001-adding-support-for-x-escape-characters.patch    
Patch: Code and Test
Approval: Not Approved

 Description   

see: https://groups.google.com/d/topic/clojure/Kl3WVtEE3FY/discussion

\x.. characters (which are the same as \u00.. characters) are produced by some systems. in particular clojurescript

Inability to read these characters hinders data interchange

After a quick look, I believe this capability can be easily introduced by adding a case to this
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L445 function.
Mirroring 'u' case and reading only 2 chars.



 Comments   
Comment by Andy Fingerhut [ 19/Jul/12 11:46 AM ]

Thanks for the patch, Dave. It is Rich Hickey's policy only to include code in Clojure written by those who have signed a Contributor Agreement (CA). See here for more details: http://clojure.org/contributing Have you signed one, or were considering it?

Comment by Andy Fingerhut [ 19/Jul/12 3:57 PM ]

Can someone find some documentation or spec somewhere that defines this \x.. format?

It is definitely different than the \x{...} syntax that exists in Perl, which permits one to insert an arbitrary Unicode character code point into a string (note: even supplementary ones that don't fit into a single UTF-16 code unit, as Java's and Clojure's \u.... is restricted to). http://perldoc.perl.org/perlunicode.html#Effects-of-Character-Semantics

Comment by Dave Sann [ 22/Jul/12 2:19 AM ]

http://es5.github.com/x7.html#x7.8.4

Comment by Dave Sann [ 31/Jul/12 4:35 AM ]

I am happy to sign the CA in principle. Just need to read and understand any implications for me.

Comment by Dave Sann [ 27/Aug/12 3:31 AM ]

CA will be with you shortly.

Comment by Dave Sann [ 16/Oct/12 3:11 AM ]

Can this go into 1.5?

Comment by Chas Emerick [ 19/Oct/12 8:10 AM ]

I'm hitting this now as well. But, adding support for JavaScript's flavour of \x.. escapes to the Clojure reader makes no sense to me. If escapes are to be used, then the \u.... format seems preferable (it supersets \x..).

However, all of the readers in play (Clojure reader, ClojureScript reader, edn) all play nice with Unicode, so there's no reason to be escaping anything except for \t, \n, and so on.

It looks like tweaking cljs' string implementations of IPrintWithWriter and IPrintable so that only those characters are escaped would be fairly easy. Right now, they're using goog.string.escape, which "encloses a string in double quotes and escapes characters so that the string is a valid JS string"; whatever escaping is appropriate for a "valid JavaScript string" seems irrelevant to what e.g. pr-str should produce.

I propose closing this ticket and moving the party to CLJS.

Comment by Stuart Halloway [ 19/Oct/12 1:55 PM ]

Following Chas's lead and closing this one. \x doesn't appear in the JSON spec, and a quick search of StackOverflow shows people stumbling over it from a bunch of other language platforms. I think we should root it out of ClojureScript.

Comment by Chas Emerick [ 19/Oct/12 1:58 PM ]

Great, I'll open a CLJS ticket with a patch tonight or tomorrow.

Comment by Ivan Kozik [ 19/Oct/12 2:39 PM ]

Re: "no reason to be escaping anything except for \t, \n": sometimes it is difficult or impossible to transmit all of Unicode (e.g. sending non-Character codepoints through XDomainRequest, or sending U+0000/U+FFFE/U+FFFF through many XHR implementations), so it might be nice to have an ASCII-only printing mode. Probably for another ticket, though.

Comment by Chas Emerick [ 19/Oct/12 7:59 PM ]

Here's the new ticket: http://dev.clojure.org/jira/browse/CLJS-400

@Ivan: I agree that options in this area would be good. There are a lot of edge cases where the defaults aren't right (e.g. I think escaping all nonprintables is a no-brainer for readably-printed strings).

I suspect planning out such details should probably happen [here](http://dev.clojure.org/pages/viewpage.action?pageId=4063586) or [here](https://github.com/edn-format/edn/issues).





[CLJ-1024] Varargs protococol impls can be defined but not called Created: 10/Jul/12  Updated: 14/Feb/13  Resolved: 13/Feb/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: Release 1.5

Type: Enhancement Priority: Minor
Reporter: Víctor M. Valenzuela Assignee: Stuart Halloway
Resolution: Declined Votes: 1
Labels: patch

Attachments: Text File 0001-CLJ-1024-Check-for-invalid-varags-destrucuring-uses.patch    
Patch: Code
Approval: Not Approved

 Description   

The compiler accepts this:

(deftype foo []
clojure.lang.IFn
(invoke [this & xs]))

However calling ((foo.) :bar) will throw an AbstractMethodError. Wouldn't some checking be desirable?



 Comments   
Comment by Tassilo Horn [ 11/Jul/12 1:20 AM ]

First of all, clojure.lang.IFn is no protocol but an interface. And it does not declare a

  public Object invoke(Object... obs)

method. It has an `invoke` method with 20 Object parameters followed by an Object... parameter, but to give an implementation for that, you have to specify every parameter separately, and the last Object... arg is just a normal argument that must be an Object[]. That's because Java-varags Type... parameters are just Java syntax sugar, but in the byte-code its simply a Type-array.

What your example does is provide an `invoke` implementation for the 2-args version, where the first parameter happens to be named `&`, which has no special meaning here. Take that example:

(deftype MyFoo []
  clojure.lang.IFn
  (invoke [this & xs]
    [& xs]))

((MyFoo.) 1 2)
=> [1 2]

But you are right in that `deftype`, `defrecord`, `defprotocol`, and `definferface` probably should error if user's seem to try to use varargs or destructuring.

Comment by Víctor M. Valenzuela [ 11/Jul/12 1:55 AM ]

Cheers for a most clarifying response.

The fact that the meaning of & gets 'subverted' makes the issue only (slightly) worse, in my opinion.

Just for the record, destructuring seems to work, at least for interface impls.

Comment by Tassilo Horn [ 11/Jul/12 2:42 AM ]

> The fact that the meaning of & gets 'subverted' makes the issue only (slightly) worse, in my opinion.

I agree. I'll attach a patch which checks for those invalid usages soon.

> Just for the record, destructuring seems to work, at least for interface impls.

Could you please provide a complete example demonstrating your statement?

I'm rather sure that varargs and destructuring don't work for any of defprotocol, definterface, deftype, defrecord, and reify. But you can use varargs and destructuring when providing dynamic implementations via `extend` (or `extend-protocol`, `extend-type`), because those impls are real functions in contrast to methods.

Comment by Tassilo Horn [ 11/Jul/12 2:43 AM ]

I attached a patch. Here's the commit message:

Check for invalid varags/destrucuring uses.

Protocol, interface method declarations and implementations don't allow for
varags and destructuring support. Currently, for example

(defprotocol FooBar
(foo [this & more]))

compiles just fine, and & is interpreted as a usual argument that happens to be
named & without special meaning. But clearly, the user wanted to specify a
varags parameter here. The same applies to definterface.

Similarly, providing method implementations via defrecord, deftype, and reify
don't allow for destructuring and varags (but dynamic extenions via extend do).

So this patch makes defprotocol, definterface, defrecord, deftype, and reify
throw an IllegalArgumentException if any argument vector contains a
destructuring form or varargs argument.

Comment by Víctor M. Valenzuela [ 12/Jul/12 3:13 AM ]

Glad you've considered my request.

As for destructuring, I was speaking after this example, which may or may not work like it looks like - I don't know.

(deftype foo []
clojure.lang.IFn
(invoke [this [a b] c] (println a b c)))

((foo.) [1 2] 3)

Comment by Tassilo Horn [ 12/Jul/12 8:22 AM ]

Indeed, descructuring seems to work for method implementations. I'll adapt my patch...

Comment by Tassilo Horn [ 12/Jul/12 8:42 AM ]

Revamped patch. Here's the commit message:

Protocol, interface method declarations don't allow for varags and
destructuring support. Currently, for example

  (defprotocol FooBar
    (foo [this & more]))

compiles just fine, and & is interpreted as a usual argument that happens to be
named & without special meaning. But clearly, the user wanted to specify a
varags parameter here. The same applies to definterface.

Similarly, providing method implementations via defrecord, deftype, and reify
don't allow for varags (but dynamic extenions via extend do).

So this patch makes defprotocol and definterface throw an
IllegalArgumentException if a user tries to use varargs and destructuring in
method signatures.

Similarly, defrecord, deftype, and reify throw an IllegalArgumentException if
any method implementation arglist contains a varargs argument.

Comment by Andy Fingerhut [ 12/Jul/12 3:43 PM ]

Tassilo, with your patch 0001-CLJ-1024-Check-for-invalid-varags-destrucuring-uses.patch dated July 12, 2012, I get the following error message while testing, apparently because some metadata is missing on the new functions your patch adds to core:

[java] Testing clojure.test-clojure.metadata
[java]
[java] FAIL in (public-vars-with-docstrings-have-added) (metadata.clj:45)
[java] expected: (= [] (remove (comp :added meta) public-vars-with-docstrin
gs-not-generated))
[java] actual: (not (= [] (#'clojure.core/throw-on-varargs-and-destr #'cl
ojure.core/throw-on-varargs)))

Comment by Tassilo Horn [ 13/Jul/12 2:10 AM ]

Hi Andy, this updated patch declares the two new checking fns private which makes the tests pass again.

Stupid mistake by me: Of course, I've tested the last version, too, but afterwards I decided it wouldn't be bad to add some docstrings, and of course, adding docstrings cannot break anything.

Comment by Aaron Bedra [ 14/Aug/12 7:58 PM ]

Patch applies cleanly against 4004d267e124f12b65b0d7fb6522f32a75e3c4fb. Submitter confirmed as a CA signer.

Comment by Aaron Bedra [ 14/Aug/12 8:02 PM ]

This looks ok to me, but it seems like a fair amount of duplication to accomplish the task. It seems like we should just be able to ask if it is ok to proceed, instead of having to pick which function needs to be called in what case.

Comment by Tassilo Horn [ 15/Aug/12 1:23 AM ]

Aaron, can you please elaborate? I don't get what you mean with duplication and asking if it is ok to proceed.

Comment by Tassilo Horn [ 31/Aug/12 1:40 AM ]

Rebased to apply cleanly on master again.

Comment by Víctor M. Valenzuela [ 31/Aug/12 7:11 AM ]

Pardon the silly contribution, but the added methods' usage of double-negations (when-not ...) seems unnecessary.

Comment by Tassilo Horn [ 31/Aug/12 8:03 AM ]

Hi Victor, this revamped patch removes the double-negation and is more concise and clearer as a result. So your comment wasn't as silly as you thought.

Comment by Tassilo Horn [ 14/Feb/13 1:36 AM ]

Hey Stu, do you mind to explain why you've declined the patch?

Comment by Marek Srank [ 14/Feb/13 8:52 AM ]

@Tassilo: https://groups.google.com/forum/#!topic/clojure-dev/qjkW-cv8nog

Comment by Tassilo Horn [ 14/Feb/13 10:03 AM ]

@Marek, Stu: Thanks, I've left a reply there: https://groups.google.com/d/msg/clojure-dev/qjkW-cv8nog/rMNFqbjNj-EJ





[CLJ-1023] non-tail-position try block breaks mutable fields in deftype Created: 08/Jul/12  Updated: 03/Dec/12  Resolved: 03/Dec/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3, Release 1.4
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Stuart Sierra Assignee: Rich Hickey
Resolution: Declined Votes: 0
Labels: None

Attachments: File demonstration.clj    

 Description   

The :unsynchronized-mutable fields of a deftype cannot be set! inside a try block that is not in tail position of the method.

See file *demonstration.clj* for an complete code example.



 Comments   
Comment by Rich Hickey [ 05/Sep/12 7:07 AM ]

I looked at this. The problem is that non-tail try blocks turn into closures, and thus the field gets propagated as a constant. IOW this can't work:

(deftype Foo4 [^:unsynchronized-mutable x]
  MutableX
  (set-x [this v]
    ((fn [] (set! x v)))
    v))

I'm not going to re-evaluate the try/closure approach right now, so I recommend you make a helper method that just does the assignment and then call that in the bigger context, as a workaround.

Comment by Timothy Baldridge [ 03/Dec/12 10:55 AM ]

Closing this as it requires more than a simple bug fix. If you feel that Rich's work-around is unsatisfactory please create a clojure-dev discussion about rewriting try-catch.





[CLJ-1014] Latest Clojure master doesn't build Created: 14/Jun/12  Updated: 20/Jul/12  Resolved: 20/Jul/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.5
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Edward Z. Yang Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

Ubuntu 10.10 Maverick
Java 1.6.0_20m OpenJDK (IcedTea6 1.9.13)



 Description   

Compile fails with the following error:

compile-clojure:
[java] Compiling clojure.core to /home/ezyang/Dev/clojure/target/classes
[java] Compiling clojure.core.protocols to /home/ezyang/Dev/clojure/target/classes
[java] Compiling clojure.core.reducers to /home/ezyang/Dev/clojure/target/classes
[java] Exception in thread "main" java.lang.ClassNotFoundException: jsr166y.ForkJoinPool, compiling:(clojure/core/reducers.clj:56)
[java] at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6262)
[java] at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6262)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6223)
[java] at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5618)
[java] at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5054)
[java] at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3674)
[java] at clojure.lang.Compiler.analyzeSeq(Compiler.java:6453)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6262)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6223)
[java] at clojure.lang.Compiler$NewExpr$Parser.parse(Compiler.java:2478)
[java] at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6262)
[java] at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6262)
[java] at clojure.lang.Compiler.access$100(Compiler.java:37)
[java] at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518)
[java] at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6262)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6223)
[java] at clojure.lang.Compiler.compile1(Compiler.java:7030)
[java] at clojure.lang.Compiler.compile1(Compiler.java:7025)
[java] at clojure.lang.Compiler.compile1(Compiler.java:7025)
[java] at clojure.lang.Compiler.compile(Compiler.java:7097)
[java] at clojure.lang.RT.compile(RT.java:387)
[java] at clojure.lang.RT.load(RT.java:427)
[java] at clojure.lang.RT.load(RT.java:400)
[java] at clojure.core$load$fn__4919.invoke(core.clj:5424)
[java] at clojure.core$load.doInvoke(core.clj:5423)
[java] at clojure.lang.RestFn.invoke(RestFn.java:408)
[java] at clojure.core$load_one.invoke(core.clj:5236)
[java] at clojure.core$compile$fn__4924.invoke(core.clj:5435)
[java] at clojure.core$compile.invoke(core.clj:5434)
[java] at clojure.lang.Var.invoke(Var.java:415)
[java] at clojure.lang.Compile.main(Compile.java:81)
[java] Caused by: java.lang.ClassNotFoundException: jsr166y.ForkJoinPool
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
[java] at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:61)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
[java] at java.lang.Class.forName0(Native Method)
[java] at java.lang.Class.forName(Class.java:264)
[java] at clojure.lang.RT.classForName(RT.java:2043)
[java] at clojure.lang.Compiler$HostExpr.maybeClass(Compiler.java:957)
[java] at clojure.lang.Compiler$HostExpr.access$400(Compiler.java:736)
[java] at clojure.lang.Compiler$NewExpr$Parser.parse(Compiler.java:2473)
[java] at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
[java] ... 35 more



 Comments   
Comment by Andy Fingerhut [ 14/Jun/12 11:42 AM ]

What command did you use?

From the error message, my guess is that you ran "ant" without first running "./antsetup.sh". If that is the case, run "./antsetup.sh" first. This is a new step added to readme.txt on May 7, 2012, because of the jsr166y.ForkJoinPool class used within Clojure to implement the new parallel reducers feature.

Comment by Edward Z. Yang [ 14/Jun/12 2:16 PM ]

Yep, that's exactly it. Can we setup ant to warn people if antsetup.sh hasn't been run?

Comment by Andy Fingerhut [ 14/Jun/12 5:12 PM ]

I don't know. I suspect if it could be done and it were a straightforward modification, a patch for that would be accepted. I suspect those who created antsetup.sh would have simply modified the build.xml file for ant, and not created antsetup.sh at all, if it were easy to do so.

Comment by Roy Truelove [ 26/Jun/12 3:58 PM ]

It can be done with just the build.xml but requires the Maven Ant Tasks jar to be in the local ant's classpath, which is not ideal.

Because a local maven install is anyway required by antsetup.sh, IMHO it would be best to remove the ant build all together and stick with solely with a maven build, no?

Comment by Andy Fingerhut [ 27/Jun/12 1:16 PM ]

I can't find the email right now, but I believe in the past Rich Hickey has expressed a preference for continuing to have a way to build Clojure using ant.

Comment by Stuart Halloway [ 20/Jul/12 4:49 PM ]

Ant is there for the convenience of various dinosaurs, myself included. In general you should use the maven build, as that is what the CI and release process do.





[CLJ-1006] Quotient on bigdec may produce wrong result Created: 01/Jun/12  Updated: 01/Mar/13  Resolved: 09/Nov/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Defect Priority: Major
Reporter: laurent joigny Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: bug
Environment:

Linux 3.2.0-24-generic #39-Ubuntu SMP i686 GNU/Linux


Attachments: Java Source File TestBigDecimalQuotient.java    

 Description   

Hi,

As discussed on the mailing list in the message "When arithmetic on a computer bite back" (01/jun)

There may be bug in the way quotient is implemented for bigdec.

user> (quot 1.4411518807585587E17 2) ;; correct with doubles
7.2057594037927936E16
user> (quot 1.4411518807585587E+17M 2) ;; wrong with BigDecs
72057594037927935M


Laurent



 Comments   
Comment by laurent joigny [ 01/Jun/12 5:48 PM ]

I can reproduce the bug when using BigDecimal constructor on String.
See attached file for a test class.

More infos :
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu3)
OpenJDK Client VM (build 20.0-b12, mixed mode, sharing)

Comment by laurent joigny [ 01/Jun/12 5:49 PM ]

A simple test file, that you can drop in Clojure sources and execute to reproduce the bug on BigDecimal constructor using String as argument.

Comment by Tassilo Horn [ 03/Jun/12 4:30 AM ]

Seems to be a general precision problem. Note that in

user> (quot 1.4411518807585587E17 2) ;; correct with doubles
7.2057594037927936E16
user> (quot 1.4411518807585587E+17M 2) ;; wrong with BigDecs
72057594037927935M

the double result is actually wrong and the bigdec one is correct. The problem which lead to the wrong conclusion is that in your calculation the input number is already wrong.

So the moral is: don't use any floating points (neither doubles nor bigdecs) for computations involving divisibility tests.

For bigdecs, you can set the math context for making computations throw exceptions if they lose precision, though:

user> (binding [*math-context* (java.math.MathContext. 1 java.math.RoundingMode/UNNECESSARY)]
	       (quot (bigdec (Math/pow 2 58)) 2))
;Division impossible
;  [Thrown class java.lang.ArithmeticException]
Comment by Stuart Sierra [ 09/Nov/12 8:49 AM ]

Not a bug. Just floating-point arithmetic.





[CLJ-996] alter-var-root + protocol function call results in StackOverflow Created: 16/May/12  Updated: 01/Mar/13  Resolved: 09/Nov/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3, Release 1.4
Fix Version/s: None

Type: Defect Priority: Critical
Reporter: Dmitri Naumov Assignee: Unassigned
Resolution: Declined Votes: 1
Labels: None


 Description   

The following code:

(ns example.core)

(defprotocol Foo
  (foo [x]))

(extend-protocol Foo
  Object (foo [x] x)
  nil (foo [x] nil))

(defn apply-foo [f]
  (fn [& args]
    (foo (apply f args))))

(alter-var-root #'assoc apply-foo)

takes forever to compile from emacs+swank. Running from lein repl results in following:

user=> (use 'example.core)
StackOverflowError   clojure.lang.ArrayChunk.<init> (ArrayChunk.java:28)

If delete the foo call from the apply-foo:

(defn apply-foo [f]
  (fn [& args]
    (apply f args)))

then code compiles and executes fine.

This is true not only for assoc, but also for conj, into and possibly some other functions. Note also that crashes was seen even when the protocol function is not called, but there is call to satisfies? in the apply-foo function (although it's not clear for me how to reproduce it). Tested on clojure 1.3 and 1.4.



 Comments   
Comment by Tassilo Horn [ 11/Oct/12 1:23 PM ]

Is this bug a fairly well-constructed joke? I guess so.

But this is what I think happens: You change the value of #'assoc to the function returned by apply-foo. The alter-var-root call executes (apply-foo assoc) because assoc is the current value of #'assoc, thus the new value of #'assoc is {{(fn [& args] (foo (apply assoc args)))}}. However, fn is a macro that expands to fn* and calls destructure which uses assoc!!! So now foo gets called, and probably there's another assoc call during protocol dispatch, and there you have your non-terminating recursion.

So the lesson is: Don't alter core functions unless you're exactly knowing what you do.

Comment by Stuart Sierra [ 09/Nov/12 8:42 AM ]

Not a bug. You can't alter core functions and expect things not to break.





[CLJ-984] Expose minKey and maxKey on PersistentTreeSet Created: 05/May/12  Updated: 07/May/12  Resolved: 07/May/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Greg Chapman Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

I have found it occasionally useful to be able to get the minimum or maximum of a sorted set. PersistentTreeMap already has public minKey and maxKey methods; I suggest adding public minKey and maxKey methods to PersistentTreeSet (which obviously will just call the relevant methods on the impl map).



 Comments   
Comment by Greg Chapman [ 05/May/12 9:09 PM ]

Actually, on further reflection, I was too hasty in opening this. first combined with seq or rseq is good enough. If I could close this I would, but I don't see a way to do so.

Comment by Andy Fingerhut [ 07/May/12 12:05 PM ]

Closing this since submitter wishes it to be.





[CLJ-982] Implement an interface? predicate to balance class? Created: 04/May/12  Updated: 09/Jun/12  Resolved: 08/Jun/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.5
Fix Version/s: None

Type: Enhancement Priority: Trivial
Reporter: David Rupp Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: enhancement, patch, test
Environment:

Any


Attachments: File drupp-add-interface-predicate.diff    
Patch: Code and Test

 Description   

clojure.core implements a class? predicate to detect if a thing is an instance of java.lang.Class. The attached patch implements interface? to further distinguish classes that are also interfaces. This gives us Clojure api for e.g., enumerating all interfaces a thing's base class implements; as in, (filter #(interface? %) (supers (class my-thing))).



 Comments   
Comment by Stuart Halloway [ 08/Jun/12 12:28 PM ]

I would prefer to see this, and other interop/reflective items, in a separate contrib lib.

Comment by David Rupp [ 09/Jun/12 9:08 AM ]

Thanks for the feedback, Stu. Is there an existing contrib lib for stuff like this? Or should I create one?





[CLJ-967] java.io/do-copy can still garble multibyte characters on IBM JDK 1.5 and 1.6 Created: 07/Apr/12  Updated: 01/Mar/13  Resolved: 01/Mar/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2, Release 1.3, Release 1.4
Fix Version/s: Release 1.5

Type: Defect Priority: Minor
Reporter: Andy Fingerhut Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

At least Linux + IBM JDK 1.5, and Linux + IBM JDK 1.6


Attachments: Text File clj-886-improved-fix-for-ibm-jdks-patch2.txt     Text File clj-967-disable-failing-io-copy-tests-on-ibm-jdk-16-patch1.txt    
Patch: Code and Test
Approval: Not Approved

 Description   

Same issue as CLJ-886, but while the patch applied for that issue fixes the problem for many OS/JDK combos, there appear to be differences in how surrogate pair characters are handled in some OS/JDK combos. In particular, at least Linux + IBM JDK 1.5 and Linux + IBM JDK 1.6 still fail the tests checked in for do-copy.



 Comments   
Comment by Andy Fingerhut [ 07/Apr/12 9:32 AM ]

clj-886-improved-fix-for-ibm-jdks-patch2.txt dated Apr 7 2012 makes the tests pass with Linux + IBM JDK 1.5, as well as these other combos tested:

Linux + Oracle JDK 1.7
Linux + IBM JDK 1.5
Mac OS X 10.6.8 + Oracle/Apple JDK 1.6

There are still failing tests for Linux + IBM JDK 1.6. This patch currently skips the failing tests whenever the java.vendor is "IBM Corporation" and java.version is "1.6.0", so that "ant" succeeds. It is easy enough to modify the patch so that the failing tests are kept as a bright shining reminder. Let me know if that would be preferred – it just involves removing the function ibm-jdk16, and simplifying where it is called after replacing it with false.

Comment by Stuart Halloway [ 18/May/12 9:30 AM ]

Not sure if we should be in the business of building JDK-specific workarounds into our IO library, but marking this as screened.

Option B is to leave the code as-is and only disable the tests. Rich?

Comment by Rich Hickey [ 18/May/12 2:42 PM ]

Please disable the tests. We shouldn't be doing such workarounds.

Comment by Andy Fingerhut [ 19/May/12 2:50 AM ]

clj-967-disable-failing-io-copy-tests-on-ibm-jdk-16-patch1.txt dated May 19, 2012 disables tests of clojure.java.io/copy that fail with IBM JDK 1.6.0. It makes minor changes to the clojure.java.io code file, but these are only to eliminate uses of reflection, and to make a few of the versions of do-copy share more of their implementation code.

Tested that all results are good on Mac OS X 10.6.8 + Oracle/Apple JDK 1.6.0 and Ubuntu 11.10 + Oracle JDK 1.7.0, including that the number of tests run are identical to before this patch. Only 2 tests are disabled on IBM JDK 1.6.0, and all of the rest pass before and after these changes.

Comment by Andy Fingerhut [ 19/May/12 3:22 AM ]

Hoping that I'm not out of line changing approval from Incomplete to None after attaching a patch that should address the reason it was marked incomplete. The only other way to get a ticket out of Incomplete state is for a core team member to do it for me, which seems like busy-work.

Comment by Andy Fingerhut [ 30/Aug/12 2:13 PM ]

Any comments from Rich or other screeners on the status of this one? Just curious, since it seemed to have been screened, and then quietly tossed back into the unscreened pile. Is it considered undesirable to disable selected tests for a particular JDK as the patch clj-967-disable-failing-io-copy-tests-on-ibm-jdk-16-patch1.txt does? My motivation was to selectively disable only the tests that fail, and only on the JDK where they fail, leaving all passing tests to continue to run wherever possible.





[CLJ-956] [java.lang.ClassFormatError: Duplicate method name&signature] when using gen-class Created: 20/Mar/12  Updated: 01/Mar/13  Resolved: 09/Nov/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Daniel Ribeiro Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: AOT
Environment:

$ java -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)



 Description   

Hi,

When extending a class that defines a method with the signature "public void load();", I get the following load time error:

java.lang.ClassFormatError: Duplicate method name&signature

Looking into javap, I see that in fact gen-class is generating two entries for the load method. Prefix does not help in this case, as the defined load method is generated anyway.

Cheers,

  • Daniel


 Comments   
Comment by Daniel Ribeiro [ 22/Mar/12 5:10 AM ]

Hi,

I've create this small sample project to exemplify the bug ocurring: https://github.com/danielribeiro/ClojureBugReport

Cheers,

  • Daniel
Comment by Daniel Ribeiro [ 24/Mar/12 6:57 PM ]

Note that the name load is not special: it works with any abstract method, no matter the name.

Comment by Daniel Ribeiro [ 24/Mar/12 7:34 PM ]

Not a bug: I was declaring the method load, which was already defined on the abstract class. The docs do mention this:

http://clojuredocs.org/clojure_core/clojure.core/gen-class

Comment by Stuart Sierra [ 09/Nov/12 8:40 AM ]

Closed as not-a-bug.





[CLJ-951] Clojure 1.3+ can't intern a dynamic var Created: 09/Mar/12  Updated: 30/Nov/12  Resolved: 30/Nov/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3, Release 1.4
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Ryan Senior Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Approval: Not Approved

 Description   

In Clojure 1.3+, interned vars don't set the dynamic field in clojure.lang.Var and can't be used in a binding:

user=> (intern ns (with-meta 'dyna-var {:dynamic true}) 100)
user=> (binding [dyna-var "one hundred"] dyna-var)
;=> IllegalStateException Can't dynamically bind non-dynamic var: user/dyna-var clojure.lang.Var.pushThreadBindings (Var.java:339)

The var has the right metadata

user=> (meta #'dyna-var)
;=> {:ns #<Namespace user>, :name dyna-var, :dynamic true}

But doesn't set the dynamic flag on the var:

user=> (.isDynamic #'dyna-var)
;=> false

The push-thread-bindings function looks for the .dynamic flag. Vars created via def have it:

user=> (def ^:dynamic def-dyna-var 100)
user=> (.isDynamic #'def-dyna-var)
;=> true

Along with the metadata

user=> (meta #'def-dyna-var)
{:ns #<Namespace user>, :name def-dyna-var, :dynamic true, :line 6, :file "NO_SOURCE_PATH"}



 Comments   
Comment by Timothy Baldridge [ 30/Nov/12 3:57 PM ]

This is actually an enhancement. The Var.java and Namespace.java code does not attempt to read the metadata on the var. Instead, the compiler handles this at compile time. If you would like to see this behavior changed, feel free to bring it up on clojure-dev, and we'll discuss it.

Closing until that time.





[CLJ-950] Function literals behavior differ from that of fns Created: 08/Mar/12  Updated: 01/Mar/13  Resolved: 08/Mar/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Víctor M. Valenzuela Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: reader


 Description   

((fn [] true)) ; true
(#(true)) ; classcast exception

((fn [])) ; nil
(#()) ; ()

(some (fn [_]_) [nil false 0 1]) ; 0
(some #(%) [nil false 0 1]) ; NPE



 Comments   
Comment by Tassilo Horn [ 08/Mar/12 12:27 PM ]

This is no defect. Function literals must have a function (or macro or special form) as first symbol.
So your examples should be written like so:

user> (#(do true))
true
user> (#(do))
nil
user> (some #(do %) [nil false 0 1])
0
Comment by Víctor M. Valenzuela [ 08/Mar/12 2:10 PM ]

It makes sense. However (and correct me if I'm wrong) there should be little problem in making them fully equivalent to fns, resulting in a more concise and consistent API.

Please consider re-opening the issue as a feature request.

Regards - Víctor.

Comment by Tassilo Horn [ 09/Mar/12 1:26 AM ]

The reader docs at http://www.clojure.org/reader say that #() is not a replacement for (fn [] ...). You can't make it more equivalent to fn without making it much harder to understand. Let me explain that with an example.

(defn get-time []
  (System/currentTimeMillis))

(#(get-time)) ;; What's the result?

What's the result of the funcall above? Clearly, right now, it is the current system time.

So if we decided to allow to write #(true) as an alternative to (constantly true) [which is a varargs fn] or #(do true) [which is a fn of zero args], then valid values of #(get-time) where both the current system time but also the function object for get-time. Functions are values, too.

Ok, one could say that in the case of a function, #(function) is always a call, but it would make it harder to reason about what the code does for not much benefit.

Comment by Víctor M. Valenzuela [ 09/Mar/12 7:56 AM ]

You're right - satisfying my request would require to change the average use of this feature to #((some_fn %1 %2)) rather than just #(some_fn %1 %2), if we wanted #(true) to be valid. Which indeed would be barely handy.

Thank you.





[CLJ-945] clojure.string/capitalize can give wrong result if first char is supplementary Created: 05/Mar/12  Updated: 01/Mar/13  Resolved: 01/Mar/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2, Release 1.3, Release 1.4
Fix Version/s: Release 1.5

Type: Defect Priority: Minor
Reporter: Andy Fingerhut Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

all


Attachments: Text File capitalize-for-supplementary-chars-patch.txt    
Patch: Code and Test
Approval: Not Approved

 Description   

When the first unicode code point of a string is supplementary (i.e. requires two 16-bit Java chars to represent in UTF-16), and that first code point is changed by converting it to upper case, clojure.string/capitalize gives the wrong answer.



 Comments   
Comment by Rich Hickey [ 20/Jul/12 7:43 AM ]

Isn't this a Java bug?

Comment by Andy Fingerhut [ 20/Jul/12 12:36 PM ]

If using UTF-16 to encode Unicode strings, and making every UTF-16 code unit (i.e. Java char) individually indexable as a separate entity in strings, is such a bad design choice that you consider it a bug, then yes, this is a Java bug (and a bug in all the other systems that use UTF-16 in this way).

clojure.string/capitalize isn't using some Java capitalization method that has a bug, though. By calling (.toUpperCase (subs s 0 1)) it is not giving enough information to .toUpperCase for any implementation, Java or otherwise, to do the job correctly. It is analogous to calling toupper on the least significant 4 bits of the ASCII encoding of a letter and expecting it to return the correct answer.





[CLJ-926] Instant literals do not round trip correctly Created: 05/Feb/12  Updated: 17/Feb/12  Resolved: 17/Feb/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.4
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Cosmin Stejerean Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: instant, reader, tagged-literals

Attachments: Text File CLJ-926-round-trip-date-instants-with-tests.patch    
Patch: Code and Test
Approval: Screened
Waiting On: Stuart Sierra

 Description   

When using java.util.Date for instant literals (which is the default) instants do not round-trip properly during daylight savings. Here is an example:

(read-string "#inst \"2010-11-12T13:14:15.666-06:00\"")
#inst "2010-11-13T06:14:15.666+10:00"

I'm currently in Melbourne, which is normally GMT+10. However, on November 12th daylight savings is in effect, so the proper GMT offset is +11. The date above is actually using the correct local time (6:14:15) but with the wrong offset. The problem is more obvious when you attempt to round-trip the instant that was read.

user> #inst "2010-11-13T06:14:15.666+10:00"
#inst "2010-11-13T07:14:15.666+10:00"

Notice that we read 6:14am but the output was 7:14 with the same offset. Upon digging deeper the real culprit seems to be the use of String.format (through clojure.core/format) when outputting java.util.Date. Notice the following inside caldate->rfc3339

(format "#inst \"%1$tFT%1$tT.%1$tL%1$tz\"" d))

Let's compare the timezone offset in the underlying date with what is printed by %1$tz

user> (def d #inst "2010-11-13T06:14:15.666+10:00")
#'clojure.instant/d                                                                                                                                                                                         
user> (.getHours d)
7                                                                                                                                                                                                           
user> (.getTimezoneOffset d)
-660

For reference, the definition of getTimezoneOffset is

-(Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / (60 * 1000)

So far it looks good. 6am in GMT+10 becomes 7am in GMT+11. Let's see how String.format handles it though.

                                                                                               
clojure.instant> (format "%1$tz" d)
"+1000"                                                                                                                                                                                                     
clojure.instant> (format "%1$tT" d)
"07:14:15"

String.format prints the correct hour, but with the wrong offset. The recommended way for formatting dates is to use a DateFormatter.

The String.format approach appears to work properly for Calendar, but not for Date. Therefore the attached patch keeps the current
implementation for java.util.Calendar but uses SimpleDateFormat to handle java.util.Date correctly. This fixes the roundtrip problem.



 Comments   
Comment by Cosmin Stejerean [ 05/Feb/12 9:29 PM ]

Not quite sure how to create a repeatable test for this since the issue depends on the local timezone.

Comment by Steve Miner [ 06/Feb/12 8:33 AM ]

java.util.TimeZone/setDefault could be used for testing in various timezones.

Comment by Steve Miner [ 06/Feb/12 8:37 AM ]

Regarding the patch: SimpleDateFormat is a relatively heavy-weight object, so it seems bad to allocate one every time you print a Date. Unfortunately, SimpleDateFormat is not thread-safe, so you can't just share one. The Java world seems to agree that you should use JodaTime instead, but if you're stuck with the JDK, you need to have a ThreadLocal SimpleDateFormat. I'm working on my own patch along those lines.

Comment by Fogus [ 06/Feb/12 7:38 PM ]

Excellent analysis. I'll keep track of this case and vet any patches that come along. Please do attach a regression test if possible.

Comment by Cosmin Stejerean [ 06/Feb/12 8:39 PM ]

I attached a new patch using a SimpleDateFormat per thread using a thread local. I'll try to add some tests next.

Comment by Cosmin Stejerean [ 06/Feb/12 10:42 PM ]

A combined patch that uses a thread local SimpleDateFormat, tests round-tripping at a known daylight savings point (by overriding the default timezone) and checks round tripping at multiple points throughout the year (every hour of the first 4 weeks of every month of the year).

Steve, thanks for the suggestions on using a thread local and TimeZone/setDefault.

Comment by Steve Miner [ 07/Feb/12 1:32 PM ]

I filed CLJ-928 with my patch for fixing the printing of Date and Timestamp using UTC. I copied the tests from the CLJ-926 patch to make sure we're compatible.

Comment by Fogus [ 07/Feb/12 3:11 PM ]

Thanks for the regression test also. I'll vett this patch ASAP.

Comment by Fogus [ 17/Feb/12 1:24 PM ]

Seems reasonable to me.

Comment by Stuart Sierra [ 17/Feb/12 1:46 PM ]

Vetted. Will apply later.

Comment by Stuart Sierra [ 17/Feb/12 1:56 PM ]

Not Vetted. Test. That thing.

Comment by Stuart Sierra [ 17/Feb/12 2:10 PM ]

No, it's "Screened," not "Test." Somebody save me.

Comment by Stuart Sierra [ 17/Feb/12 3:55 PM ]

Superseded by CLJ-928.





[CLJ-922] Transient maps lose values Created: 31/Jan/12  Updated: 31/Jan/12  Resolved: 31/Jan/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3, Release 1.4
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Carl Lerche Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

OS X, java 1.6.0_29


Attachments: File bug.clj    

 Description   

I have tested this on the latest clojure 1.4 alpha (1.4.0-alpha5).

I am not exactly sure what the problem is w/ transient maps, but at a certain point they appear to lose values (values that are inserted into the maps w/ assoc! do not get saved).

I have a test script that illustrates this bug:

https://gist.github.com/497879a727dabac46ec3

All the values up to content-length are saved, but content-length never makes it into the transient map.



 Comments   
Comment by Tassilo Horn [ 31/Jan/12 1:20 AM ]

This is no bug, but you use assoc! wrongly. Just like with assoc, you need to use the return value of the call instead of "bashing the transient map in place". I.e., in your code, replace the doto with ->, which threads the result of each assoc! call to the next one, returning the last value.

BTW: This came up on the list the last days, too. See:

https://groups.google.com/d/msg/clojure/rmLLnRx5p3U/10GYNQdTVksJ

Comment by Tassilo Horn [ 31/Jan/12 1:21 AM ]

This is no bug but a usage error.





[CLJ-913] slurp fails on /proc files (linux) Created: 19/Jan/12  Updated: 01/Mar/13  Resolved: 29/Feb/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Romain Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

linux



 Description   

On my machine,
(slurp "/proc/cpuinfo")
fails with:
java.io.IOException: Argument invalide (NO_SOURCE_FILE:0)

whereas the following succeeds:
(with-open [f (java.io.FileReader. "/proc/cpuinfo")] (slurp f))



 Comments   
Comment by Tassilo Horn [ 23/Jan/12 8:57 AM ]

It seems this is not an error in Clojure but an error in the native implementation of FileInputStream.available(). For example, this Java code throws the same exception.

    FileInputStream fis = new FileInputStream("/home/horn/dead.letter");
    System.out.println(fis.available());  // Works fine

    fis = new FileInputStream("/proc/cpuinfo");
    System.out.println(fis.available());  // IOException is thrown

Tested with sun-jdk 1.6.0.29 and IcedTea 7.2.0.

Comment by Andy Fingerhut [ 20/Feb/12 7:42 PM ]

This is not a fix, but a workaround for this issue with the JVM: call slurp on a reader that you force to be constructed as unbuffered. For example:

(slurp (java.io.InputStreamReader. (java.io.FileInputStream. "/proc/cpuinfo")))

(tested with Sun/Oracle JDK 1.7.0_02)

This is less efficient for large files, so I wouldn't recommend that the slurp code be modified to work this way for all files.

One can imagine an implementation of Clojure slurp and clojure.java.io/reader that first tried the slurp call with buffered I/O, and if an exception like this one occurs fall back to unbuffered I/O. However, that sounds like it would get very hairy very quickly, and would be difficult to write it in such a way that it did not mask I/O errors that should be visible to the caller. Also that seems like unwanted complexity in Clojure to work around what is likely a bug in the JVM. Someone (Tassilo?) filed a bug with Oracle about this exception:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7132461

Comment by Andy Fingerhut [ 29/Feb/12 1:06 AM ]

I contacted Romain, the submitter, and they agreed that trying to work around this JVM bug in Clojure's slurp might be a bit excessive, and that closing the ticket was reasonable.

I have added a note about Romain's workaround at http://clojuredocs.org/clojure_core/1.3.0/clojure.core/slurp in hopes that others will be able to find it more easily.





[CLJ-912] clojure.java.browse/browse-url fails to open http://localhost:3000 with swing backend Created: 17/Jan/12  Updated: 12/Mar/12  Resolved: 12/Mar/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Dmitri Naumov Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

I've got the following exception after launching (clojure.java.browse/browse-url "http://localhost:3000"):

java.lang.RuntimeException: java.io.FileNotFoundException: http://localhost:3000
at clojure.lang.Util.runtimeException(Util.java:165)
at clojure.lang.Reflector.invokeConstructor(Reflector.java:193)
at clojure.java.browse_ui$open_url_in_swing.invoke(browse_ui.clj:15)
at clojure.lang.Var.invoke(Var.java:401)
at clojure.java.browse$open_url_in_swing.invoke(browse.clj:44)
at clojure.java.browse$browse_url.invoke(browse.clj:52)
at user$eval1689.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at swank.commands.basic$eval_region.invoke(basic.clj:47)
at swank.commands.basic$eval_region.invoke(basic.clj:37)
at swank.commands.basic$eval845$listener_eval__846.invoke(basic.clj:71)
at clojure.lang.Var.invoke(Var.java:401)
at user$eval1687.invoke(NO_SOURCE_FILE)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at swank.core$eval_in_emacs_package.invoke(core.clj:92)
at swank.core$eval_for_emacs.invoke(core.clj:239)
at clojure.lang.Var.invoke(Var.java:409)
at clojure.lang.AFn.applyToHelper(AFn.java:167)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.core$apply.invoke(core.clj:600)
at swank.core$eval_from_control.invoke(core.clj:99)
at swank.core$eval_loop.invoke(core.clj:104)
at swank.core$spawn_repl_thread$fn_527$fn_528.invoke(core.clj:309)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.core$apply.invoke(core.clj:600)
at swank.core$spawn_repl_thread$fn__527.doInvoke(core.clj:306)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.io.FileNotFoundException: http://localhost:3000
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1458)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1452)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1106)
at javax.swing.JEditorPane.getStream(JEditorPane.java:827)
at javax.swing.JEditorPane.setPage(JEditorPane.java:433)
at javax.swing.JEditorPane.setPage(JEditorPane.java:939)
at javax.swing.JEditorPane.<init>(JEditorPane.java:273)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at clojure.lang.Reflector.invokeConstructor(Reflector.java:183)
... 32 more
Caused by: java.io.FileNotFoundException: http://localhost:3000
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1401)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:397)
at javax.swing.JEditorPane.getStream(JEditorPane.java:792)
... 40 more

It works with urls like http://google.com:80, so probably the problem is in the combination of one-segment domen and port.

Note: I use Ubuntu 11.10 with Chromium as a default browser. I'm not sure why browse-url fails to open urls via standart browser. Should I create another issue for that or is it a java problem?



 Comments   
Comment by Andy Fingerhut [ 29/Feb/12 1:38 PM ]

Dmitri: CLJ-896 has a patch that changes browse-url to use the command line tool xdg-open instead of Java Swing. If the command:

xdg-open http://localhost:3000

works on your system from the command line, then that patch will probably also make (browse-url "http://localhost:3000") work, too.

I tried (browse-url "http://localhost:3000") on an Ubuntu 10.04 LTS system using Sun/Oracle's JVM 1.6.0_26, and it worked. Which JVM are you using?

Comment by Dmitri Naumov [ 12/Mar/12 1:09 PM ]

I tried it again and now I can't reproduce it - browse-url works as expected and Swing gui also works when launched manually. I use openjdk, so maybe it was a problem with its classes? Anyway, the issue should be closed.
Sorry for bothering you.

Comment by Andy Fingerhut [ 12/Mar/12 1:17 PM ]

I'm not sure if this should be marked with a Resolution of Declined or Completed, if the issue cannot be reproduced. I'm picking Declined for this change. Feel free to change it if I've picked incorrectly.

Comment by Dmitri Naumov [ 12/Mar/12 1:24 PM ]

Yeah, I also think Declined is correct.





[CLJ-907] records do not enforce type hints Created: 08/Jan/12  Updated: 01/Mar/13  Resolved: 27/Nov/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2, Release 1.3
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Chip Salzenberg Assignee: Unassigned
Resolution: Declined Votes: 1
Labels: None

Approval: Not Approved

 Description   

Specify a record with a field as say ^String, but the constructor won't throw if you pass in a non-String.



 Comments   
Comment by Alan Malloy [ 10/Jan/12 4:59 PM ]

I doubt there's any desire to change this. Records only support typehints to enable performant storage of primitive types like ints, not to provide static typing in general. An Object is stored the same way as a String, so there's no need to pay attention to that typehint.

Functions behave the same way: ((fn [^String x] x) :test) works just fine. Only if you use a member method of the hinted type (such as .substring in this example) is an exception thrown then the compiler casts to String in order to call the method.

Comment by Chip Salzenberg [ 10/Jan/12 5:08 PM ]

I don't understand how you get from "this is how it is" to "this is how it is meant to be." The compiler can do a better job if the underlying field is properly typed: Type errors can be caught sooner, and cast operations can be omitted on use. This is a worthy enhancement.

Comment by Timothy Baldridge [ 27/Nov/12 1:52 PM ]

Alan is correct, the reason type hints exist is to reduce reflection and to allow for the unboxing of primitives. String is not a primitive and therefore type-hinting it only reduces the amount of reflection performed.

It has always been Rich's policy that any type systems used in Clojure should not throw compile time errors, but instead should only enhance the performance of existing code. (see the implementation of Typed Clojure for more info on this).

Closing this issue, as it is by design.

Comment by Timothy Baldridge [ 27/Nov/12 1:52 PM ]

By design.





[CLJ-906] defrecord with protocol implementation fails when field and method names collide Created: 01/Jan/12  Updated: 01/Mar/13  Resolved: 27/Nov/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2, Release 1.3
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Brian Stiles Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Approval: Not Approved

 Description   

The following produces a NullPointerException:

(defprotocol Foo (act [this]))
(defrecord Fred []
Foo
(act [this] (println "done.")))
(defrecord Bar [act] ;; <<<<<======= Field name is the same as method name.
Foo
(act [this] (act (Fred.)))) ;; <<<<<====== Behaves as (nil (Fred.))
(act (Bar. nil))

Produces:
Exception in thread "main" java.lang.NullPointerException
at protocol.Bar.act(protocol.clj:8)
at protocol$eval66.invoke(protocol.clj:9)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.load(Compiler.java:6902)
at clojure.lang.Compiler.loadFile(Compiler.java:6863)
at clojure.main$load_script.invoke(main.clj:282)
at clojure.main$script_opt.invoke(main.clj:342)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:401)
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)

The following works as expected:

(defprotocol Foo (act [this]))
(defrecord Fred []
Foo
(act [this] (println "done.")))
(defrecord Bar [x] ; <<== Field name is the DIFFERENT than method name
Foo
(act [this] (act (Fred.))))
(act (Bar. [1 2 3]))

Produces:
"done."

The following also works:

(defprotocol Foo (act [this]))
(defrecord Fred [])
(defrecord Bar [act]) ; <<== Field name is the same as method name
(extend-protocol Foo
Fred
(act [this] (println "done."))
Bar
(act [this] (act (Fred.))))
(act (Bar. [1 2 3]))



 Comments   
Comment by Timothy Baldridge [ 27/Nov/12 2:03 PM ]

The thing to remember here is that protocol functions are not (only) methods on a class, they are functions global to the namespace. So notice the subtle difference here:

user=> (defprotocol Foo (act [this]))
Foo
user=> (defrecord Fred [act] Foo (act [this] (act this)))
user.Fred
user=> (Fred. 42)
#user.Fred{:act 42}
user=> (act (Fred. 42))
ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn user.Fred (NO_SOURCE_FILE:1)

user=> (defrecord Fred [act] Foo (act [this] (user/act this)))
user.Fred
user=> (act (Fred. 42))
StackOverflowError user.Fred (NO_SOURCE_FILE:1)

So, it you want to access the data, you can use "act" directly, if you want to recursively call act (the protocol function), you can use recur, or the fully qualified name. Also, since these are records we're talking about, the following also works:

user=> (defrecord Fred [act] Foo (act [this] (:act this)))
user.Fred
user=> (act (Fred. 42))
42

Comment by Timothy Baldridge [ 27/Nov/12 2:07 PM ]

Declined since this is not really a bug. There is a work-around and no obvious solution to the more general problem of defrecord name collisions. If this still bugs you, please feel free to bring it up on clojure-dev, and we'll open a new ticket once a discussion has been had.





[CLJ-901] implementation of doc macro in core.repl incorrect for special names... add one character to fix Created: 23/Dec/11  Updated: 01/Mar/13  Resolved: 28/Feb/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Trivial
Reporter: Daniel Eklund Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

In the implementation of the doc macro in core.repl, the line:
(if-let [special-name ('{& fn catch try finally try} name)]
contains:{& fn catch try finally try} which is a hashmap.

It should be a set, and the line should read:
(if-let special-name ('#{& fn catch try finally try} name)

To see the bug at work:
user> (doc &)
-------------------------
clojure.core/fn
(fn name? [params*] exprs*)
(fn name? ([params*] exprs*) +)
Special Form
params => positional-params* , or positional-params* & next-param
positional-param => binding-form
next-param => binding-form
name => symbol

Defines a function

Please see http://clojure.org/special_forms#fn



 Comments   
Comment by Andy Fingerhut [ 17/Feb/12 12:06 AM ]

Daniel, I'm pretty sure it is intended to be a map, not a set. The goal is to show the same documentation for try whether you ask for the documentation of try, catch, or finally. Also, to show the documentation for fn if you ask for the documentation of &, since that symbol is only useful in arg lists in fn (or let). They could have put multiple entries in special-doc-map and not had that little map inside doc, but that little map avoided the need for such duplication.

Comment by Daniel Eklund [ 28/Feb/12 7:34 PM ]

100% agree. It was an incorrect report on my part. Thanks for clearing it up.

Comment by Andy Fingerhut [ 28/Feb/12 8:04 PM ]

Daniel asked me to change the state of the ticket, since he could not see how to (perhaps insufficient privileges). Not sure if it should be marked Closed or Resolved, so I'm picking Resolved.





[CLJ-894] Better reduce performance Created: 09/Dec/11  Updated: 13/Apr/12  Resolved: 13/Apr/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Backlog
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Mike Anderson Assignee: Unassigned
Resolution: Declined Votes: 2
Labels: None

Attachments: Text File clj-894-better-reduce-performance-patch2.txt    
Patch: Code and Test

 Description   

Currently reduce is implemented in Clojure by calling seq on a collection. Construction of an entire new seq is an unnecessary and expensive operation, particularly for the key persistent collections (map, set and vector suffer - list is not a problem because it implements ISeq directly for free).

This patch proposes to improve this by doing the following:
1. Make use of a Java interface for reducible collections (IReduce)
2. Make persistent collections support implementations of reduce
directly by implementing IReduce
3. Modify the internal-reduce protocol to operate on concrete
collections (not just seqs) and make use of IReduce implementations
where available
4. Change reduce itself to call internal-reduce directly rather than
calling seq first



 Comments   
Comment by Mike Anderson [ 09/Dec/11 3:58 AM ]

Link to initial discussion on Clojure Dev Google Group

http://groups.google.com/group/clojure-dev/browse_frm/thread/bdab332c4e47721f?hl=en

Comment by Mike Anderson [ 09/Dec/11 3:59 AM ]

Link to experimental implementation on GitHub:

https://github.com/mikera/clojure/tree/better-reduce

Comment by Mike Anderson [ 09/Dec/11 4:00 AM ]

Performance testing shows approx 2x speedup for relevant operations:

Clojure 1.3.0
(def ms (zipmap (range 100) (range 100)))
#'user/ms
user=> (dotimes [i 10] (time (dotimes [i 100000] (reduce (fn [acc [k
v]] (+ acc v)) 0 ms))))
"Elapsed time: 646.512414 msecs"
"Elapsed time: 553.264593 msecs"
"Elapsed time: 544.999672 msecs"
"Elapsed time: 510.606868 msecs"
"Elapsed time: 513.192451 msecs"
"Elapsed time: 537.665664 msecs"
"Elapsed time: 524.166514 msecs"
"Elapsed time: 512.966964 msecs"
"Elapsed time: 501.677219 msecs"
"Elapsed time: 496.379194 msecs"

Clojure 1.4.0-alpha2
user=> (def ms (zipmap (range 100) (range 100)))
#'user/ms
user=> (dotimes [i 10] (time (dotimes [i 100000] (reduce (fn [acc [k
v]] (+ acc v)) 0 ms))))
"Elapsed time: 548.822683 msecs"
"Elapsed time: 469.275299 msecs"
"Elapsed time: 464.742096 msecs"
"Elapsed time: 443.500129 msecs"
"Elapsed time: 431.272138 msecs"
"Elapsed time: 430.514649 msecs"
"Elapsed time: 432.753752 msecs"
"Elapsed time: 431.195876 msecs"
"Elapsed time: 435.254274 msecs"
"Elapsed time: 433.516375 msecs"

Clojure 1.4.0 snapshot (with better reduce modifications)
(def ms (zipmap (range 100) (range 100)))
#'user/ms
user=> (dotimes [i 10] (time (dotimes [i 100000] (reduce (fn [acc [k
v]] (+ acc v)) 0 ms))))
"Elapsed time: 202.29696 msecs"
"Elapsed time: 186.589505 msecs"
"Elapsed time: 179.691805 msecs"
"Elapsed time: 184.191644 msecs"
"Elapsed time: 183.265131 msecs"
"Elapsed time: 180.162578 msecs"
"Elapsed time: 182.323219 msecs"
"Elapsed time: 181.810649 msecs"
"Elapsed time: 182.896285 msecs"
"Elapsed time: 187.30153 msecs"

Comment by Mike Anderson [ 19/Feb/12 4:03 AM ]

better_reduce branch now updated to merge in the latest changes from the clojure/clojure master branch.

Comment by Brian Taylor [ 19/Feb/12 1:29 PM ]

Reviewers:

To make this change easier to review (and for a cleaner history), I mashed all of the commits that make up this change together and rebased that onto the latest from clojure/clojure master.

https://github.com/netguy204/clojure/tree/better-reduce
https://github.com/netguy204/clojure/commit/b262a69c32d26bb6f3c5ba711310361d77609a22

Hope it helps.

Comment by Mike Anderson [ 19/Feb/12 6:24 PM ]

Awesome, thanks Brian! I must admit that my git-fu is not yet good enough to do things like this, so your help is much appreciated!

Comment by Andy Fingerhut [ 23/Feb/12 1:52 AM ]

clj-894-better-reduce-performance-patch1.txt was created from pulling Brian Taylor's Clojure github repo, creating a diff of it, applying it to latest master as of Feb 22, 2012, and making a properly formatted patch from it. It has only a single commit, and has Mike Anderson's name and email address in it, along with a date of 4 Dec 2011, when it appears he made his final commit of this work. It compiles and tests cleanly, and I have run Mike's timing experiments and seen similar speed improvements.

No docstrings need changing that I can think of. Mike and I have both signed CAs. I don't see Brian Taylor's name on the list of those who signed a CA, but as long as the patch contains only code that Mike wrote, it should be clean. Patch status is "Code and Test".

Comment by Andy Fingerhut [ 23/Feb/12 2:00 AM ]

Correcting Mike's name and email address in patch.

Comment by Brian Taylor [ 23/Feb/12 5:08 AM ]

The patch contains only code that Mike wrote.

Comment by Mike Anderson [ 23/Feb/12 7:32 AM ]

Thanks guys I've reviewed the patch and can confirm that it looks like exactly the changes I intended to make. I am happy for them to be committed as per my signed CA.

Comment by Rich Hickey [ 13/Apr/12 8:05 AM ]

Similar objective now achieved via a protocol:
https://github.com/clojure/clojure/commit/1f90942690d5395330347cb31fdb3d69cea1ec56





[CLJ-883] Clojure head holding bug Created: 27/Nov/11  Updated: 01/Mar/13  Resolved: 27/Nov/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Gerrard McNulty Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

java 6 jdk on linux, jre 6 on windows 7


Approval: Not Approved

 Description   

I've a head holding problem that I believe is a bug in clojure 1.3. I
wrote the following function to split a a lazy seq of strings across
files of x size:

(defn split-file
 ([path strs size]
    (trampoline split-file path (seq strs) size 0))
 ([path strs size part]
    (with-open [f (clojure.java.io/writer (str path "." part))]
      (loop [written 0, ss strs]
        (when ss
          (if (>= written size)
            #(split-file path ss size (inc part))
            (let [s (first ss)]
              (.write f s)
              (recur (+ written (.length s)) (next ss)))))))))

If I call the 3 arg version of the function:
(split-file "foo" (repeat 100000000 "blah blah blah") 100000000)

I see memory usage increases as I'm writing each file with the usual
gc slow down, then memory usage goes back down again as I get to a new
split file.

Memory usage is fine if I call the 4 arg version (which only writes
one part of the split file):
(split-file "foo" (repeat 100000000 "blah blah blah") 100000000 0)

I can also avoid the head holding problem by removing trampoline and
recursively calling split-file directly, but then those recursive
calls use up stack and don't close files until all calls complete



 Comments   
Comment by a_strange_guy [ 16/Jan/12 4:15 AM ]

There is actually no problem with head retention in your code.
It's zust the garbage collector that doesn't collect the seq right away. If there were problems, then you would get a OutOfMemoryError pretty fast.

compare
(split-file "foo" (repeat 100000000 "blah blah blah") 100000000 0)
with
(doall (repeat 100000000 "blah blah blah"))
to see the difference

Comment by Timothy Baldridge [ 27/Nov/12 2:29 PM ]

Closing due to lack of reproducible tests. On my system I actually saw memory usage not move at all when I ran the demo code, and at one point the GC kicked in and the memory usage went down a bit.





[CLJ-877] contains? is broken for vectors Created: 14/Nov/11  Updated: 14/Nov/11  Resolved: 14/Nov/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Critical
Reporter: Jeff Palmucci Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

OSX Lion



 Description   

contains? returns the wrong result for the last item in a vector:

user> (map #(contains? [1 2 3 4] %) [1 2 3 4])
(true true true false)



 Comments   
Comment by Steve Miner [ 14/Nov/11 12:41 PM ]

This is not a bug. Check the doc – contains? refers to the keys of the collection, not the values. For a vector, the "keys" are the indices.

user=> (map #(contains? [10 20 30 40] %) (range 4))
(true true true true)

Comment by Ben Smith-Mannschott [ 14/Nov/11 12:45 PM ]

This is a (common) misusing of contains?. Perhaps it would have been better if contains? had been named contains-key?, but that ship has sailed.

Usage: (contains? coll key)

Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'.

A vector of length 4 has four keys (indexes): 0, 1, 2, 3, which is why your example is returning (true true true false).

To get the behavior your are expecting from contains?, use some:

Usage: (some pred coll)

Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)

user> (map #(some #{%} [1 2 3 4]) [1 2 3 4])
(1 2 3 4) ; all of which are truthy

If you prefer booleans, you could do something like this:

user> (map (comp boolean #(some #{%} [1 2 3 4])) [1 2 3 4])
(true true true true)




[CLJ-875] Clojure's seq, keys, and vals can produce inconsistent values on strange iterators (e.g., IdentityHashMap) Created: 11/Nov/11  Updated: 02/Dec/11  Resolved: 02/Dec/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3, Release 1.4
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Jason Wolfe Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

user> clojure-version
{:major 1, :minor 4, :incremental 0, :qualifier "alpha1"}
user> (def x (keys (java.util.IdentityHashMap. {:a true :b true})))
#'user/x
user> x
(:b :a)
user> x
(:a :a)

As discussed on the mailing list, it's not clear exactly whose fault this is:
https://groups.google.com/group/clojure-dev/browse_frm/thread/bed458abf8e266aa#
given that the javadocs for iterators and entrySet dont' seem to require (or mention at all) whether each .next() must return a unique value.

keys and vals could be fixed by using keySet and values rather than entrySet, at least in this case, but this would not help for seq.



 Comments   
Comment by Stuart Halloway [ 02/Dec/11 9:28 AM ]

The powers that be acknowledge that this is Java's fault: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6312706





[CLJ-869] Macro auto-gensym in let not visible after a nested unquote/syntax-quote Created: 03/Nov/11  Updated: 02/Dec/11  Resolved: 02/Dec/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Alexander Taggart Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

See the following simplified example:

user=> (defmacro foo [flag]
        `(let [a# 1]
          ~(if flag
             `(println a#))))
#'user/foo
user=> (foo false)
nil
user=> (foo true)
java.lang.Exception: Unable to resolve symbol: a__574__auto__ in this context (NO_SOURCE_FILE:6)
user=> (macroexpand-1 '(foo true))
(clojure.core/let [a__575__auto__ 1] (clojure.core/println a__574__auto__))


 Comments   
Comment by Rich Hickey [ 02/Dec/11 10:42 AM ]

This is not a bug





[CLJ-851] Type-hinting a var with primitive array pseudo-class results in IllegalArgumentException when the var is used as an arg Created: 10/Oct/11  Updated: 01/Mar/13  Resolved: 09/Nov/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Alexander Taggart Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File CLJ-851-test.patch    

 Description   

Example:

user=> (def ^longs la (long-array 0))
#'user/la
user=> (defn foo [] (alength la))
CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: clojure.core$longs@32dfcb47, compiling:(NO_SOURCE_PATH:9) 

Workaround: use the class string, e.g., ^"[J"



 Comments   
Comment by Ben Smith-Mannschott [ 15/Oct/11 11:40 AM ]

CLJ-851-test.patch

Provides a test to reproduce this issue, as well as a test that shows that the workaround of using ^"[J" as type hint works correctly.

Comment by Ben Smith-Mannschott [ 16/Oct/11 2:23 AM ]

OK, I see the problem here: longs plays two roles in Clojure:

  1. As an unqualified symbol, it's taken to mean long[].class.
  2. clojure.core/longs is a definline function which calls clojure.lang.Numbers.longs(...).

The example in the issue description is expecting the first interpretation, but what we're actually getting is the second interpretation, i.e. the :tag is not a symbol longs, but rather a function (an instance of the class clojure.core$longs, to be precise).

So, it's as if we'd written this:

(def ^{:tag clojure.core/longs} la (long-array 0))

When really, we meant this:

(def ^{:tag 'longs} la (long-array 0))

While the behavior described by this issue is confusing, it looks to me like it's not a bug.

Comment by Stuart Sierra [ 09/Nov/12 8:39 AM ]

Correct, this is not a bug. The reader will attempt to resolve symbols in the ^tag metadata form, so that it can resolve unqualified class names.





[CLJ-848] defn :or form does not warn you if you provide a vector instead of a map Created: 06/Oct/11  Updated: 25/Oct/11  Resolved: 25/Oct/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: Approved Backlog

Type: Enhancement Priority: Trivial
Reporter: Dave Barker Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

Clojure 1.3, Emacs 23, OSX Lion



 Description   

I had a problem defining a function today, I passed :or a vector instead of a map - everything seemed to work fine but later on I got a really puzzling "Null pointer exception".

raek helped me debug the problem and suggested opening this ticket. I think it would be useful if an exception was thrown on the :or line unless it's given a map.

Here are some examples

(defn broken-example [{:keys [i processor]
:or [processor identity]}]
(processor i))

(defn working-example [{:keys [i processor]
:or {processor identity}}]
(processor i))

(working-example {:i 1})
=> 1
(broken-example {:i 1})
=> Null pointer exception

Cheers, Dave.



 Comments   
Comment by Dave Barker [ 06/Oct/11 6:51 AM ]

Apologies, I meant to tag this as a minor issue instead of a major one!

Comment by Stuart Halloway [ 07/Oct/11 9:39 AM ]

Since vectors are associative, maybe using vectors for :or should just work?

(let [{noun 0
       verb 1
       obj 2
       :or [:n :v :o]}
      [:code :is]] obj)
Comment by Stuart Halloway [ 25/Oct/11 6:04 PM ]

Closing this until someone wants to make a principled argument for what should happen (see my previous comment)





[CLJ-841] Unable to download clojure using wget. Wget seems to be blocked... Created: 23/Sep/11  Updated: 01/Mar/13  Resolved: 08/May/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Thomas Dziedzic Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

wget http://repo1.maven.org/maven2/org/clojure/clojure/1.3.0/clojure-1.3.0.zip
Gives me a 403, same with other people.

When I add -U YUBLOCKWGET to the command, it downloads the file successfully.

This "feature" needs to be removed.

Also, I encountered this while trying to package clojure 1.3. So no, I can't just use a browser



 Comments   
Comment by Jim Blomo [ 08/May/12 11:44 PM ]

This is actually a policy of maven.org/sonatype: https://issues.sonatype.org/browse/MVNCENTRAL-119 , not Clojure.





[CLJ-826] Include drop, take, butlast from clojure.contrib.string (1.2) in clojure.string 1.3 Created: 08/Aug/11  Updated: 02/Dec/11  Resolved: 02/Dec/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Backlog
Fix Version/s: Backlog

Type: Enhancement Priority: Minor
Reporter: Arthur Edelstein Assignee: Unassigned
Resolution: Declined Votes: 3
Labels: None

Attachments: File clj-826-add-take-drop-butlast.diff     File clj-826-add-take-drop-butlast-v3.diff     File clj-826-add-take-drop-butlast-with-versions.diff    
Patch: Code and Test
Approval: Test
Waiting On: Matthew Lee Hinman

 Description   

From clojure.contrib.string 1.2, I have found myself using drop, take,
and butlast. (These are more than just wrappers for String/substring,
because they behave nicely when indices exceed the string length.) I
like these methods in part because they match the behavior of
corresponding sequence methods, but have better performance. This
makes optimizing (when needed) easier.



 Comments   
Comment by Matthew Lee Hinman [ 08/Aug/11 1:22 PM ]

Attached patch for adding the methods.

Comment by Matthew Lee Hinman [ 08/Aug/11 6:28 PM ]

I intentionally left out the {:added "_"} from the vars since I have no idea when this will be added.

This (as expected) causes this test to fail:
[java] FAIL in (public-vars-with-docstrings-have-added) (metadata.clj:42)
[java] expected: (= [] (remove (comp :added meta) public-vars-with-docstrings))
[java] actual: (not (= [] (#'clojure.string/butlast #'clojure.string/drop #'clojure.string/take)))

Which is easily remedied. If desired, let me know what version this will be added to and I'll submit a new patch with the :added metadata included.

Comment by Matthew Lee Hinman [ 12/Nov/11 4:29 PM ]

I have attached a patch with "1.4" as the added version now that 1.3 has been released.

Comment by Chouser [ 18/Nov/11 10:29 PM ]

The algorithms, docs, and tests look good. I think the functions would be better if they used clojure.core/subs like the rest of clojure.string does, instead of .substring. This is more idiomatic Clojure and allows you to avoid hinting the String arg.

When a new patch is uploaded, please remember to set the Patch field of this ticket to "Code and Test" and the Approval field to "Test". Hopefully this will lead to faster screening.

Comment by Matthew Lee Hinman [ 21/Nov/11 12:50 PM ]

Attached a patch that uses subs instead of .substring (clj-826-add-take-drop-butlast-v3.diff).

Comment by Stuart Halloway [ 02/Dec/11 9:14 AM ]

These fns were left out intentionally. Feel free to propose a contrib home for them, though.





[CLJ-820] int coercion doesn't work in clojure 1.3 Created: 14/Jul/11  Updated: 20/Jul/12  Resolved: 20/Jul/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: Release 1.5

Type: Defect Priority: Major
Reporter: Tassilo Horn Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

Gentoo GNU/Linux



 Description   

Using the clojure git head as of 2011-07-14 (commit f704853751d02faf72bd53be599ee0be6c1da63e), int coercion doesn't work:

user> (class (int 1))
java.lang.Long

byte, short, double, and float coercion work fine, though:

user> (class (byte 1))
java.lang.Byte
user> (class (short 1))
java.lang.Short
user> (class (double 1))
java.lang.Double
user> (class (float 1))
java.lang.Float

Also creating integers directly works fine:

user> (class (Integer. "100"))
java.lang.Integer
user> (class (Integer/valueOf 1))
java.lang.Integer
user> (class (Integer. 100))
java.lang.Integer

This is probably related to CLJ-439.



 Comments   
Comment by Sebastián Bernardo Galkin [ 15/Jul/11 2:33 PM ]

Related documentation here: http://dev.clojure.org/display/doc/Enhanced+Primitive+Support

all long-or-smaller integers are boxed as Long
You can't use primitive coercions to force specific box types
Your code was broken if you were relying on that

So, apparently (int) has the correct behavior. It's byte and short which should be also boxed into Longs

Comment by Sebastián Bernardo Galkin [ 15/Jul/11 2:34 PM ]

See also this topic in clojure-dev: https://groups.google.com/d/topic/clojure-dev/fXQAYv8s0tQ/discussion

Comment by Tassilo Horn [ 15/Jul/11 3:00 PM ]

So to call some Java method that requires an int you have to use Integer/valueOf?

Comment by Sebastián Bernardo Galkin [ 15/Jul/11 3:46 PM ]

Yes, I think so

Comment by Tassilo Horn [ 15/Jul/11 4:16 PM ]

But for what are the coercion functions now good for? I mean, http://clojure.org/java_interop#Java Interop-Coercions states:

"At times it is necessary to have a value of a particular primitive type. These coercion functions yield a value of the indicated type as long as such a coercion is possible: bigdec bigint boolean byte char double float int long num short"

That's exactly my use case which is not supported anymore.

Comment by Sebastián Bernardo Galkin [ 15/Jul/11 11:09 PM ]

(int) (char) etc. are not intended to return boxed types, they always return primitive types. If you want boxed types you can use (num). When you do (class (int 42)) you are casting the long 42 to a int and then boxing it into a Long to get its class.

For short and byte, I don't know, I think there is a bug, (class (short 42)) should be Short.

Comment by Tassilo Horn [ 16/Jul/11 7:13 AM ]

(int) (char) etc. are not intended to return boxed types, they always return primitive types.

Thank you, Sebastián, that made it clear and unveiled the problem at my side. When I did

(set-value! foo :position (int 17))

I got the exception "java.lang.Long cannot be cast to java.lang.Integer". set-value! is a protocol function extended on the java types of the java library I'm interacting with. Eventually, it'll call (doto foo (.setAttribute "position" (mutable <providedVal>)), where mutable is yet another protocol function that converts clojure collections to the libraries counterparts and does nothing for primitive types.

Now, although (int 17) returns an unboxed int, these two indirections box it into a Long again and the java setter is called with that leading to the error.

(set-value! foo :position (Integer/intValue 17))

circumvents the issue, because here you directly get an int boxed as Integer.

If you want boxed types you can use (num).

Well, I want a boxed value of a certain type, like Integer.

For short and byte, I don't know, I think there is a bug, (class (short 42)) should be Short.

Should or should not? Currently, for all primitive types <primType>, the call (class (<primType> <val>)) returns the wrapper class corresponding to <primType> with the exception of int where you get a Long instead of an Integer. That's totally surprising and caused me to file this bug report.

Comment by Michel Alexandre Salim [ 26/May/12 12:55 PM ]

This is fixed in 1.4.0 – could one of the screeners confirm this, and maybe close the issue?





[CLJ-819] deftype print/read doesn't munge field names Created: 12/Jul/11  Updated: 24/Aug/11  Resolved: 24/Aug/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Chas Emerick Assignee: Chas Emerick
Resolution: Declined Votes: 0
Labels: None


 Description   

Example:

=> *clojure-version*
{:major 1, :minor 3, :incremental 0, :qualifier "beta1"}
=> (deftype P [a-b])
user.P
=> (P. "foo")
#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: a-b for class user.P>

The field names being passed along to the reflector need to be munged properly in core_print.clj (line 246), and the Compiler needs to do the same in the IType block in ObjExpr.emitValue.



 Comments   
Comment by Chas Emerick [ 12/Jul/11 12:48 PM ]

I'll pick this up on Friday if no one else has by then.

Comment by Chas Emerick [ 24/Aug/11 5:05 AM ]

deftype print-method and print-dup pulled per CLJ-812; this is no longer relevant.





[CLJ-818] doc string for resolve mentions &env Created: 07/Jul/11  Updated: 01/Mar/13  Resolved: 23/Mar/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Enhancement Priority: Trivial
Reporter: Steve Miner Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File clj-818-resolve-doc-string-patch.txt    
Patch: Code

 Description   

(defn resolve
"same as (ns-resolve ns symbol) or (ns-resolve ns &env symbol)"

The ampersand on "&env" in the doc string is distracting. There's no macro magic involved so it should just say "env".



 Comments   
Comment by Andy Fingerhut [ 24/Feb/12 11:20 AM ]

There are earlier uses of &form and &env in core.clj, but they are all in bootstrap code and none of them become visible in doc strings. There are no other occurrences of & in resolve or ns-resolve, so it seems reasonable to remove it from resolve's doc string.

Patch applies cleanly to latest master as of Feb 24, 2012.

Comment by Stuart Sierra [ 23/Mar/12 8:41 AM ]

The only way to access local environments in Clojure is with the special &env argument in a macro, so the use of &env in the ns-resolve docstring makes sense.

Declined.





[CLJ-814] Make the #= reader macro an official" part of the language Created: 22/Jun/11  Updated: 28/Jun/11  Resolved: 28/Jun/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: G. Ralph Kuntz, MD Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

All



 Description   

Can the #= reader macro be made "official" by documenting it on the clojure.org website. It seems to be quite useful for several applications, including regular macro definitions.



 Comments   
Comment by Aaron Bedra [ 28/Jun/11 6:24 PM ]

Although this seems useful, we are not ready to commit to supporting it.





[CLJ-810] clojure.set/difference Created: 15/Jun/11  Updated: 20/Jun/11  Resolved: 20/Jun/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Joel Kaasinen Assignee: Unassigned
Resolution: Declined Votes: 1
Labels: None
Environment:

Linux, openjdk 6



 Description   

This seems a bit weird. Maybe set difference could check that the collections are sets?

(clojure.set/difference (set [0 300 :a]) [:a :b])
#{0 300}
(clojure.set/difference (set [0 300 :a]) [:a :b :c :d])
#{:a 300}
(clojure.set/difference (set [0 300 :a]) (set [:a :b :c :d]))
#{0 300}

The problem is still present in the master branch too.



 Comments   
Comment by Stuart Halloway [ 20/Jun/11 7:04 AM ]

set/difference's behavior is not documented if you don't pass in a set.





[CLJ-804] Expose memoization cache and original as metadata on memoized functions. Created: 01/Jun/11  Updated: 21/Jun/11  Resolved: 21/Jun/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Trivial
Reporter: Phil Hagelberg Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File 0001-Add-metadata-to-memoized-functions.patch    
Patch: Code

 Description   

The attached patch exposes the memoization cache and original pre-memoized value as metadata on memoized functions.

The metadata keys are ::memoize-cache and ::prememoized respectively, to which I'm not too attached.



 Comments   
Comment by Stuart Halloway [ 20/Jun/11 6:51 AM ]

Can you say more about the problems(s) being solved there? Given all the other feature work that has been done/requested around memoization, tempted to let this work happen in a contrib library first. But that is partially because I don't know from this ticket what pain is being addressed.

Comment by Fogus [ 20/Jun/11 8:17 AM ]

Unk may provide a starting point for a contrib lib. https://github.com/fogus/unk

Comment by Phil Hagelberg [ 20/Jun/11 12:18 PM ]

I'm in support of a smarter memoize a la unk; this could be considered a stop-gap measure that helps in situations where the current memoize implementation simply cannot be used due to unbounded memory use.

I've also come across circumstances where I can't use memoize because it will make my function untestable, though admittedly these involve memoizing impure functions—perhaps the answer there is just "don't do that".

Comment by Christopher Redinger [ 21/Jun/11 6:04 PM ]

Let's do one of the following instead:

  • make unk a contrib (after addressing Rich's questions)
  • recommend Guava for advanced caching
  • make a Guava-wrapping contrib




[CLJ-799] ArrayMaps print-dup with read-eval Created: 16/May/11  Updated: 27/May/11  Resolved: 27/May/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Alexander Taggart Assignee: Alexander Taggart
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File print-dup-array-maps.patch    
Patch: Code and Test
Approval: Not Approved
Waiting On: Stuart Halloway

 Description   
user=> (binding [*print-dup* true] (print-str (hash-map :k :v)))
"{:k :v}"
user=> (binding [*print-dup* true] (print-str {:k :v}))
"#=(clojure.lang.PersistentArrayMap/create {:k :v})"

In the top example, the reader will automatically create an array-map due to the number of entries, so unless there is an overriding reason to force type-preservation in the bottom example, it can likewise be printed as a literal map.



 Comments   
Comment by Alexander Taggart [ 21/May/11 9:56 PM ]

Apply patch after CLJ-797.

Comment by Rich Hickey [ 27/May/11 7:38 AM ]

The point of print-dup is type preservation





[CLJ-793] print-doc triggers NPE in clojure.lang.Namespace.find Created: 13/May/11  Updated: 31/May/11  Resolved: 31/May/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Philipp Meier Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

windows xp / java 1.6.0_24



 Description   

In a swank repl I tried to invoke (print-doc ADefTypeInCurrentNamespace) and got the following exception:

No message.
[Thrown class java.lang.NullPointerException]

Restarts:
0: [QUIT] Quit to the SLIME top level

Backtrace:
0: java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
1: clojure.lang.Namespace.find(Namespace.java:188)
2: clojure.core$find_ns.invoke(core.clj:3180)
3: clojure.core$the_ns.invoke(core.clj:3208)
4: clojure.core$ns_name.invoke(core.clj:3214)
5: clojure.core$print_doc.invoke(core.clj:3831)
6: les$eval36576.invoke(NO_SOURCE_FILE:1)
7: clojure.lang.Compiler.eval(Compiler.java:5424)
8: clojure.lang.Compiler.eval(Compiler.java:5391)
9: clojure.core$eval.invoke(core.clj:2382)
10: swank.commands.basic$eval_region.invoke(basic.clj:47)
11: swank.commands.basic$eval_region.invoke(basic.clj:37)
12: swank.commands.basic$eval797$listener_eval__798.invoke(basic.clj:71)
13: clojure.lang.Var.invoke(Var.java:365)
14: les$eval36574.invoke(NO_SOURCE_FILE)
15: clojure.lang.Compiler.eval(Compiler.java:5424)
16: clojure.lang.Compiler.eval(Compiler.java:5391)
17: clojure.core$eval.invoke(core.clj:2382)
18: swank.core$eval_in_emacs_package.invoke(core.clj:90)
19: swank.core$eval_for_emacs.invoke(core.clj:237)
20: clojure.lang.Var.invoke(Var.java:373)
21: clojure.lang.AFn.applyToHelper(AFn.java:169)
22: clojure.lang.Var.applyTo(Var.java:482)
23: clojure.core$apply.invoke(core.clj:540)
24: swank.core$eval_from_control.invoke(core.clj:97)
25: swank.core$eval_loop.invoke(core.clj:102)
26: swank.core$spawn_repl_thread$fn_482$fn_483.invoke(core.clj:307)
27: clojure.lang.AFn.applyToHelper(AFn.java:159)
28: clojure.lang.AFn.applyTo(AFn.java:151)
29: clojure.core$apply.invoke(core.clj:540)
30: swank.core$spawn_repl_thread$fn__482.doInvoke(core.clj:304)
31: clojure.lang.RestFn.invoke(RestFn.java:398)
32: clojure.lang.AFn.run(AFn.java:24)
33: java.lang.Thread.run(Thread.java:619)



 Comments   
Comment by Philipp Meier [ 13/May/11 3:18 AM ]

The following steps reproduce the error:

(deftype Foo [])
(print-doc Foo)

Comment by Stuart Sierra [ 31/May/11 9:15 AM ]

clojure.repl/print-doc is private in Clojure 1.3, and no longer throws NPE in the example case.





[CLJ-785] Optimize / Created: 30/Apr/11  Updated: 13/May/11  Resolved: 13/May/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Enhancement Priority: Major
Reporter: Alan Dipert Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Optimization to / such that the & more version expands to equivalent of (/ x (reduce * y more)) rather than (reduce / (/ x y) more). There should be an inlined variant of & more as well.

This was originally part of CLJ-184, but was pulled out because it's big enough to be its own ticket. The rationale is that multiplies are significantly faster than divides on the JVM, and n-ary calls to / could be faster.

See "Java Multiplication (Much) Faster than Division" for background and Java benchmarks.



 Comments   
Comment by Alan Dipert [ 13/May/11 9:26 AM ]

We don't want to mess with the semantics of division at the bottom.





[CLJ-767] Remove support for non-primitive bit-shift operations Created: 04/Apr/11  Updated: 25/May/11  Resolved: 25/May/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Alexander Taggart Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Per Rich's comment:

Shift ops would be limited to primitives only. Default versions 64-bit, but explicit shift-int versions for 32 bits.



 Comments   
Comment by Alexander Taggart [ 05/Apr/11 4:23 PM ]

Rather than changing the behaviour of the extant unchecked ops (see the original discussion), I've created three new namespaces:

  • clojure.unchecked: Contains unchecked versions of the primitive cast functions. Removed the unchecked-prim cast functions that were added to core recently.
  • clojure.unchecked.long: Contains unchecked, long-arg versions of the numeric and bit-op functions from core.
  • clojure.unchecked.double: Contains unchecked, double-arg versions of the numeric functions from core.
Comment by Alexander Taggart [ 06/Apr/11 1:23 PM ]

Note that the clojure.unchecked namespace idea was first proffered by Rich in the comments on CLJ-441.

Comment by Rich Hickey [ 07/Apr/11 8:25 AM ]

This does way too much, and thus makes it hard to talk about.

Moving unchecked coercions into unchecked ns is ok, and would make a fine and acceptably-sized patch.

unchecked double makes no sense to me at all - no double ops are checked

There seems to be general confusion about unchecked vs primitive-taking. Only a small subset of ops have the overflow checking that is turned off by 'unchecked'

There's no sense in which the interacts with *unchecked-math*, nor with the latest numerics approach (primitive semantics by default)

There's a ton of duplication with things already in Numbers that handle primitive overloads. esp. in combination with different primitives and objects.

The things we need for bit ops are lost in the noise.

What I want for bit ops is the same thing we currently (in latest) have for other ops - primitive semantics by default, no conditionals, direct mapping to JVM primitive ops.

And separate tickets and patches for each step, please. This is simply too much to consider.

Thanks,

Rich

Comment by Alexander Taggart [ 07/Apr/11 8:11 PM ]

Patch removes support for non-primitive args to bit-shift operations.

Comment by Alexander Taggart [ 25/May/11 12:12 PM ]

Was effectively replaced by CLJ-772.





[CLJ-762] Clojure compilation hangs Created: 20/Mar/11  Updated: 24/Feb/12  Resolved: 24/Feb/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Dmitry Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

linux


Attachments: File sudoku.clj    

 Description   

Good day, i was trying to write simple sudoku solver as learning excercise, but suddenly stuck
on some point becasue compiler hangs when trying to run my snippet (attached).



 Comments   
Comment by Dmitry [ 20/Mar/11 2:20 PM ]

Sorry for false alert, its not compiler, it is program itself (ash on my head)

Comment by Andy Fingerhut [ 24/Feb/12 10:36 AM ]

Bug reporter Dmitry apparently discovered that it was compiling and running, just taking longer to finish than he expected, which is not unusual for a program doing this much searching with no printing of intermediate results.





[CLJ-758] Add Clojure program to generate HTML and LaTeX cheatsheets from common source Created: 14/Mar/11  Updated: 01/Mar/13  Resolved: 17/Feb/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Andy Fingerhut Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: File clj758-patch-v1.diff    

 Description   

Discussion thread on clojure-dev: http://groups.google.com/group/clojure-dev/browse_thread/thread/265b887a940219b2#

Steve Tayon created a cheat sheet of Clojure functions, macros, and vars organized into categories. He created it in LaTeX, editing it through several revisions. One or a few revisions were manually converted to HTML for publication at URL http://clojure.org/cheatsheet

Alex Miller proposed creating a single source that could then be used to automatically generate both HTML and LaTeX/PDF versions, where each symbol on the cheatsheet would be a link to documentation on clojure.github.com

Andy Fingerhut created a Clojure program that, from a single data structure contained within the program, generates either HTML or LaTeX, with or without the links. The LaTeX can be used to generate PDF files in either A4 or US letter size pages.



 Comments   
Comment by Andy Fingerhut [ 14/Mar/11 9:19 PM ]

First attempt at patch for adding cheat sheet generator program. See readme.txt inside there for some open questions on how this ought to be packaged, e.g. does it belong here or in clojure-contrib? What kinds of ant/maven targets should it have?

Comment by Andy Fingerhut [ 17/Feb/12 2:36 AM ]

Updated versions of this code for newer versions of the cheatsheet will be added to a github repo soon, perhaps this one: http://github.com/fogus/clojure-cheatsheets





[CLJ-756] Workable upload destination for release zips Created: 11/Mar/11  Updated: 22/Apr/11  Resolved: 22/Apr/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.3

Type: Enhancement Priority: Major
Reporter: Stuart Halloway Assignee: Stuart Halloway
Resolution: Declined Votes: 0
Labels: None

Approval: Vetted

 Description   

We have been using Github's file upload under http://github.com/clojure for uploading releases

Pros:

  • looked easy
  • download tracking
  • tool we are already using

Cons:

  • unreliable
    • fails to upload
      • tested on multiple browsers with and without Flash
    • even when it works seems to show up during upload
      • presumably would fail the download in these cases
    • claims to upload but has garbage file
      • shows up in UI
      • permission error when you try to get it
      • sometimes causes browser to crash (not Github fault, but still...)
    • has added two hours of dev time to the current release (so far)

In order to get 1.3.0-alpha6 out the door (and end a multihour ordeal) I am pushing it to the files section at clojure.org.



 Comments   
Comment by Stuart Sierra [ 13/Mar/11 5:59 PM ]

What's behind clojure.org? Is it a real server we can log into or some kind of hosted app?

Comment by Christopher Redinger [ 22/Apr/11 9:34 AM ]

Will take this up with GitHub if we continue to have problems.





[CLJ-746] Unreference keywords not correctly removed from keyword table (Utils.clearCache) Created: 25/Feb/11  Updated: 04/Mar/11  Resolved: 04/Mar/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Hugo Duncan Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

I just ran into http://dev.clojure.org/jira/browse/CLJ-444 in clojure 1.2 and think the anlaysis there missed the cause of the issue.

Reading http://download.oracle.com/javase/1.4.2/docs/api/java/lang/ref/ReferenceQueue.html#poll() suggests poll removes an item from the queue.

In Util.clearCache, there are two calls to rq.poll() with discarded return values, with the result that some of the enqueued soft references are not being removed from cache (ie the keyword table)



 Comments   
Comment by Stuart Halloway [ 04/Mar/11 9:49 PM ]

The references do not need to be removed using the queue. They can be (and are) removed by directly walking the values of the map. The queue serves only to notify that this work needs to be done.





[CLJ-744] proxy hides protected final methods Created: 22/Feb/11  Updated: 01/Mar/13  Resolved: 25/Feb/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Daniel Solano Gómez Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

When using proxy to override a class that has a protected final method, that method is not exposed.

For example, given the class:

ProxyMe.java
public class ProxyMe {
    public final void publicFinal() {}
    protected void protectedNonFinal() {}
    protected final void protectedFinal() {}
}

And the Clojure code:

proxy_me.clj
(ns proxy-me
  (:import ProxyMe))

(def proxied-class (class (proxy [ProxyMe] [])))
(def no-args (into-array Class []))

; both are ok
(.getMethod proxied-class "publicFinal" no-args)
(.getMethod proxied-class "protectedNonFinal" no-args)

; throws NoSuchMethodException
(.getMethod proxied-class "protectedFinal" no-args)

Any attempt to access protectedFinal() fails.



 Comments   
Comment by Daniel Solano Gómez [ 22/Feb/11 9:34 PM ]

I should have re-read the documentation.

Comment by Daniel Solano Gómez [ 22/Feb/11 10:01 PM ]

Okay, someone on #clojure ran into this problem as well, and I have verified it's an actual bug for both gen-class and proxy. Neither one has access to protected final methods.

Comment by Daniel Solano Gómez [ 25/Feb/11 1:34 PM ]

I've looked into this a bit more, and I think it's difficult for proxy to be able to call protected final methods. It would be nice to be able to do, but for now I think it's best allow that functionality through gen-class.

I will open a new ticket with a patch to allow gen-class to expose protected final methods.





[CLJ-743] Error messages for invalid destructured bindings are not helpful Created: 22/Feb/11  Updated: 01/Mar/13  Resolved: 24/Feb/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Luke VanderHart Assignee: Luke VanderHart
Resolution: Declined Votes: 0
Labels: None


 Description   

Errors in destructured forms throw errors that give no clue to what the actual problem is. For example, evaluating (let [[a b] 3] a) throws a 'nth not supported on type Long' error. It is not obvious that the destructuring expression is at fault.

There should be another exception at the top level in the stack trace, something along the lines of of "DestructuringException: value <value> could not be destructured", with the 'nth not supported' exception as its cause.



 Comments   
Comment by Luke VanderHart [ 23/Feb/11 8:27 PM ]

This may not be possible. Destructuring is implemented as a macro-like transformation on the expressions - by the time the expressions are evaluated and an error occurs, the runtime has no way of knowing that the expression was once destructured.

Tagging the expressions with some sort of flag to indicate they were destructured is unviable. Not only is is complicated, it has runtime performance penalties.

Comment by Stuart Halloway [ 24/Feb/11 6:35 PM ]

I don't see a way to do this without runtime implications, even in the no-error case. I guess the destructure macro could emit special variants destructuring-nth and destructuring-get, etc. that provide specaliazed error messages...





[CLJ-732] (keyword "") can be printed, but not read Created: 26/Jan/11  Updated: 29/Jul/11  Resolved: 29/Jul/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: Backlog

Type: Defect Priority: Minor
Reporter: Zach Tellman Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: File clj-732.diff    
Approval: Incomplete
Waiting On: Rich Hickey

 Description   

user=> (keyword "")
:
user=> (prn-str *1)
":\n"
user=> (read-string *1)
java.lang.RuntimeException: java.lang.Exception: Invalid token: : (NO_SOURCE_FILE:0)

This obviously isn't a huge defect, but I'd argue that anything that can be printed should be readable.



 Comments   
Comment by Stuart Halloway [ 28/Jan/11 9:06 AM ]

Patch that throws IllegalArgumentException would be ok for this.

Comment by Stuart Halloway [ 05/Apr/11 8:57 PM ]

After a brief review of places that call intern, it appears that this problem might never be reached in the reader, only in user code calling (keyword ...). Does it make more sense to have the patch there, and a matching change for (symbol ...)?





[CLJ-725] (;) causes repl to hang in Clojure 1.3-0-alpha3 on Mac OS X 10.6.3 Intel Created: 22/Jan/11  Updated: 26/Jan/11  Resolved: 26/Jan/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Jason E. Aten Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

From the new-to-Clojure but very excited about the language perspective, this seems simply seemed like low-priority-but-should-be-fixed-eventually bug. When I invoked ; as a function name by accident, I found that the REPL simply hung.

jaten@host151:~$ uname -a
Darwin host151.wifi.epochcoffee.com 10.3.0 Darwin Kernel Version 10.3.0: Fri Feb 26 11:58:09 PST 2010; root:xnu-1504.3.12~1/RELEASE_I386 i386

jaten@host151:~$ java -server -cp "/home/jaten/pkg/clojure/jars/*" clojure.main
Clojure 1.3.0-alpha3
user=> ( ; causes REPL to hang forever...???

Also happens in clojure 1.2.0. I didn't try any other versions.



 Comments   
Comment by Chouser [ 26/Jan/11 12:30 AM ]

The semicolon comments out the rest of the line, including the close paren. The REPL then blocks waiting for the expression begun with the open paren to be completed with an (uncommented) close paren. If you type a second close paren on and press Enter, I think you'll see the REPL was not hung but just waiting for more input.

I don't know if it would be useful to provide a different prompt instead of no prompt at all when the REPL is waiting for the conclusion of an expression, but in any case that would be a feature request.

The current behavior is as expected.





[CLJ-724] bean throws NPE when key doesn't exist Created: 22/Jan/11  Updated: 05/Apr/11  Resolved: 05/Apr/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Benjamin Teuber Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: File clj-724.diff    
Patch: Code and Test
Approval: Test

 Description   

The result of (bean obj) throws a NullPointerException when passed in a key that doen't exist. I think instead it should return nil to be consistent with maps and records - or at least the error message should be more explicit.



 Comments   
Comment by Alexander Redington [ 25/Mar/11 9:51 AM ]

The proxy returned by (bean) performs a bare invocation on the getter method without checking if it exists first. Fixed the bug by adding a long-hand constantly as the missing value for the map fetch. (constantly is not defined yet when core_proxy is read.)

Also renamed the property map defined in bean to 'propmap' instead of 'pmap' to avoid ambiguity with clojure.core/pmap

Comment by Stuart Halloway [ 05/Apr/11 8:46 PM ]

Beans aren't maps, and without any discussion of motivation it isn't clear that this change is an improvement.

If bean was more consumer-friendly, people might use it in production more often. Don't. Reflection is slow. If there is a motivating use case other than REPL exploration for converting beans to maps, let's design something more performant targeted to that case.





[CLJ-723] Add def- macro to core Created: 22/Jan/11  Updated: 22/Jan/11  Resolved: 22/Jan/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.3
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Benjamin Teuber Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File add-def-.patch    
Patch: Code

 Description   

Having a def- macro in core as sugar for ^:private seems consistent and nice.






[CLJ-722] Misleading documentation string in doseq Created: 21/Jan/11  Updated: 02/Dec/11  Resolved: 02/Dec/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Trivial
Reporter: Baishampayan Ghose Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File 0001-Fix-the-docstring-of-doseq-to-clarify-that-it-works-.patch    
Patch: Code
Waiting On: Rich Hickey

 Description   

The documentation string of doseq is slightly misleading because it doesn't state that doseq will behave like "do" when the seq-exprs argument is empty.

Attached patch clarifies this.



 Comments   
Comment by Aaron Bedra [ 28/Jan/11 10:40 AM ]

Rich is this behavior intentional or a side effect? Just wondering about this before I promote it up.

Comment by Kevin Downey [ 29/Nov/11 7:38 PM ]

looks like an implementation detail to me.





[CLJ-717] A range function for characters, char-range Created: 15/Jan/11  Updated: 16/Jan/11  Resolved: 15/Jan/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Anthony Simpson Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: File char-range.diff    
Patch: Code

 Description   

I've seen a lot of cases where people would do stuff like this:

(def alphabet "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

Or other equally meh things in order to get a range of characters. Haskell's range supports creating ranges of characters, so that was inspiration for this addition.

I've created a function that is the analogue of range for characters. I've called it char-range. It works almost precisely the same as range (and uses range under the hood), only the upper bound isn't exclusive. It made more sense to me for it to be inclusive, so that things like (char-range \a \z) work and make sense.

It takes the same argument combinations as range. For no arguments, it produces a lazy sequence of characters from Character/MIN_VALUE to Character/MAX_VALUE. For two arguments, it produces a lazy sequence from Character/MIN_VALUE to end. It allows for the same stepping that range allows for as well.



 Comments   
Comment by Anthony Simpson [ 15/Jan/11 10:29 AM ]

A friend pointed out to me that I shouldn't have set the issue's approval to 'Test'. I took "If the ticket has (or you write) a patch that applies, test it. If it seems to work, set the status to "Test."" out of context. I don't see a way to set the Approval back to "None", so I'm just going to apologize and whistle.

Comment by Stuart Halloway [ 15/Jan/11 4:30 PM ]

Before implementing a feature like this, please document the problem and the other possible solutions/variants. Some things to think about:

  • is the alphabet example a one-off, or representative of a family of things that are causing real pain?
    • wouldn't alphabet be less readable as a range? You'd have to use two ranges, and know the character after Z
  • we already have range, this would add char-range. Are other things rangeable?
    • Haskell comparison useful
    • more so if expanded to a few other languages
  • if rangeable-ness is going to extend to non-numeric things, should it be polymorphic, instead of separate functions?
  • is rangeable-ness a categoric thing, like Comparable?
    • if so, are there ever types that might range in more than one way
  • what are the performance/needs and expectations of char-range users? At a glance, this patch uses higher-order fns and a fair amount of boxing, where the existing range fn is built in a lower-level way.

If you want, please start a design discussion at http://dev.clojure.org/display/design/Home

Comment by Scott Olson [ 15/Jan/11 6:14 PM ]

It's a lot easier to tell that (char-range \a \z) is correct than "abcdefghijkmnopqrstuvwxyz" (did you notice the missing character at a glance?).

Why would you need to know the character after Z? The OP clearly said the upper bound would be inclusive.

As for performance, char-range uses the functions map and range which are themselves built in a fast low-level way, so as long as they perform well, so will char-range.

Comment by Stuart Halloway [ 16/Jan/11 9:12 AM ]

So range will be exclusive while char-range will be inclusive? Tough sell. You will need more motivation that this one example.

I am not saying this couldn't be the right patch. I am saying that the hard part is answering the design questions, which has to come first. Also, threaded comments on a patch isn't the best place to do it. If char-range is important enough to you, then please start a design page under http://dev.clojure.org/display/design/Home.





[CLJ-714] Real multi-line comments Created: 11/Jan/11  Updated: 03/Sep/11  Resolved: 03/Sep/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Alan Malloy Assignee: Unassigned
Resolution: Declined Votes: 5
Labels: None

Attachments: File 0001-Add-multi-line-comments.diff     Text File patch.txt    
Patch: Code and Test

 Description   

The (comment) macro is not a viable substitute for real multi-line comments:

  • It evaluates to nil, so isn't really useful except at the top level
  • It requires proper paren/etc nesting inside itself
  • Contents must be valid tokens; for example TODO: is illegal inside a (comment)

Common Lisp has #|...|# for multi-line comments, and I think Clojure would benefit from having them too. I've implemented #| to behave in a way that is identical (so far as I am able to test) to CL's implementation, and added tests to the reader test to verify that they work.

Apologies for my formatting in the java files not quite matching up with the rest of the code: I didn't want to go through the pain of making it perfect unless this patch would actually be accepted; I can go back through if necessary.



 Comments   
Comment by Anthony Simpson [ 11/Jan/11 11:56 PM ]

I am totally for this. I agree that comment isn't a valid substitution. comment is useless for a lot of things.

Comment by Benjamin Teuber [ 13/Jan/11 6:09 AM ]

Nice - but are you sure just doing nothing on an unexpected EOF is a good idea?
I guess it usually means I've forgotten the close tag somewhere, so I'd rather be informed about it by an exception. Omitting the |# on purpose just to save two characters seems dirty to me.

Comment by G. Ralph Kuntz, MD [ 13/Jan/11 8:19 AM ]

What about #_(...)?

I know that the parens have to be balanced, but other than that, doesn't it do everything else?

Comment by Anthony Simpson [ 13/Jan/11 8:35 AM ]

No.

user=> #_(TODO: Hi there!)
java.lang.Exception: Invalid token: TODO:

And then, as you mentioned, we have the paren balance problem. The idea is to have something completely ignores what is inside of it.

Comment by Alan Malloy [ 13/Jan/11 1:13 PM ]

Good point, Benjamin. I just assumed most languages didn't need comments to close nicely, but having tried it out I can't find a single one that would let me get away with an unclosed multi-line comment.

Revised patch attached, and using git format-patch now that I know it exists.

Comment by a_strange_guy [ 13/Jan/11 4:02 PM ]

You can use #_ with string literals already:

#_"TODO: Hi there!"

The only problem we have is that we don't have raw strings. I don't think that we need another litrals for comments.

And I don't see any use for multiline comments. In Java etc. you use them to uncomment parts of your program (we have #_ (...) for that) or to document classes & methods (we have docstrings which are superior). If you need multiline comments to explain some part of your code, then you should do something about the code (or use #_ "..." if you are lazy).

Comment by Anthony Simpson [ 13/Jan/11 4:20 PM ]

Except with #_"" you can't just paste something in there because it has to be escaped properly if it has strings and such embedded in it.

Sure, we can work around these limitations somewhat. We can pile hacks on hacks to get half-working multiline comments or just add this trivial patch and have real multiline comments like every other language in existence. Just sayin'.

Multi-line comments aren't for just explaining bad code. #_ isn't designed for this and thus is not a solution to this, and marking every line of a prewritten text with ; and/or removing or editing it later is just tedious.

Curiosity: wouldn't this be useful for literate programming tools?

Comment by Stuart Halloway [ 14/Jan/11 7:18 AM ]

Rich: if you are interested in this assign to me and I will screen.

Comment by a_strange_guy [ 14/Jan/11 11:41 PM ]

Don't think that this is a pressing issue, because every editor that has support for Clojure (or even just Scheme/CL) has a comment-region feature.

I would support adding a reader macro for raw strings, because that is an issue (almost every ns docstring is escaped), and if we had those, then multiline comments would be subsumed by them:

#_
#[[ ;; lua-like proposal for raw strings

]]
Comment by Lau Jensen [ 15/Jan/11 7:26 AM ]

If its a pressing issue or not isn't really the question is it?

To me its a straightforward patch which adds functionality currently not found in Clojure and which I personally would label a welcomed addition.

Comment by Chouser [ 24/Jan/11 9:40 AM ]

Sure it adds a feature, but it also adds syntax and complexity to the language. If the feature it adds doesn't solve real problems of sufficient importance, it may be a net loss for the language.

For temporarily commenting out code, #_ and (comment ...) work fine. For hunks of documentation text, ; or ;; work nicely, especially if you have an ultra-advanced editor like vim to handle your text reformatting. Is there another use case?

Comment by Fogus [ 24/Jan/11 9:59 AM ]

I'm with Chouser on this. Additionally, I would add that the description of #_ is "The form following #_ is completely skipped by the reader." However, trying something like:

    (defn gimmie-pi []
      #_( TODO: validate the accuracy
                of the return value. )
      3)

currently throws an exception. Maybe the form should really be skipped by the reader and allow free form text? I don't know if this is the right answer, but I would feel more comfortable with that than a new reader macro.

Comment by Alan Malloy [ 24/Jan/11 11:21 AM ]

I don't think that's possible, Fogus. If it's going to skip "a form", then it has to understand the syntax therein well enough to determine which closing paren matches up.

Comment by Fogus [ 24/Jan/11 11:40 AM ]

> which closing paren matches up

I'm sorry, I was not clear that I didn't expect my idea to provide the entire functionality of the proposed #| ... |#.

I don't see the utility in providing a whole new reader macro to allow mismatched embedded parentheses. I can kinda see the value in allowing things like `TODO:`, although I would probably just use #_() or comment and just make sure that my embedded comment was not malformed and ; otherwise.

Comment by Rich Hickey [ 26/Jan/11 7:12 AM ]

I'm opposed. I don't think the benefit/complexity ratio (especially for tools) is high enough. We've done without for quite a while and no one's caught fire.

Comment by Chas Emerick [ 03/Sep/11 10:05 PM ]

Closed per request from Alan Malloy.





[CLJ-709] Add a way to test/detect promise objects Created: 09/Jan/11  Updated: 03/Sep/11  Resolved: 03/Sep/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Alan Malloy Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

I'd like a predicate to determine whether an object is a (promise). Currently promises are implemented as a reify of IFn and IDeref, meaning there is no meaningful superclass to test for. It seems to me the simplest solution would be to create an IPromise interface extending IDeref; then (defn promise? [x] (instance? IPromise x)) is a simple solution. Even an empty "tagging" interface for IPromise would do, but it might also be nice to add a delivered? predicate for promises so that it's possible to test whether they're delivered without blocking or catching the "multiple deliver" exception; that would make the IPromise interface more meaningful as well.

This is fairly simple stuff, so I'll start plugging away at a patch and hope nobody objects.



 Comments   
Comment by Alan Malloy [ 09/Jan/11 2:55 AM ]

Um, just noticed http://dev.clojure.org/jira/browse/CLJ-680 but I don't know how to close this issue as a duplicate of that one. The only thing his patch doesn't have that I'd like is:

(defn promise? [x] (instance? IPromiseImpl x))
(defn has-value? [^IPromiseImpl x] (.hasValue x))

Comment by Chas Emerick [ 03/Sep/11 10:05 PM ]

Closed per request from Alan Malloy.





[CLJ-707] -> produces known-invalid code when it could be smarter Created: 07/Jan/11  Updated: 03/Sep/11  Resolved: 03/Sep/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Alan Malloy Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File patch.txt    

 Description   

(-> inc (comp read ())

Macroexpands to (nil (comp read promise)), which is known at compile-time to be illegal code.
It seems like it would be harmless, and occasionally useful, to special-case () to expand into wrapping parens around the preceding form, such as:

((comp inc read))

I'll put together a patch for this shortly if nobody tells me it's a terrible idea.



 Comments   
Comment by Alan Malloy [ 07/Jan/11 4:28 PM ]

Sorry, that -> form came out wrong. The first line should read: (-> inc (comp read) ())

Comment by Alan Malloy [ 08/Jan/11 12:16 AM ]

Here's me testing that my improved versions of -> and ->> work in my use case, and preserve existing behavior for (-> x []) just in case someone was depending on the expansion of this crazy form. Patch will be attached momentarily.

clojure.core> (macroexpand-all '(-> inc (comp read) ()))
((comp inc read))
clojure.core> (macroexpand-all '(->> inc (comp read) ()))
((comp read inc))
clojure.core> (macroexpand-all '(->> read (comp inc) () inc))
(inc ((comp inc read)))
clojure.core> (macroexpand-all '(-> x))
x
clojure.core> (macroexpand-all '(-> x []))
([] x)

Comment by Alan Malloy [ 08/Jan/11 12:20 AM ]

I also factored out some of the behavior common to -> and ->> into a separate function - especially helpful as I was adding still more common behavior. If y'all think it's a good idea I can lift the rest of the common functionality (ie the defns and recursive cases) into a macro that gets called twice, but that seems likely to be less readable and it's not like we're playing golf here.

Comment by Alan Malloy [ 11/Jan/11 11:41 PM ]

Having run ant test, I see that defn- isn't actually available at this point in the bootstrapping process; it should read defn ^:private.

Comment by Stuart Halloway [ 14/Jan/11 7:38 AM ]

Rich: interested?

Comment by Rich Hickey [ 14/Jan/11 8:06 AM ]

No

Comment by Chas Emerick [ 03/Sep/11 10:05 PM ]

Closed per request from Alan Malloy.





[CLJ-694] Set func create sorted hash-set Created: 18/Dec/10  Updated: 27/Dec/10  Resolved: 27/Dec/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Sergey Krauchenia Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

Ubuntu 10.04



 Description   
(def _sortedset (set (list 1,3,2)))
(println _sortedset)
(println (class _sortedset))

This code output is:

>> #{1 2 3}
>> clojure.lang.PersistentHashSet

As you can see set function create hash-set, but already sorted.



 Comments   
Comment by Fogus [ 27/Dec/10 8:15 AM ]

The hash set that you're creating only seems sorted. That is, while the ordering of a set is not guaranteed, it's a perfectly valid set if it is. The ordering in this case is due to implementation details guided by the fact that you happen to be inserting values of the same type whose hash values are ordered. If you make a change to one of the values then you could see a change:

(set (list 1 3.0 2))
;=> #{3.0 1 2)

Comment by Sergey Krauchenia [ 27/Dec/10 12:51 PM ]

Thanks Michel for explanation.





[CLJ-692] Should "some" be using "seq?" rather than "seq" ? Created: 16/Dec/10  Updated: 08/Jul/11  Resolved: 27/Dec/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Matthew Phillips Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Environment:

Mac OS X Java 6



 Description   

Very minor, but noticed while browsing that "some" is defined as:

(defn some
...
[pred coll]
(when (seq coll)
(or (pred (first coll)) (recur pred (next coll)))))

The "(seq coll)" call will potentially generate an unused seq each time.



 Comments   
Comment by Fogus [ 27/Dec/10 7:57 AM ]

The `seq` function is the idiomatic way to ask the question "does this collection have something in it?" and is the correct approach in the case of `some`. If we were to use `seq?` then we would be asking an entirely different question: "does this collection implement the ISeq interface". In the case of using `seq?`, `some` would no longer work against the seq abstraction. It's tempting to look at the name `seq` and `seq?` and assume that they mean similar things. The type-based predicates are tricky.

Comment by Matthew Phillips [ 08/Jul/11 3:28 AM ]

Thanks for the informative comment Michael. I was just watching Rich's talk on seq's, and remembered making this noob bug report: sorry!





[CLJ-688] subs function should count back from the end of the string when given negative offset Created: 09/Dec/10  Updated: 01/Mar/13  Resolved: 31/Dec/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Phil Hagelberg Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File 0001-subs-should-count-backwards-when-given-a-negative-ar.patch    
Patch: Code and Test
Approval: Test

 Description   

subs function should count back from the end of the string when given negative offset.

Patch attached with test and implementation.



 Comments   
Comment by Stuart Halloway [ 31/Dec/10 3:39 PM ]

A major strength of Clojure is consistency. If (foo X) works, then (foo Y) should work if X and Y are similar in relevant ways.

The negative offset convenience was considered and rejected when the string library was originally moved into Clojure. In order for a feature like this to be on the table, a proposal would need to include an evaluation of all API fns that take indexes, and a plan to either make all of them handle negative indexes, or have a meaningful rule about which ones do and which ones don't. If someone is interested in doing this, please begin with a motivating problem statement in the Design space.

That said, this feels very low priority.





[CLJ-676] Calling seq on the resultset-seq of an empty ResultSet throws an exception Created: 16/Nov/10  Updated: 17/Dec/10  Resolved: 17/Dec/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Alex Miller Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

The clojure.sql/resultset-seq function returns a seq over the JDBC ResultSet.

Expected: calling seq on an empty ResultSet should return nil
Actual: throws an error due to a closed ResultSet

Example:

(def db {:classname "oracle.jdbc.driver.OracleDriver"
         :subprotocol "oracle:thin"
         :subname "@detroit:1521:XE"
         :user "ted"
         :password "nugent"
         :schema "sweaty"})

(with-connection db
  (with-query-results res ["SELECT 1 FROM dual WHERE 0=1"]
    (seq res)))

returns:

java.sql.SQLRecoverableException: Closed Resultset: next
  [Thrown class java.lang.RuntimeException]

Backtrace:
  0: clojure.lang.LazySeq.sval(LazySeq.java:47)
  1: clojure.lang.LazySeq.seq(LazySeq.java:56)
  2: clojure.lang.Cons.next(Cons.java:39)
  3: clojure.lang.RT.next(RT.java:560)
  4: clojure.core$next.invoke(core.clj:61)
  5: clojure.core$nthnext.invoke(core.clj:3399)
  6: clojure.core$print_sequential.invoke(core_print.clj:55)
  7: clojure.core$fn__4845.invoke(core_print.clj:138)
  8: clojure.lang.MultiFn.invoke(MultiFn.java:167)
  9: clojure.core$pr_on.invoke(core.clj:2812)
 10: clojure.core$pr.invoke(core.clj:2824)
 11: clojure.lang.AFn.applyToHelper(AFn.java:163)
 12: clojure.lang.RestFn.applyTo(RestFn.java:133)
 13: clojure.core$apply.invoke(core.clj:540)
 14: clojure.core$pr_str.doInvoke(core.clj:3700)
 15: clojure.lang.RestFn.invoke(RestFn.java:409)

Suggested workaround:

(with-connection db
  (with-query-results res ["SELECT 1 FROM dual WHERE 0=0"]
    (not (empty? res))))


 Comments   
Comment by Stuart Sierra [ 17/Dec/10 7:56 PM ]

This is not a Clojure issue. clojure.contrib.sql is part of the old clojure-contrib project, soon to be replaced.





[CLJ-670] Add filter-indexed function Created: 04/Nov/10  Updated: 06/Jan/11  Resolved: 06/Jan/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Phil Hagelberg Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Waiting On: Phil Hagelberg

 Description   

In Clojure 1.2, keep-indexed and map-indexed were introduced in lieu of promoting clojure.contrib.seq/indexed.

The difference between filter and keep is that keep treats false and nil differently; only nil values are removed. This behaviour may be desired in some places, but filter is much more common. It seems that since keep-indexed exists without filter-indexed, people might pull in the nil/false distinction where that's not appropriate.

I can provide a patch for this if desired.



 Comments   
Comment by Stuart Halloway [ 31/Dec/10 3:43 PM ]

Rich: Please mark this waiting on Phil if you want a patch for this, or decline if not.

Comment by Rich Hickey [ 04/Jan/11 8:17 PM ]

The difference between filter and keep is that filter returns the values in the collection based upon the predicate function and keep returns the result of the function itself.

Is this an actual problem people are having or a completeness exercise?

Comment by Phil Hagelberg [ 06/Jan/11 4:02 PM ]

OK, this is due to a misunderstanding then; I must have read some misleading info about keep.





[CLJ-463] Strip leading colons when creating keywords from single strings Created: 20/Oct/10  Updated: 19/Nov/10  Resolved: 19/Nov/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Enhancement
Reporter: Anonymous Assignee: Chas Emerick
Resolution: Declined Votes: 0
Labels: None


 Description   

This seems unfortunate:

=> (-> :foo str keyword)
::foo

Symbols are far saner in this regard:

=> (-> 'foo str symbol)
foo

Simply stripping leading colons from strings prior to turning them into keywords should suffice. The 2-arity Keyword.intern method and clojure.core/keyword fn should be left intact, so as to provide an escape hatch for those that really do need colon-prefixed keywords.



 Comments   
Comment by Assembla Importer [ 20/Oct/10 4:44 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/463
Attachments:
463-strip-keyword-colons.diff - https://www.assembla.com/spaces/clojure/documents/bKmJCu2_Wr36meeJe5cbLA/download/bKmJCu2_Wr36meeJe5cbLA

Comment by Assembla Importer [ 20/Oct/10 4:44 AM ]

cemerick said: [file:bKmJCu2_Wr36meeJe5cbLA]

Comment by Stuart Halloway [ 29/Oct/10 10:00 AM ]

I am uncomfortable with this. If I say (keyword "::foo"), what am I asking for? I almost wonder if this should throw an exception.

Comment by Rich Hickey [ 29/Oct/10 10:07 AM ]

I think (keyword "::foo") (and any more leading colons) should fail, and this patch should only strip one colon.

Comment by Chas Emerick [ 29/Oct/10 11:11 AM ]

Updated patch forthcoming.

Comment by Chas Emerick [ 19/Nov/10 10:07 AM ]

After thinking about this for a while, I've now reversed my position, and am in favor or retaining the current functionality. Thanks for the pushback.

As for throwing exceptions on colon-prefixed, un-namespaced keywords, I'm not certain that that's a good idea. People use keywords to hold all sorts of data, use them as map keys and lookup fns, etc.





[CLJ-461] require namespace implicitly Created: 16/Oct/10  Updated: 21/Jun/11  Resolved: 21/Jun/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Enhancement Priority: Blocker
Reporter: Mike Hinchey Assignee: Mike Hinchey
Resolution: Declined Votes: 1
Labels: None

Approval: Not Approved

 Description   

Referencing a function with a fully-qualified namespace should work without first using require or use, similar to how a fully-qualified java class can be used without importing it.

It's a small change in Compiler that tries to call (require x) if the fully qualified classname is not found. This should give priority to the java class, which protects backwards compatibility. There is no runtime performance impact, only compile time (the first time the namespace is seen). The fact that code (the namespace) is loaded during compilation of a form is no different than loading code to look up a java class.

This makes it easier to write quick scripts as in the example below, also to use one-liners in the repl or ad hoc in code.

For example: java -cp src/clj/:classes clojure.main -e "(clojure.set/union #{1} #{2})"

Currently on master, this produces: Exception in thread "main" java.lang.ClassNotFoundException: clojure.set
but this works: java -cp src/clj/:classes clojure.main -e "(require 'clojure.set) (clojure.set/union #{1} #{2})"

Obviously, (use) would make the code shorter, but my goal is to make it implicit.

Discussion: http://groups.google.com/group/clojure-dev/t/69823ce63dd94a0c



 Comments   
Comment by Assembla Importer [ 17/Oct/10 9:37 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/461
Attachments:
mh-461-require.patch - https://www.assembla.com/spaces/clojure/documents/cQSfQ22L8r37zxeJe5cbCb/download/cQSfQ22L8r37zxeJe5cbCb

Comment by Assembla Importer [ 17/Oct/10 9:37 PM ]

mikehinchey said: [file:cQSfQ22L8r37zxeJe5cbCb]: patch to fix #461

Comment by Assembla Importer [ 17/Oct/10 9:37 PM ]

mikehinchey said: The discussion shows some people want this, other's aren't sure. Attached the patch so people can try it out.

Comment by Stuart Sierra [ 12/Dec/10 4:06 PM ]

One problem I see: With this change, it becomes harder for code-reading tools to determine all the dependencies of a namespace without evaluating it. Right now, I can parse the "ns" declaration of any file and know its dependencies. (Obviously, this breaks if the file loads code outside of the "ns" declaration, but then static analysis is virtually impossible.)

With this change, the "ns" declaration no longer represents the complete set of dependencies for the namespace. I can try to read the whole file, but I have no way of knowing if "foo.bar.baz/quux" represents a namespace-qualified symbol or a static Java member, unless I evaluate it.

I think loading Java classes and loading Clojure namespaces are fundamentally different operations because classes, unlike namespaces, cannot change after they are loaded.

Comment by Paul Stadig [ 10/Jun/11 2:01 PM ]

Stuart,
On the first point: it is already hard for code-reading tools. One can (require 'something) outside of the ns form. There are also uses of eval, direct references to fully qualified classes, and other nefarious ways. You seem to have admitted this already, so I'm not quite sure what you are objecting to? Objection 1: OVERRULED.

On the second point: you already admitted above that the ns declaration doesn't represent the complete set of dependencies, so there is no "no longer" about it. It was just never the case. Secondly, "foo.bar.baz/quux" could be a static Java member, or a Clojure Var, but that is irrelevant to this patch. That was always the case, and the patch is about autoloading, not about interpreting to what "foo.bar.baz/quux" is referring. Objection 2: OVERRULED.

On the third point: again, I don't see the relevance of the fact that a namespace can be changed after it has been loaded but a class cannot. Again, the patch is about autoloading, and the immutability/mutability of namespaces vs. classes is orthogonal. Objection 3: OVERRULED.

Finally, the original ML thread that spawned this had a +1 from the following persons: myself, Christophe Grand, Phil Hagelberg, Laurent Petit, Steve Gilardi, Cosmin Stejerean, and Chas Emerick.

It had a -1 only from: you, Dimitry Gashinsky.

A negative comment from Stu Halloway, and a positive-ish comment from Chris Houser.

I say we move forward with this.

Comment by Kevin Downey [ 10/Jun/11 2:07 PM ]

I have serious reservations about the complexity this will add to the compiler. the current patch is no good, it will break for aot compilation.

Comment by Paul Stadig [ 10/Jun/11 2:21 PM ]

So I've been told that my tongue-in-cheek may not have translated well, but that was the intent. I apologize if that was the case.

My point is just to draw attention to this ticket again. It was discussed on the ML with several +1's and has been mentioned again in chat. I don't think any of the objections that Stuart Sierra raised are particularly relevant to the question of autoloading the namespace of a fully qualified var.

Has anyone tried the patch? Kevin Downey seems to think it will not work in the context of AOT.

Do we need a new patch?

Comment by Kevin Downey [ 10/Jun/11 2:27 PM ]

the patch doesn't actually cause code to load the required namespaces to be generated. it only loads the required namespaces during compilation, which is why it breaks aot. once you get into code generation for aot it gets complicated, where does the generated code go? do we want to try and emit it separately like the requires from an ns form or does it get emitted in the middle of the particular function being compiled. I think the first approach is desirable from a stand point of correctness, but carries with it a load of complexity.

Comment by Paul Stadig [ 10/Jun/11 3:00 PM ]

I think it gets emitted in the middle of a function, just like would happen now if you do (require 'clojure.set) (clojure.set/union ...)

Is there a benefit to having it emit separately like an ns form? Isn't the ns form just a macro that turns into calls to (require ...) which happen to be at the top of a file because that's where the ns form is?

Comment by Rich Hickey [ 21/Jun/11 6:41 PM ]

This is not a good idea, for many reasons, the simplest of which is: it makes loading a side effect of calling a function in a module. Since loading can have arbitrary effects, it shouldn't be implicit. This isn't warranted by the meager benefits it might provide.





[CLJ-455] Calculating large numbers results in java.math.BigIntegerArithmeticException Created: 08/Oct/10  Updated: 23/Oct/10  Resolved: 23/Oct/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

(class (* 1000 1000 1000 1000 1000 1000 1000))
1.1 returns : java.math.BigInteger
1.3.0-alpha returns : java.math.BigIntegerArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1575)



 Comments   
Comment by Assembla Importer [ 23/Oct/10 10:52 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/455

Comment by Assembla Importer [ 23/Oct/10 10:52 PM ]

ataggart said: This is correct behavior with respect to 1.3.0 (yes, it's a breaking change).

If one wants to allow numbers larger than what fits in a long to flow out of math ops, one needs to explicitly start with a BigInt:

user=> (type 1N)
clojure.lang.BigInt
user=> (class (* 1000N 1000N 1000N 1000N 1000N 1000N 1000N))
clojure.lang.BigInt</code></pre>
If one wants to allow autopromotion, one can use the new "tick" math ops:
<pre><code>user=> (class (*' 1000 1000 1000 1000 1000 1000 1000))
clojure.lang.BigInt

NB: Rich suspects almost no one should need these ops, and if you think you do, you're probably wrong.





[CLJ-452] Miscellaneous improvements to Clojure runtime usability from Java Created: 06/Oct/10  Updated: 07/Oct/11  Resolved: 07/Oct/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.4

Type: Enhancement Priority: Major
Reporter: Chas Emerick Assignee: Chas Emerick
Resolution: Declined Votes: 0
Labels: None


 Description   

Using Clojure from Java is very pleasant overall, but there are some rough edges, many of which could be smoothed over with very simple enhancements. I would suggest:

  • there should be an RT.var or Var.find that takes a single string
  • an IFn wrapper should be available that catches and rethrows Exceptions as RuntimeExceptions
  • a simple class (clojure.lang.Clojure perhaps?) that provides a well-documented and stable API for common operations: requiring namespaces, loading files, finding vars, evaluating strings, etc. This also would have a side benefit of allowing breaking changes to the implementation details without breaking interop code.

There are others of this sort that I've come across; will update the above as I remember them.



 Comments   
Comment by Assembla Importer [ 26/Oct/10 10:30 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/452

Comment by Assembla Importer [ 26/Oct/10 10:30 PM ]

cemerick said: Here's an implementation of that IFn wrapper that rethrows Exceptions as RuntimeExceptions: SafeFn.java

This makes sense to me, but perhaps not everyone. Thoughts?

Comment by Chas Emerick [ 21/Mar/11 9:03 AM ]

See http://dev.clojure.org/display/design/Improvements+to+interop+from+Java for a discussion of these changes.

Comment by Stuart Halloway [ 07/Oct/11 12:22 PM ]

While the title of this ticket is broad, it looks like the actual discussion is about rethrowing RuntimeException. Clojure 1.3 and later solve this problem a different way, by not declaring Exception on the relevant interface points.

Please add tickets for the other items discussed on the wiki as appropriate.





[CLJ-446] 1.3 alpha1 gives reflection warning in a case where 1.2 does not Created: 29/Sep/10  Updated: 09/Dec/11  Resolved: 09/Dec/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect Priority: Minor
Reporter: Stuart Sierra Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Approval: Incomplete

 Description   

Feel free to reclassify this as something other than a bug if I've misclassified it.

Related Clojure Google group conversation: http://groups.google.com/group/clojure/browse_thread/thread/83c08f6c2f313c50#

When doing AOT compilation on the attached program nbody.clj with 1.2:

java -Dclojure.compile.path=. -cp clojure-1.2.0.jar:. clojure.lang.Compile nbody

there are no reflection warnings, and a more complex version of the program using the type Body runs quickly. When doing AOT compilation with 1.3 alpha1:

java -Dclojure.compile.path=. -cp clojure-1.3.0-alpha1.jar:. clojure.lang.Compile nbody

I see these reflection warnings, and a more complex version of the program using the type Body runs significantly more slowly, most likely due to the reflection warned about:

Reflection warning, nbody.clj:18 - reference to field x can't be resolved.
Reflection warning, nbody.clj:19 - reference to field y can't be resolved.

Changing the name of the file to nbod.clj and the first line to "(ns nbod", and making corresponding changes to the compilation commands above, causes the reflection warnings to go away in 1.3 alpha1.

Similarly, taking the original attached file nbody.clj and replacing the three occurrences of "nbody" that are not the namespace name with a different name like "nbod" (or probably any name other than "nbody") also causes the reflection warnings to go away in 1.3 alpha1.

In case it makes any difference, I was using Clojure jars pulled via Leiningen, and HotSpot 1.6.0_xxx JVMs on Mac OS X 10.5.8 and Ubuntu 10.4.

Admittedly, a change with very limited impact on typical Clojure users. I wanted to file a ticket in case this was an unwanted consequence of some desirable change in 1.3.



 Comments   
Comment by Assembla Importer [ 03/Oct/10 1:32 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/446
Attachments:
nbody.clj - https://www.assembla.com/spaces/clojure/documents/auzfxEY2Or35j2eJe5cbCb/download/auzfxEY2Or35j2eJe5cbCb

Comment by Assembla Importer [ 03/Oct/10 1:32 AM ]

ataggart said: Fix available via #445.

Comment by Stuart Sierra [ 09/Dec/11 3:19 PM ]

Marking "Incomplete" because no patch is included.

Furthermore, I cannot reproduce the problem described using Clojure 1.3.0.





[CLJ-436] Bug in clojure.contrib.json/read-json Created: 21/Sep/10  Updated: 01/Oct/10  Resolved: 01/Oct/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

What (small set of) steps will reproduce the problem?
$ java -cp lib/clojure-1.2.0.jar:lib/clojure-contrib-1.2.0.jar clojure.main
Clojure 1.2.0
user=> (require 'clojure.contrib.json)
nil
user=> (clojure.contrib.json/read-json "")
java.lang.IllegalArgumentException: Value out of range for char: -1 (NO_SOURCE_FILE:0)
user=>

What is the expected output? What do you see instead?

Expected:

(if eof-error?
  (throw (EOFException. "JSON error (end-of-file)"))
  eof-value)

What version are you using?
1.2

Was this discussed on the group? If so, please provide a link to the discussion
[13:51] <na_ka_na> Hey guys I think there's a bug in clojure.contrib.json at line 116
[13:51] <na_ka_na> in clojure 1.2
[13:52] <na_ka_na> it has a (char i) and then checks for (= i -1) ... but (char -1) fails
[13:52] <na_ka_na> where can I report it ?
[13:53] <LauJensen> na_ka_na: assembla/support



 Comments   
Comment by Assembla Importer [ 01/Oct/10 3:32 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/436

Comment by Assembla Importer [ 01/Oct/10 3:32 PM ]

donmullen said: Added ticket on clojure-contrib-99





[CLJ-419] LispReader uses Character.isWhitespace rather than Character.isSpaceChar Created: 04/Aug/10  Updated: 23/Oct/10  Resolved: 23/Oct/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Character.isWhitespace doesn't handle non-breaking space correctly. Apparently it's pretty ancient from The Olden Days Before People Knew How To Do Character Encodings.

In Java 1.5 Character.isSpaceChar was added, which handles supplementary characters the right way: http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Character.html#isWhitespace(char)



 Comments   
Comment by Assembla Importer [ 23/Oct/10 3:03 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/419

Comment by Assembla Importer [ 23/Oct/10 3:03 PM ]

stu said: Phil,

Please add an example and nag me to bump the priority if this is causing real and present pain.

Comment by Assembla Importer [ 23/Oct/10 3:03 PM ]

technomancy said: Eh; it's not causing real pain.

I would be OK with a WONTFIX if that's what is decided. Just thought it wouldn't hurt to have a record of it somewhere (even as a closed-as-invalid ticket), and I was in a particularly pedantic mood last night for some reason.

I ran across it because of an escaping bug in Wine where I wanted to treat "(use 'foo)(-main)" as a single token in bash but two still be valid Clojure code. But luckily I found a better workaround. I am OK with leaving it at lowest priority.

Comment by Assembla Importer [ 23/Oct/10 3:03 PM ]

djpowell said: Hmm, I'm not sure isSpaceChar is right - it doesn't seem to allow things like tabs and newlines. If you really wanted to support non-break-space, then it would probably be best to just use isWhitespace and add them as a special case.

Actually... I would quite like to see \ufeff treated as whitespace. It is the Unicode BOM. Some editors including Windows Notepad include the BOM at the start of UTF-8 files. The latest Unicode docs seem to recognise the UTF-8 BOM. By treating it as whitespace we can avoid any problems with it.

Comment by Assembla Importer [ 23/Oct/10 3:03 PM ]

technomancy said: Sounds like I had this not quite right; probably not worth worrying about.





[CLJ-414] In latest clojure, empty list is neither true nor false Created: 24/Jul/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

In latest Clojure, compiled today:

user> (true? ())
false
user> (false? ())
false

This makes empty collections the only entities in Clojure which are neither true, nor false.
I'm fairly sure () used to be true – is this an intentional change? Googling reveals lots of warnings about the empty list not being false in Clojure.



 Comments   
Comment by Assembla Importer [ 24/Aug/10 12:35 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/414

Comment by Assembla Importer [ 24/Aug/10 12:35 AM ]

bpsm said: You've confused true? and false? with boolean.

Clojure 1.0.1-alpha-SNAPSHOT
user=> (false? '())
false
user=> (true? '())
false
user=> (boolean '())
true
</code></pre>
<pre><code>Clojure 1.1.0
user=> (false? '())
false
user=> (true? '())
false
user=> (boolean '())
true
</code></pre>
<pre><code>Clojure 1.2.0-beta1
user=> (false? '())
false
user=> (true? '())
false
user=> (boolean '())
true

boolean converts its argument to either true or false. nil and false yield false, everything else yields true.
true? and false? do no such conversion, nor should they. Only true is true?. Only false is false?.





[CLJ-412] clojure.xml/emit, emit-element are not documented at clojure.org Created: 23/Jul/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Enhancement
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Neither function makes an appearance here:
http://clojure.github.com/clojure/clojure.xml-api.html
Despite the fact that neither appears to be private. Perhaps the doc generator just ignores all functions that have no doc comment?



 Comments   
Comment by Assembla Importer [ 24/Aug/10 12:34 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/412

Comment by Assembla Importer [ 24/Aug/10 12:34 AM ]

stu said: If a var is (a) public (b) has a docstring and (c) has :added metadata, then the Clojure team is committed to supporting it. These vars don't meet the criteria. In the context of a broader overhaul of XML support these might become official APIs.

Comment by Assembla Importer [ 24/Aug/10 12:34 AM ]

bpsm said: That makes sense. I wasn't aware of those conventions. Perhaps the library should advertise itself as being only for XML reading:

--- a/src/clj/clojure/xml.clj
+++ b/src/clj/clojure/xml.clj
@@ -6,7 +6,7 @@
 ;   the terms of this license.
 ;   You must not remove this notice, or any other, from this software.
 
-(ns ^{:doc "XML reading/writing."
+(ns ^{:doc "XML reading."
        :author "Rich Hickey"}
   clojure.xml
   (:import (org.xml.sax ContentHandler Attributes SAXException)




[CLJ-411] clojure.xml/emit should be encoding-aware Created: 23/Jul/10  Updated: 01/Oct/10  Resolved: 01/Oct/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

clojure.xml/emit blithely asserts that it's writing UTF-8 despite the fact that it's actually writing characters, not bytes. Encoding isn't actually decided until actual bytes are written. This forces clients using clojure.xml/emit to write XML back to disk to use UTF-8. They won't know to do that unless they actually peek at the implementation. This behavior isn't documented.

(defn emit [x]
  (println "<?xml version='1.0' encoding='UTF-8'?>")
  (emit-element x))


 Comments   
Comment by Assembla Importer [ 01/Oct/10 9:56 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/411

Comment by Assembla Importer [ 01/Oct/10 9:56 AM ]

stu said: APIs without docstrings (like emit) are not supported.

We would welcome a redesign of the XML support that made this good enough to publicize and support.





[CLJ-410] clojure.xml parse/emit do not round-trip Created: 23/Jul/10  Updated: 15/Nov/10  Resolved: 30/Oct/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.3

Type: Defect
Reporter: Anonymous Assignee: Rich Hickey
Resolution: Declined Votes: 0
Labels: None

Approval: Not Approved

 Description   

I'm not expecting (emit (parse x)) to produce the same characters as originally in x. (That would be canonical form.)
However, it seems reasonable to expect that (= (parse x) (parse (emit (parse x)))). That's not currently the case because of #277 and #408.
It's not currently possible to demonstrate this bug via a unit test because of #409.
This fails:

(deftest parse-and-emit-should-round-trip-data
  (are [s0]
       (let [x1 (str->xml s0)
             s2 (xml->str x1)
             x3 (str->xml s2)]
         (is (= x1 x3)))
       "<e/>"
       "<e></e>"
       "<e>content</e>"
       "<e a='attribute'/>"
       "<e a='attribute'>content</e>"
       "<e><e><e/></e></e>"
       "<e> </e>"
       "<e>&lt;&amp;&gt;</e>"))
</code></pre>
Where:
<pre><code>(defn xml->str [x]
  (with-out-str
    (xml/emit-element x)))

(defn str->xml [s]
  (xml/parse
   (ByteArrayInputStream. (.getBytes s "UTF-8"))))

Or, rather it crashes prematurely in str->xml because of #409.



 Comments   
Comment by Assembla Importer [ 28/Sep/10 11:19 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/410
Attachments:
410-emit-element-no-longer-emits-spurious-new.patch - https://www.assembla.com/spaces/clojure/documents/b6SULoLZer346_eJe5cbLr/download/b6SULoLZer346_eJe5cbLr

Comment by Assembla Importer [ 28/Sep/10 11:19 AM ]

bpsm said: Tests that demonstrate #410 are available at http://github.com/bpsm/test-clojure-xml.

Comment by Assembla Importer [ 28/Sep/10 11:19 AM ]

bpsm said: [file:b6SULoLZer346_eJe5cbLr]: see also http://github.com/bpsm/clojure/commits/fix408,410,277

Comment by Assembla Importer [ 28/Sep/10 11:19 AM ]

stu said: Duplicated association with ticket #277 was added

Comment by Assembla Importer [ 28/Sep/10 11:19 AM ]

chouser@n01se.net said: Please consider the solution provided by clojure.contrib.lazy-xml/emit which uses javax.xml.transform classes to fix not only these bugs (#410 and #408) but also support indent, xml-declaration, and encoding options.

Comment by Stuart Halloway [ 30/Oct/10 2:46 PM ]

emit is not part of Clojure's public API, and we don't want to grow a public API via an issue-driven random walk. If you are interested in this issue, please chime in on the design page for a new data.xml library: http://dev.clojure.org/display/DXML/Home





[CLJ-409] SAXParserFactoryImpl is missing at unit testing time Created: 23/Jul/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

SAXParserFactoryImpl seems to be AWOL while clojure unit tests are running, but is present when clojure is started from the command line. WTF?

(ns clojure.test-clojure.clojure-xml
  (:use clojure.test)
  (:import [javax.xml.parsers SAXParserFactory])
  (:require [clojure.xml :as xml]))

(deftest sax-parser-factory-is-not-awol
  (is (SAXParserFactory/newInstance)))
</code></pre>
<pre><code>Tell ant to run the unit tests:

$ ant test

And get the following exception:

ERROR in (sax-parser-factory-is-not-awol) (SAXParserFactory.java:134)
expected: (SAXParserFactory/newInstance)
actual: javax.xml.parsers.FactoryConfigurationError: Provider
        org.apache.xerces.jaxp.SAXParserFactoryImpl not found
at javax.xml.parsers.SAXParserFactory.newInstance (SAXParserFactory.java:134)
   clojure.test_clojure.clojure_xml/fn (clojure_xml.clj:17)

Yet, when I run clojure from the command line and do the same thing,
all is well.

$ java -jar clojure.jar
Clojure 1.2.0-beta1
user=> (import 'javax.xml.parsers.SAXParserFactory)
javax.xml.parsers.SAXParserFactory
user=> (SAXParserFactory/newInstance)
#<SAXParserFactoryImpl org.apache.xerces.jaxp.SAXParserFactoryImpl@19381960>
user=>

See also:
http://github.com/bpsm/clojure/commits/409show



 Comments   
Comment by Assembla Importer [ 24/Aug/10 12:34 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/409
Attachments:
show-409-on-oberon.txt - https://www.assembla.com/spaces/clojure/documents/aSijYaMmCr35jQeJe5cbLr/download/aSijYaMmCr35jQeJe5cbLr

Comment by Assembla Importer [ 24/Aug/10 12:34 AM ]

bpsm said: Provide link to my '409show' branch, which does what it says on the tin.

Comment by Assembla Importer [ 24/Aug/10 12:34 AM ]

stu said: This code works fine for me locally (Mac OS X). I would investigate a busted Ant setup, or getting a different version of Java, on your end.

I'll be looking through the rest of the XML tickets your filed this morning – thanks for taking the time!

Comment by Assembla Importer [ 24/Aug/10 12:34 AM ]

bpsm said: Thanks. I've seen this both on my Mac and Linux netbook (JDK 1.6.0_20), but I'm sitting in front of a machine I haven't tried to reproduce this on yet, so I'll give it a whirl here and report what I find.

Comment by Assembla Importer [ 24/Aug/10 12:34 AM ]

bpsm said: [file:aSijYaMmCr35jQeJe5cbLr]: demonstrates #409 on x64, Java1.6.0_20, ant 1.7.1

Comment by Assembla Importer [ 24/Aug/10 12:34 AM ]

bpsm said: I see the failure on my workstation as well, alas. I've attached a transcript including ant -diagnostics output. If it is my local setup at fault, I'm not sure what it could be. Perhaps something there will catch your eye.





[CLJ-408] clojure.xml emit does not properly escape attribute and element content Created: 23/Jul/10  Updated: 15/Nov/10  Resolved: 30/Oct/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Rich Hickey
Resolution: Declined Votes: 0
Labels: None

Approval: Not Approved

 Description   
(with-out-str
  (clojure.xml/emit-element {:tag :e :attrs nil :content "&"}))
</code></pre>
produces: <e>&</e>
correct would be: <e>&amp;</e>
This is true for both element content and attribute content. < and > are not escaped as well. Furthermore, apostrophe ( ' ) in an attribute value leads to broken xml:
<pre><code>
<e a='''/>


 Comments   
Comment by Assembla Importer [ 28/Sep/10 8:51 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/408
Attachments:
408-escape-and-in-content-and-attribute-value.patch - https://www.assembla.com/spaces/clojure/documents/aBCHT2LZer34ioeJe5cbLr/download/aBCHT2LZer34ioeJe5cbLr

Comment by Assembla Importer [ 28/Sep/10 8:51 AM ]

bpsm said: Tests that demonstrate #408 are available at http://github.com/bpsm/test-clojure-xml.

Comment by Assembla Importer [ 28/Sep/10 8:51 AM ]

bpsm said: [file:aBCHT2LZer34ioeJe5cbLr]: see also http://github.com/bpsm/clojure/commits/fix408,410,277

Comment by Assembla Importer [ 28/Sep/10 8:51 AM ]

bpsm said: I saw rich's message about marking issues "ready for test" to get patches noticed. This was in connection with marking #410 as ready for test. This issue is joined at the hip with 410 and also has a patch ready.

Comment by Stuart Halloway [ 30/Oct/10 2:47 PM ]

emit is not part of Clojure's public API, and we don't want to grow a public API via an issue-driven random walk. If you are interested in this issue, please chime in on the design page for a new data.xml library: http://dev.clojure.org/display/DXML/Home





[CLJ-406] Typo in underive causes breaking in the resulting hierarchy Created: 22/Jul/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

There's a typo on line 4515 in core.clj, in the definition of underive:

{:parent ... }
; should be
{:parents ... }
</code></pre>
causing breakage in hierarchies which had relationships underived in them.

E.g.
<pre><code>
(derive ::foo ::bar)
(underive ::foo ::bar)
(derive ::foo ::bar)
; => NPE

#clojure discussion:

http://clojure-log.n01se.net/date/2010-07-21.html#20:54



 Comments   
Comment by Assembla Importer [ 24/Aug/10 6:31 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/406

Comment by Assembla Importer [ 24/Aug/10 6:31 PM ]

stu said: Already discussed as a subset of #382.





[CLJ-395] "underive" corrupts ad hoc hierarchies. Created: 07/Jul/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

See transcript below, from 1.20-dev snapshot compiled about a week ago:

user=> (derive ::dad ::grandad)
nil
user=> (derive ::son ::dad)
nil
user=> (underive ::dad ::grandad)
nil
user=> (derive ::dad ::grandad)
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=> (derive ::foo ::bar)
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=>



 Comments   
Comment by Assembla Importer [ 24/Aug/10 11:06 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/395

Comment by Assembla Importer [ 24/Aug/10 11:06 AM ]

stu said: Duplicates #382.





[CLJ-389] slurp should not read one character at a time Created: 25/Jun/10  Updated: 01/Mar/13  Resolved: 02/Dec/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Approved Backlog
Fix Version/s: Release 1.4

Type: Enhancement Priority: Minor
Reporter: Aaron Bedra Assignee: Aaron Bedra
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File 0001-Improve-slurp-performance-by-using-native-Java-Strin.patch     Text File 0001-needles-StrinbBuilder-in-slurp.patch     File 0389_buffered_slurp.diff    
Patch: Code
Approval: Incomplete

 Description   

A discussion of slurp performance came up on the mailing list. The attached patch makes slurp use a 4kb buffer size instead of reading one character at a time, resulting in a significant performance improvement.



 Comments   
Comment by Assembla Importer [ 25/Oct/10 9:30 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/389
Attachments:
slurp-buffer-size.patch - https://www.assembla.com/spaces/clojure/documents/c7INhmGfSr34YDeJe5cbCb/download/c7INhmGfSr34YDeJe5cbCb

Comment by Assembla Importer [ 25/Oct/10 9:30 PM ]

stu said: Updating tickets (#389, #371)

Comment by Assembla Importer [ 25/Oct/10 9:30 PM ]

aaron said: Patch does not apply. It is not in the proper format. Please take a look at http://clojure.org/patches and resubmit. I will continue to review the code itself against the current master.

Comment by Aaron Bedra [ 29/Oct/10 9:43 AM ]

Contacted original poster about this to inform him of the move to JIRA and ensure interest in this patch

Comment by Aaron Bedra [ 12/Nov/10 1:55 PM ]

The patch has been reformatted and submitted.

Comment by Jürgen Hötzel [ 13/Nov/10 2:07 AM ]

Maybe duplicate: CLJ-668

Comment by Aaron Bedra [ 26/Nov/10 10:17 AM ]

CLJ-668 is a duplicate of this ticket. I have tested your patch and would like to consider it as a resolution to this ticket along with closing CLJ-668 as a duplicate. Can you please submit a patch to this ticket instead of a link to github? I am going to test all of the patches presented on OSX, Linux, EC2, and Windows.

Comment by Jürgen Hötzel [ 27/Nov/10 4:57 AM ]

Seems like the changes are already applied by your previous commit:

https://github.com/clojure/clojure/commit/cbd789d1a5b472d92b91f2fe0e273f48c2583483

Just a leftover StringBuilder Object (patch attached)

Comment by Aaron Bedra [ 28/Nov/10 10:06 AM ]

Yes, that was a mistake. It should not have gone in under #441. I was doing some testing and somehow I didn't properly revert what I was working on. Please consider that a mistake for now and include a patch here so you can get credit for your work.

Comment by Jürgen Hötzel [ 29/Nov/10 2:50 AM ]

Thanks. Patch enclosed.

Comment by Aaron Bedra [ 03/Dec/10 8:19 AM ]

Thanks. I am going to be testing the various ideas on multiple platforms to see which (if any) is the best fit.

Comment by Aaron Bedra [ 30/Nov/11 7:59 PM ]

This patch carries a performance hit. For example:

Clojure 1.4.0

File Size best timed 10x slurp
7.3 MB 2960.363 msecs
260 KB 105.255 msecs

With Patch

File Size best timed 10x slurp
7.3 MB 3700.406 msecs
260 KB 129.311 msecs

This was tested with

(time (dotimes [_ 10] (slurp "file")))

with each execution of this form done 20 times.





[CLJ-384] Document upgrade from 1.1 to 1.2 Created: 18/Jun/10  Updated: 01/Oct/10  Resolved: 01/Oct/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

In addition to things I assume are bugs, I've hit a couple of issues going from 1.1 to 1.2

The change in meaning of the ^ reader macro is big

I'm seeing errors now that meta data is limited to String, Keyword, Symbol or Map (I had some boolean values as meta data in my framework).

There's the notes about how name collisions on imports are now warnings, not errors (I've also heard that may change back to errors as in 1.1).

What else?

Anyway, IMHO there needs to be a "Upgrade to 1.2" page on clojure.org



 Comments   
Comment by Assembla Importer [ 01/Oct/10 8:45 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/384

Comment by Assembla Importer [ 01/Oct/10 8:45 AM ]

hlship said: Related association with ticket #383 was added

Comment by Assembla Importer [ 01/Oct/10 8:45 AM ]

stu said: Nobody stepped up and did this, so I am killing it so it stops showing up in reports. The Confluence is open to any CA signer who wants to write such documentation.





[CLJ-383] different arrities of macro don't work in 1.2 (20100607 build) Created: 18/Jun/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

I've been in the process of upgrading my framework from 1.1 to 1.2 and I've hit a serious stopper in code that works (and was tested) under 1.1.

~/clojure-workspace/cascade
$ lein repl
cascade.version=> (use 'cascade)
nil
cascade.version=> (link nil nil nil)
java.lang.IllegalArgumentException: Wrong number of args (3) passed to: cascade$link (NO_SOURCE_FILE:1)
cascade.version=> (doc link)
-------------------------
cascade/link
([env function] [env function extra-path-info] [env function extra-path-info query-parameters])
Macro
  Creates a link to a view or action function. Additional path info data may be specified (as a seq of
  data items), as well as query parameters (as a map whose keys are strings or keywords and whose values
  are converted to strings.). Uses standard keys from the env map. The resulting link is returned as a string.
nil
cascade.version=> (.printStackTrace *e)
java.lang.IllegalArgumentException: Wrong number of args (3) passed to: cascade$link (NO_SOURCE_FILE:1)
 at clojure.lang.Compiler.eval(Compiler.java:5437)
 at clojure.lang.Compiler.eval(Compiler.java:5388)
 at clojure.core$eval.invoke(core.clj:2370)
 at clojure.main$repl$read_eval_print__5620.invoke(main.clj:183)
 at clojure.main$repl$fn__5625.invoke(main.clj:203)
 at clojure.main$repl.doInvoke(main.clj:203)
 at clojure.lang.RestFn.invoke(RestFn.java:422)
 at user$eval9$fn__10.invoke(NO_SOURCE_FILE:1)
 at user$eval9.invoke(NO_SOURCE_FILE:1)
 at clojure.lang.Compiler.eval(Compiler.java:5421)
 at clojure.lang.Compiler.eval(Compiler.java:5412)
 at clojure.lang.Compiler.eval(Compiler.java:5412)
 at clojure.lang.Compiler.eval(Compiler.java:5388)
 at clojure.core$eval.invoke(core.clj:2370)
 at clojure.main$eval_opt.invoke(main.clj:234)
 at clojure.main$initialize.invoke(main.clj:253)
 at clojure.main$null_opt.invoke(main.clj:278)
 at clojure.main$main.doInvoke(main.clj:353)
 at clojure.lang.RestFn.invoke(RestFn.java:422)
 at clojure.lang.Var.invoke(Var.java:369)
 at clojure.lang.AFn.applyToHelper(AFn.java:165)
 at clojure.lang.Var.applyTo(Var.java:482)
 at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: Wrong number of args (3) passed to: cascade$link
 at clojure.lang.AFn.throwArity(AFn.java:439)
 at clojure.lang.AFn.invoke(AFn.java:47)
 at cascade$link.invoke(cascade.clj:90)
 at cascade$link.invoke(cascade.clj:92)
 at clojure.lang.Var.invoke(Var.java:381)
 at clojure.lang.AFn.applyToHelper(AFn.java:180)
 at clojure.lang.Var.applyTo(Var.java:482)
 at clojure.lang.Compiler.macroexpand1(Compiler.java:5283)
 at clojure.lang.Compiler.macroexpand(Compiler.java:5338)
 at clojure.lang.Compiler.eval(Compiler.java:5406)
 ... 22 more
Reflection warning, NO_SOURCE_PATH:6 - reference to field printStackTrace can't be resolved.
nil
cascade.version=> 
</code></pre>
 

Here's the source:

<pre><code>
(defmacro link
  "Creates a link to a view or action function. Additional path info data may be specified (as a seq of
  data items), as well as query parameters (as a map whose keys are strings or keywords and whose values
  are converted to strings.). Uses standard keys from the env map. The resulting link is returned as a string."
  ([env function]
    (link env function nil))
  ([env function extra-path-info]
    (link env function extra-path-info nil))
  ([env function extra-path-info query-parameters]
    `(link-path ~env (link-map-from-function ~function ~extra-path-info ~query-parameters))))

So, (doc) shows the number of parameters correctly, as does the code, but attempting to use it with 3 parameters generates the spurious error.

Here's a simpler example:

<pre>
<code>
$ lein repl
cascade.version=> (defmacro ex ([a] (ex a "no-b")) ([a b] `(format "a=%s, b=%s" ~a ~b)))
#'cascade.version/ex
cascade.version=> (ex)
java.lang.IllegalArgumentException: Wrong number of args (2) passed to: version$ex (NO_SOURCE_FILE:1)
cascade.version=> (ex 1)
java.lang.IllegalArgumentException: Wrong number of args (2) passed to: version$ex (NO_SOURCE_FILE:1)
cascade.version=> (ex 1 2)
"a=1, b=2"
cascade.version=>
</code>
</pre>



 Comments   
Comment by Assembla Importer [ 24/Aug/10 8:47 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/383

Comment by Assembla Importer [ 24/Aug/10 8:47 AM ]

hlship said: Related association with ticket #384 was added

Comment by Assembla Importer [ 24/Aug/10 8:47 AM ]

cgrand said: You were relying on an implementation detail (relying on macros being fns of same arity and those fns being not yet tagged as macro during the 1st evaluation of the body. Indeed this behaviour is brittle if your reload a new definition of the macro:

user=> (defmacro ex ([] (ex "v1")) ([v] (str "v1: I'm " v)))
#'user/ex
user=> (ex)
"v1: I'm v1"
user=> (defmacro ex ([] (ex "v2")) ([v] (str "v2: I'm " v)))
#'user/ex
user=> (ex)
"v1: I'm v2" ; and not "v2: I'm v2"</code></pre>

The correct way has always been to write:
<pre><code>(defmacro ex ([a] `(ex ~a "no-b")) ([a b] `(format "a=%s, b=%s" ~a ~b)))

and this till works with 1.2.

Comment by Assembla Importer [ 24/Aug/10 8:47 AM ]

hlship said: Point taken; I've been reviewing Stu's book and I can see how he does as your example (what I've called the workaround), which is to have the short form expand into a macro call to the next larger form. Anyway, this does rub me a little oddly ... I had thought of macros as merely special functions whose execution was integrated into the Clojure reader/compiler but not otherwise unlike ordinary functions. This is clearly not the case, though I'm curious as to the underlying change from 1.1 to 1.2.

Further I think there's still an underlying problem:

user=> (defmacro ex ([a] `(ex ~a "no-b")) ([a b] `(format "a=%s, b=%s" ~a ~b)))
#'user/ex
user=> (ex)
java.lang.IllegalArgumentException: Wrong number of args (2) passed to: user$ex (NO_SOURCE_FILE:1)
user=> (ex 1)
"a=1, b=no-b"
user=> (ex 1 2)
"a=1, b=2"
user=> (ex 1 2 3)
java.lang.IllegalArgumentException: Wrong number of args (5) passed to: user$ex (NO_SOURCE_FILE:1)
user=>

Seems like macros now get two extra invisible arguments, presumably related to how they are now implemented. Even so, the error message is confusing since the programmer's code didn't pass 2 arguments, it passed 0 arguments.

Comment by Assembla Importer [ 24/Aug/10 8:47 AM ]

cgrand said: The two implicit args are &env (a map whose keys are the locally bound symbols, values are unspecified) and &form (the whole form undergoing macroexpansion – it allows you to look at form's metadata). I reckon the off-by-two argcount in errors is annoying.

Comment by Assembla Importer [ 24/Aug/10 8:47 AM ]

hlship said: Right, so fixing that part of the problem, identifying the number of arguments in terms of what the coder wrote, rather than how Clojure is implemented, is a low priority fix, but one that should be addressed.

Comment by Assembla Importer [ 24/Aug/10 8:47 AM ]

stu said: Error reporting issue captured in #397.





[CLJ-372] possible binding issue in clojure.template? Created: 03/Jun/10  Updated: 01/Mar/13  Resolved: 26/Nov/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect
Reporter: Anonymous Assignee: Stuart Sierra
Resolution: Declined Votes: 0
Labels: None

Approval: Screened

 Description   

I came across some strange behavior the other day in clojure.test/are, where the template replacement seems a bit over-eager. As a simple case:

(use 'clojure.test)

(are [x y] (= x y)
'(4 9 16) (map (fn [x] (* x x)) '(2 3 4)))

gives "java.lang.Exception: Unsupported binding form: clojure.lang.LazySeq@7bed76a7", but

(are [x y] (= x y)
'(4 9 16) (map (fn [z] (* z z)) '(2 3 4)))

is fine. It seems that all instances of the variable x get replaced, even the ones in other expressions that are doing the replacing. A macroexpand-1 traced it to clojure.template, and if I patch apply-template there to use postwalk-replace rather than prewalk-replace, clojure.test/are works as I had expected. However, the simple test case I wrote to expose this problem (wrapping deftest around the first example above) fails with what seems to me to be a bizarre error:

[java] FAIL in (can-test-using-local-bindings) (test_clojure.clj:87)
[java] but got :pass
[java] expected: (= (quote (4 9 16)) (map (fn [x] (* x x)) (quote (2 3 4))))
[java] actual: (#<core$EQ clojure.core$EQ@a947850> (4 9 16) (4 9 16))

Can anyone decipher why this fails, or come up with a better solution?



 Comments   
Comment by Assembla Importer [ 24/Aug/10 11:29 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/372
Attachments:
template-local-binding.patch - https://www.assembla.com/spaces/clojure/documents/bEvfq-BS8r36foeJe5cbLA/download/bEvfq-BS8r36foeJe5cbLA

Comment by Assembla Importer [ 24/Aug/10 11:29 AM ]

stuart.sierra said: Reason for the bizarre error is the awkwardness of using clojure.test to test itself. clojure.test-clojure.test uses an alternate reporting function that looks at the doc string of the assertion.

This can be fixed by placing the can-test-use-local-bindings test in a different namespace.

Comment by Assembla Importer [ 24/Aug/10 11:29 AM ]

stuart.sierra said: I can't reproduce the error. This works for me:

user=> (are [x y] (= x y) '(4 9 16) (map (fn [x] (* x x)) '(2 3 4)))
true
Comment by Stuart Sierra [ 26/Nov/10 8:54 AM ]

Could not reproduce the reported error.





[CLJ-371] dynamic defrecord definitions trumped by AOT versions in classpath Created: 02/Jun/10  Updated: 02/Dec/11  Resolved: 02/Dec/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Approved Backlog
Fix Version/s: Approved Backlog

Type: Defect Priority: Minor
Reporter: Assembla Importer Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Approval: Vetted

 Description   

Symptom: Define a defrecord at the repl and you still see the old (AOT'd) defrecord.

In the attached project:
lein compile
lein repl

and enter the commands in the comment in src/defrecordissue/core.clj

Design Discussion here: http://dev.clojure.org/display/design/Dynamic+defrecord+definitions+trumped+by+AOT+versions+in+classpath



 Comments   
Comment by Assembla Importer [ 24/Aug/10 11:29 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/371
Attachments:
defrecordissue.tar.gz - https://www.assembla.com/spaces/clojure/documents/aggm70BPir356HeJe5cbLr/download/aggm70BPir356HeJe5cbLr

Comment by Assembla Importer [ 24/Aug/10 11:29 AM ]

stu said: Rich: I understand the classloader situation that causes this. If you tell me what you think should happen instead I will make a patch.

Comment by Assembla Importer [ 24/Aug/10 11:29 AM ]

stu said: Updating tickets (#389, #371)

Comment by Assembla Importer [ 24/Aug/10 11:29 AM ]

cemerick said: AFAICT, this also affects protocol definitions, where the associated interface classfile is available on the classpath.

Comment by Christopher Redinger [ 15/Apr/11 12:57 PM ]

You said you'd make a patch if Rich said it needed on. Your move.

Comment by Stuart Halloway [ 15/Apr/11 6:25 PM ]

This behavior is to be expected, given Java's class loaders. If you want static classes, compile them onto your classpath. If you want reloadable classes, load them at runtime (preferable) from source.

The real place to fix this problem is in build tools and IDEs. When you are developing interactively, these tools should default to non-compilation of Clojure files. The Clojure/core team will fix this in a future version of the Clojure maven build tools.

Comment by Christopher Redinger [ 22/Apr/11 11:47 AM ]

Re-opening - we closed this thinking it would be handled via tooling. It seems we should fix this though.

Comment by Stuart Halloway [ 15/Nov/11 7:16 PM ]

I don't know of any appropriate action to take, other than to change tools.

Comment by Stuart Halloway [ 02/Dec/11 1:39 PM ]

no, really, declined





[CLJ-370] record multimethod Created: 01/Jun/10  Updated: 16/Oct/11  Resolved: 16/Oct/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Assembla Importer Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Approval: Vetted
Waiting On: Stuart Halloway

 Description   

non-reflective dynamic creation of defrecord instances via a multimethod



 Comments   
Comment by Assembla Importer [ 24/Aug/10 10:27 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/370
Attachments:
0370-record-multimethod.patch - https://www.assembla.com/spaces/clojure/documents/d2J0riBEKr35rdeJe5cbLA/download/d2J0riBEKr35rdeJe5cbLA
0370-record-multimethod-take-2.patch - https://www.assembla.com/spaces/clojure/documents/aGvvlSCmWr35fseJe5cbCb/download/aGvvlSCmWr35fseJe5cbCb

Comment by Assembla Importer [ 24/Aug/10 10:27 AM ]

stu said: [file:d2J0riBEKr35rdeJe5cbLA]

Comment by Assembla Importer [ 24/Aug/10 10:27 AM ]

stu said: Questions:

  • I don't like that create-record is public in core. Change its name? Throw in another namespace?
Comment by Assembla Importer [ 24/Aug/10 10:27 AM ]

richhickey said: how about record-implementation-detail-multimethod?

Inside emit-record-factory-method, how about:

  • using :keys destructuring for fields
  • no need for apply on dissoc - it takes multiple keys

Also, you might want to make record itself a macro, so you can flow metadata to the created record:

^{:my "meta"}(record ::Foo :a 1 :b 2)

This will be useful since this will likely become at least the print-dup form for records

Comment by Assembla Importer [ 24/Aug/10 10:27 AM ]

stu said: I was thinking that record might often get apply-ed. Do we need a function and a macro?

Comment by Assembla Importer [ 24/Aug/10 10:27 AM ]

stu said: [file:aGvvlSCmWr35fseJe5cbCb]

Comment by Assembla Importer [ 24/Aug/10 10:27 AM ]

stu said: second patch subsumes first and incorporates Rich's feedback. print/read moved to separate ticket #374

Comment by Assembla Importer [ 24/Aug/10 10:27 AM ]

richhickey said: second thoughts here

Comment by Assembla Importer [ 24/Aug/10 10:27 AM ]

stu said: Updating tickets (#370, #366, #374)

Comment by Stuart Halloway [ 04/Jan/11 7:40 PM ]

Rich: updated design proposal at http://dev.clojure.org/display/design/defrecord+improvements. Please provide feedback there and then mark this as waiting on me.

Comment by Stuart Halloway [ 16/Oct/11 5:33 AM ]

Old ticket. Goal was accomplished via factory fns and literals.





[CLJ-363] defn doesn't put the right metadata on its fn value Created: 27/May/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

duplicate of #270

user=> (defn foo {:bar :baz} [] 42)
#'user/foo
user=> (meta #'foo)
{:ns #<Namespace user>, :name foo, :file "NO_SOURCE_PATH", :line 221, :arglists ([]), :bar :baz}
user=> (meta foo)
{:ns #<Namespace user>, :name foo} ; the value has only the basic keys
user=> (defn foo {:lucy :ethel} [] 43)
#'user/foo
user=> (meta #'foo)
{:ns #<Namespace user>, :name foo, :file "NO_SOURCE_PATH", :line 224, :arglists ([]), :lucy :ethel}
user=> (meta foo) ; the value has the previous metadata
{:ns #<Namespace user>, :name foo, :file "NO_SOURCE_PATH", :line 221, :arglists ([]), :bar :baz}


 Comments   
Comment by Assembla Importer [ 24/Aug/10 8:20 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/363

Comment by Assembla Importer [ 24/Aug/10 8:20 AM ]

cgrand said: Parent association with ticket #270 was added

Comment by Assembla Importer [ 24/Aug/10 8:20 AM ]

cgrand said: duplicate of #270





[CLJ-351] Disable transients after persistent! call Created: 19/May/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.2

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Comments   
Comment by Assembla Importer [ 24/Aug/10 8:10 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/351





[CLJ-345] clojure.contrib.string.replace-str throws NPE on nil string Created: 10/May/10  Updated: 01/Oct/10  Resolved: 01/Oct/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Version: Clojure 1.2 / clojure-contrib 1.2

This call:

user=> (clojure.contrib.string/replace-str "a" "b" nil)
#<CompilerException java.lang.NullPointerException (NO_SOURCE_FILE:29)>

throws a NullPointerException when passed a nil string. It seems like more corner cases could be automatically handled by returning nil in this case rather than throwing an NPE. At the very least, it would be nice to update the docstring to state that s cannot be nil.



 Comments   
Comment by Assembla Importer [ 01/Oct/10 6:44 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/345

Comment by Assembla Importer [ 01/Oct/10 6:44 AM ]

stu said: I evaluated this agains the latest version of the fn in clojre (e.g. clojure.string/replace).

The documentation string correctly lists legal parameters for replace as string, char, or fn, so an NPE is expected behavior.

Note also: the contrib versions of most string fns are deprecated.





[CLJ-307] consistent deprecation strategy Created: 21/Apr/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.2

Type: Enhancement
Reporter: Anonymous Assignee: Stuart Halloway
Resolution: Declined Votes: 0
Labels: None


 Description   

I am filing this as a Clojure ticket even though the problem currently occurs mostly in Contrib. That's because I think there needs to be an official "Clojure way" – this ticket is a request for documentation, not implementation.

Absent official guidelines, function and namespace deprecation has been handled in an ad hoc fashion. Sometimes functions move from one namespace to another, leaving no trace. Other times, something is left in the old namespace: either an error or a warning redirecting to the new namespace.

I would like to see a recommendation that leaves some kind of visible trace (for at least one point release) both in the source code tree and in the api docs.

Fallback namespaces (http://groups.google.com/group/clojure-dev/browse_thread/thread/9fde83ce4c06ed77) are out of scope for this ticket, but might be a separate ticket that builds on whatever is decided here.



 Comments   
Comment by Assembla Importer [ 24/Aug/10 10:39 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/307

Comment by Assembla Importer [ 24/Aug/10 10:39 AM ]

stu said: Updating tickets (#303, #306, #307)

Comment by Assembla Importer [ 24/Aug/10 10:39 AM ]

stu said: We are sorting this out in contrib.





[CLJ-295] disambiguate protocol extended to two interfaces Created: 15/Apr/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.2

Type: Enhancement
Reporter: Anonymous Assignee: Rich Hickey
Resolution: Declined Votes: 0
Labels: None


 Description   

If a protocol is extended to two interfaces, and an object implements both, it will get one of them at random. I'd be happy if this case was simply an error.



 Comments   
Comment by Assembla Importer [ 24/Aug/10 10:32 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/295





[CLJ-287] (take-nth 0 coll) spins wheels on Solaris Created: 31/Mar/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

(take-nth 0 (range 5)) is a silly thing to do, but if you're anything like me then it inexorably fills heap space and cpu time by an infinite number of RMI calls.
I'm running Clojure 1.1.0-master-SNAPSHOT under Java 1.6R17 on Solaris 10 and I watched it fill up to 56GB
I think it should raise an exception instead but Im too new to clojure to recommend one. Sorry
Cheers
Simon



 Comments   
Comment by Assembla Importer [ 24/Aug/10 10:10 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/287
Attachments:
take-nth.diff - https://www.assembla.com/spaces/clojure/documents/awDmNUpz4r34FheJe5aVNr/download/awDmNUpz4r34FheJe5aVNr

Comment by Assembla Importer [ 24/Aug/10 10:10 AM ]

bhurt said: [file:awDmNUpz4r34FheJe5aVNr]: Proposed patch to fix this ticket

Comment by Assembla Importer [ 24/Aug/10 10:10 AM ]

stu said: Hi Simon,

If you set the print-length you can prevent runaway sequences from trying to print. Try the following, and if still blows up please re-open or file a new bug:

(set! *print-length* 10)
 (take-nth 0 (range 5))

Cheers,
Stu

Comment by Assembla Importer [ 24/Aug/10 10:10 AM ]

bhurt said: I think the real problem is that (take-nth 0 some-list) is invalid. It's nonsensical in a deep way- take every 0th element? If you glanced at my patch, all I did was validate the arguments and throw an exception if the n argument is not positive, rather than returning an infinite list. I mean, a similar problem shows up if you do (count (take-nth 0 (range 5))).





[CLJ-284] Cannot cast 0xFF to a byte (fails range check) Created: 24/Mar/10  Updated: 28/Sep/10  Resolved: 28/Sep/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Enhancement
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

Prompted by a thread on the clojure group.

The recently added range checking to casts/coercions adversely affects a common usage of the byte cast to pull the 8 LSBs of an integer. Since the numerical representation of a byte is signed in java, the Byte.MIN_VALUE</code> and <code>Byte.MAX_VALUE</code> used in the range check of <code>clojure.lang.RT.byteCast() do not allow for integer values up to 0xFF.



 Comments   
Comment by Assembla Importer [ 28/Sep/10 1:05 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/284
Attachments:
ubyte.diff - https://www.assembla.com/spaces/clojure/documents/b_MyyAn4mr34xSeJe5avMc/download/b_MyyAn4mr34xSeJe5avMc

Comment by Assembla Importer [ 28/Sep/10 1:05 PM ]

ataggart said: [file:b_MyyAn4mr34xSeJe5avMc]: Adds a ubyte coercion when the resulting byte should be considered unsigned, thus inputs of 0-255 are acceptable

Comment by Assembla Importer [ 28/Sep/10 1:05 PM ]

ataggart said: Patch provided to add a ubyte coercion:

<pre>user=> 0xFF
255
user=> (Integer/toBinaryString 0xFF)
"11111111"
user=> (byte 0xFF)
java.lang.IllegalArgumentException: Value out of range for byte: 255 (NO_SOURCE_FILE:0)
user=> (ubyte 0xFF)
-1
user=> (ubyte 256)
java.lang.IllegalArgumentException: Value out of range for unsigned byte: 256 (NO_SOURCE_FILE:0)
</pre>

Comment by Assembla Importer [ 28/Sep/10 1:05 PM ]

richhickey said: This is really a subset of #441

Comment by Assembla Importer [ 28/Sep/10 1:05 PM ]

ataggart said: Agreed.





[CLJ-283] recur ignores rest args Created: 17/Mar/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

When you recur inside a function, the arguments are not assigned as expected:

(defn weird [& b]
(println b)
(when (< (first b) 2)
(recur (inc (first b)))))

(weird 1)

The first time it runs, b is a seq, but the second time it's just an integer.

After some discussion I found out this is because there's no way to apply recur, so technically making recur act as a normal function call means you can't pass a seq of args in. While this is arguably a decent workaround, it leads to very confusing, undocumented behaviour; at the very least it should be tracked in an issue until a better solution can be found.



 Comments   
Comment by Assembla Importer [ 24/Aug/10 7:55 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/283

Comment by Assembla Importer [ 24/Aug/10 7:55 AM ]

stu said: Recur doesn't re-enter the function, it just goes back to the top (the vararging doesn't happen again). Since b is a collection coming in, recur with a collection and you will be fine.

(defn weird [& b]
  (println b)
  (when (< (first b) 2)
    (recur (cons (inc (first b)) (rest b)))))

I find this intuitive, but when I launch the Assembla FAQ feel free to add an item for this if you like.

Comment by Assembla Importer [ 24/Aug/10 7:55 AM ]

technomancy said: > I find this intuitive, but when I launch the Assembla FAQ feel free to add an item for this if you like.

OK. Anecdotally I asked four other seasoned Clojure users what they thought was going on here and only one had an explanation, so most folks are going to think this is an unintended result when they see it. I don't know if it's FA enough to qualify this for a FAQ, but even having this closed issue show up in search results is an improvement.

I know internally there's a difference between calling a function and executing the body of a function, but up till this point I considered that an implementation detail.





[CLJ-271] Determine direct binding policy and controls Created: 16/Feb/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.2

Type: Enhancement
Reporter: Anonymous Assignee: Rich Hickey
Resolution: Declined Votes: 0
Labels: None


 Description   

Direct binding is in place as an experiment. We need ways to control the application and granularity of direct binding.



 Comments   
Comment by Assembla Importer [ 24/Aug/10 6:25 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/271

Comment by Assembla Importer [ 24/Aug/10 6:25 AM ]

technomancy said: Related association with ticket #246 was added

Comment by Assembla Importer [ 24/Aug/10 6:25 AM ]

stu said: disable for 1.2 and then move to approved backlog

Comment by Assembla Importer [ 24/Aug/10 6:25 AM ]

stu said: Direct binding is dead in favor of a better perf enhancement post 1.2.





[CLJ-261] Use Ant instead of Maven for Clojure-Contrib Created: 10/Feb/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

It would be nice if we could go back to Ant for building the clojure-contrib. At this time, it appears to be downloading many different packages that are not a part of the Clojure-Contrib source but Maven dependencies. Furthermore, it would be consistent with the way that we currently build Clojure.



 Comments   
Comment by Assembla Importer [ 24/Aug/10 6:19 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/261

Comment by Assembla Importer [ 24/Aug/10 6:19 AM ]

technomancy said: Regardless of whether this is a valid point, it should be opened on the Contrib project rather than Clojure.

http://www.assembla.com/spaces/clojure-contrib/tickets





[CLJ-260] Cannot load clojure classes from Jar files outside classpath using URLClassLoader Created: 09/Feb/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.2

Type: Defect
Reporter: Anonymous Assignee: Stuart Halloway
Resolution: Declined Votes: 0
Labels: None


 Description   

It is not possible to use URLClassLoader to load a class from a jar file if the jar is outside the classpath. It seems that RT.load tries to search for *.clj file within the classpath and doesn't respect the URLClassLoader and then fails with:

Exception in thread "main" java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at Loader.main(Loader.java:17)
Caused by: java.io.FileNotFoundException: Could not locate net/experimentalworks/Foo__init.class or net/experimentalworks/Foo.clj on classpath:
at clojure.lang.RT.load(RT.java:402)
at clojure.lang.RT.load(RT.java:371)
at clojure.core$load_6449$fn_6458.invoke(core.clj:4171)
at clojure.core$load__6449.doInvoke(core.clj:4170)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at clojure.lang.Var.invoke(Var.java:359)
at net.experimentalworks.Foo.<clinit>(Unknown Source)
... 7 more

The attached .tar.gz contains a sample jar file and the clojure file that was used to generate the class files as well as the sample loader. Java oder Scala written classes can be loaded without any problems. For sure the I put the clojure runtime into the classpath but not the loadme-clojure.jar



 Comments   
Comment by Assembla Importer [ 24/Aug/10 3:18 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/260
Attachments:
loader.tar.gz - https://www.assembla.com/spaces/clojure/documents/ayyZTifAyr34QPeJe5aVNr/download/ayyZTifAyr34QPeJe5aVNr

Comment by Assembla Importer [ 24/Aug/10 3:18 PM ]

stu said: Clojure's base loader uses the thread context loader so long as use-context-classloader is true (the default). Make sure context class loader is set, and then set the thread context class loader to be the loader you have created by calling:

Thread.currentThread().setContextClassLoader(loader);

Do this before using the loader to load classes.

Cheers,
Stu





[CLJ-251] macroexpand should respect :inline Created: 28/Jan/10  Updated: 07/Oct/11  Resolved: 07/Oct/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Enhancement
Reporter: Anonymous Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


 Description   

macroexpand and macroexpand-1 currently do not respect the :inline metadata of
functions. For example you currently see:

(macroexpand '(+ 1 2))
;=> (+ 1 2)

Instead, macroexpand should return something like:

;=> (. clojure.lang.Numbers (add 1 2))

...depending of course on the exact definition of +'s :inline fn.



 Comments   
Comment by Assembla Importer [ 24/Aug/10 6:06 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/251





[CLJ-241] Tests for reify Created: 12/Jan/10  Updated: 24/Aug/10  Resolved: 24/Aug/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.2

Type: Enhancement
Reporter: Anonymous Assignee: Stuart Halloway
Resolution: Declined Votes: 0
Labels: None


 Description   

subsumed by #239 and #240



 Comments   
Comment by Assembla Importer [ 24/Aug/10 3:51 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/241





[CLJ-238] Make re-pattern accept multiple arguments to concatenate them. Created: 05/Jan/10  Updated: 07/Oct/11  Resolved: 07/Oct/11

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Enhancement
Reporter: Anonymous Assignee: Nicolas Buduroi
Resolution: Declined Votes: 0
Labels: