Skip to content

Constructor Syntax #47

Closed
Closed
@DartBot

Description

@DartBot

This issue was originally filed by ervok...@gmail.com


I have an issue with the following:

class Point {
  var x, y;
  Point(this.x, this.y);
  scale(factor) => new Point(x*factor, y*factor);
  distance() => Math.sqrt(x*x + y*y);
}

The problem is that the constructor (in this case there's only one, but there may be many) includes the name of the class. This is (as far as I can tell) unnecessary duplication. Every time you rename a class, you need to change the name in multiple places.

I understand this could be solved by an IDE (which would do the work for you). However, simpler text editors have their place, too.

Please implement a different syntax, perhaps a 'new' keyword. I don't care what the exact syntax is, as long as there isn't unnecessary duplication.

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-not-plannedClosed as we don't intend to take action on the reported issuetype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions