Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6673577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:38:37+00:00 2026-05-26T03:38:37+00:00

I recently asked about composite keys in maps in clojure : How can you

  • 0

I recently asked about composite keys in maps in clojure : How can you implement Composite keys in clojure? …

The answer was that they work similar to java keys – if something overrides “equals”, then it can be used effectively as a key.

I was wondering : Are there macros that allow us to override “equals” for custom data structures ? For example, say I wanted to use a Map as a key, and define uniqueness as “if this map contains 2 or more elements in common with another map, they are equal”. How could I override the default behavior of a map ?

In java, I find this facility to be quite powerful when making high speed maps with thousands of beans as keys.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:38:37+00:00Added an answer on May 26, 2026 at 3:38 am

    It’s not that clojure collections override equals; overriding equals happens almost everywhere you’re doing something interesting. Clojure types provide an implementation of equals that is intended to be consistent for the whole language (arguably in a way that Java’s equals was intended to be used). That means that things that are “equal” should be singular items in sets, and singular keys in maps, always, everywhere. The language design depends on that. Clojure 1.3 made some explicit non-backward compatible changes to get closer to that ideal.

    Going against that expected behavior of equals is very likely going to cause trouble somewhere, somehow. And it’s not too difficult to use your own set-like composites when you really need them without forcing your will on core equals anyway.

    That said, you can use many java interop functions and macros to pervert the equals system if you really want to. See http://clojure.org/datatypes as a starting point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently asked a question about IIf vs. If and found out that there
I recently asked a question about what I called method calls. The answer referred
I recently asked a question about tracing Linq-to-Entities I think that one of the
I recently asked a question about functional programming, and received (good!) answers that prompted
I recently asked about how to plot graphs in Java and I was recommended
I was recently asked about alternatives to Coverity Prevent for a code base that
I recently asked a question about controlling the volume of a Java audio clip
I've recently asked a question on StackoverFlow about the MVC: Can the MVC Design
I was recently asked a question, apparently in an Interview, about extending the java.lang.RuntimeException.
I recently asked a question about Self-Joins and I got a great answer. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.