Re: [Vala] Custom attributes/decorators



On Wed, Apr 22, 2009 at 3:54 AM, Christian Hergert <christian hergert gmail com> wrote:
Hi Folks,

I'm curious about how people feel about adding a feature for custom
attributes/decorators that can be used for meta-programming.  If that
doesn't make sense, let me show an example of what I would like to
make possible.

...

Does this sound interesting to anyone?  Should I file an enhancement request?


Well it surely does to me. However, which approach would benefit the most?

Custom attributes could be
a. available at compile-time. A plugin/gmodule for valac would be used to process them (generate code, in your case).
b. available at runtime, the Flex way. The mxmlc just stores your custom attributes which can be inspected at runtime with describeType's XML [1][2]
c. available at runtime, the Java way. The custom attributes are just interfaces from your code, further present in type.getAnnotations/method.getAnnotations

For b. and c., I don't have any workable idea how this could be implemented with the existing GObjects  (maybe something like comments?[3] )
I think the most flexible way is a., since from there you could implement b. or c.

That said, I would prefer a).

One more question though: should it be possible to annotate existing classes from other libraries? In C# you could do something like:
[MyAnnotation]
public partial class ExistingClass {}

(if ExistingClass is part of your code, but it's autogenerated and you don't want to modify the generated source each time)


[1] http://coenraets.org/blog/2007/10/annotating-actionscript-classes-with-custom-metadata-simple-orm-framework-for-air/
[2] http://livedocs.adobe.com/flex/2/langref/flash/utils/package.html#describeType%28%29
[3] http://live.gnome.org/GObjectIntrospection/Annotations


Regards,
Vlad


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]