On Wed, Oct 19, 2011 at 4:19 AM, Sherwin Daganato <sherw...@gmail.com>wrote:
> Has anyone here got any idea how to implement Java annotation[1] or > .NET attributes[2] with Moose? I'm particularly interested in how it > can be applied to a Moose class and attribute. > > Right now I'm looking into MooseX-Role-Parameterized to create > parameterized metaclass and attribute traits. It seems to be a fit for > what I want to do, except that the role block which it requires will > be empty. > > Anyone with a more elegant solution? > > [1] http://en.wikipedia.org/wiki/Java_annotation > [2] http://en.wikipedia.org/wiki/.NET_metadata#Attributes > You don't really need Moose to emulate .NET attributes*; vanilla Perl has subroutine attributes: http://perldoc.perl.org/Attribute/Handlers.html http://perldoc.perl.org/attributes.html But honestly, why would you want to do that? Trying to program X in Y is always a code smell. In what little Moose I've done, a trait has always been the best fit for this sort of thing. *Though there's probably a MooseX module out there that will handle things for you. Just saying that it might be overkill.