Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dart:core: replace @foo with @Foo() #14860

Open
DartBot opened this issue Nov 6, 2013 · 7 comments
Open

dart:core: replace @foo with @Foo() #14860

DartBot opened this issue Nov 6, 2013 · 7 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-n library-core type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Nov 6, 2013

This issue was originally filed by @seaneagan


Currently in dart:core we have top-level variables for annotations:

@deprecated
@Proxy
@OverRide

But in order to allow specifying an expiration date, the Deprecated class is also public:

@deprecated('1/1/2014')

This means when I refactor between the 2 forms, I have to convert between 'd' and 'D', which is annoying. If the argument to the Deprecated constructor were made optional, then deprecated could be removed, since you could just do:

@deprecated()

If we ever need to add an optional argument to @­proxy, we would similarly need to add a Proxy class, but we couldn't add it to dart:core, because it would break existing apps, and putting it in some other library away from @­proxy would be really strange. For example, maybe we would want to limit the interfaces implemented by the proxy, to those explicitly stated in the implements clause:

@Proxy(explicitInterfaces: true)
class Foo implements A, B {
  // ...
  noSuchMethod(Invocation invocation) {
    
  }
}

... so that new Foo().someBogusField still yields warnings:

Also, if this pattern of @­foo + @­Foo(bar) is introduced in dart:core, it will set a style precedent to be followed by other annotations. This will lead to a lot of unnecessary top-level variables, which lead to name conflicts, shadowing issues, and unnecessary API surface.

Suggestion is to instead use:

@deprecated()
@Proxy()
@OverRide()

And now with issue #7 fixed, there is the possibility of issue #2 getting fixed in the future, at which point these could be shortened to:

@deprecated
@Proxy
@OverRide

@dgrove
Copy link
Contributor

dgrove commented Nov 6, 2013

Added Area-Library, Library-Core, Triaged labels.

@floitschG
Copy link
Contributor

CCing people that have more opinions on annotations.


cc @lrhn.
cc @peter-ahe-google.
cc @gbracha.

@bwilkerson
Copy link
Member

I agree completely. I think the proposed approach would be much better. (And it would be kind of cute to see 'deprecated' be marked as being deprecated.)

@DartBot
Copy link
Author

DartBot commented Nov 19, 2013

This comment was originally written by @seaneagan


Looks like we ran out of time on this one.

IMO, there should still be a style guide rule (issue #4) to at least PREFER @­Foo() over @­foo, and this should be done quickly before a bunch of important packages which expose annotations start reaching 1.0 status.

It could be seen as quite similar to num/int/double/bool violating the UpperCamelCase class names style guide rule.

I filed issue #9 specifically for polymer/observe annotations.

@sigmundch
Copy link
Member

I like the idea in 13582 that you can omit '()' as it will make it easier to transition between no-arg and some args on some annotations.

However, I personally prefer @­foo over @­Foo(). I understand this might be a matter of taste, but maybe we should try to agree on what we want the styleguide for annotations to be. I'd be more inclined to have a different style for annotations that makes them especially readable. For example, if a class is intended for annotations, maybe we want to use @­lowerCamelCase or @­lower_case_with_underscores rather than @­UpperCamelCase.

Just my 2 cents.

@sigmundch
Copy link
Member

Issue #11474 is tracking the general discussion about the style we want for annotations. I'm adding it as a prerequisite here.


Marked this as being blocked by #11474.

@lrhn
Copy link
Member

lrhn commented Dec 16, 2013

Removed Type-Defect label.
Added Type-Enhancement label.

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core labels Dec 16, 2013
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@lrhn lrhn added the core-m label Aug 11, 2017
@floitschG floitschG added core-n and removed core-m labels Aug 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-n library-core type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants