waneck / testrepo

0 stars 0 forks source link

Issue 1834 - feature request : Annotation instance object like in Java and to call a macro - haxe #1834

Open waneck opened 11 years ago

waneck commented 11 years ago

[Google Issue #1834 : http://code.google.com/haxe/issues/detail?id=1834] by julopez....@gmail.com, at 2013-05-20T16:23:33.000Z

ANNOTATION AS INSTANCE. Be able to place Annotation wich are retrievable instances object (class instance or anon object). Allow also documentation on annotation and annotation properties. Resolve naming conflicts since annotation are typed (need import). (In near futur more librarie will rely on annotations and mixing libraries became a nigthmare). This simplify a lot working with annotation and to design AOP frameworks relying on annotation. (like java Dependency injection CDI, ioc, hibernate, Validation Framework,Link C#...)

/* an custom annotation.../ class MyAnnotation { /* ...infos... / var version:Int; var comment:String;

function new(version:Int, comment:String) { this.version = version; this.comment = comment; } }

@MyAnnotation(version=3,comment="someComment") class MyClass { }

....getAnnotations(MyClass) var meta:MyAnnotation = ...;


ANNOTATION TO CALL MACRO CONTEXTUALY We have also powerful macro wich should be called directly by annotation. Easier to make things like buildType... Replace the use of some magic interfaces wich are some time too magic to understand.

//CONCEPT DRAFT macro class MyMacroClass { macro function process(e:Expr):Expr{....} }

@:MyMacroClass.process() class MyClass { }


ANNOTATION Attributes

Current annotation lacks of constraint (when building framework wich users will use annotations). As an example : actually in java annotation can be configured with.

@Retention(param) - Specifies how the marked annotation is stored—Whether in code only, compiled into the class, or available at runtime through reflection.
@Documented - Marks another annotation for inclusion in the documentation.
@Target(param) - Marks another annotation to restrict what kind of java elements the annotation may be applied to (field, constructor...)
@Inherited -Marks another annotation to be inherited to subclasses of annotated class (by default annotations are not inherited to subclasses).

please see a short extract http://en.wikipedia.org/wiki/Java_annotation

hope it helps to keep haxe as the best.

Ju.

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-05-23T10:22:18.000Z]