Java-style annotations (attributes?)

I did a little googling, but didn't find this specific question being asked. I've had the question in my head for a while now, so I apologize if I already brought this up.

Will Swift ever support introspectable Java-style annotations? I think the current syntactic construct is called an Attribute, but they'd be customizable, created in much the same way as classes are.

They provide a very convenient way to provide plug-ins to a containing environment. For example, web servers are often built in Java using these techniques. You define a (plain) class that represents a service, whose methods represent individual request endpoints:

@Service(root="/my/sub/webapp/")
class
MyWebapp
{
    @Get(path="users/{id}/")
    func getUsers(@Param("id") userID inUserID: Int)
  -> [String:AnyObject]?
    {
  // return dictionary for user with ID inUserID
    }
}

The container uses introspection to find all classes annotated with "Service." It pulls the values of the parameters out of the Service annotation using introspection. It then does a similar thing on the methods in the Service class, etc.

Is there any work being done along these lines?

···

--
Rick Mann
rmann@latencyzero.com

Hi Rick,

This is something that many people are aware of and is commonly requested. It isn’t on the short-term todo list (which is oriented around ABI stability at the moment) but is something that many folks are interested in adding at some point.

-Chris

···

On Sep 27, 2016, at 5:02 PM, Rick Mann via swift-evolution <swift-evolution@swift.org> wrote:

I did a little googling, but didn't find this specific question being asked. I've had the question in my head for a while now, so I apologize if I already brought this up.

Will Swift ever support introspectable Java-style annotations? I think the current syntactic construct is called an Attribute, but they'd be customizable, created in much the same way as classes are.

Thank you, that's great news.

In case you're interested, this is why I want it. I'd really like to see Baratine re-implemented in pure Swift:

  http://baratine.io

If you can spare the time, I highly recommend checking out the Getting Started. It's revolutionary for web services.

···

On Sep 27, 2016, at 20:24 , Chris Lattner <clattner@apple.com> wrote:

On Sep 27, 2016, at 5:02 PM, Rick Mann via swift-evolution <swift-evolution@swift.org> wrote:

I did a little googling, but didn't find this specific question being asked. I've had the question in my head for a while now, so I apologize if I already brought this up.

Will Swift ever support introspectable Java-style annotations? I think the current syntactic construct is called an Attribute, but they'd be customizable, created in much the same way as classes are.

Hi Rick,

This is something that many people are aware of and is commonly requested. It isn’t on the short-term todo list (which is oriented around ABI stability at the moment) but is something that many folks are interested in adding at some point.

--
Rick Mann
rmann@latencyzero.com