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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:41:26+00:00 2026-05-26T16:41:26+00:00

The macro, transform! , as defined below seems to work for => (transform! [foo

  • 0

The macro, transform!, as defined below seems to work for => (transform! ["foo" 1 2 3]). The purpose is to take in a list, with the first element being a string that represents a function in the namespace. Then wrapping everything into swap!.

The problem is that transform! doesn’t work for => (transform! coll), where (def coll ["foo" 1 2 3]). I am getting this mystery exception:

#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: Symbol>

The function:

(defmacro transform! 
" Takes string input and update data with corresponding command function.
"  
  [[f & args]]  ;; note double brackets
 `(swap! *image* ~(ns-resolve *ns* (symbol f)) ~@args))

I find it strange that it works for one case and not the other.

  • 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-26T16:41:26+00:00Added an answer on May 26, 2026 at 4:41 pm

    Macros work at compile-time and operate on code, not on runtime data. In the case of (transform! coll), the macro is being passed a single, unevaluated argument: the symbol coll.

    You don’t actually need a macro; a regular function will suffice:

    (defn transform! [[f & args]]
      (apply swap! *image* (resolve (symbol f)) args)))
    

    Resolving vars at runtime could be considered a code smell, so think about whether you really need to do it.

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

Sidebar

Related Questions

I have seen this macro defined before but never really knew its purpose. Can
I am looking for a C/C++ macro that can transform a random SVN revision
I have a 'foreach' macro I use frequently in C++ that works for most
Can you define a macro that accesses a normal variable, but in a read-only
I am writing a macro for Visual studio that will generate some code. I
The macro is defined as: #define MAKEINTRESOURCEA(i) ((LPSTR)((ULONG_PTR)((WORD)(i)))) #define MAKEINTRESOURCEW(i) ((LPWSTR)((ULONG_PTR)((WORD)(i)))) How come this
I've written a macro that takes a 2 dimensional array, and prints it to
I found this macro for Word that replaces text anywhere (headers, footers, body, text
My macro updates a large spreadsheet with numbers, but it runs very slowly as
This macro should activate tabs in sequence from 1th to 5th and then again.

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.