Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Clojure and the fly likes Getting the name of a variable as a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » Clojure
Bookmark "Getting the name of a variable as a string" Watch "Getting the name of a variable as a string" New topic
Author

Getting the name of a variable as a string

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I want to pass a variable to a macro, and concatenate its name to a string. For example, something like (str "tag-" variable). I have several struct-map (e.g. s1, s2) and I'd like to make a string based on the name of the struct-map (e.g "tag-s1", "tag-s2"). Is there a way to do it ?


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Variables have some implicit metadata placed on them. One of those is ":name" :
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Thanks for sharing
 
jQuery in Action, 2nd edition
 
subject: Getting the name of a variable as a string
 
Similar Threads
It is so confusion Question about polymorphism.
Problem with character behavior (lowercase ,uppercase)
String s = "Hello"
method dynamic loading
object name to string variable