Regexp are never equal

Description

The following (= #"asd" #"asd") will return false in CLJ, even if they are the same.

Consequently, everything with a regexp in it (lists, vectors, maps...) will never be equal.

It seems to have been fixed for CLJS, but not for CLJ.
https://github.com/clojure/clojurescript/commit/e35c3a57472fa62ae41591418a73794dc8ac6dde

Environment

None

Activity

Show:
Michael Drogalis
April 14, 2013, 3:13 AM

It was prompted as a matter of consistency, which I think is valid. I can't think of a good reason to use regex's as keys though.

import
April 11, 2014, 5:13 PM

Comment made by: trevorhartman

This issue surfaced as a bug in my code, e.g.: (get {#"^named$" 1} #"^named$") ;=> nil ; surprise!

Jason Felice
April 30, 2018, 2:44 AM

Datomic cannot compile-cache expressions containing a pattern (causing a day or so of debugging). I suspect this is the only built-in syntax which does not create comparable expressions when read. I think this makes sense in that regard, for caching and otherwise working with expressions which may contain patterns.

Also, the Java language spec indicates that .toString returns the string from which the pattern was compiled specifically, so implementing this would provide an intensional equality similar to unicode strings.

Andy Fingerhut
May 1, 2018, 4:47 PM

Jason, I have no idea if Rich would consider your recent comment compelling in a way to cause him to reconsider this issue. I am guessing that while this is a reasonable CLJ bug to comment on, a declined issue seems unlikely to get attention from anyone except the handful of people who watch all Clojure JIRA comments, and even we will forget about it a month afterwards. Maybe send an email to Clojure Dev Google group asking whether your use case warrants reopening this issue, or creating a new one?

Alex Miller
May 2, 2018, 7:10 PM

We have no plans to reopen this.

Declined

Assignee

olenhad

Reporter

import

Labels

None

Approval

Triaged

Patch

Code

Affects versions

Priority

Minor
Configure