Re: Small bug in clojure.core/bases?

2011-08-15 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Mittwoch, 10. August 2011 22:15:48 UTC+2 schrieb Alf:

 When calling bases on an inteface it returns an array. Should this not
 be a seq?

Would that make a difference? You can pass an array where you'd expect a 
sequence.

Sincerely
Meikel

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Alf Kristian Støyle
I think a function should generally return the same types for
different input. A seq and a Java array are two very different things
even though Clojure often lets us pass both to the same functions. It
seemed like a small fix, but I guess not everyone agrees.

Like a wrote, I think this is small bug. I was just playing around
with the function at the repl, and the behavior surprised me, so I
thought I would mention it on the mailing list.

user= (bases java.util.List)
#Class[] [Ljava.lang.Class;@315b0333
user= (bases java.util.ArrayList)
(java.util.AbstractList java.util.List java.util.RandomAccess
java.lang.Cloneable java.io.Serializable)

Cheers,
Alf



On Mon, Aug 15, 2011 at 08:03, Meikel Brandmeyer (kotarak) m...@kotka.de 
wrote:
 Hi,

 Am Mittwoch, 10. August 2011 22:15:48 UTC+2 schrieb Alf:

 When calling bases on an inteface it returns an array. Should this not
 be a seq?

 Would that make a difference? You can pass an array where you'd expect a
 sequence.

 Sincerely
 Meikel

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Small bug in clojure.core/bases?

2011-08-15 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Montag, 15. August 2011 11:25:33 UTC+2 schrieb Alf:

 I think a function should generally return the same types for
 different input. A seq and a Java array are two very different things
 even though Clojure often lets us pass both to the same functions. It
 seemed like a small fix, but I guess not everyone agrees.


No issue. Just thought you might have a specific use case where this is an 
issue.

Sincerely
Meikel
 

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Phillip Garland
On Aug 10, 2011 1:16 PM, Alf Kristian Støyle alf.krist...@gmail.com
wrote:
 I think I found a small bug in clojure.core/bases. Extending the
 existing unit test reveals it:

 (deftest test-bases
 (are [x y] (= x y)
 (bases java.lang.Math)
 (list java.lang.Object)
 (bases java.lang.Integer)
 (list java.lang.Number java.lang.Comparable) )
 (is (seq? (bases java.util.List

 Test output is:

 FAIL in (test-bases) (java_interop.clj:143)
 expected: (seq? (bases java.util.List))
 actual: (not (seq? #Class[] [Ljava.lang.Class;@363256a5))

 When calling bases on an inteface it returns an array. Should this not
 be a seq?

 An easy fix though, 'seq' the else part:

 (defn bases
 Returns the immediate superclass and direct interfaces of c, if any
 {:added 1.0
 :static true}
 [^Class c]
 (when c
 (let [i (.getInterfaces c)
 s (.getSuperclass c)]
 (not-empty
 (if s (cons s i) (seq i))

 Should I file a bug, submit a pull request, or is the behavior intended?

 Cheers,
 Alf

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Armando Blancas
 I think a function should generally return the same types for
 different input. A seq and a Java array are two very different things
 even though Clojure often lets us pass both to the same functions. It
 seemed like a small fix, but I guess not everyone agrees.

That's clearly a bug; they forgot to seq one of the two possible
return values. File a bug and add a patch.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Small bug in clojure.core/bases?

2011-08-15 Thread Alf Kristian Støyle
Thanks. Submitted an issue to Jira, and I guess I will just see how it goes.

http://dev.clojure.org/jira/browse/CLJ-828

Cheers
Alf



On Mon, Aug 15, 2011 at 16:26, Armando Blancas
armando_blan...@yahoo.com wrote:
 I think a function should generally return the same types for
 different input. A seq and a Java array are two very different things
 even though Clojure often lets us pass both to the same functions. It
 seemed like a small fix, but I guess not everyone agrees.

 That's clearly a bug; they forgot to seq one of the two possible
 return values. File a bug and add a patch.

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Small bug in clojure.core/bases?

2011-08-14 Thread Stephen Compall
On Wednesday, August 10, 2011 4:15:48 PM UTC-4, Alf wrote:

 Should this not be a seq?


That depends on how you interpret the plural (immediate superclass and 
direct interfaces) in its docstring.

user (clojure-version)
1.2.1
user (use 'clojure.contrib.core 'clojure.pprint)
nil
user (pprint (map (fn [p?]
 (cons (:name (meta p?))
   (map (juxt identity p?)
[[1]
 (map identity [1])
 (bases java.util.List)])))
   [#'seq? #'sequential? #'seqable?]))
((seq? [[1] false] [(1) true] [[java.util.Collection] false])
 (sequential? [[1] true] [(1) true] [[java.util.Collection] false])
 (seqable? [[1] true] [(1) true] [[java.util.Collection] true]))

I personally favor seqable? as the test for plural return values.  
sequential? almost qualifies, but excludes sets.  seq? fails on account of 
rejecting even vectors, but you may feel differently.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Small bug in clojure.core/bases?

2011-08-14 Thread Sean Corfield
On Sun, Aug 14, 2011 at 9:04 PM, Stephen Compall
stephen.comp...@gmail.com wrote:
 I personally favor seqable? as the test for plural return values.
 sequential? almost qualifies, but excludes sets.  seq? fails on account of
 rejecting even vectors, but you may feel differently.

And just to do my usual pitch for the new contrib libraries so folks
can get used to them and start switching from old monolithic contrib
to the new modular contribs...

seqable? now lives in [org.clojure/core.incubator 0.1.0]
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Small bug in clojure.core/bases?

2011-08-10 Thread Alf Kristian Støyle
I think I found a small bug in clojure.core/bases. Extending the
existing unit test reveals it:

(deftest test-bases
  (are [x y] (= x y)
  (bases java.lang.Math)
(list java.lang.Object)
  (bases java.lang.Integer)
(list java.lang.Number java.lang.Comparable) )
(is (seq? (bases java.util.List

Test output is:

FAIL in (test-bases) (java_interop.clj:143)
expected: (seq? (bases java.util.List))
  actual: (not (seq? #Class[] [Ljava.lang.Class;@363256a5))

When calling bases on an inteface it returns an array. Should this not
be a seq?

An easy fix though, 'seq' the else part:

(defn bases
  Returns the immediate superclass and direct interfaces of c, if any
  {:added 1.0
   :static true}
  [^Class c]
  (when c
(let [i (.getInterfaces c)
  s (.getSuperclass c)]
  (not-empty
   (if s (cons s i) (seq i))

Should I file a bug, submit a pull request, or is the behavior intended?

Cheers,
Alf

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en