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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:04:09+00:00 2026-06-02T07:04:09+00:00

Probably obvious, but given this code (from http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/reify ): (defn reify-str [] (let [f

  • 0

Probably obvious, but given this code (from http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/reify):

(defn reify-str []
  (let [f "foo"]
    (reify Object
      (ToString [this] f))))

(defn -main [& args]
  (println (reify-str))
  (System.Console/ReadLine))

Why am I getting this output?

#<ui$reify_str$reify__4722__4727 foo>

Instead of:

foo

I’m running ClojureCLR in Windows, if it helps. Thanks!

  • 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-02T07:04:11+00:00Added an answer on June 2, 2026 at 7:04 am

    Your basic problem is that the Clojure REPL uses print-method, not .toString. You have to define print-method for your type. It’s a little bit annoying for reified types since it makes them kind of verbose. You’ll have to do something like this:

    (defn reify-str []
      (let [f "foo"
            r (reify Object
                (ToString [this] f))]
        (defmethod clojure.core/print-method (type r) [this writer] 
          (print-simple f writer))
        r))
    

    (I’ve only tested this in vanilla Clojure, but I think it’s the same in ClojureCLR.)

    At this point, though, you’re almost better off creating an actual type instead of reifying, because you’re redefining the method every time. (I guess you could do some sort of global state to avoid the necessity, but…well, you can see why defining a type might be preferable.)

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

Sidebar

Related Questions

This will probably be obvious but I can't find the best way. I want
I'm probably missing something obvious here but here's what I'm trying to do. From
I know this is probably really obvious, but I cannot figure out why I
This is with SBCL 1.0.55 on Debian squeeze. I'm probably missing something obvious, but
This is probably really obvious to most of you but i am new to
This seems like a pretty obvious, basic thing to expect from the Graph API
Ok, I think whatever I'm doing wrong, it's probably blindingly obvious, but I can't
I am probably missing something obvious, but I am getting a 'Object reference not
Probably missing something completely obvious here, but here goes. I'm starting out with Spring
Probably I'm just missing something obvious, but I can't get the image in my

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.