<< Back to previous view

[CLJS-638] Keyword invoke is inconsistent with clojure Created: 25/Oct/13  Updated: 26/Oct/13  Resolved: 25/Oct/13

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

Type: Defect Priority: Major
Reporter: George Fraser Assignee: Unassigned
Resolution: Completed Votes: 0
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.



 Comments   
Comment by David Nolen [ 25/Oct/13 5:11 PM ]

fixed, http://github.com/clojure/clojurescript/commit/fbae5fb331e9e45c89f95b94b372947e43ad254d

Comment by Jozef Wagner [ 26/Oct/13 2:55 AM ]

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.

Comment by David Nolen [ 26/Oct/13 10:08 AM ]

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.

Generated at Tue Sep 23 05:29:18 CDT 2014 using JIRA 4.4#649-r158309.