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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:45:14+00:00 2026-06-18T00:45:14+00:00

I wrote a macro for creating a record (defmacro def-entity [name & value] `(do

  • 0

I wrote a macro for creating a record

(defmacro def-entity [name & value]
 `(do
    (defrecord ~name (vector  ~@value))
    ))

and I created one entity

(def-entity p a b)

But when I try to create a concrete instance
(def something (p. “a” “b”))
I get this message java.lang.IllegalArgumentException: No matching ctor found for class user.p (repl-1:40).
So I have to provide 3 parameters, like this
(def someone (p. “a” “b” “x”))
And it puts the values like this

 (-> someone :a)
 "b"
 (-> neko :p)
 nil

I don’t seem to understand what is happening?

  • 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-18T00:45:15+00:00Added an answer on June 18, 2026 at 12:45 am

    As defrecord is itself a macro, and expects the fields of the record to be passed in as a vector literal, you should better avoid passing a symbol referring to a vector, and really construct a vector literal as part of your macro work:

    (defmacro defentity [name & values]
      `(defrecord ~name ~(vec values)))
    

    Which results in:

    user=> (macroexpand-1 '(defentity p a b))
    (clojure.core/defrecord p [a b])
    user=> (defentity Test foo bar)
    user.Test
    user=> (def s (Test. "foo" "bar"))
    #'user/s
    user=> s
    #user.Test{:foo "foo", :bar "bar"}
    

    In contrast, your version results in the following, which doesn’t use a vector literal as input to defrecord:

    user=> (macroexpand-1 '(def-entity p a b))
    (do (clojure.core/defrecord p (clojure.core/vector a b)))
    

    In facts, I can’t even use your version in Clojure 1.4:

    user=> (def-entity w x y)
    CompilerException java.lang.RuntimeException: Can't use qualified name as parameter: clojure.core/vector, compiling:(NO_SOURCE_PATH:1) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a record (defrecord Rec [id]) I work with it like (def my
I wrote a macro from scratch but would like to have non-technical people install/run
I wrote this very simple macro to delete all rows when Column P has
I wrote a macro as an add-in, and I need to get the path
I wrote a debug macro that prints to the console the passed-in string whenever
I wrote an Excel VBA macro to do conditional formatting using an intersect of
I created a macro that conveniently builds lambda functions using which I can iterate
I wrote the following makefile, but I don't really understand what's going on (I
I wrote a macro that imports a CSV file into my spreadsheet, using a
I wrote macro in Excel that uses dynamic array. Users will add elements to

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.