Ryan Cole <[email protected]> writes:

> Hi all, beginner here,
>
> I'm trying to write a Minecraft plugin in Clojure, and use AOT so that the 
> Minecraft server can load it right up. I've got this much going, and all as 
> well. The server expect some of my functions in a class that I'm extending 
> to use an appropriate annotation on the function.
>
> How do I add these annotations? I've Googled around and see that it looks 
> like support for this was added back in 2010, so I'm sure it's possible. 
> Maybe I've seen the solution but didn't realize that it was a solution. 
> Clojure still looks pretty alien to me, so crazy things like this are rough 
> to search for and realize when the answer is in front of me.


Annotations are added as metadata to functions in a deftype definition.
Something like this (untested):

(deftype MyType []
   SomeInterface
   (^{EventHandler {}} onPlayerLogin [event] ...))

For some examples of using annotations:

https://github.com/pallet/clojure-maven/blob/develop/mojo/src/main/clojure/clojure/maven/mojo/defmojo.clj#L45
https://github.com/pallet/zi/blob/develop/src/main/clojure/zi/test.clj#L109

I'm afraid it's not very friendly code if you're new to clojure.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Reply via email to