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

Parse [new Constructor.name] #17635

Closed
nex3 opened this issue Mar 19, 2014 · 15 comments
Closed

Parse [new Constructor.name] #17635

nex3 opened this issue Mar 19, 2014 · 15 comments
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams.

Comments

@nex3
Copy link
Member

nex3 commented Mar 19, 2014

When referring to constructors in comments, I often like to write [new Constructor.name]. Currently dartdoc doesn't linkify these properly.

@bwilkerson
Copy link
Member

Neither does the analyzer. Please let us know if you decide to accept this syntax so that we can keep in sync.

@kevmoo
Copy link
Member

kevmoo commented Mar 20, 2014

Is there any linking for ctors at the moment?

Is there precedent (in other doc tools) for [new Class.ctor]?

I think the proposal is fine...just want some context


cc @alan-knight.
cc @efortuna.

@bwilkerson
Copy link
Member

For what it's worth, here's the grammar that used to be in the language specification (but has since been removed) and that analyzer still uses:

commentReference ::=
    '[' 'new'? qualified ']' libraryReference?

libraryReference ::=
     '(' stringLiteral ')'

I don't know how often the "new" is included. Analyzer will resolve the reference to the constructor either with or without it.

@kevmoo
Copy link
Member

kevmoo commented Mar 20, 2014

Can one have name collisions between the name of a ctor and static/instance members?

Is using the 'new' prefix just for clarity in the source code or does it enable a new feature?

@bwilkerson
Copy link
Member

Can one have name collisions between the name of a ctor and static/instance members?

Not in error-free code. According to the specification:

A constructor name always begins with the name of its immediately enclosing class, and may optionally be followed by a dot and an identifier id. It is a compile-time error if id is the name of a member declared in the immediately enclosing class.

Is using the 'new' prefix just for clarity in the source code or does it enable a new feature?

In analyzer, it doesn't change anything. We know because of the class name that we're referencing a constructor, so the 'new' has no effect. As far as I know, it's merely a question of personal taste.

@kevmoo
Copy link
Member

kevmoo commented Mar 20, 2014

I guess referring to the default ctor vs the class is one feature.

@DartBot
Copy link

DartBot commented Mar 21, 2014

This comment was originally written by @seaneagan


Yes, and presumably the same syntax should be used to refer to constructors in docs as for closurizing them in code, which is issue #10659.

@efortuna
Copy link
Contributor

To answer your question, Kevin, Dartdoc can and does link to constructors currently. You need to link it like [Foo.Foo] for the basic unnamed constructor to distinguish it from the classname itself, though.

@kevmoo
Copy link
Member

kevmoo commented Apr 7, 2014

Removed Pkg-DartDoc label.
Added Pkg-DocGen label.

@lrhn
Copy link
Member

lrhn commented May 7, 2014

It's not clear to me whether "Foo.Foo" is a valid constructor name (votes are 2:1 for from the implementations). If so, [Foo.Foo] should refer to that, and not to [new Foo].

@bwilkerson
Copy link
Member

It's not clear to me whether "Foo.Foo" is a valid constructor name ...

Section 7 of the specification (Classes) states:

  It is a compile time error if a class C declares a member with the same name as C.

I think this precludes the use of the class name as the name of a constructor. (I think it's a bug that analyzer doesn't currently catch this case.)

But personally, I think it's ugly to use [Foo.Foo] to refer to the default constructor of a class because it doesn't match the syntax of the language. I agree that [new Foo] is not great either, but I do think it's better.


cc @gbracha.

@gbracha
Copy link
Contributor

gbracha commented May 7, 2014

Sadly, Foo.Foo is a valid constructor name per spec. Given that some implementations accept it, I don't see that we should change the spec.

@bwilkerson
Copy link
Member

Foo.Foo is a valid constructor name per spec.

Then I won't create an issue against analyzer for this case :-)

But I think that means that it isn't safe to use "Foo.Foo" for the unnamed constructor, and we really do need to support "new Foo".

@efortuna
Copy link
Contributor

efortuna commented May 7, 2014

okay dogen will need to be changed.

@sethladd
Copy link
Contributor

Moved to dart-lang/dartdoc#103


Added MovedToGithub label.

@nex3 nex3 added Type-Defect area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. labels Jan 13, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams.
Projects
None yet
Development

No branches or pull requests

8 participants