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 9180847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:09:01+00:00 2026-06-17T18:09:01+00:00

Following up from this question: Idiomatic clojure map lookup by keyword Map access using

  • 0

Following up from this question: Idiomatic clojure map lookup by keyword

Map access using clojure can be done in many ways.

(def m {:a 1}

(get m :a) ;; => 1
(:a m) ;; => 1
(m :a) ;; => 1

I know I use mainly the second form, and sometimes the third, rarely the first. what are the advantages (speed/composability) of using each?

  • 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-06-17T18:09:02+00:00Added an answer on June 17, 2026 at 6:09 pm

    From the clojure web page we see that

    Maps implement IFn, for invoke() of one argument (a key) with an
    optional second argument (a default value), i.e. maps are functions of
    their keys. nil keys and values are ok.

    Sometimes it is rewarding to take a look under the hoods of Clojure. If you look up what invoke looks like in a map, you see this:

    https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/APersistentMap.java#L196

    It apparently calls the valAt method of a map.

    If you look at what the get function does when called with a map, this is a call to clojure.lang.RT.get, and this really boils down to the same call to valAt for a map (maps implement ILookUp because they are Associatives):

    https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L634.

    The same is true for a map called with a key and a not-found-value. So, what is the advantage? Since both ways boil down to pretty much the same, performance wise I would say nothing. It’s just syntactic convenience.

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

Sidebar

Related Questions

Following on from this question: Referencing parent field on document creation I'm using the
Following on from this question , I'm using a simple ViewModel class to test
Following on from this question: Can't I use JQuery inside my FancyZoom popup? The
Following on from this question here: Entity Framework Reverse Engineer using Power Tools -
Following on from this question I am using the code provided in one of
Following on from this question I asked yesterday: Can I shorten this regular expression?
Following on from this question , can someone explain the following in Scala: class
Following up from this question: How can I unlock a file that is locked
Following on from this question I now have code that can attach to a
Following on from this question , I am interested in finding out how you

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.