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

  • Home
  • SEARCH
  • 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 8674465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:43:01+00:00 2026-06-12T19:43:01+00:00

I have a clojure application that need some configuration variable, mainly string but also

  • 0

I have a clojure application that need some configuration variable, mainly string but also stuff to evaluate.

I could just declare every single variable with something like:

(def config-db "URI_DB"))
(def config-time (hours 1))

But I thought that might be a good idea (I am not very sure) write a macro to do that, something that will looks like this:

(make-config 
  config-db "URI_DB"
  config-time (hours 1))

(Or I can put the names inside a vector to looks more like a let statement)

But I am getting problem when I put more than one couple, I did this:

(defmacro define-config
  [name definition]
  `(def ~name ~definition))

But I have really no glue to how expand this in something more useful…

Any suggestions or ideas ?

  • 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-12T19:43:03+00:00Added an answer on June 12, 2026 at 7:43 pm

    I strongly recommend just doing each def separately. This macro is trivial but isn’t very useful. When someone sees def, they know precisely what is going on. When they see your custom make-config call, they have to look at the implementation of make-config to know what is going on. You get rid of a few characters in large examples and lose readability.

    With that said, you can make a macro to do this easily:

    (defmacro make-config [& forms]
      `(do ~@(for [[name body] (partition 2 forms)]
               `(def ~name ~body))))
    

    And an example of usage:

    user=> (make-config foo "foo" bar (str "b" "a" "r"))
    #'user/bar
    user=> foo
    "foo"
    user=> bar
    "bar"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASPNET MVC application that works fine locally but when I deployed
I have a Clojure main application that depends on several Clojure libraries, two of
I have installed clojure plugins in eclipse so that I can start developing apps
I have a clojure/ring project that has two distinct app/handlers running on different ports
I have a string which is a representation of a clojure map. Is there
I am trying to build my project that has some java source and clojure
I have a simple java application that gets jmx connection url, object name and
We have an application that uses both the google closure and dojo libraries. We
I have manage to create a small size js application that uses jQuery and
I have a post-hook function that receives some data for itself, reference to another

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.