ClojureScript

Keyword invoke is inconsistent with clojure

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    CLJS 1934

Description

ClojureScript:

(deftype Empty []
  ILookup 
  (-lookup [o k] :nothing)
  (-lookup [o k not-found] not-found))

(:a (Empty.))

==> nil

Clojure:

(import clojure.lang.ILookup)
(deftype Empty []
  ILookup
  (valAt [o k] :nothing)
  (valAt [o k not-found] not-found))
(:a (Empty.))

==> :nothing

I realize that returning something other than nil for not-found is a questionable design decision but unless Clojure is changed it seems to me ClojureScript should be consistent.

Activity

Hide
Jozef Wagner added a comment -

The ILookup protocol should be changed in the first place. Having (valAt [o k]) is redundant, as by definition (valAt [o k]) has to be equal to (valAt [o k nil]). The 'optionality' of not-found parameter should be handled in the get function.

Show
Jozef Wagner added a comment - The ILookup protocol should be changed in the first place. Having (valAt [o k]) is redundant, as by definition (valAt [o k]) has to be equal to (valAt [o k nil]). The 'optionality' of not-found parameter should be handled in the get function.
Hide
David Nolen added a comment -

Not true as you may in some cases know you have an ILookup instance and prefer and to avoid the indirection to get all together.

Show
David Nolen added a comment - Not true as you may in some cases know you have an ILookup instance and prefer and to avoid the indirection to get all together.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: