- 
                Notifications
    
You must be signed in to change notification settings  - Fork 227
 
Description
The declaring constructors feature introduces several new non-terminals in the Dart grammar. In particular:
<classNameMaybePrimary> ::= // New rule.
     <primaryConstructor>
   | <typeWithParameters>;To give some context, it is used together with rules such as the following:
<classDeclaration> ::= // First alternative modified.
     (<classModifiers> | <mixinClassModifiers>)
     'class' <classNameMaybePrimary> <superclass>? <interfaces>? <classBody>
   | ...;
<primaryConstructor> ::= // New rule.
     'const'? <typeWithParameters> ('.' <identifierOrNew>)?
     <declaringParameterList>;In short, <classNameMaybePrimary> is the syntactic construct that occurs in the header of classes (and other declarations like mixin classes, enums, and extension types), right after the keyword(s) specifying the kind of declaration (class, mixin class, etc). For example:
class A {} // The `<classNameMaybePrimary>` is `A`.
class B<X> // The `<classNameMaybePrimary>` is `B<X>`.
class C.name(final int i); // The `<classNameMaybePrimary>` is `C.name(final int i)`.The <classNameMaybePrimary> is invariably the location where the name of the declaration can be found (in the examples: A, B, C). This constructor used to be called the <className> previously, even though it may also contain a formal type parameter list (<X>).
So there's precedence for not mentioning the type parameters in the non-terminal name.
With the declaring constructors feature we can add a substantial amount of new constructs at this location: We can declare a primary constructor, which includes (in addition to the class name and potential type parameters):
- optionally the keyword 
const, before the class name, to indicate that the primary constructor is constant, - optionally the second part of the name of the primary constructor (
.namein the last example above), and - a formal parameter list (
(final int i)above). 
I've chosen the non-terminal name <classNameMaybePrimary> to indicate that this is
- definitely the location where we'll find the name of the declaration as a whole (and type parameters), and
 - optionally the location where we can find a primary constructor.
 
However, this name seems to create a substantial amount of controversy, and it would be great if anybody could come up with a word (that is, a short sequence of words that we'll squeeze together to a camel cased thingy) that everybody loves. ;-)
In particular, @dart-lang/language-team, WDYT?