On Tue, Jan 27, 2009 at 4:04 PM, Mark Volkmann
<r.mark.volkm...@gmail.com> wrote:
>
> I ran across two dispatch macros today that I haven't seen before.
>
> What does #= do? I see in LispReader.java that it uses an EvalReader
> which is also defined in that source file, but it's not clear to me
> what it does.

It's used by the print-dup mechanism to print and re-create objects of
exactly the right type.

For example, normally a sorted-set prints identically as a hash-set,
so printing and re-reading would create an object of a different type:

user=> (prn (sorted-set 1 2 3))
#{1 2 3}
nil

print-dup and #= work around this:

user=> (binding [*print-dup* true] (prn (sorted-set 1 2 3)))
#=(clojure.lang.PersistentTreeSet/create [1 2 3])
nil

My understanding is that #= forms are not meant to be writen or read
by humans.  They're for data storage, AOT compilations, etc.

> What does #! do? I see in LispReader.java that it uses a
> CommentReader. Is it just an alternative for a semicolon?

Yes, but it's specifically meant to be used as the first line of a
file, to allow Clojure script to use unix "shebang" format.

--Chouser

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to