Cheers,
Kasper
--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
Am 31.08.2012 15:15 schrieb "Sean Eagan" <seane...@gmail.com>:
>
>
> I've seen a few references to lowercase annotation names such as @deprecated, @override, and @resource, which I believe would correspond to lower case class names,
Why should they?
> which is against Dart's current style guide and Java. I like that it's easier to type the lower case names, but isn't consistency more important?
>
What consistency? Annotations are annotations. Classes are only one (and in Dart seemingly the only) way to implement them.
> Also, instead of repeated annotations:
>
> @Resource("favicon.png")
> @Resource("logo.png")
> @Resource("sprite.png")
>
> passing a List might make more sense:
>
> @Resources(const ["favicon.png", "logo.png", "sprite.png"])
>
> depending on the probability of adding more parameters to Resource beyond just the URI in the future.
Right. What is requested is a meta-language, kind of DSL. Unfortunately this is often confused with the implementation of the concepts in the language being annotated.
Resource may be a class, the annotation may resemble its constructor call.
But that doesn't mean that the concepts are necessarily identical. They are only made up to closely match for lack of alternative design and ease of implementation (thus the necessity for const too).
Annotations could for example be simple strings, a Lisp-like list or a JSON structure, just to name alternative representations/implementations.
Am 31.08.2012 15:15 schrieb "Sean Eagan" <seane...@gmail.com>:
> I've seen a few references to lowercase annotation names such as @deprecated, @override, and @resource, which I believe would correspond to lower case class names,Why should they?
I just noticed that annotations can be "either a reference to compile-time constant variable, or a call to constant constructor". So I guess the intention is to have `deprecated` and `override` be top-level const variables.
But why expose extra top-level variables when you will already be exposing Deprecated and Override classes?
And what if you ever need to add an argument to the annotations? For example, it would be useful to have a link to a new method which is replacing a deprecated method:@Deprecated(by: SomeClass.newMethod);void oldMethod();
Also, am I correct that annotations corresponding to const constructor calls can omit "()" if not passing any arguments, which would allow for example:@Overridevoid someMethod();