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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:02:23+00:00 2026-05-14T01:02:23+00:00

In clojure, keywords evaluate to themselves, e.g.: >>:test :test They don’t take any parameters,

  • 0

In clojure, keywords evaluate to themselves, e.g.:

>>:test
:test

They don’t take any parameters, and they aren’t bound to anything. Why then, would we need to qualify keywords in a namespace?

I know that creating isa hierachies using derive requires namespace qualified keywords (e.g. ::test). Are there any other cases where there is a clear need for keywords to be in a namespace?

  • 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-14T01:02:23+00:00Added an answer on May 14, 2026 at 1:02 am

    One place where Clojure currently requires namespace-qualified keywords is when using the extend function function to add an implementation of a protocol to an existing type. (This is 1.2 functionality, available with the latest snapshots, but not the 1.1 stable release.) The relevant snippet from (doc extend):

    extend takes a type/class (or interface, see below), and one or more
    protocol + method map pairs. It will extend the polymorphism of the
    protocol’s methods to call the supplied methods when an AType is
    provided as the first argument. Note that deftype types are specified
    using their keyword tags:

    ::MyType or :my.ns/MyType

    Indeed, for an Apple type and an Eatable protocol:

    (deftype Apple [colour])
    (defprotocol Eatable (eat [x]))
    

    the following throws an exception (No implementation of method: :eat etc.):

    (extend :Apple Eatable {:eat (fn [x] (println (str (name (:colour x)) ", yummy!")))})
    (eat (Apple :red))
    

    while this prints out red, yummy!:

    (extend ::Apple Eatable {:eat (fn [x] (println (str (name (:colour x)) ", yummy!")))})
    (eat (Apple :red))
    

    Note I’ve just typed it all in at the REPL. Also note that if you want to reproduce it, it’s best that you type / paste it in in the order given above; e.g. reevaluating either of the (deftype Apple [colour]) and (defprotocol Eatable (eat [x])) forms (or even both) does not make Clojure forget about the protocol implementation.

    Again, this is a 1.2 feature, so it’s not even there in 1.1 and might change prior to the actual release of 1.2.


    Sharing a hash-map between a number of namespaces is another possible use case, as Brian says. Note that there’s no need for a reference type to be involved. Say there’s a bunch of libraries — which may perhaps be added to in the future — which manipulate (maybe transform, maybe just observe) hash-maps keyed by keywords, where each library is free to define which keywords it looks for and what it uses them for; then one might be tempted to use namespace qualified keywords to avoid collisions.

    Actually, there currently exists an example which is not at all contrived, namely the Ring spec v0.1 (a key piece of the present day Clojure Web ecosystem). See the Request and response map keyword namespacing message to the Ring Google group (made by Ring author
    Mark McGranaghan) for some insight into the rationale behind that design decision, as well as behind the decision to no longer require namespacing keywords in Ring spec v0.2. There’s also a message by James Reeves (the author of Compojure) in support of the change.


    Ultimately, as all namespacing, this is a collision avoidance feature. Clojure code that is written nowadays doesn’t tend to care about having “private” keywords, so they don’t see much use; but it is good to have them available for when they may make a difference.

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

Sidebar

Related Questions

Is there anything in Clojure that is equivalent to Common Lisp's symbol-name function?
Should I feel wary about creating clojure keywords which have non-existent namespaces? An example
All, I'm starting to take a look at the Clojure language, and had a
Clojure macro noob here. I have a function with some optional parameters, e.g. (defn
Clojure structs can be arbitrarily extended, adding new fields. Is it possible to extend
in clojure i have vector [myfn1 myfn2 myfn3] how can i call functions named
Clojures clojure.xml/parse, clojure.zip/xml-zip and clojure.contrib.zip-filter.xml/xml-> are excellent tools for pulling values out of xml,
In Clojure, I want to combine two lists to give a list of pairs,
I have the following Clojure code and I'm not sure why it's not working:
I was reading about Clojure and found a discussion about Java not supporting tail

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.