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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:23:46+00:00 2026-05-16T20:23:46+00:00

what is the parameter to ns ? the documentation says something, but it’s not

  • 0

what is the parameter to ns ? the documentation says something, but it’s not clear (to me, at least)


my-new-namespace=> (doc ns)
-------------------------
clojure.core/ns
([name docstring? attr-map? references*])
Macro
  Sets *ns* to the namespace named by name (unevaluated), creating it
   if needed. 

...the rest of the documentation was not copied

the confusion comes from all the other functions that play with namespaces:


user=> (find-ns 'my-new-namespace)
nil
user=> (remove-ns 'my-new-namespace)
nil
user=> (create-ns 'my-new-namespace)
#<Namespace my-new-namespace>
user=> (ns 'my-new-namespace)
java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol (NO_SOURCE_FILE:26)
user=> (ns my-new-namespace)
nil
my-new-namespace=>

find-ns, create-ns, remove-ns take my-new-namespace quoted, while ns takes my-new-namespace unquoted

so, what is the deal ? why some get a quoted form and others get and unquoted form of my-new-namespace ?

what is, in each case, my-new-namespace ?

ps: think i figured out the answer to this as i was writing the question here, but it seemed and interesting exercise, so the question still got posted 😀

  • 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-16T20:23:47+00:00Added an answer on May 16, 2026 at 8:23 pm

    ns is a macro and under the hood if quotes the name to save you the trouble:

    user> (macroexpand '(ns foo))
        (do (clojure.core/in-ns (quote foo)) (clojure.core/with-loading-context   
            (clojure.core/refer (quote clojure.core))))
    

    the other functions cant get away with unquoted arguments because they are functions, and functions have there arguments evaluated first.

    the ns macro, as a macro, gets to look at and twiddle its arguments before they are evaluated so it can get at the my-new-namespace before the reader attempts to look it up as a variable name.

    in short this saves wear and tare on your keyboard and wrists 😉 Just kidding, the in both cases what the function receives is a symbol they just differ in what you have to do to pass them that symbol.

    for comparason; if you where to go ahead and pass (ns 'my-new-namespace) it would get the symbol 'my-new-namespace quote and all! you likely don’t want the quote to be part of the name space.

    if you want to make it consistent you could write wrapper macros that take unquoted symbols for the rest of the namespace functions that simply quote the first argument and return a call to the real function (remember that macros return the code to be called)

    (defmacro my-find-ns [name]
        `(find-ns (quote ~name)))
    

    though this would break “the first rule of macro club”

    the error about the argument being a list is caused by it attempting to use (quote my-new-namespace) as a name

     user> (macroexpand '(ns 'foo))
           (do (clojure.core/in-ns (quote (quote foo))) (clojure.core/with-loading-context
               (clojure.core/refer (quote clojure.core))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Constructor for PHP's exception has third parameter, documentation says: $previous: The previous exception used
The documentation says the cin.get(...) will leave the termination character(parameter t) in the buffer!
The MSDN documentation says of the exitContext boolean parameter: true to exit and reacquire
SimpleIni Documentation says wchar_t is supported but I don't understand how to use it.
According to Apple documentation on debugging Core Data it says we should be able
The urllib2 documentation says that timeout parameter was added in Python 2.6. Unfortunately my
The documentation says parameters are supported but the example uses hl and # which
The documentation of jQuery.animate states that The only required parameter is a map of
ParameterExpression parameter = Expression.Parameter(typeof(Product), x); MemberExpression Left = Expression.MakeMemberAccess(parameter, typeof(Product).GetProperty(Name)); ConstantExpression Right = Expression.Constant(value,
EventDispatcher.addEventListener() expects first parameter for event type (parameter of String type). But the current

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.