clojure.string/escape in ClojureScript (unlike in Clojure) assumes cmap is a map

Description

The ClojureScript implementation of the clojure.string/escape function assumes that the cmap parameter will always be a map. This makes it different from (and specifically less general than) the Clojure implementation of the same function, which permits cmap to be anything callable.

Here's the relevant lines of the clojure.string/escape implementations in Clojure and ClojureScript. The ClojureScript implementation calls get on cmap, while the Clojure implementation invokes cmap directly.

Here's an example that works on Clojure, but doesn't work on ClojureScript, because it passes a function to clojure.string/escape instead of a map:

Ideally, this discrepancy would be fixed by changing the ClojureScript implementation of clojure.string/escape to follow the Clojure one. This would also match the behavior described in the function's docstring, which is the same on both platforms.

Environment

None

Activity

Show:
Mike Fikes
May 12, 2019, 2:44 AM

0001-CLJS-2268-Make-clojure.string-escape-constent-with-C.patch added to Patch Tender

Your pinned fields
Click on the next to a field label to start pinning.

Assignee

David Nolen

Reporter

import

Labels

Patch

Code and Test