On Apr 13, 5:14 pm, Alex Osborne <a...@meshy.org> wrote:
> Travis <twell...@gmail.com> writes:
> > I'm just curious where those numbers come from. For example, if I
> > compile the class bar.clj containing:
>
> > (ns bar)
> > (defn foo []
> >   nil)
>
> > I'll get three classes, one of which is:
>
> > bar$foo__5.class
>
> The numbers are just a global incrementing counter (the same one used
> for gensym).  The reason for them is to make the names of the classes
> unique, for example you can define your function foo twice:
>
> (defn foo []
>   nil)
>
> (def baz foo)
>
> (defn foo []
>   5)
>
> A more common example is anonymous functions (fn [] ...).  These all
> have the same name "fn", but they obviously need to be written to
> different class files.

Thanks Alex,

I wonder if it would be possible to specify that name with metadata
and allow for throwing an exception if it's not unique.

I found where this seems to happen in the code but it looks like a
real investment to figure it out and make changes. I may come back to
it at some point soon anyway.

http://github.com/richhickey/clojure/blob/4f6fda54954fe7407967d65a5518906453312395/src/jvm/clojure/lang/Compiler.java#LID5877

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to