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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:15:27+00:00 2026-05-18T22:15:27+00:00

Bit of background, I’m a total lisp noob, only started a few weeks ago,

  • 0

Bit of background, I’m a total lisp noob, only started a few weeks ago, but I’ve been developing in other langs for years. Logic no problem, lisp, problem.

I’m trying to write a macro that will define two clsql classes for me to get around a problem with the library. I’d like the classes to be named x and `x-insert“ , so within the macro I’d like the macro to compute the symbol name of x-insert, but I’m having difficulity doing this. My attempt is below, but i’m stumped on two things.

How do I get it to create the class names. If i remove the space in ,class -insert, it wont eval, which I understand, so I presume I’m missing some straightforward way to tell it to ignore the space,and create the name as a single word, and the second problem is getting it to create two classes, not one, as its only expanding the last part of the macro from what I can see using macro expand.

Perhaps I’m going about this the wrong way altogether, so feel free to kick me in the right direction.

(defmacro gen-pair (class base-slots pkey-slot base-table)
  `(clsql:def-view-class ,class -insert()
     (
      ,base-slots
     )
     (:base-table ,base-table)
   )

  `(clsql:def-view-class ,class (,class -insert)
     (
      ,pkey-slot
     )
     (:base-table ,base-table)
   )
)
  • 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-18T22:15:28+00:00Added an answer on May 18, 2026 at 10:15 pm

    It is difficult to begin an explanation here, since you seem to have a
    whole stack of misconceptions.

    First question (how to compose symbol names): Lisp macros do not
    operate on text but on code. In a backquote form, ,class
    evaluates to the code passed into the class parameter of the macro,
    most likely a class name in this case. Writing another symbol after
    that does not magically merge the symbol names; why should it? If you
    want to compose a new symbol name, you have to construct it:

    ,(intern (string-upcase (concatenate 'string
                                         (symbol-name class)
                                         "-insert")))
    

    Second question (why it seems to expand only the second part): the
    contents of a defmacro form are evaluated in an implicit progn
    (that is why it does not complain about an invalid number of arguments
    here). The return value of the last form is the return value of the
    whole defmacro form. In this case, the return value is the code
    produced by that backquote form. A macro defines a function that
    expands a form into a new form; you cannot expand it into two
    unrelated forms. You have to produce a progn form that contains the
    two forms you want to have.

    Third question (why your code looks so different from what Lispers
    write): do not throw around parentheses like nail clippings. There
    are several Lisp style guides flying around on the net. Read them.
    Wer die Form beherrscht, kann mit ihr spielen (roughly: when you
    know the proper way, you can play with it).

    Fourth question (how to come around the perceived limitation of
    clsql): you could ask that question directly, no? What limitation do
    you mean?

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

Sidebar

Related Questions

No related questions found

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.