<< Back to previous view

[CLJ-1305] Add optional not-found argument when invoking vectors or sets as functions Created: 12/Dec/13  Updated: 13/Dec/17

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

Type: Feature Priority: Minor
Reporter: Dave Tenny Assignee: Unassigned
Resolution: Unresolved Votes: 11
Labels: None

Attachments: Text File 0001-Added-tests-for-using-get-on-sets-refs-1305.patch     Text File 0001-add-not-found-to-sets-and-vecs-as-functions-refs-130.patch    
Approval: Triaged


Maps, keywords, and symbols when used as operators allow optional second arguments for 'default-not-found' values is if to 'get'.

({:a 1} :b 'b) => b

However sets don't support this behavior (though they do with 'get') and vectors don't allow the optional default-not-found in their pseudo 'nth' semantics.

user=> (#{:a  :b} :b 'notfound)
ArityException Wrong number of args (2) passed to: PersistentHashSet  clojure.lang.AFn.throwArity (AFn.java:437)

Comment by Pepijn de Vos [ 12/Nov/14 1:31 PM ]

I fixed the problem with Dirk at the Amsterdam Clojurians Hackathon.

Comment by Bozhidar Batsov [ 12/Nov/14 3:15 PM ]

Guess you can add a couple of unit tests as well.

Comment by Dirk Geurs [ 30/Dec/14 9:51 AM ]

I have added some tests for the changes made earlier.

Comment by Aaron Brooks [ 13/Dec/17 5:58 PM ]

Is there something that is needed for these patches to be applied? I run into this semi-regularly.

Comment by Alex Miller [ 13/Dec/17 9:40 PM ]

Sorry, has just never been looked at afaik. Votes help raise visibility.

Generated at Tue Jan 16 02:12:44 CST 2018 using JIRA 4.4#649-r158309.