On 4/24/2016 2:54 PM, Fleshgrinder wrote: > Another way to illustrate what I mean: > > The feature will be used /to annotate/ (add metadata) and the so > /annotated/ data has additional /attributes/ afterwards. > > Trying building the sentence if the feature is called /attributes/. > > @entity > @invariant > final class A { > > @inject > private static $x; > > @test > public memoized function f(){} > > } > > r = reflect A > r.getModifiers = [ final ] > r.getAnnotations = [ entity, invariant ] > r.getAttributes = [ final, entity, invariant ] > > r = reflect A.x > r.getModifiers = [ private, static ] > r.getAnnotations = [ inject ] > r.getAttributes = [ private, static, inject ] > > r = reflect A.f > r.getModifiers = [ public, memoized ] > r.getAnnotations = [ test ] > r.getAttributes = [ public, memoized, test ] > > Note that there are programming languages that allow adding of metadata > solely via annotations: Ceylon. No matter the data to annotate. Hence, > in Ceylon no differentiation would be made between modifiers and > annotations. However, one could check the actual annotation type to > determine what it is. > > https://modules.ceylon-lang.org/repo/1/ceylon/language/1.2.2/module-doc/api/index.html#section-annotations >
The example isn't actually complete, sorry: @entity @invariant final class A { @inject private static $x = 0; @test public memoized function f(){} } r = reflect A r.getModifiers = [ final ] r.getAnnotations = [ entity, invariant ] r.getAttributes = [ final, entity, invariant, $x, f() ] r = reflect A.x r.getModifiers = [ private, static ] r.getAnnotations = [ inject ] r.getAttributes = [ private, static, inject, value((int) 0) ] r = reflect A.f() r.getModifiers = [ public, memoized ] r.getAnnotations = [ test ] r.getAttributes = [ public, memoized, test ] I hope I didn't forgot any attribute. :P All in all, attributes are things that things have to describe those things and annotations allows us to add additional attributes to things, on top of possible other attributes that are already addable by other means (modifiers, values, ...). -- Richard "Fleshgrinder" Fussenegger
signature.asc
Description: OpenPGP digital signature