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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:01:44+00:00 2026-05-20T22:01:44+00:00

I have a problem constructing a DSL in Clojure. This is the concrete problem

  • 0

I have a problem constructing a DSL in Clojure. This is the concrete problem I have isolated from everything else.

Let’s say we hava a simple macro:

user> (defmacro m1 [x] `'~x)
#'user/m1 

it just returns the literal supplied
user> (m1 toUpperCase)
toUpperCase

if we call java method for object everything works as expected

user> (. "a" toUpperCase)
"A"

but if we substitute method name for macro call that returns the methodname

user> (. "a" (m1 toUpperCase))

; Evaluation aborted.
Unable to resolve symbol: toUpperCase in this context

I want to use some java library that has fluent interface like a().b().c().
This maps to Clojure as:

(.. obj method1 method2 method3....etc)

I want to create macros that substitute some parts of this chain so my code should be like:

(.. obj method1 macro1)

and that should expand to

(.. obj method1 method2 method3)

definline also doesn’t help. I tried that also

  • 1 1 Answer
  • 1 View
  • 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-20T22:01:45+00:00Added an answer on May 20, 2026 at 10:01 pm

    The reason you’re running into this problem is that the . special form does not evaluate its second argument (the symbol specifying the method or field) in the way you expect: it sees it as a call of the METHOD m1, with the ARGUMENT toUppercase. Because of that, you cannot generate the symbol for the method dynamically just as an argument to . (dot) – even if you use a macro to specify that argument.

    A way to work around that is to include the . in your macro:

     (defmacro m1 [x y] `(. ~x (~y)))
     (m1 "a" toUppercase)
     user> "A"
    

    Note that you need to wrap parentheses around ~y to indicate you want to call a method instead of reading a field.

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

Sidebar

Related Questions

This is a follow up question from Problem with array assignment I now have
I have a problem constructing a mysql query: I have this table tSubscribers were
I'm constructing a form. No problem there. Aside of a submit button, I have
I have problem with my query on C, I’m using the oci8 driver. This
I have problem with UIWebView delay when the load image from url. In my
I have a problem when constructing a polygon. The error message says something like:
I am constructing a simple login php page. The problem is, whatever I put
I'm trying to create a DSL and running into a problem. I have these
I'm constructing a datagrid in Windows Presentation Foundation, and I have a problem. When
We have a simple LOB application that: pulls data from EF serves data across

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.