Clojure

PersistentQueue doesn't implement java.util.List, causing nontransitive equality

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test

Description

PersistentQueue implements Sequential but doesn't implement java.util.List. Lists form an equality partition, as do Sequentials. This means that you can end up with nontransitive equality:

(def q (conj clojure.lang.PersistentQueue/EMPTY 1 2 3))
;=> #user/q
(def al (doto (java.util.ArrayList.) (.add 1) (.add 2) (.add 3)))
;=> #user/al
(def v [1 2 3])
;=> #user/v
(= al v)
;=> true
(= v q)
;=> true
(not= al q)
;=> true

This happens because PersistentQueue is a Sequential but not a List, ArrayList is a List but not a Sequential, and PersistentVector is both.

Activity

Philip Potter made changes -
Field Original Value New Value
Attachment 001-make-PersistentQueue-implement-List.diff [ 11501 ]
Andy Fingerhut made changes -
Patch Code and Test [ 10002 ]
Philip Potter made changes -
Affects Version/s Release 1.4 [ 10040 ]
Philip Potter made changes -
Assignee Philip Potter [ ppotter ]
Philip Potter made changes -
Attachment 002-make-PersistentQueue-implement-ASequential.diff [ 11509 ]
Philip Potter made changes -
Attachment 001-make-PersistentQueue-implement-List.diff [ 11501 ]
Philip Potter made changes -
Attachment 002-make-PersistentQueue-implement-ASequential.diff [ 11509 ]
Philip Potter made changes -
Attachment 002-clj-1059-asequential.diff [ 11661 ]
Attachment 001-clj-1059-make-persistentqueue-implement-list.diff [ 11660 ]
Timothy Baldridge made changes -
Approval Vetted [ 10003 ]
Philip Potter made changes -
Philip Potter made changes -
Attachment 002-clj-1059-asequential.diff [ 11661 ]
Rich Hickey made changes -
Approval Vetted [ 10003 ]
Alex Miller made changes -
Description PersistentQueue implements Sequential but doesn't implement java.util.List. Lists form an equality partition, as do Sequentials. This means that you can end up with nontransitive equality:

(def q (conj clojure.lang.PersistentQueue/EMPTY 1 2 3))
;=> #user/q
(def al (doto (java.util.ArrayList.) (.add 1) (.add 2) (.add 3)))
;=> #user/al
(def v [1 2 3])
;=> #user/v
(= al v)
;=> true
(= v q)
;=> true
(not= al q)
;=> true

This happens because PersistentQueue is a Sequential but not a List, ArrayList is a List but not a Sequential, and PersistentVector is both.
PersistentQueue implements Sequential but doesn't implement java.util.List. Lists form an equality partition, as do Sequentials. This means that you can end up with nontransitive equality:

{code}
(def q (conj clojure.lang.PersistentQueue/EMPTY 1 2 3))
;=> #user/q
(def al (doto (java.util.ArrayList.) (.add 1) (.add 2) (.add 3)))
;=> #user/al
(def v [1 2 3])
;=> #user/v
(= al v)
;=> true
(= v q)
;=> true
(not= al q)
;=> true
{code}

This happens because PersistentQueue is a Sequential but not a List, ArrayList is a List but not a Sequential, and PersistentVector is both.
Labels queue

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated: