That was what I was missing.  Thanks, Aaron.

Regarding using :gen-class in the ns macro, and also (gen-class) at the top level, I am using the first because I know it works for AOT compilation (important for the shootout web site to avoid measuring compilation as part of the run time). If there is another way to do AOT compilation without that, I'm all ears if it has important technical advantages, and/or would be a better example for people reading these sample programs and learning from them.

I am using the (gen-class) at the top level because I want to extend another class, and then use that from -main or from a function that - main calls.

I understand that most people would probably define these classes in separate files, but for the shootout web site it is advantageous (perhaps even required -- I'm not sure) that it all fits in one file.

Thanks,
Andy

On Jan 28, 2011, at 4:07 PM, Aaron Cohen wrote:

On Fri, Jan 28, 2011 at 6:13 PM, Andy Fingerhut
<andy.finger...@gmail.com> wrote:

(ns andy.try
 (:gen-class))

(gen-class
:name  andy.try.ReversibleByteArray
:prefix rba-)

I find it confusing that you have both of ":gen-class in the ns macro"
(I guess you're using this to get -main) and "(gen-class) at the top
level".

The class you are creating extends no interfaces and defines no
methods. (Note, the only reason that you get a "main" method in one of
your generated classes is because the :gen-class option to ns
automatically specifies (:main true). If you add (:methods [[reverse
[] void]) to your gen-class statement, it will add a reverse method to
the generated class which calls your rba-reverse function and returns
void.

I would look into combining the two gen-classes though.

Here's a great blog post that goes into gen-class some more:
http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html

--Aaron

--
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

--
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

Reply via email to